use of org.teiid.language.Argument.Direction in project teiid by teiid.
the class LanguageBridgeFactory method translate.
/* Execute */
Call translate(StoredProcedure sp) {
Procedure proc = null;
if (sp.getProcedureID() != null) {
try {
proc = this.metadataFactory.getProcedure(sp.getGroup().getName());
} catch (TranslatorException e) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30486, e);
}
}
Class<?> returnType = null;
List<Argument> translatedParameters = new ArrayList<Argument>();
for (SPParameter param : sp.getParameters()) {
Direction direction = Direction.IN;
switch(param.getParameterType()) {
case ParameterInfo.IN:
direction = Direction.IN;
break;
case ParameterInfo.INOUT:
direction = Direction.INOUT;
break;
case ParameterInfo.OUT:
direction = Direction.OUT;
break;
case ParameterInfo.RESULT_SET:
// already part of the metadata
continue;
case ParameterInfo.RETURN_VALUE:
returnType = param.getClassType();
continue;
}
if (param.isUsingDefault() && BaseColumn.OMIT_DEFAULT.equalsIgnoreCase(metadataFactory.getMetadata().getExtensionProperty(param.getMetadataID(), BaseColumn.DEFAULT_HANDLING, false))) {
continue;
}
ProcedureParameter metadataParam = metadataFactory.getParameter(param);
// we can assume for now that all arguments will be literals, which may be multivalued
org.teiid.language.Expression value = null;
if (direction != Direction.OUT) {
if (param.isVarArg()) {
ArrayImpl av = (ArrayImpl) ((Constant) param.getExpression()).getValue();
if (av != null) {
for (Object obj : av.getValues()) {
Argument arg = new Argument(direction, new Literal(obj, param.getClassType().getComponentType()), param.getClassType().getComponentType(), metadataParam);
translatedParameters.add(arg);
}
}
break;
}
value = translate(param.getExpression());
}
Argument arg = new Argument(direction, value, param.getClassType(), metadataParam);
translatedParameters.add(arg);
}
Call call = new Call(removeSchemaName(sp.getProcedureName()), translatedParameters, proc);
call.setReturnType(returnType);
return call;
}
Aggregations