Package com.google.appengine.api.datastore

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


  }

  public void initSchema() { // Initiate the first entity for our set (the
                // highest parent node)
    Transaction txn = datastore.beginTransaction();
    Entity e = new Entity(DATASTORE_ENTITY_SET_NAME,
        DATASTORE_ENTITY_KEY_NAME);
    datastore.put(e);
    txn.commit();
  }
View Full Code Here


    q.setAncestor(k);
    q.setKeysOnly();
    List<Entity> l = datastore.prepare(q).asList(
        FetchOptions.Builder.withDefaults());
    for (Iterator i = l.iterator(); i.hasNext();) {
      Entity e = (Entity) i.next();
      System.out.println(e.getKey().toString());
    }
  }
View Full Code Here

    q.setAncestor(k);
    q.setKeysOnly();
    List<Entity> l = datastore.prepare(q).asList(
        FetchOptions.Builder.withDefaults());
    for (Iterator i = l.iterator(); i.hasNext();) {
      Entity e = (Entity) i.next();
      System.out.println("deleting " + e.getKey());
      datastore.delete(e.getKey());
    }
  }
View Full Code Here

                        // entity to (in this case our
                        // top most node)
      Transaction txn = datastore.beginTransaction(); // begin a
                              // transaction for
                              // atomic adding
      Entity e = new Entity(DEPARTMENT_KIND, k); // Create the entity with
                            // the parent designated
                            // with the key
      e.setProperty(DEPARTMENT_ID_PROPERTY, dio.getDepartmentId()); // Set
                                      // all
                                      // properties
      e.setProperty(SUBJECT_TITLE_PROPERTY, dio.getSubjectTitle());
      e.setProperty(FACULTY_PROPERTY, dio.getFaculty());
      datastore.put(e); // put the entity in the datastore
      txn.commit(); // commit
      return true;
    }
    return false;
View Full Code Here

   */
  public boolean addCourse(CourseInformationObject cio) {
    if (!checkCourseExists(cio)) {
      Transaction txn = datastore.beginTransaction();
      Key k = makeParentKey(cio);
      Entity e = new Entity(COURSE_KIND, k);
      e.setProperty(DEPARTMENT_ID_PROPERTY, cio.getDepartmentId());
      e.setProperty(COURSE_ID_PROPERTY, cio.getCourseId());
      e.setProperty(COURSE_TITLE_PROPERTY, cio.getCourseTitle());
      e.setProperty(PREREQ_PROPERTY, cio.getPrereqString());
      e.setProperty(COREQ_PROPERTY, cio.getCoreqString());
      e.setProperty(CREDIT_PROPERTY, cio.getCredits());
      datastore.put(e);
      txn.commit();
      return true;
    }
    return false;
View Full Code Here

   */
  public boolean addSection(SectionInformationObject sio) {
    if (!checkSectionExists(sio)) {
      Key k = makeParentKey(sio);
      Transaction txn = datastore.beginTransaction();
      Entity e = new Entity(SECTION_KIND, k);
      e.setProperty(DEPARTMENT_ID_PROPERTY, sio.getDepartmentId());
      e.setProperty(COURSE_ID_PROPERTY, sio.getCourseId());
      e.setProperty(SECTION_ID_PROPERTY, sio.getSectionId());
      e.setProperty(ACTIVITY_PROPERTY, sio.getActivity());
      e.setProperty(TERM_PROPERTY, sio.getTerm());
      e.setProperty(DAY_PROPERTY, sio.getDay());
      e.setProperty(LOCATION_PROPERTY, sio.getLocation());
      e.setProperty(START_PROPERTY, sio.getStart());
      e.setProperty(END_PROPERTY, sio.getEnd());
      e.setProperty(INSTRUCTOR_PROPERTY, sio.getInstructor());
      e.setProperty(BUILDING_PROPERTY, sio.getBuilding());
      e.setProperty(ROOM_PROPERTY, sio.getRoom());
      e.setProperty(CDF_PROPERTY, sio.isCdf());
      e.setProperty(DROP_NO_W_PROPERTY, sio.getDropNoWDate());
      e.setProperty(DROP_W_PROPERTY, sio.getDropWDate());
      datastore.put(e);
      txn.commit();
      System.out.println("Added section: " + sio.getSectionId());
      return true;
    }
View Full Code Here

  public boolean addBooks(BookInformationObject bio) {
    if (!checkBookExists(bio)) {
      Key k = makeParentKey(bio);
      Transaction txn = datastore.beginTransaction();
      Entity e = new Entity(BOOK_KIND, k);
      e.setProperty(DEPARTMENT_ID_PROPERTY, bio.getDepartmentId());
      e.setProperty(COURSE_ID_PROPERTY, bio.getCourseId());
      e.setProperty(SECTION_ID_PROPERTY, bio.getSectionId());
      e.setProperty(BOOK_TITLE_PROPERTY, bio.getTitle());
      e.setProperty(BOOK_REQUIRED_PROPERTY, bio.getRequired());
      e.setProperty(BOOK_AUTHOR_PROPERTY, bio.getAuthor());
      e.setProperty(BOOK_ISBN_PROPERTY, bio.getIsbn());
      datastore.put(e);
      txn.commit();
      return true;
    }
    return false;
View Full Code Here

  public List<DepartmentInformationObject> getDepartmentList() {
    List<Entity> del = getKindEntityList(DEPARTMENT_KIND);
    List<DepartmentInformationObject> diol = new ArrayList<DepartmentInformationObject>();
    for (Iterator i = del.iterator(); i.hasNext();) {
      Entity e = (Entity) i.next();
      DepartmentInformationObject dio = getDepartmentFromEntity(e);
      diol.add(dio);
    }
    return diol;
  }
View Full Code Here

  public List<CourseInformationObject> getCourseList() {
    List<Entity> cel = getKindEntityList(COURSE_KIND);
    List<CourseInformationObject> ciol = new ArrayList<CourseInformationObject>();
    for (Iterator i = cel.iterator(); i.hasNext();) {
      Entity e = (Entity) i.next();
      CourseInformationObject cio = getCourseFromEntity(e);
      ciol.add(cio);
    }
    return ciol;
  }
View Full Code Here

    q.addSort(DEPARTMENT_ID_PROPERTY, SortDirection.ASCENDING);
    q.addSort(COURSE_ID_PROPERTY, SortDirection.ASCENDING);
    List<Entity> cel = datastore.prepare(q).asList(FetchOptions.Builder.withDefaults());
    List<CourseInformationObject> ciol = new ArrayList<CourseInformationObject>();
    for (Iterator i = cel.iterator(); i.hasNext();) {
      Entity e = (Entity) i.next();
      CourseInformationObject cio = getCourseFromEntity(e);
      ciol.add(cio);
    }
    return ciol;
  }
View Full Code Here

TOP

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

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.