}
}
private Command rewriteCommand(String sourceName, Command command) throws ExpressionEvaluationException, TeiidComponentException {
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;
}
String shortName = SingleElementSymbol.getShortName(param.getName());
if(shortName.equalsIgnoreCase(MultiSourceElement.MULTI_SOURCE_ELEMENT_NAME)) {
Constant source = (Constant)param.getExpression();
params.remove();
if (param.isUsingDefault() && source.isNull()) {
continue;
}
if (!source.getValue().equals(sourceName)) {
return null;
}
}
}
} 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(metadataID instanceof MultiSourceElement) {
Constant source = (Constant)obj.getValues().get(i);
obj.getVariables().remove(i);
obj.getValues().remove(i);
if (!source.getValue().equals(sourceName)) {
return null;
}
}
}