use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class SystemSource method addNvlFunction.
private void addNvlFunction(String valueType) {
FunctionMethod nvl = new // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"nvl", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
QueryPlugin.Util.getString("SystemSource.Nvl_desc"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
MISCELLANEOUS, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"ifnull", new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("value", valueType, QueryPlugin.Util.getString("SystemSource.Nvl_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("valueIfNull", valueType, QueryPlugin.Util.getString("SystemSource.Nvl_arg2")) }, // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", valueType, QueryPlugin.Util.getString("SystemSource.Nvl_result")));
nvl.setNullOnNull(false);
functions.add(nvl);
}
use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class SystemSource method addEndsWithFunction.
private void addEndsWithFunction() {
FunctionMethod f = new // $NON-NLS-1$ //$NON-NLS-2$
FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
SourceSystemFunctions.ENDSWITH, // $NON-NLS-1$ //$NON-NLS-2$
QueryPlugin.Util.getString("SystemSource.endswith_desc"), // $NON-NLS-1$ //$NON-NLS-2$
STRING, // $NON-NLS-1$ //$NON-NLS-2$
FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$
"endsWith", new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("substring", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.endswith_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.endswith_arg2")) }, // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.endswith_result")));
functions.add(f);
}
use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class SystemSource method addIfNullFunction.
private void addIfNullFunction(String valueType) {
FunctionMethod nvl = new // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"ifnull", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
QueryPlugin.Util.getString("SystemSource.Ifnull_desc"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
MISCELLANEOUS, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"ifnull", new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("value", valueType, QueryPlugin.Util.getString("SystemSource.Ifnull_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("valueIfNull", valueType, QueryPlugin.Util.getString("SystemSource.Ifnull_arg2")) }, // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", valueType, QueryPlugin.Util.getString("SystemSource.Ifnull_result")));
nvl.setNullOnNull(false);
functions.add(nvl);
}
use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class SystemSource method addSecurityFunctions.
private void addSecurityFunctions() {
functions.add(new // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"hasRole", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
QueryPlugin.Util.getString("SystemSource.hasRole_description"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
SECURITY, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PushDown.CANNOT_PUSHDOWN, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
SECURITY_FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"hasRole", Arrays.asList(// $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("roleType", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param1")), // $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("roleName", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param2"))), new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), true, // $NON-NLS-1$ //$NON-NLS-2$
Determinism.USER_DETERMINISTIC));
functions.add(new // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"hasRole", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
QueryPlugin.Util.getString("SystemSource.hasRole_description"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
SECURITY, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PushDown.CANNOT_PUSHDOWN, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
SECURITY_FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"hasRole", Arrays.asList(// $NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("roleName", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param2"))), new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), true, // $NON-NLS-1$ //$NON-NLS-2$
Determinism.USER_DETERMINISTIC));
}
use of org.teiid.metadata.FunctionParameter in project teiid by teiid.
the class TestFunctionMetadataReader method testLoadFunctionMethods.
public void testLoadFunctionMethods() throws Exception {
List<FunctionMethod> fns = FunctionMetadataReader.loadFunctionMethods(new FileInputStream(UnitTestUtil.getTestDataPath() + File.separator + "udf.xmi"));
assertEquals(3, fns.size());
for (FunctionMethod m : fns) {
if (m.getName().equals("GetSystemProperty")) {
assertEquals("MyFunctions", m.getCategory());
assertEquals("com.metamatrix.dqp.embedded.udf.MyFunctions", m.getInvocationClass());
assertEquals("getProperty", m.getInvocationMethod());
assertEquals(PushDown.CAN_PUSHDOWN, m.getPushdown());
assertEquals(Determinism.DETERMINISTIC, m.getDeterminism());
assertNull(m.getDescription());
assertEquals(1, m.getInputParameterCount());
FunctionParameter in = m.getInputParameters().get(0);
assertEquals("prop", in.getName());
assertEquals("string", in.getType());
assertNull(in.getDescription());
assertNotNull(m.getOutputParameter());
assertEquals(FunctionParameter.OUTPUT_PARAMETER_NAME, m.getOutputParameter().getName());
assertEquals("string", m.getOutputParameter().getType());
} else if (m.getName().equals("getpushdown")) {
assertEquals("MyFunctions", m.getCategory());
assertEquals("com.metamatrix.dqp.embedded.udf.MyFunctions", m.getInvocationClass());
assertEquals("getPropertyNoArgs", m.getInvocationMethod());
assertEquals(PushDown.CANNOT_PUSHDOWN, m.getPushdown());
assertEquals(Determinism.DETERMINISTIC, m.getDeterminism());
assertNull(m.getDescription());
assertEquals(0, m.getInputParameterCount());
assertNotNull(m.getOutputParameter());
assertEquals(FunctionParameter.OUTPUT_PARAMETER_NAME, m.getOutputParameter().getName());
assertEquals("string", m.getOutputParameter().getType());
} else if (m.getName().equals("getxyz")) {
assertEquals("MyFunctions", m.getCategory());
assertEquals("com.metamatrix.dqp.embedded.udf.MyFunctions", m.getInvocationClass());
assertEquals("getPropertyNoArgs", m.getInvocationMethod());
assertEquals(PushDown.CAN_PUSHDOWN, m.getPushdown());
assertEquals(Determinism.NONDETERMINISTIC, m.getDeterminism());
assertNull(m.getDescription());
assertEquals(0, m.getInputParameterCount());
assertNotNull(m.getOutputParameter());
assertEquals(FunctionParameter.OUTPUT_PARAMETER_NAME, m.getOutputParameter().getName());
assertEquals("string", m.getOutputParameter().getType());
} else {
fail("unknown method");
}
}
}
Aggregations