use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class FunctionMetadataReader method parseParameter.
private static FunctionParameter parseParameter(XMLStreamReader reader) throws XMLStreamException {
FunctionParameter fp = new FunctionParameter();
if (reader.getAttributeCount() > 0) {
for (int i = 0; i < reader.getAttributeCount(); i++) {
String attrName = reader.getAttributeLocalName(i);
String attrValue = reader.getAttributeValue(i);
if (Element.NAME.getLocalName().equals(attrName)) {
fp.setName(attrValue);
} else if (Element.DESCRIPTION.getLocalName().equals(attrName)) {
fp.setDescription(attrValue);
} else if (Element.TYPE.getLocalName().equals(attrName)) {
fp.setType(attrValue);
}
}
}
while (reader.nextTag() != XMLStreamConstants.END_ELEMENT) ;
return fp;
}
use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class FunctionMetadataValidator method validateFunctionMethod.
/**
* Determine whether a FunctionMethod is valid. The following items are validated:
* <UL>
* <LI>Validate method name</LI>
* <LI>Validate description</LI>
* <LI>Validate category</LI>
* <LI>Validate invocation method</LI>
* <LI>Validate all input parameters</LI>
* <LI>Validate output parameter</LI>
* </UL>
* @param method The method to validate
* @param report The report to update during validation
*/
public static final void validateFunctionMethod(FunctionMethod method, ValidatorReport report, Map<String, Datatype> runtimeTypeMap) {
if (method == null) {
// $NON-NLS-1$ //$NON-NLS-2$
updateReport(report, method, QueryPlugin.Util.getString("ERR.015.001.0052", "FunctionMethod"));
// can't validate
return;
}
try {
// Validate attributes
validateName(method.getName());
validateDescription(method.getDescription());
validateCategory(method.getCategory());
validateInvocationMethod(method.getInvocationClass(), method.getInvocationMethod(), method.getPushdown());
// Validate input parameters
List<FunctionParameter> params = method.getInputParameters();
if (params != null && !params.isEmpty()) {
for (int i = 0; i < params.size(); i++) {
FunctionParameter param = params.get(i);
validateFunctionParameter(param);
param.setPosition(i + 1);
MetadataFactory.setDataType(param.getRuntimeType(), param, runtimeTypeMap, true);
param.getUUID();
}
}
// Validate output parameters
validateFunctionParameter(method.getOutputParameter());
method.getOutputParameter().setPosition(0);
MetadataFactory.setDataType(method.getOutputParameter().getRuntimeType(), method.getOutputParameter(), runtimeTypeMap, true);
} catch (FunctionMetadataException e) {
updateReport(report, method, e.getMessage());
}
}
use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class SystemSource method addUuidFunction.
private void addUuidFunction() {
FunctionMethod rand = new // $NON-NLS-1$ //$NON-NLS-2$
FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
SourceSystemFunctions.UUID, // $NON-NLS-1$ //$NON-NLS-2$
QueryPlugin.Util.getString("SystemSource.uuid_desc"), // $NON-NLS-1$ //$NON-NLS-2$
MISCELLANEOUS, // $NON-NLS-1$ //$NON-NLS-2$
FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$
"uuid", new FunctionParameter[] {}, // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.uuid_result_desc")));
rand.setDeterminism(Determinism.NONDETERMINISTIC);
functions.add(rand);
}
use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class SystemSource method addCommandPayloadFunctions.
private void addCommandPayloadFunctions() {
functions.add(new // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"commandpayload", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
QueryPlugin.Util.getString("SystemSource.CommandPayload_desc0"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
MISCELLANEOUS, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PushDown.CANNOT_PUSHDOWN, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"commandPayload", null, new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_result")), true, // $NON-NLS-1$ //$NON-NLS-2$
Determinism.COMMAND_DETERMINISTIC));
functions.add(new // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"commandpayload", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
QueryPlugin.Util.getString("SystemSource.CommandPayload_desc1"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
MISCELLANEOUS, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PushDown.CANNOT_PUSHDOWN, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"commandPayload", Arrays.asList(// $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("property", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_property"))), new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_result")), true, // $NON-NLS-1$ //$NON-NLS-2$
Determinism.COMMAND_DETERMINISTIC));
}
use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class SystemSource method addAtan2Function.
private void addAtan2Function(String name, String description) {
functions.add(new FunctionMethod(name, description, NUMERIC, FUNCTION_CLASS, name, new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("number1", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Atan_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("number2", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Atan_arg2")) }, // $NON-NLS-1$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, description)));
functions.add(new FunctionMethod(name, description, NUMERIC, FUNCTION_CLASS, name, new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("number1", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Atan_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("number2", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Atan_arg2")) }, // $NON-NLS-1$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, description)));
}
Aggregations