public FormulaValidator(FormTree formTree) { this.formTree = formTree; this.nodeMatcher = new NodeMatcher(formTree); }
@Override public ColumnPlanNode visitCompoundExpr(CompoundExpr compoundExpr) { NodeMatcher nodeMatcher = new NodeMatcher(formTree); Collection<NodeMatch> nodeMatches = nodeMatcher.resolveCompoundExpr(compoundExpr); return plan(nodeMatches); } });
public QueryEvaluator(FilterLevel filterLevel, FormTree formTree, FormScanBatch batch) { this.filterLevel = filterLevel; this.tree = formTree; this.resolver = new NodeMatcher(formTree); this.rootFormClass = tree.getRootFormClass(); this.batch = batch; }
@Override public ColumnPlanNode visitSymbol(SymbolNode symbolNode) { NodeMatcher nodeMatcher = new NodeMatcher(formTree); Collection<NodeMatch> nodeMatches = nodeMatcher.resolveSymbol(symbolNode); return plan(nodeMatches); }
private Collection<String> resolve(String exprString) { FormTree tree = tree(); symbolTable = new NodeMatcher(tree); FormulaNode expr = FormulaParser.parse(exprString); Collection<NodeMatch> matches; if(expr instanceof SymbolNode) { matches = symbolTable.resolveSymbol((SymbolNode) expr); } else if(expr instanceof CompoundExpr) { matches = symbolTable.resolveCompoundExpr((CompoundExpr) expr); } else { throw new IllegalArgumentException(exprString); } // Create a string that we can match against easily List<String> strings = Lists.newArrayList(); for (NodeMatch match : matches) { strings.add(match.toDebugString()); } System.out.println("Resolved " + exprString + " => " + strings); return strings; }
@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()); }