public static NodeMatch forId(FormTree.Node parent, FormClass formClass) { List<List<FormTree.Node>> partitions = partitionOnJoins(parent); List<FormTree.Node> leaf = partitions.get(partitions.size() - 1); // Embedded records are not independent resources, and so // do not have their own ID. So the leaf field MUST be a reference field Preconditions.checkArgument(leaf.get(0).isReference()); NodeMatch match = new NodeMatch(); match.joins = joinsTo(partitions, Optional.<StatFunction>absent()); match.joins.add(new JoinNode(JoinType.REFERENCE, leaf.get(0).getDefiningFormClass().getId(), toExpr(leaf), formClass.getId())); match.formClass = formClass; match.type = Type.RECORD_ID; return match; }
/** * Creates a NodeMatch for the given field. */ public static NodeMatch forField(FormTree.Node fieldNode, Optional<StatFunction> aggregation) { Preconditions.checkNotNull(fieldNode, "fieldNode"); List<List<FormTree.Node>> partitions = partitionOnJoins(fieldNode); List<FormTree.Node> leaf = partitions.get(partitions.size() - 1); NodeMatch match = new NodeMatch(); match.joins = joinsTo(partitions, aggregation); match.type = Type.FIELD; match.formClass = leaf.get(0).getDefiningFormClass(); match.fieldNode = fieldNode; match.fieldComponent = new FieldComponent(fieldNode.getField().getName()); FormulaNode leafFormula = toExpr(leaf); if(!(leafFormula instanceof SymbolNode)) { throw new UnsupportedOperationException("TODO: " + leafFormula); } return match; }
FormField leftField = left.get(0).getField(); ResourceId leftFormId = left.get(0).getDefiningFormClass().getId(); FormulaNode leftFieldExpr = toExpr(left);