Search in sources :

Example 1 with HrdFormStorage

use of org.activityinfo.store.hrd.HrdFormStorage 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));
}
Also used : FormStorageProvider(org.activityinfo.store.spi.FormStorageProvider) FormStorage(org.activityinfo.store.spi.FormStorage) HrdFormStorage(org.activityinfo.store.hrd.HrdFormStorage) JsonValue(org.activityinfo.json.JsonValue) HrdFormStorage(org.activityinfo.store.hrd.HrdFormStorage)

Aggregations

JsonValue (org.activityinfo.json.JsonValue)1 HrdFormStorage (org.activityinfo.store.hrd.HrdFormStorage)1 FormStorage (org.activityinfo.store.spi.FormStorage)1 FormStorageProvider (org.activityinfo.store.spi.FormStorageProvider)1