List values, CommandContext context, QueryMetadataInterface metadata) throws QueryResolverException, TeiidComponentException, QueryValidatorException {
VariableContext result = new VariableContext();
//the size of the values must be the same as that of the parameters
if (params.size() != values.size()) {
String msg = QueryPlugin.Util.getString("QueryUtil.wrong_number_of_values", new Object[] {new Integer(values.size()), new Integer(params.size())}); //$NON-NLS-1$
throw new QueryResolverException(msg);
}
//the type must be the same, or the type of the value can be implicitly converted
//to that of the reference
for (int i = 0; i < params.size(); i++) {
Reference param = params.get(i);
Object value = values.get(i);
//TODO: why is the list check in here
if(value != null && !(value instanceof List)) {
try {
String targetTypeName = DataTypeManager.getDataTypeName(param.getType());
Expression expr = ResolverUtil.convertExpression(new Constant(value), targetTypeName, metadata);
value = Evaluator.evaluate(expr);
} catch (ExpressionEvaluationException e) {
String msg = QueryPlugin.Util.getString("QueryUtil.Error_executing_conversion_function_to_convert_value", new Integer(i + 1), value, DataTypeManager.getDataTypeName(param.getType())); //$NON-NLS-1$
throw new QueryResolverException(msg);
} catch (QueryResolverException e) {
String msg = QueryPlugin.Util.getString("QueryUtil.Error_executing_conversion_function_to_convert_value", new Integer(i + 1), value, DataTypeManager.getDataTypeName(param.getType())); //$NON-NLS-1$
throw new QueryResolverException(msg);
}
}
if (param.getConstraint() != null) {
param.getConstraint().validate(value);