use of org.activityinfo.model.formula.SymbolNode 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.SymbolNode 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.SymbolNode 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.SymbolNode 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;
}
use of org.activityinfo.model.formula.SymbolNode in project activityinfo by bedatadriven.
the class SubFormSummaryTest method matchNodes.
@Test
public void matchNodes() {
TestingStorageProvider catalog = new TestingStorageProvider();
ClinicForm clinicForm = catalog.getClinicForm();
FormTree formTree = catalog.getFormTree(clinicForm.getFormId());
NodeMatcher nodeMatcher = new NodeMatcher(formTree);
Collection<NodeMatch> nodeMatches = nodeMatcher.resolveSymbol(new SymbolNode("NUM_CONSULT"));
assertThat(nodeMatches, hasSize(1));
NodeMatch nodeMatch = Iterables.getOnlyElement(nodeMatches);
JoinNode joinNode = Iterables.getOnlyElement(nodeMatch.getJoins());
}
Aggregations