Ejemplo n.º 1
1
  public static void main(String arr[]) {
    ParseQuery pq = new ParseQuery();
    // DBSystem.readConfig("/tmp/config.txt");
    String configFilePath = arr[0];
    DBSystem.readConfig(configFilePath);
    // String query = "Select distinct * from countries where id=123 and code like 'jkl' group by
    // continent having code like 'antartic' order by name";
    String inputFile = arr[1];
    try {
      BufferedReader br = new BufferedReader(new FileReader(inputFile));
      String line;
      while ((line = br.readLine()) != null) {
        pq.queryType(line);
      }
    } catch (FileNotFoundException e) {
      System.out.println("Input file not found");
      // e.printStackTrace();
    } catch (IOException e) {
      System.out.println("I/O Exception");
      // e.printStackTrace();
    }

    //        /String query = "create table rtyui(name varchar, age int, rollno int)";

  }
Ejemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);

    /*
    This line gets the unique id associated with each android device. Can only be reset by wiping the phone
     */
    final String android_id =
        Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
    Log.d("ANDROID ID", android_id);

    ParseQuery<ParseUser> query = ParseUser.getQuery();
    query.whereEqualTo(
        "androidID",
        android_id); // If these id's match, an account has already been registered on that account
    query.findInBackground(
        new FindCallback<ParseUser>() {
          public void done(List<ParseUser> scoreList, ParseException e) {
            if (e == null) {
              if (scoreList.size() > 0) {
                Log.d("id", "android_id matches one already in the table");
                // Displays dialog to inform the user the passwords were unequal and they must try
                // again
                AlertDialog.Builder builder = new AlertDialog.Builder(Register.this);
                builder
                    .setMessage(R.string.androidIdAlertMessage)
                    .setTitle(R.string.androidIdAlertTitle);
                builder.setCancelable(
                    false); // Makes it so a user can't click outside of the alert to close the
                            // dialog. They must click the button
                builder.setPositiveButton(
                    "Back to Home",
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int id) {
                        // These two lines automatically take the user back to the home page after a
                        // successful registration
                        Intent goHome = new Intent(Register.this, HomePage.class);
                        startActivity(goHome);
                      }
                    });
                AlertDialog alert = builder.create();
                alert.show();
              } else {
                Log.d("No Match", "Android ID does not match any in table");
              }

            } else {
              Log.d("score", "Error: " + e.getMessage());
            }
          }
        });
  }
Ejemplo n.º 3
0
  public void discLoad() {

    // Acessa todos os dados de uma tabela
    ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Disciplina");
    query.whereEqualTo("owner", ParseUser.getCurrentUser());
    query.findInBackground(
        new FindCallback<ParseObject>() {
          public void done(List<ParseObject> markers, ParseException e) {
            if (e == null) {

              for (ParseObject p : markers) {
                if (!p.getString("day_1").isEmpty()) {

                  TextView t = listTextViewHour.get(p.getString("day_1"));
                  String text =
                      p.getString("hour_1")
                          + " - "
                          + p.getString("name")
                          + "    ("
                          + p.getParseObject("course").getString("name")
                          + ")\n";
                  t.append(text);
                }

                if (!p.getString("day_2").isEmpty()) {

                  TextView t = listTextViewHour.get(p.getString("day_2"));
                  String text =
                      p.getString("hour_2")
                          + " - "
                          + p.getString("name")
                          + "    ("
                          + p.getParseObject("course").getString("name")
                          + ")\n";
                  t.append(text);
                }
              }

              for (int i = 0; i < listTextViewHour.size(); i++) {
                if (listTextViewHour.get(days[i]).getText().toString().isEmpty())
                  listTextViewHour
                      .get(days[i])
                      .setText("Você não tem nenhuma disciplina neste dia!");
              }

            } else {
              // handle Parse Exception here
              e.getCause();
            }
          }
        });
  }
Ejemplo n.º 4
0
  private void prepareListData() {
    listDataHeader = new ArrayList<String>();
    listDataChild = new HashMap<String, List<String>>();
    listDataChildObject = new HashMap<String, List<ParseObject>>();

    // Adding child data
    ParseQuery<ParseObject> query1 = ParseQuery.getQuery("Category");
    List<ParseObject> listHeaders = null;
    try {
      listHeaders = query1.find();
    } catch (Exception e) {
    }

    for (ParseObject x : listHeaders) {
      listDataHeader.add((String) x.get("category_name"));
    }

    int n = listDataHeader.size();

    // Adding child data
    for (int i = 0; i < n; i++) {
      String s = listDataHeader.get(i);
      ParseObject obj = listHeaders.get(i);
      List<String> list = new ArrayList<String>();
      List<ParseObject> listObject = new ArrayList<ParseObject>();

      ParseQuery<ParseObject> query =
          ParseQuery.getQuery("Menu_Item").whereEqualTo("category", obj);

      List<ParseObject> matches = null;

      try {
        matches = query.find();
      } catch (Exception e) {
      }

      for (ParseObject a : matches) {
        // if(isActive(a)) {
        list.add((String) a.get("item_name"));
        listObject.add(a);
        // }
      }
      listDataChild.put(s, list);
      listDataChildObject.put(s, listObject);
    }
  }
Ejemplo n.º 5
0
 public static ParseQuery getQuery()
 {
     return ParseQuery.getQuery(com/parse/ParseRole);
 }