protected AndedParts completeKey(EqualityPart existing, PEColumn c, ConstantExpression litex) { EqualityPart np = makeNewEqualityPart(existing, c, litex); FunctionCall andEx = new FunctionCall( FunctionName.makeAnd(), (ExpressionNode) existing.getParent(), (ExpressionNode) np.getParent()); ArrayList<Part> subp = new ArrayList<Part>(); subp.add(existing); subp.add(np); return buildAndedParts(andEx, subp); }
private EqualityPart makeNewEqualityPart( EqualityPart existing, PEColumn c, ConstantExpression litex) { TableKey tk = existing.getColumn().getColumnKey().getTableKey(); ColumnInstance nc = new ColumnInstance(c, tk.toInstance()); FunctionCall eq = new FunctionCall(FunctionName.makeEquals(), nc, litex); EqualityPart eqp = buildEqualityPart(eq, nc, litex); return eqp; }
private Part buildPart(LanguageNode parentNode, ColumnInstance ci, ConstantExpression litex) { EqualityPart sp = parent.buildEqualityPart(parentNode, ci, litex); if (parent.isComplete(sp)) { setComplete(sp); state.put(parentNode, sp); } else { AndedParts xformed = parent.maybeMakeComplete(sp); if (xformed != null) { setComplete(xformed); LanguageNode ret = xformed.getParent(); state.put(ret, xformed); return xformed; } else { state.put(sp.getParent(), sp); } } return sp; }
protected AndedParts maybeMakeComplete(EqualityPart sp, ConstantExpression litex) { if (litex == null) return null; List<ColumnKey> needed = getNeeded(Collections.singletonList(sp.getColumn().getColumnKey())); if (needed.isEmpty()) return null; else if (needed.size() == 1) { PEColumn c = needed.get(0).getPEColumn(); if (c.isTenantColumn()) { return completeKey(sp, c, litex); } } return null; }