use of org.activityinfo.model.form.FormRecord in project activityinfo by bedatadriven.
the class ActivityInfoClient method getTypedRecord.
public FormInstance getTypedRecord(FormClass formClass, ResourceId recordId) {
FormRecord record = getRecord(formClass.getId(), recordId);
FormInstance instance = FormInstance.toFormInstance(formClass, record);
return instance;
}
use of org.activityinfo.model.form.FormRecord in project activityinfo by bedatadriven.
the class QuerySubRecords method run.
@Override
public List<FormRecord> run() {
QueryResultIterable<FormRecordEntity> query = ofy().load().type(FormRecordEntity.class).ancestor(FormEntity.key(formClass)).filter("parentRecordId", this.parentRecordId.asString()).iterable();
List<FormRecord> records = Lists.newArrayList();
for (FormRecordEntity entity : query) {
records.add(entity.toFormRecord(formClass));
}
return records;
}
use of org.activityinfo.model.form.FormRecord in project activityinfo by bedatadriven.
the class SyncSetBuilder method buildUpdateArrays.
private List<FormRecord> buildUpdateArrays() {
FormRecord[] records = new FormRecord[snapshots.size()];
int i = 0;
for (FormRecordSnapshotEntity snapshotEntity : snapshots.values()) {
records[i++] = snapshotEntity.getRecord().toFormRecord(formClass);
}
return Arrays.asList(records);
}
use of org.activityinfo.model.form.FormRecord in project activityinfo by bedatadriven.
the class FormRecordEntity method toFormRecord.
public FormRecord toFormRecord(FormClass formClass) {
FormRecord.Builder record = FormRecord.builder();
record.setFormId(formClass.getId());
record.setRecordId(getRecordId());
if (formClass.getParentField().isPresent()) {
record.setParentRecordId(ResourceId.valueOf(getParentRecordId()));
}
for (FormField formField : formClass.getFields()) {
Object value = fieldValues.getProperty(formField.getName());
if (value != null) {
FieldConverter<?> converter = FieldConverters.forType(formField.getType());
record.setFieldValue(formField.getId(), converter.toFieldValue(value));
}
}
return record.build();
}
use of org.activityinfo.model.form.FormRecord in project activityinfo by bedatadriven.
the class RecordFetcher method get.
public Optional<FormRecord> get(ResourceId resourceId) {
FormClass formClass = collection.getFormClass();
FormRecord.Builder formRecord = FormRecord.builder();
formRecord.setRecordId(resourceId);
formRecord.setFormId(formClass.getId());
IdCollector id = new IdCollector();
ColumnQueryBuilder query = collection.newColumnQuery();
query.addResourceId(id);
query.only(resourceId);
for (FormField formField : formClass.getFields()) {
if (hasValues(formField)) {
query.addField(formField.getId(), new FieldCollector(formField.getId(), formRecord));
}
}
query.execute();
if (id.value == null) {
return Optional.absent();
} else {
return Optional.of(formRecord.build());
}
}
Aggregations