public static NodeMatch forLabel(String labelSymbol, FormClass formClass) { NodeMatch match = new NodeMatch(); match.formClass = formClass; if(labelSymbol.equals(ColumnModel.FORM_NAME_SYMBOL)) { match.type = Type.FORM_NAME; } else { throw new IllegalArgumentException(labelSymbol); } match.joins = Lists.newLinkedList(); return match; }
public static NodeMatch forId(String idSymbol, FormClass formClass) { NodeMatch match = new NodeMatch(); match.formClass = formClass; if(idSymbol.equals(ColumnModel.FORM_NAME_SYMBOL)) { match.type = Type.FORM_NAME; } else if(idSymbol.equals(ColumnModel.RECORD_ID_SYMBOL)) { match.type = Type.RECORD_ID; } else if(idSymbol.equals(ColumnModel.FORM_ID_SYMBOL)){ match.type = Type.FORM_ID; } else { throw new IllegalArgumentException(idSymbol); } match.joins = Lists.newLinkedList(); return match; }
public NodeMatch withComponent(String component) { NodeMatch nodeMatch = new NodeMatch(); nodeMatch.type = type; nodeMatch.joins = joins; nodeMatch.formClass = formClass; nodeMatch.fieldNode = fieldNode; nodeMatch.fieldComponent = new FieldComponent(fieldComponent.getFieldId(), component); return nodeMatch; }
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; }