コード例 #1
0
 /**
  * Helper function for constructors.
  *
  * @param parameterTableRelation
  * @param fsc
  * @param cc
  * @return
  * @throws ODKDatastoreException
  */
 protected static final <T extends CommonFieldsBase> T retrieveEntity(
     T parameterTableRelation, FormServiceCursor fsc, CallingContext cc)
     throws ODKDatastoreException {
   Datastore ds = cc.getDatastore();
   User user = cc.getCurrentUser();
   return ds.getEntity(parameterTableRelation, fsc.getAuriService(), user);
 }
コード例 #2
0
 @Override
 public void setUploadCompleted(CallingContext cc)
     throws ODKEntityPersistException, ODKOverQuotaException {
   fsc.setUploadCompleted(true);
   if (fsc.getExternalServicePublicationOption() == ExternalServicePublicationOption.UPLOAD_ONLY) {
     fsc.setOperationalStatus(OperationalStatus.COMPLETED);
   }
   Datastore ds = cc.getDatastore();
   User user = cc.getCurrentUser();
   ds.putEntity(fsc, user);
 }
コード例 #3
0
 static final synchronized FormSettingsTable assertRelation(CallingContext cc)
     throws ODKDatastoreException {
   if (relation == null) {
     FormSettingsTable relationPrototype;
     Datastore ds = cc.getDatastore();
     User user = cc.getUserService().getDaemonAccountUser();
     relationPrototype = new FormSettingsTable(ds.getDefaultSchemaName());
     ds.assertRelation(relationPrototype, user); // may throw exception...
     // at this point, the prototype has become fully populated
     relation = relationPrototype; // set static variable only upon success...
   }
   return relation;
 }
コード例 #4
0
  @Override
  public void persist(CallingContext cc) throws ODKEntityPersistException, ODKOverQuotaException {
    Datastore ds = cc.getDatastore();
    User user = cc.getCurrentUser();

    CommonFieldsBase serviceEntity = retrieveObjectEntity();
    List<? extends CommonFieldsBase> repeats = retrieveRepeatElementEntities();

    if (repeats != null) {
      ds.putEntities(repeats, user);
    }
    ds.putEntity(serviceEntity, user);
    ds.putEntity(fsc, user);
  }
コード例 #5
0
  @Override
  public void delete(CallingContext cc) throws ODKDatastoreException {
    CommonFieldsBase serviceEntity = retrieveObjectEntity();
    List<? extends CommonFieldsBase> repeats = retrieveRepeatElementEntities();

    Datastore ds = cc.getDatastore();
    User user = cc.getCurrentUser();

    if (repeats != null) {
      List<EntityKey> keys = new ArrayList<EntityKey>();
      for (CommonFieldsBase repeat : repeats) {
        keys.add(repeat.getEntityKey());
      }
      ds.deleteEntities(keys, user);
      repeats.clear();
    }

    ds.deleteEntity(serviceEntity.getEntityKey(), user);
    ds.deleteEntity(fsc.getEntityKey(), user);
  }
コード例 #6
0
 /**
  * Helper function for constructors.
  *
  * @param parameterTableRelation
  * @param cc
  * @return
  * @throws ODKDatastoreException
  */
 protected static final <T extends CommonFieldsBase> T newEntity(
     T parameterTableRelation, CallingContext cc) throws ODKDatastoreException {
   Datastore ds = cc.getDatastore();
   User user = cc.getCurrentUser();
   return ds.createEntityUsingRelation(parameterTableRelation, user);
 }