use of org.activityinfo.model.formTree.FieldPath in project activityinfo by bedatadriven.
the class SingleClassTargetBuilder method newImporter.
public SingleClassImporter newImporter(Map<TargetSiteId, ColumnAccessor> mappings) {
List<ColumnAccessor> sourceColumns = Lists.newArrayList();
Map<FieldPath, Integer> referenceValues = targetCollector.getPathMap(mappings, sourceColumns);
List<FieldImporterColumn> fieldImporterColumns = targetCollector.fieldImporterColumns(mappings);
ResourceId rangeClassId = Iterables.getOnlyElement(rootField.getRange());
return new SingleClassImporter(rangeClassId, rootField.getField().isRequired(), sourceColumns, referenceValues, fieldImporterColumns, rootField.getFieldId());
}
use of org.activityinfo.model.formTree.FieldPath in project activityinfo by bedatadriven.
the class TargetCollector method getPathMap.
public Map<FieldPath, Integer> getPathMap(Map<TargetSiteId, ColumnAccessor> mappings, List<ColumnAccessor> sourceColumns) {
Map<FieldPath, Integer> referenceValues = new HashMap<>();
List<FieldImporterColumn> importerColumns = Lists.newArrayList();
int columnIndex = 0;
for (Map.Entry<TargetSiteId, ColumnAccessor> entry : mappings.entrySet()) {
ImportTarget target = getTargetBySiteId(entry.getKey());
ColumnAccessor source = entry.getValue();
importerColumns.add(new FieldImporterColumn(target, source));
sourceColumns.add(entry.getValue());
ResourceId fieldId = ResourceId.valueOf(entry.getKey().asString());
for (FieldPath path : getFieldPathMap().get(fieldId)) {
referenceValues.put(path, columnIndex);
}
columnIndex++;
}
return referenceValues;
}
use of org.activityinfo.model.formTree.FieldPath in project activityinfo by bedatadriven.
the class DefaultQueryBuilder method simpleColumnModel.
private List<ColumnModel> simpleColumnModel(String aliasPrefix, FieldPath pathPrefix, FormField formField) {
ColumnModel column = new ColumnModel();
column.setId(aliasPrefix + formatFieldAlias(formField));
column.setFormula(new FieldPath(pathPrefix, fieldFormula(formField)));
return Collections.singletonList(column);
}
use of org.activityinfo.model.formTree.FieldPath in project activityinfo by bedatadriven.
the class DefaultQueryBuilder method geoPointColumns.
private List<ColumnModel> geoPointColumns(String aliasPrefix, FieldPath pathPrefix, FormField field) {
String fieldAlias = aliasPrefix + formatFieldAlias(field);
FieldPath fieldPath = new FieldPath(pathPrefix, fieldFormula(field));
ColumnModel latitudeColumn = new ColumnModel();
latitudeColumn.setId(fieldAlias + ".latitude");
latitudeColumn.setFormula(new FieldPath(fieldPath, ResourceId.valueOf(GeoPointType.LATITUDE)));
ColumnModel longitudeColumn = new ColumnModel();
longitudeColumn.setId(fieldAlias + ".longitude");
longitudeColumn.setFormula(new FieldPath(fieldPath, ResourceId.valueOf(GeoPointType.LONGITUDE)));
return Arrays.asList(latitudeColumn, longitudeColumn);
}
use of org.activityinfo.model.formTree.FieldPath in project activityinfo by bedatadriven.
the class DefaultQueryBuilder method build.
public QueryModel build() {
LOGGER.info("No query fields provided, querying all.");
addFields("", new FieldPath(), tree.getRootFields());
this.queryModel = new QueryModel(tree.getRootFormId());
this.queryModel.selectResourceId().as("@id");
for (ColumnModel columnModel : columns.values()) {
this.queryModel.addColumn(columnModel);
}
return queryModel;
}
Aggregations