Search in sources :

Example 21 with FunctionParameter

use of org.teiid.metadata.FunctionParameter in project teiid by teiid.

the class SystemSource method addLocateFunction.

private void addLocateFunction() {
    FunctionMethod func = new // $NON-NLS-1$ //$NON-NLS-2$
    FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
    SourceSystemFunctions.LOCATE, // $NON-NLS-1$ //$NON-NLS-2$
    QueryPlugin.Util.getString("SystemSource.Locate_desc"), // $NON-NLS-1$ //$NON-NLS-2$
    STRING, // $NON-NLS-1$ //$NON-NLS-2$
    FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$
    "locate", new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("substring", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Locate_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Locate_arg2")), // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("index", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Locate_arg3")) }, // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Locate_result")));
    func.setNullOnNull(false);
    functions.add(func);
    functions.add(new // $NON-NLS-1$ //$NON-NLS-2$
    FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
    SourceSystemFunctions.LOCATE, // $NON-NLS-1$ //$NON-NLS-2$
    QueryPlugin.Util.getString("SystemSource.Locate2_desc"), // $NON-NLS-1$ //$NON-NLS-2$
    STRING, // $NON-NLS-1$ //$NON-NLS-2$
    FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$
    "locate", new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("substring", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Locate2_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Locate2_arg2")) }, // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Locate2_result"))));
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter)

Example 22 with FunctionParameter

use of org.teiid.metadata.FunctionParameter in project teiid by teiid.

the class SystemSource method addConcatFunction.

private void addConcatFunction(String type) {
    functions.add(new // $NON-NLS-1$ //$NON-NLS-2$
    FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
    SourceSystemFunctions.CONCAT, // $NON-NLS-1$ //$NON-NLS-2$
    QueryPlugin.Util.getString("SystemSource.Concat_desc"), // $NON-NLS-1$ //$NON-NLS-2$
    STRING, // $NON-NLS-1$ //$NON-NLS-2$
    FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$
    "concat", new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("string1", type, QueryPlugin.Util.getString("SystemSource.Concat_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("string2", type, QueryPlugin.Util.getString("SystemSource.Concat_arg2")) }, // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.Concat_result_desc"))));
    functions.add(new // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    "||", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    QueryPlugin.Util.getString("SystemSource.Concatop_desc"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    STRING, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    "concat", new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("string1", type, QueryPlugin.Util.getString("SystemSource.Concatop_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("string2", type, QueryPlugin.Util.getString("SystemSource.Concatop_arg2")) }, // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.Concatop_result_desc"))));
    FunctionMethod concat2 = new // $NON-NLS-1$ //$NON-NLS-2$
    FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
    SourceSystemFunctions.CONCAT2, // $NON-NLS-1$ //$NON-NLS-2$
    QueryPlugin.Util.getString("SystemSource.Concat_desc"), // $NON-NLS-1$ //$NON-NLS-2$
    STRING, // $NON-NLS-1$ //$NON-NLS-2$
    FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$
    "concat2", new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("string1", type, QueryPlugin.Util.getString("SystemSource.Concat_arg1")), // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("string2", type, QueryPlugin.Util.getString("SystemSource.Concat_arg2")) }, // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.Concat_result_desc")));
    concat2.setNullOnNull(false);
    functions.add(concat2);
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter)

Example 23 with FunctionParameter

use of org.teiid.metadata.FunctionParameter in project teiid by teiid.

the class SystemSource method addUserFunction.

private void addUserFunction() {
    functions.add(new // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    "user", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    QueryPlugin.Util.getString("SystemSource.User_desc"), // $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$
    "user", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    null, new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.User_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$
    "user", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    QueryPlugin.Util.getString("SystemSource.User_desc"), // $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$
    "user", Arrays.asList(// $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("includeSecurityDomain", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.User_param1"))), new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.User_result")), true, // $NON-NLS-1$ //$NON-NLS-2$
    Determinism.USER_DETERMINISTIC));
}
Also used : FunctionParameter(org.teiid.metadata.FunctionParameter)

Example 24 with FunctionParameter

use of org.teiid.metadata.FunctionParameter in project teiid by teiid.

the class SystemSource method addDoubleFunction.

private void addDoubleFunction(String name, String description) {
    functions.add(new FunctionMethod(name, description, NUMERIC, FUNCTION_CLASS, name, new FunctionParameter[] { // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("number", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Double_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("number", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Double_arg2")) }, // $NON-NLS-1$
    new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, description)));
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) FunctionParameter(org.teiid.metadata.FunctionParameter)

Example 25 with FunctionParameter

use of org.teiid.metadata.FunctionParameter in project teiid by teiid.

the class SystemSource method addRandFunction.

private void addRandFunction() {
    // With Seed
    FunctionMethod rand = new // $NON-NLS-1$ //$NON-NLS-2$
    FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
    SourceSystemFunctions.RAND, // $NON-NLS-1$ //$NON-NLS-2$
    QueryPlugin.Util.getString("SystemSource.Rand_desc"), // $NON-NLS-1$ //$NON-NLS-2$
    NUMERIC, // $NON-NLS-1$ //$NON-NLS-2$
    FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$
    "rand", // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter[] { new FunctionParameter("seed", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Rand_arg")) }, // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Rand_result_desc")));
    rand.setNullOnNull(false);
    rand.setDeterminism(Determinism.NONDETERMINISTIC);
    // seed handling varies greatly by source
    rand.setPushdown(PushDown.CANNOT_PUSHDOWN);
    functions.add(rand);
    // Without Seed
    rand = new // $NON-NLS-1$ //$NON-NLS-2$
    FunctionMethod(// $NON-NLS-1$ //$NON-NLS-2$
    SourceSystemFunctions.RAND, // $NON-NLS-1$ //$NON-NLS-2$
    QueryPlugin.Util.getString("SystemSource.Rand_desc"), // $NON-NLS-1$ //$NON-NLS-2$
    NUMERIC, // $NON-NLS-1$ //$NON-NLS-2$
    FUNCTION_CLASS, // $NON-NLS-1$ //$NON-NLS-2$
    "rand", new FunctionParameter[] {}, // $NON-NLS-1$ //$NON-NLS-2$
    new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Rand_result_desc")));
    rand.setDeterminism(Determinism.NONDETERMINISTIC);
    functions.add(rand);
}
Also used : FunctionMethod(org.teiid.metadata.FunctionMethod) 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