Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.PreparedQuery


 
  public boolean deleteWorklistItem(String user, WorklistItemObject wio){
      Query q_user = new Query(ACCOUNT_KIND);
      q_user.setKeysOnly();
      q_user.addFilter(ACCOUNT_ID_PROPERTY, FilterOperator.EQUAL, user);
      PreparedQuery pq = datastore.prepare(q_user);
      Entity e_user = pq.asSingleEntity();
      if (e_user == null)
        return false;
      Key k = e_user.getKey();
      Query q_wio = new Query(WORKLIST_ITEM_KIND);
      q_wio.setAncestor(k);
      q_wio.setKeysOnly();
      q_wio.addFilter(WORKLIST_ITEM_DEPT_PROPERTY, FilterOperator.EQUAL, wio.getDeptId());
      q_wio.addFilter(WORKLIST_ITEM_COURSE_PROPERTY, FilterOperator.EQUAL, wio.getCourseId());
      q_wio.addFilter(WORKLIST_ITEM_SECTION_PROPERTY, FilterOperator.EQUAL, wio.getSectionId());
      PreparedQuery pq_wio = datastore.prepare(q_wio);
      if(pq_wio.asSingleEntity() == null)
        return false;
      Transaction txn = datastore.beginTransaction();
      datastore.delete(pq_wio.asSingleEntity().getKey());
      txn.commit();
      return true;
  }
View Full Code Here


  public List<SectionInformationObject> getWorklistAsSIO(String user){
    List<SectionInformationObject> siol = new ArrayList<SectionInformationObject>();
    Query q_user = new Query(ACCOUNT_KIND);
    q_user.setKeysOnly();
    q_user.addFilter(ACCOUNT_ID_PROPERTY, FilterOperator.EQUAL, user);
    PreparedQuery pq = datastore.prepare(q_user);
    Entity e_user = pq.asSingleEntity();
    if(e_user == null)
      return siol;
    Key k = e_user.getKey();
    Query q = new Query(WORKLIST_ITEM_KIND);
    q.setAncestor(k);
    PreparedQuery pq_wl = datastore.prepare(q);
    List<Entity> el = pq_wl.asList(FetchOptions.Builder.withDefaults());
    for(Iterator<Entity> i = el.iterator(); i.hasNext(); ) {
      Entity e = i.next();
      String dept = (String) e.getProperty(WORKLIST_ITEM_DEPT_PROPERTY);
      String course = (String)e.getProperty(WORKLIST_ITEM_COURSE_PROPERTY);
      String section = (String)e.getProperty(WORKLIST_ITEM_SECTION_PROPERTY);
View Full Code Here

  public List<WorklistItemObject> getWorklistAsWIO(String user){
    List<WorklistItemObject> wiol = new ArrayList<WorklistItemObject>();
    Query q_user = new Query(ACCOUNT_KIND);
    q_user.setKeysOnly();
    q_user.addFilter(ACCOUNT_ID_PROPERTY, FilterOperator.EQUAL, user);
    PreparedQuery pq = datastore.prepare(q_user);
    Entity e_user = pq.asSingleEntity();
    if(e_user == null)
      return wiol;
    Key k = e_user.getKey();
    Query q = new Query(WORKLIST_ITEM_KIND);
    q.setAncestor(k);
    PreparedQuery pq_wl = datastore.prepare(q);
    List<Entity> el = pq_wl.asList(FetchOptions.Builder.withDefaults());
    for(Iterator<Entity> i = el.iterator(); i.hasNext(); ) {
      Entity e = i.next();
      String dept = (String) e.getProperty(WORKLIST_ITEM_DEPT_PROPERTY);
      String course = (String)e.getProperty(WORKLIST_ITEM_COURSE_PROPERTY);
      String section = (String)e.getProperty(WORKLIST_ITEM_SECTION_PROPERTY);
View Full Code Here

 
  public boolean checkLoginExist(LoginInformationObject lio){
    Query q = new Query("Login Information");
    q.addFilter("username", Query.FilterOperator.EQUAL,
        lio.getUsername());
    PreparedQuery pq = datastore.prepare(q);
    if (pq.countEntities(FetchOptions.Builder.withDefaults()) == 0)
      return false;
    return true;
  }
View Full Code Here

        uco.getDepartmentName());
    q.addFilter("courseNumber", Query.FilterOperator.EQUAL,
        uco.getCourseNumber());
    q.addFilter("sectionNumber", Query.FilterOperator.EQUAL,
        uco.getSectionNumber());
    PreparedQuery pq = datastore.prepare(q);
    return pq.asSingleEntity();
  }
View Full Code Here

        uco.getDepartmentName());
    q.addFilter("courseNumber", Query.FilterOperator.EQUAL,
        uco.getCourseNumber());
    q.addFilter("sectionNumber", Query.FilterOperator.EQUAL,
        uco.getSectionNumber());
    PreparedQuery pq = datastore.prepare(q);
    if (pq.countEntities(FetchOptions.Builder.withDefaults()) == 0)
      return false;
    return true;
  }
View Full Code Here

    {
      Query query = new Query(kind);
      if ((searchFor != null) && (!"".equals(searchFor))) {
        query.addFilter(searchBy, Query.FilterOperator.EQUAL, searchFor);
      }
      PreparedQuery pq = datastore.prepare(query);
      return pq.asIterable();
    }
View Full Code Here

    public static Iterable<Entity> listChildren(String kind, Key ancestor, int offset, int limit)
    {
      Query query = new Query(kind);
      query.setAncestor(ancestor);
      query.addFilter("__key__", Query.FilterOperator.GREATER_THAN, ancestor);
      PreparedQuery pq = datastore.prepare(query);
      if ((limit == 0) && (offset == 0)) {
        return pq.asIterable();
      }
      return pq.asIterable(FetchOptions.Builder.withOffset(offset).limit(limit));
    }
View Full Code Here


    Query q = new Query(table);
    q = q.addFilter(field,qf,value);
     DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
        PreparedQuery pq = datastore.prepare(q) ;
    return pq.countEntities();
}
View Full Code Here

   for (int ct = 0; ct < readTries;ct++)
{
try{  
     DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
     Query q = new Query(table);
        PreparedQuery pq = datastore.prepare(q) ;
    return pq.countEntities();

  }catch (com.google.appengine.api.datastore.DatastoreTimeoutException e){
  ex = e;
  if ((ct) == (readTries -3))
  System.out.println(ct + "JGU.count TABLE TRYING " + table  +  ":" + e.toString());
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.PreparedQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.