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));
}
Aggregations