Search in sources :

Example 1 with ColumnModel

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);
}
Also used : ColumnModel(org.activityinfo.model.query.ColumnModel) QueryModel(org.activityinfo.model.query.QueryModel)

Example 2 with ColumnModel

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);
}
Also used : CompoundExpr(org.activityinfo.model.formula.CompoundExpr) SymbolNode(org.activityinfo.model.formula.SymbolNode) ColumnModel(org.activityinfo.model.query.ColumnModel)

Example 3 with ColumnModel

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);
}
Also used : CompoundExpr(org.activityinfo.model.formula.CompoundExpr) SymbolNode(org.activityinfo.model.formula.SymbolNode) ColumnModel(org.activityinfo.model.query.ColumnModel)

Example 4 with ColumnModel

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);
}
Also used : FieldPath(org.activityinfo.model.formTree.FieldPath) ColumnModel(org.activityinfo.model.query.ColumnModel)

Example 5 with ColumnModel

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);
}
Also used : FieldPath(org.activityinfo.model.formTree.FieldPath) ColumnModel(org.activityinfo.model.query.ColumnModel)

Aggregations

ColumnModel (org.activityinfo.model.query.ColumnModel)16 CompoundExpr (org.activityinfo.model.formula.CompoundExpr)6 QueryModel (org.activityinfo.model.query.QueryModel)6 FieldPath (org.activityinfo.model.formTree.FieldPath)5 SymbolNode (org.activityinfo.model.formula.SymbolNode)5 Nullable (javax.annotation.Nullable)4 DimensionCategory (org.activityinfo.legacy.shared.reports.content.DimensionCategory)4 ColumnSet (org.activityinfo.model.query.ColumnSet)4 FormTree (org.activityinfo.model.formTree.FormTree)3 ColumnView (org.activityinfo.model.query.ColumnView)2 ResourceId (org.activityinfo.model.resource.ResourceId)2 EnumItem (org.activityinfo.model.type.enumerated.EnumItem)2 ActivityField (org.activityinfo.store.mysql.metadata.ActivityField)2 ArrayList (java.util.ArrayList)1 FormClass (org.activityinfo.model.form.FormClass)1 EnumType (org.activityinfo.model.type.enumerated.EnumType)1 QueryFilter (org.activityinfo.server.command.QueryFilter)1 Activity (org.activityinfo.store.mysql.metadata.Activity)1 LinkedActivity (org.activityinfo.store.mysql.metadata.LinkedActivity)1