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;
}
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();
}
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);
}
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;
}
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;
}
Aggregations