Search in sources :

Example 26 with FunctionParameter

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);
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter)

Example 27 with FunctionParameter

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);
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter)

Example 28 with FunctionParameter

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);
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter)

Example 29 with FunctionParameter

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));
}
Also used : FunctionParameter(org.teiid.metadata.FunctionParameter)

Example 30 with FunctionParameter

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");
        }
    }
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FileInputStream(java.io.FileInputStream) FunctionParameter(org.teiid.metadata.FunctionParameter)

Aggregations

FunctionParameter (org.teiid.metadata.FunctionParameter)36 FunctionMethod (org.teiid.metadata.FunctionMethod)31 Test (org.junit.Test)9 Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 DeployVDBParameter (org.teiid.jdbc.FakeServer.DeployVDBParameter)3 ArrayList (java.util.ArrayList)2 AggregateAttributes (org.teiid.metadata.AggregateAttributes)2 FileInputStream (java.io.FileInputStream)1 Method (java.lang.reflect.Method)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 UserDefinedAggregate (org.teiid.UserDefinedAggregate)1 FunctionExecutionException (org.teiid.api.exception.query.FunctionExecutionException)1 FunctionMetadataException (org.teiid.api.exception.query.FunctionMetadataException)1 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)1 BinaryType (org.teiid.core.types.BinaryType)1 ReflectionHelper (org.teiid.core.util.ReflectionHelper)1