/** * Constructs a new LookupKey for the given form using the raw record id. */ LookupKey(int keyIndex, FormClass formClass) { this(keyIndex, null, null, formClass, new SymbolNode(ColumnModel.RECORD_ID_SYMBOL), "ID"); }
public CompoundExpr(@Nonnull ResourceId value, @Nonnull String field) { this.value = new SymbolNode(value); this.field = new SymbolNode(field); }
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; }
public DimensionMapping(ResourceId formId, ResourceId fieldId) { this.formId = formId; this.formula = new SymbolNode(fieldId).asExpression(); this.type = Type.VALUE; }
private static FormulaNode toExpr(List<FormTree.Node> partition) { Iterator<FormTree.Node> it = partition.iterator(); FormulaNode expr = new SymbolNode(it.next().getFieldId()); while(it.hasNext()) { expr = new CompoundExpr(expr, new SymbolNode(it.next().getFieldId())); } return expr; }
private SymbolNode symbol(Token token) { assert token.getType() == TokenType.SYMBOL; return new SymbolNode(token); }
private static FormulaNode toListFormula(FormulaNode field, FilterConfig filter) { // Shockingly, the gxt filterconfig for list is generated by concatenating // ids together with "::" String[] enumItemIds = filter.getValue().split("::"); List<FormulaNode> enumConditions = new ArrayList<>(); for (String enumItemId : enumItemIds) { enumConditions.add(new CompoundExpr(field, new SymbolNode(enumItemId))); } return Formulas.anyTrue(enumConditions); }
public ColumnNode(FormTree.Node node) { this.node = node; this.header = composeHeader(node); if(node.isRoot()) { this.expr = new SymbolNode(node.getFieldId()); } else { this.expr = new CompoundExpr( new SymbolNode(node.getDefiningFormClass().getId()), new SymbolNode(node.getFieldId())); } }
/** * Adds the {@code ResourceId} as a string column to the table model with * the given column id */ public ColumnModel selectRecordId() { ColumnModel columnModel = new ColumnModel(); columnModel.setFormula(new SymbolNode(ColumnModel.RECORD_ID_SYMBOL)); columns.add(columnModel); return columnModel; }
LookupKey(int keyIndex, List<ParentKey> parentKeys, FormClass formClass, FormField formField) { this(keyIndex, null, null, formClass, new SymbolNode(formField.getId()), formField.getLabel()); for (ParentKey parentKey : parentKeys) { parentLevels.add(parentKey); parentKey.getKey().childLevels.add(this); } }
/** * Constructs a new LookupKey for the given parent, form, and key field. */ LookupKey(int keyIndex, String parentFieldId, LookupKey parentLevel, FormClass formClass, FormField formField) { this(keyIndex, parentFieldId, parentLevel, formClass, new SymbolNode(formField.getId()), formField.getLabel()); }
@Test public void parseFunctions() { expect("containsAll({f1},{v1})", new FunctionCallNode(ContainsAllFunction.INSTANCE, new SymbolNode("f1"), new SymbolNode("v1")) ); expect("!containsAll({f1},{v1})", new FunctionCallNode(NotFunction.INSTANCE, new FunctionCallNode(ContainsAllFunction.INSTANCE, new SymbolNode("f1"), new SymbolNode("v1")) )); }
@Test public void binaryInfix() { assertThat( new FunctionCallNode(PlusFunction.INSTANCE, new SymbolNode("X"), new SymbolNode("Y")).asExpression(), equalTo("X + Y")); }
@Test public void normalCall() { assertThat( new FunctionCallNode(MaxFunction.INSTANCE, new SymbolNode("X"), new SymbolNode("Y")).asExpression(), equalTo("max(X, Y)")); }
@Test public void parseCalc() { expect("{Exp}*{Alloc}*{InCostUnsp}/10000", new FunctionCallNode(FormulaFunctions.get("/"), new FunctionCallNode(FormulaFunctions.get("*"), new FunctionCallNode(FormulaFunctions.get("*"), new SymbolNode("Exp"), new SymbolNode("Alloc")), new SymbolNode("InCostUnsp")), new ConstantNode(10000))); }
private FormulaNode measureFormula() { if (rootFormId.equals(formId)) { return new SymbolNode(field.getId()); } else { return new CompoundExpr(formId, field.getName()); } }
private static FormulaNode exprFor(FormTree.Node node) { SymbolNode fieldSymbol = new SymbolNode(symbolFor(node.getField())); if(node.isRoot()) { return fieldSymbol; } else { return new CompoundExpr(exprFor(node.getParent()), fieldSymbol); } }
private QueryModel buildQuery(List<EffectiveTableColumn> columns, RecordRef recordRef) { QueryModel queryModel = buildQuery(columns); queryModel.setFilter(Formulas.equals(new SymbolNode("@parent"), new ConstantNode(recordRef.getRecordId().asString()))); return queryModel; }
private ImmutableDimensionModel marriedDimension() { return ImmutableDimensionModel.builder() .id(ResourceId.generateCuid()) .label("Married") .addMappings(new DimensionMapping(new SymbolNode("MARRIED"))) .missingIncluded(false) .build(); }
@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()); }