Search in sources :

Example 6 with CompoundExpr

use of org.activityinfo.model.formula.CompoundExpr in project activityinfo by bedatadriven.

the class NodeMatch method forEnumItem.

public static NodeMatch forEnumItem(FormTree.Node fieldNode, EnumItem item) {
    NodeMatch match = forField(fieldNode, Optional.<StatFunction>absent());
    match.fieldExpr = new CompoundExpr(match.fieldExpr, new SymbolNode(item.getId()));
    match.enumItem = item;
    return match;
}
Also used : CompoundExpr(org.activityinfo.model.formula.CompoundExpr) SymbolNode(org.activityinfo.model.formula.SymbolNode)

Example 7 with CompoundExpr

use of org.activityinfo.model.formula.CompoundExpr in project activityinfo by bedatadriven.

the class TableViewModel method parentFormula.

private String parentFormula(ParsedFormula formula) {
    if (!formula.isValid()) {
        return formula.getFormula();
    }
    SymbolNode parentSymbol = new SymbolNode(ColumnModel.PARENT_SYMBOL);
    FormulaNode transformed = formula.getRootNode().transform(node -> {
        if (node instanceof SymbolNode) {
            // A -> parent.A
            return new CompoundExpr(parentSymbol, (SymbolNode) node);
        } else {
            return node;
        }
    });
    return transformed.asExpression();
}
Also used : CompoundExpr(org.activityinfo.model.formula.CompoundExpr) SymbolNode(org.activityinfo.model.formula.SymbolNode) FormulaNode(org.activityinfo.model.formula.FormulaNode)

Example 8 with CompoundExpr

use of org.activityinfo.model.formula.CompoundExpr in project activityinfo by bedatadriven.

the class GeoPointFormat method getColumnModels.

@Override
public List<ColumnModel> getColumnModels() {
    ColumnModel latitudeModel = new ColumnModel();
    latitudeModel.setId(getLatitudeId());
    latitudeModel.setFormula(new CompoundExpr(formula, new SymbolNode("latitude")));
    ColumnModel longitudeModel = new ColumnModel();
    longitudeModel.setId(getLongitudeId());
    longitudeModel.setFormula(new CompoundExpr(formula, new SymbolNode("longitude")));
    return Arrays.asList(latitudeModel, longitudeModel);
}
Also used : CompoundExpr(org.activityinfo.model.formula.CompoundExpr) SymbolNode(org.activityinfo.model.formula.SymbolNode) ColumnModel(org.activityinfo.model.query.ColumnModel)

Example 9 with CompoundExpr

use of org.activityinfo.model.formula.CompoundExpr in project activityinfo by bedatadriven.

the class MultiEnumFormat method getColumnModels.

@Override
public List<ColumnModel> getColumnModels() {
    List<ColumnModel> columns = new ArrayList<>();
    for (EnumItem enumItem : enumType.getValues()) {
        ColumnModel model = new ColumnModel();
        model.setId(getItemId(enumItem));
        model.setFormula(new CompoundExpr(formula, new SymbolNode(enumItem.getId())));
        columns.add(model);
    }
    return columns;
}
Also used : CompoundExpr(org.activityinfo.model.formula.CompoundExpr) SymbolNode(org.activityinfo.model.formula.SymbolNode) ArrayList(java.util.ArrayList) ColumnModel(org.activityinfo.model.query.ColumnModel) EnumItem(org.activityinfo.model.type.enumerated.EnumItem)

Example 10 with CompoundExpr

use of org.activityinfo.model.formula.CompoundExpr in project activityinfo by bedatadriven.

the class FieldPath method toExpr.

public FormulaNode toExpr() {
    Iterator<ResourceId> it = path.iterator();
    FormulaNode expr = new SymbolNode(it.next());
    while (it.hasNext()) {
        expr = new CompoundExpr(expr, new SymbolNode(it.next()));
    }
    return expr;
}
Also used : CompoundExpr(org.activityinfo.model.formula.CompoundExpr) SymbolNode(org.activityinfo.model.formula.SymbolNode) FormulaNode(org.activityinfo.model.formula.FormulaNode) ResourceId(org.activityinfo.model.resource.ResourceId)

Aggregations

CompoundExpr (org.activityinfo.model.formula.CompoundExpr)16 SymbolNode (org.activityinfo.model.formula.SymbolNode)12 FormulaNode (org.activityinfo.model.formula.FormulaNode)7 ColumnModel (org.activityinfo.model.query.ColumnModel)6 Test (org.junit.Test)4 FormTree (org.activityinfo.model.formTree.FormTree)3 ArrayList (java.util.ArrayList)2 LookupKey (org.activityinfo.model.formTree.LookupKey)2 LookupKeySet (org.activityinfo.model.formTree.LookupKeySet)2 ResourceId (org.activityinfo.model.resource.ResourceId)2 EnumItem (org.activityinfo.model.type.enumerated.EnumItem)2 ImmutableTableColumn (org.activityinfo.model.analysis.ImmutableTableColumn)1 ImmutableTableModel (org.activityinfo.model.analysis.ImmutableTableModel)1 TableColumn (org.activityinfo.model.analysis.TableColumn)1 TableModel (org.activityinfo.model.analysis.TableModel)1 FormClass (org.activityinfo.model.form.FormClass)1 FormField (org.activityinfo.model.form.FormField)1 FieldPath (org.activityinfo.model.formTree.FieldPath)1 ConstantNode (org.activityinfo.model.formula.ConstantNode)1 ColumnSet (org.activityinfo.model.query.ColumnSet)1