Package com.google.appengine.api.datastore

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


    // does nothing
    return null;
  }

  public SienaFuture<Void> commitTransaction() {
    Transaction txn = ds.getCurrentTransaction();
    return new SienaFutureContainer<Void>(txn.commitAsync());
  }
View Full Code Here


    Transaction txn = ds.getCurrentTransaction();
    return new SienaFutureContainer<Void>(txn.commitAsync());
  }

  public SienaFuture<Void> rollbackTransaction() {
    Transaction txn = ds.getCurrentTransaction();
    return new SienaFutureContainer<Void>(txn.rollbackAsync());
  }
View Full Code Here

  public void closeConnection() {
    // does nothing
  }

  public void commitTransaction() {
    Transaction txn = ds.getCurrentTransaction();
    txn.commit();
  }
View Full Code Here

    Transaction txn = ds.getCurrentTransaction();
    txn.commit();
  }

  public void rollbackTransaction() {
    Transaction txn = ds.getCurrentTransaction();
    txn.rollback();
  }
View Full Code Here

    datastore = DatastoreServiceFactory.getDatastoreService();
  }

  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

      Key k = KeyFactory.createKey(DATASTORE_ENTITY_SET_NAME,
          DATASTORE_ENTITY_KEY_NAME); // Get the key of the parent
                        // node you wish to attach
                        // 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

   *            CourseInformationObject - course data to be added
   * @return boolean value whether add was successful or not
   */
  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

   * @return boolean value whether add was successful or not
   */
  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;
    }
    return false;
  }
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

 
  private static void initSchema(){
    Query q = new Query(DATASTORE_ENTITY_SET_NAME);
    q.setKeysOnly();
    if(datastore.prepare(q).asSingleEntity() == null) {
      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

TOP

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

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.