use of org.activityinfo.promise.Promise in project activityinfo by bedatadriven.
the class HierarchyClassImporter method prepare.
@Override
public Promise<Void> prepare(ResourceLocator locator, List<? extends SourceRow> batch) {
final List<Promise<Void>> promises = Lists.newArrayList();
for (final ResourceId formId : rootField.getRange()) {
if (isMatchableAtLevel(formId, referenceFields.keySet())) {
QueryModel queryModel = new QueryModel(formId);
queryModel.selectResourceId().as("_id");
for (FieldPath referenceFieldPath : referenceFields.keySet()) {
queryModel.selectField(referenceFieldPath).as(referenceFieldPath.toString());
}
promises.add(locator.queryTable(queryModel).then(new Function<ColumnSet, Void>() {
@Override
public Void apply(ColumnSet columnSet) {
scoreSources.put(formId, new InstanceScoreSourceBuilder(formId, referenceFields, sourceColumns).build(columnSet));
return null;
}
}));
}
}
return Promise.waitAll(promises);
}
Aggregations