use of org.activityinfo.model.query.ColumnModel in project activityinfo by bedatadriven.
the class ApiViewModel method getQueryPostBody.
public String getQueryPostBody() {
QueryModel queryModel = new QueryModel(tableModel.getFormId());
for (EffectiveTableColumn tableColumn : tableModel.getColumns()) {
List<ColumnModel> columns = tableColumn.getQueryModel();
if (columns.size() == 1) {
ColumnModel columnModel = new ColumnModel();
columnModel.setId(tableColumn.getLabel());
columnModel.setFormula(tableColumn.getFormulaString());
queryModel.addColumn(columnModel);
} else if (columns.size() > 1) {
for (int i = 0; i < columns.size(); i++) {
ColumnModel columnModel = new ColumnModel();
columnModel.setId(tableColumn.getLabel() + "." + i);
columnModel.setFormula(tableColumn.getFormulaString());
queryModel.addColumn(columnModel);
}
}
}
return Json.stringify(queryModel.toJson(), 2);
}
use of org.activityinfo.model.query.ColumnModel in project activityinfo by bedatadriven.
the class PartnerDimBinding method getColumnQuery.
private List<ColumnModel> getColumnQuery(ResourceId formId) {
SymbolNode partnerField = new SymbolNode(CuidAdapter.field(formId, CuidAdapter.PARTNER_FIELD));
ColumnModel partnerId = new ColumnModel();
partnerId.setFormula(partnerField);
partnerId.setId(PARTNER_ID_COLUMN);
ColumnModel partnerLabel = new ColumnModel();
partnerLabel.setFormula(new CompoundExpr(partnerField, new SymbolNode("label")));
partnerLabel.setId(PARTNER_LABEL_COLUMN);
return Arrays.asList(partnerId, partnerLabel);
}
use of org.activityinfo.model.query.ColumnModel in project activityinfo by bedatadriven.
the class ProjectDimBinding method getTargetColumnQuery.
@Override
public List<ColumnModel> getTargetColumnQuery(ResourceId targetFormId) {
SymbolNode projectField = new SymbolNode(CuidAdapter.field(targetFormId, CuidAdapter.PROJECT_FIELD));
ColumnModel projectId = new ColumnModel();
projectId.setFormula(projectField);
projectId.setId(PROJECT_ID_COLUMN);
ColumnModel projectLabel = new ColumnModel();
projectLabel.setFormula(new CompoundExpr(projectField, new SymbolNode("label")));
projectLabel.setId(PROJECT_LABEL_COLUMN);
return Arrays.asList(projectId, projectLabel);
}
use of org.activityinfo.model.query.ColumnModel 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.query.ColumnModel 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);
}
Aggregations