@Override public void visit(CompareCriteria obj) { preVisitVisitor(obj); visitNode(obj.getLeftExpression()); visitNode(obj.getRightExpression()); postVisitVisitor(obj); }
private Expression rewriteMultiSourceCommand(Command command) throws TeiidComponentException { Expression result = null; if (command instanceof StoredProcedure) { StoredProcedure obj = (StoredProcedure) command; for (Iterator<SPParameter> params = obj.getMapOfParameters().values().iterator(); params.hasNext(); ) { SPParameter param = params.next(); if (param.getParameterType() != SPParameter.IN) { continue; } if (metadata.isMultiSourceElement(param.getMetadataID())) { Expression source = param.getExpression(); params.remove(); if (param.isUsingDefault() && source instanceof Constant && ((Constant) source).isNull()) { continue; } result = source; break; } } } if (command instanceof Insert) { Insert obj = (Insert) command; for (int i = 0; i < obj.getVariables().size(); i++) { ElementSymbol elem = obj.getVariables().get(i); Object metadataID = elem.getMetadataID(); if (metadata.isMultiSourceElement(metadataID)) { Expression source = (Expression) obj.getValues().get(i); obj.getVariables().remove(i); obj.getValues().remove(i); result = source; break; } } } else if (command instanceof FilteredCommand) { for (Criteria c : Criteria.separateCriteriaByAnd(((FilteredCommand) command).getCriteria())) { if (!(c instanceof CompareCriteria)) { continue; } CompareCriteria cc = (CompareCriteria) c; if (cc.getLeftExpression() instanceof ElementSymbol) { ElementSymbol es = (ElementSymbol) cc.getLeftExpression(); if (metadata.isMultiSourceElement(es.getMetadataID()) && EvaluatableVisitor.willBecomeConstant(cc.getRightExpression())) { if (result != null && !result.equals(cc.getRightExpression())) { return Constant.NULL_CONSTANT; } result = cc.getRightExpression(); } } } } return result; }