use of org.activityinfo.store.spi.ColumnQueryBuilder 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());
}
}
use of org.activityinfo.store.spi.ColumnQueryBuilder in project activityinfo by bedatadriven.
the class ColumnSetBuilder method executeScan.
private void executeScan(FormScan scan) {
if (scan.isEmpty()) {
LOGGER.info("Skipping form scan of " + scan.getFormId() + ", fully resolved from cache");
return;
}
Optional<FormStorage> form = catalog.getForm(scan.getFormId());
if (!form.isPresent()) {
throw new IllegalStateException("No storage for form " + scan.getFormId());
}
ColumnQueryBuilder queryBuilder = form.get().newColumnQuery();
scan.prepare(queryBuilder);
// Run the query
Stopwatch stopwatch = Stopwatch.createStarted();
queryBuilder.execute();
LOGGER.info("Form scan of " + scan.getFormId() + " completed in " + stopwatch);
}
Aggregations