use of org.activityinfo.store.spi.FormStorageProvider in project activityinfo by bedatadriven.
the class ActivityInfoClientAsyncStub method updateRecord.
@Override
public Promise<Void> updateRecord(String formId, String recordId, FormRecordUpdateBuilder query) {
try {
FormStorageProvider catalog = newCatalog();
Updater updater = new Updater(catalog, currentUserId(), blobAuthorizer, new SerialNumberProviderStub());
updater.execute(ResourceId.valueOf(formId), ResourceId.valueOf(recordId), query.toJsonObject());
return Promise.resolved(null);
} catch (Exception e) {
return Promise.rejected(e);
}
}
use of org.activityinfo.store.spi.FormStorageProvider in project activityinfo by bedatadriven.
the class ActivityInfoClientAsyncStub method updateFormSchema.
@Override
public Promise<Void> updateFormSchema(String formId, FormClass updatedSchema) {
FormStorageProvider catalog = newCatalog();
try {
EntityTransaction tx = entityManager.get().getTransaction();
tx.begin();
Optional<FormStorage> collection = catalog.getForm(updatedSchema.getId());
if (collection.isPresent()) {
collection.get().updateFormClass(updatedSchema);
} else {
((MySqlStorageProvider) catalog).createOrUpdateFormSchema(updatedSchema);
}
tx.commit();
return Promise.resolved(null);
} catch (Exception e) {
return Promise.rejected(e);
}
}
use of org.activityinfo.store.spi.FormStorageProvider in project activityinfo by bedatadriven.
the class ActivityInfoClientAsyncStub method createRecord.
@Override
public Promise<Void> createRecord(String formId, NewFormRecordBuilder query) {
try {
FormStorageProvider catalog = newCatalog();
Updater updater = new Updater(catalog, currentUserId(), blobAuthorizer, new SerialNumberProviderStub());
updater.create(ResourceId.valueOf(formId), query.toJsonObject());
return Promise.resolved(null);
} catch (Exception e) {
return Promise.rejected(e);
}
}
use of org.activityinfo.store.spi.FormStorageProvider in project activityinfo by bedatadriven.
the class ActivityInfoClientAsyncStub method queryTableColumns.
@Override
public Promise<ColumnSet> queryTableColumns(QueryModel query) {
try {
FormStorageProvider catalog = newCatalog();
ColumnSetBuilder builder = new ColumnSetBuilder(catalog, new NullFormSupervisor());
return Promise.resolved(builder.build(query));
} catch (Exception e) {
return Promise.rejected(e);
}
}
use of org.activityinfo.store.spi.FormStorageProvider in project activityinfo by bedatadriven.
the class ActivityInfoClientAsyncStub method getRecords.
@Override
public Promise<FormRecordSet> getRecords(String formId, String parentId) {
FormStorageProvider catalog = newCatalog();
Optional<FormStorage> collection = catalog.getForm(ResourceId.valueOf(formId));
JsonValue recordArray = Json.createArray();
if (collection.isPresent()) {
if (collection.get() instanceof HrdFormStorage) {
HrdFormStorage hrdForm = (HrdFormStorage) collection.get();
Iterable<FormRecord> records = hrdForm.getSubRecords(ResourceId.valueOf(parentId));
for (FormRecord record : records) {
recordArray.add(record.toJson());
}
}
}
JsonValue object = createObject();
object.put("formId", formId);
object.put("records", recordArray);
return Promise.resolved(FormRecordSet.fromJson(object));
}
Aggregations