Package com.google.appengine.api.datastore

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


  }
 
  public static String addNotifier(String email, String pNum, String dept, String course, String section){
    String verifyKey = generateVerificationKey();
    Key k = KeyFactory.createKey(DATASTORE_ENTITY_SET_NAME, DATASTORE_ENTITY_KEY_NAME);
    Transaction txn = datastore.beginTransaction();                               
    Entity e = new Entity(ENTRY_KIND,k);                                      
    e.setProperty(EMAIL_PROPERTY, email);    
    e.setProperty(ACTIVATED_PROPERTY, false);
    e.setProperty(VERIFY_KEY_PROPERTY, verifyKey);
    e.setProperty(PHONE_NUMBER_PROPERTY, pNum);
    e.setProperty(DEPT_PROPERTY, dept);
    e.setProperty(COURSE_PROPERTY, course);
    e.setProperty(SECTION_PROPERTY, section);
    datastore.put(e);                                                             
    txn.commit();
    return verifyKey;
  }
View Full Code Here


  public 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

 
  public boolean addAccount(AccountObject ao){
    if(!this.checkAccountExist(ao.getEmail())){
      //create and commit this entry
      Key k = KeyFactory.createKey(DATASTORE_ENTITY_SET_NAME, DATASTORE_ENTITY_KEY_NAME);
      Transaction txn = datastore.beginTransaction();                               
      Entity e = new Entity(ACCOUNT_KIND,k);                                      
      e.setProperty(ACCOUNT_ID_PROPERTY, ao.getEmail());    
      e.setProperty(PASSWORD_PROPERTY, ao.getPassword());
      e.setProperty(ACTIVATED_PROPERTY, ao.isActivated());
      e.setProperty(AUTHENTICATION_KEY_PROPERTY, ao.getAuthkey());
      e.setProperty(PREFERENCE_NOTIFY_CONFIG_PROPERTY, ao.getNotifyConfig());
      e.setProperty(PREFERENCE_PHONE_NUMBER_PROPERTY, ao.getPhoneNumber());
      e.setProperty(PREFERENCE_CARRIER_PROPERTY, ao.getCarrier().getGateway());
      datastore.put(e);                                                             
      txn.commit();                                                                 
      return true;
    }
    return false;
  }
View Full Code Here

      return false;
    if(!e.getProperty(AUTHENTICATION_KEY_PROPERTY).equals(authKey))
      return false;
    if(e.getProperty(ACTIVATED_PROPERTY).equals(true))
      return false;
    Transaction txn = datastore.beginTransaction();
    e.setProperty(ACTIVATED_PROPERTY, true);
    datastore.put(e);
    txn.commit();
    return true;
  }
View Full Code Here

    Query q = new Query(ACCOUNT_KIND);
    q.addFilter(ACCOUNT_ID_PROPERTY, Query.FilterOperator.EQUAL, lao.getEmail());
    Entity qe = datastore.prepare(q).asSingleEntity();
    if(qe == null)
      return false;
    Transaction txn = datastore.beginTransaction();  
    qe.setProperty(PASSWORD_PROPERTY, lao.getPassword());
    qe.setProperty(AUTHENTICATION_KEY_PROPERTY, lao.getAuthkey());
    qe.setProperty(PREFERENCE_NOTIFY_CONFIG_PROPERTY, lao.getNotifyConfig());
    qe.setProperty(PREFERENCE_PHONE_NUMBER_PROPERTY, lao.getPhoneNumber());
    qe.setProperty(PREFERENCE_CARRIER_PROPERTY, lao.getCarrier().getGateway());
    datastore.put(qe);
    txn.commit();
    return true;
  }
View Full Code Here

      return false;
    Key k_from = e_from.getKey();
    Key k_to = e_to.getKey();
    if(checkSubscriptionExists(k_from, from, k_to, to))
      return false;
    Transaction txn = datastore.beginTransaction();
    Entity sub_from = new Entity(SUBSCRIPTION_KIND, k_from);
    sub_from.setProperty(SUBSCRIPTION_EMAIL_PROPERTY, to);
    //When first add, set a pending request
    sub_from.setProperty(SUBSCRIPTION_STATUS_PROPERTY, "Waiting");
    datastore.put(sub_from);
    Entity sub_to = new Entity(SUBSCRIPTION_KIND, k_to);
    sub_to.setProperty(SUBSCRIPTION_EMAIL_PROPERTY, from);
    sub_to.setProperty(SUBSCRIPTION_STATUS_PROPERTY, "Pending");
    datastore.put(sub_to);
    txn.commit();
    return true;
  }
View Full Code Here

    PreparedQuery pq_from = datastore.prepare(s_from);
    Entity sub_from = pq_from.asSingleEntity();
    if(sub_from == null || !sub_from.getProperty(SUBSCRIPTION_STATUS_PROPERTY).equals(SUBSCRIPTION_STATUS_PENDING))
      return false;
    sub_from.setProperty(SUBSCRIPTION_STATUS_PROPERTY, SUBSCRIPTION_STATUS_ACTIVE);
    Transaction txn = datastore.beginTransaction();
    datastore.put(sub_to);
    datastore.put(sub_from);
    txn.commit();
    return true;
  }
View Full Code Here

    s_from.setKeysOnly();
    PreparedQuery pq_from = datastore.prepare(s_from);
    Entity sub_from = pq_from.asSingleEntity();
    if(sub_from == null || !sub_from.getProperty(SUBSCRIPTION_STATUS_PROPERTY).equals(SUBSCRIPTION_STATUS_PENDING))
      return false;
    Transaction txn = datastore.beginTransaction();
    datastore.delete(sub_to.getKey());
    datastore.delete(sub_from.getKey());
    txn.commit();
    return true;
  }
View Full Code Here

    PreparedQuery pq_sender = datastore.prepare(q_sub_sender);
    Entity sender_entity = pq_sender.asSingleEntity();
    if(sender_entity == null)
      return false;
    Key sender_key = sender_entity.getKey();
    Transaction txn = datastore.beginTransaction();
    Entity sender_feed = new Entity(FEED_KIND, sender_key);
    sender_feed.setProperty(FEED_READ_STATUS_PROPERTY, false);
    sender_feed.setProperty(FEED_MESSAGE_PROPERTY, new Text(message));
    sender_feed.setProperty(FEED_TIMESTAMP_PROPERTY, new Date());
    datastore.put(sender_feed);
    txn.commit();
    return true;
  }
View Full Code Here

      PreparedQuery pq = datastore.prepare(q_user);
      Entity e_user = pq.asSingleEntity();
      if (e_user == null)
        return false;
      Key k = e_user.getKey();
      Transaction txn = datastore.beginTransaction();
      Entity e_wli = new Entity(WORKLIST_ITEM_KIND, k);
      e_wli.setProperty(WORKLIST_ITEM_DEPT_PROPERTY, wio.getDeptId());
      e_wli.setProperty(WORKLIST_ITEM_COURSE_PROPERTY, wio.getCourseId());
      e_wli.setProperty(WORKLIST_ITEM_SECTION_PROPERTY, wio.getSectionId());
      if(spiderDatastore.querySectionFromId( wio.getDeptId(), wio.getCourseId(),wio.getSectionId()) == null)
        return false;
      datastore.put(e_wli);
      txn.commit();
    } else
      return false;
    return true;
  }
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.