Package com.google.appengine.api.datastore

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


    }
    return biol;
  }

  private List<Entity> getKindEntityList(String entityKind) {
    Query q = new Query(entityKind);
    if (entityKind.equals(DEPARTMENT_KIND)) {
      q.addSort(DEPARTMENT_ID_PROPERTY, SortDirection.ASCENDING);
    }
    else if (entityKind.equals(COURSE_KIND)) {
      q.addSort(DEPARTMENT_ID_PROPERTY, SortDirection.ASCENDING);
      q.addSort(COURSE_ID_PROPERTY, SortDirection.ASCENDING);
    } else if (entityKind.equals(SECTION_KIND)) {
      q.addSort(DEPARTMENT_ID_PROPERTY, SortDirection.ASCENDING);
      q.addSort(COURSE_ID_PROPERTY, SortDirection.ASCENDING);
      q.addSort(SECTION_ID_PROPERTY, SortDirection.ASCENDING);
    }
    List<Entity> results = datastore.prepare(q).asList(
        FetchOptions.Builder.withDefaults());
    return results;
  }
View Full Code Here


        FetchOptions.Builder.withDefaults());
    return results;
  }

  private Key makeParentKey(CourseInformationObject cio) {
    Query q = new Query(DEPARTMENT_KIND);
    q.setKeysOnly();
    q.addFilter(DEPARTMENT_ID_PROPERTY, FilterOperator.EQUAL,
        cio.getDepartmentId());
    PreparedQuery pq = datastore.prepare(q);
    return pq.asSingleEntity().getKey();
  }
View Full Code Here

    PreparedQuery pq = datastore.prepare(q);
    return pq.asSingleEntity().getKey();
  }

  private Key makeParentKey(SectionInformationObject sio) {
    Query q = new Query(COURSE_KIND);
    q.setKeysOnly();
    q.addFilter(DEPARTMENT_ID_PROPERTY, FilterOperator.EQUAL,
        sio.getDepartmentId());
    q.addFilter(COURSE_ID_PROPERTY, FilterOperator.EQUAL, sio.getCourseId());
    PreparedQuery pq = datastore.prepare(q);
    return pq.asSingleEntity().getKey();
  }
View Full Code Here

    PreparedQuery pq = datastore.prepare(q);
    return pq.asSingleEntity().getKey();
  }

  private Key makeParentKey(BookInformationObject bio) {
    Query q = new Query(DEPARTMENT_KIND);
    q.setKeysOnly();
    q.addFilter(DEPARTMENT_ID_PROPERTY, FilterOperator.EQUAL,
        bio.getDepartmentId());
    q.addFilter(COURSE_ID_PROPERTY, FilterOperator.EQUAL, bio.getCourseId());
    q.addFilter(SECTION_ID_PROPERTY, FilterOperator.EQUAL,
        bio.getSectionId());
    PreparedQuery pq = datastore.prepare(q);
    return pq.asSingleEntity().getKey();
  }
View Full Code Here

    PreparedQuery pq = datastore.prepare(q);
    return pq.asSingleEntity().getKey();
  }

  public DepartmentInformationObject queryDepartmentFromId(String departmentId) {
    Query q = new Query(DEPARTMENT_KIND);
    q.addFilter(DEPARTMENT_ID_PROPERTY, FilterOperator.EQUAL, departmentId);
    PreparedQuery pq = datastore.prepare(q);
    Entity e = pq.asSingleEntity();
    if (e == null)
      return null;
    return getDepartmentFromEntity(e);
View Full Code Here

    return getDepartmentFromEntity(e);
  }

  public CourseInformationObject queryCourseFromId(String departmentId,
      String courseId) {
    Query q = new Query(COURSE_KIND);
    q.addFilter(DEPARTMENT_ID_PROPERTY, FilterOperator.EQUAL, departmentId);
    q.addFilter(COURSE_ID_PROPERTY, FilterOperator.EQUAL, courseId);
    PreparedQuery pq = datastore.prepare(q);
    Entity e = pq.asSingleEntity();
    if (e == null)
      return null;
    return getCourseFromEntity(e);
View Full Code Here

    return getCourseFromEntity(e);
  }

  public SectionInformationObject querySectionFromId(String departmentId,
      String courseId, String sectionId) {
    Query q = new Query(SECTION_KIND);
    q.addFilter(DEPARTMENT_ID_PROPERTY, FilterOperator.EQUAL, departmentId);
    q.addFilter(COURSE_ID_PROPERTY, FilterOperator.EQUAL, courseId);
    q.addFilter(SECTION_ID_PROPERTY, FilterOperator.EQUAL, sectionId);
    PreparedQuery pq = datastore.prepare(q);
    Entity e = pq.asSingleEntity();
    if (e == null)
      return null;
    return getSectionFromEntity(e);
View Full Code Here

    return new BookInformationObject(departmentId, courseId, sectionId,
        title, required, author, isbn);
  }

  public List<DepartmentInformationObject> queryDepartmentByPrefix(String prefix) {
    Query q = new Query(DEPARTMENT_KIND);
    q.addFilter(DEPARTMENT_ID_PROPERTY, FilterOperator.GREATER_THAN_OR_EQUAL, prefix);
    q.addSort(DEPARTMENT_ID_PROPERTY,SortDirection.ASCENDING);
    PreparedQuery pq = datastore.prepare(q);
    List<Entity> results = pq.asList(FetchOptions.Builder.withLimit(10));
    List<DepartmentInformationObject> diol = new ArrayList<DepartmentInformationObject>();
    for(Iterator<Entity> i = results.iterator(); i.hasNext();) {
      Entity e = i.next();
View Full Code Here

    }
    return diol;
  }

  public List<CourseInformationObject> queryCourseByPrefix(String deptId, String prefix) {
    Query q = new Query(COURSE_KIND);
    q.addFilter(DEPARTMENT_ID_PROPERTY, FilterOperator.EQUAL, deptId);
    q.addFilter(COURSE_ID_PROPERTY, FilterOperator.GREATER_THAN_OR_EQUAL, prefix);
    q.addSort(DEPARTMENT_ID_PROPERTY, SortDirection.ASCENDING);
    q.addSort(COURSE_ID_PROPERTY, SortDirection.ASCENDING);
    PreparedQuery pq = datastore.prepare(q)
    List<Entity> results = pq.asList(FetchOptions.Builder.withLimit(10));
    List<CourseInformationObject> ciol = new ArrayList<CourseInformationObject>();
    for(Iterator<Entity> i = results.iterator(); i.hasNext();) {
      Entity e = i.next();
View Full Code Here

    }
    return ciol;
  }

  public List<SectionInformationObject> querySectionByPrefix(String deptId, String courseId, String prefix) {
    Query q = new Query(SECTION_KIND);
    q.addFilter(DEPARTMENT_ID_PROPERTY, FilterOperator.EQUAL, deptId);
    q.addFilter(COURSE_ID_PROPERTY, FilterOperator.EQUAL, courseId);
    q.addFilter(SECTION_ID_PROPERTY, FilterOperator.GREATER_THAN_OR_EQUAL, prefix);
    q.addSort(DEPARTMENT_ID_PROPERTY, SortDirection.ASCENDING);
    q.addSort(COURSE_ID_PROPERTY, SortDirection.ASCENDING);
    q.addSort(SECTION_ID_PROPERTY, SortDirection.ASCENDING);
    PreparedQuery pq = datastore.prepare(q);
    List<Entity> results = pq.asList(FetchOptions.Builder.withLimit(10));
    List<SectionInformationObject> siol = new ArrayList<SectionInformationObject>();
    for(Iterator<Entity> i = results.iterator(); i.hasNext();){
      Entity e = i.next();
View Full Code Here

TOP

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

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.