@Override
 public void abandon(CallingContext cc) throws ODKDatastoreException {
   if (fsc.getOperationalStatus() != OperationalStatus.COMPLETED) {
     fsc.setOperationalStatus(OperationalStatus.ABANDONED);
     persist(cc);
   }
 }
 @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);
 }
 /**
  * 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);
 }
 /** @see java.lang.Object#hashCode() */
 @Override
 public int hashCode() {
   int hashCode = 13;
   if (retrieveObjectEntity() != null) hashCode += retrieveObjectEntity().hashCode();
   if (fsc != null) hashCode += fsc.hashCode();
   return hashCode;
 }
 @Override
 public ExternServSummary transform() {
   return new ExternServSummary(
       fsc.getUri(),
       fsc.getCreatorUriUser(),
       fsc.getOperationalStatus(),
       fsc.getEstablishmentDateTime(),
       fsc.getExternalServicePublicationOption(),
       fsc.getUploadCompleted(),
       fsc.getLastUploadCursorDate(),
       fsc.getLastStreamingCursorDate(),
       fsc.getExternalServiceType(),
       getOwnership(),
       getDescriptiveTargetString());
 }
  protected void postUploadTask(CallingContext cc) throws ODKExternalServiceException {
    // upload data to external service
    if (!fsc.getExternalServicePublicationOption()
        .equals(ExternalServicePublicationOption.STREAM_ONLY)) {

      UploadSubmissions uploadTask = (UploadSubmissions) cc.getBean(BeanDefs.UPLOAD_TASK_BEAN);
      CallingContext ccDaemon = ContextFactory.duplicateContext(cc);
      ccDaemon.setAsDaemon(true);
      uploadTask.createFormUploadTask(fsc, true, ccDaemon);
    }
  }
 /** Helper function for constructors. */
 protected static FormServiceCursor createFormServiceCursor(
     IForm form,
     CommonFieldsBase entity,
     ExternalServicePublicationOption externalServiceOption,
     ExternalServiceType type,
     CallingContext cc)
     throws ODKDatastoreException {
   FormServiceCursor formServiceCursor =
       FormServiceCursor.createFormServiceCursor(form, type, entity, cc);
   formServiceCursor.setExternalServiceOption(externalServiceOption);
   formServiceCursor.setIsExternalServicePrepared(false);
   formServiceCursor.setOperationalStatus(OperationalStatus.ESTABLISHED);
   formServiceCursor.setEstablishmentDateTime(new Date());
   formServiceCursor.setUploadCompleted(false);
   return formServiceCursor;
 }
  @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);
  }