Search in sources :

Example 1 with ProcedureParameter

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

the class S3ExecutionFactory method addGetTextFileMethod.

private void addGetTextFileMethod(MetadataFactory metadataFactory) {
    Procedure p = metadataFactory.addProcedure(GETTEXTFILE);
    // $NON-NLS-1$
    p.setAnnotation("Returns text files that match the given path as CLOBs");
    // $NON-NLS-1$
    ProcedureParameter param = metadataFactory.addProcedureParameter("name", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p);
    // $NON-NLS-1$
    param.setAnnotation("The name of the file to return.  Currently the patterns like *.<ext> are not supported");
    addCommonParameters(metadataFactory, p);
    // $NON-NLS-1$
    param = metadataFactory.addProcedureParameter("encryption", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p);
    // $NON-NLS-1$
    param.setAnnotation("Server side encryption algorithm used");
    param.setNullType(NullType.Nullable);
    // $NON-NLS-1$
    param = metadataFactory.addProcedureParameter("encryptionkey", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p);
    // $NON-NLS-1$
    param.setAnnotation("Server side encryption key to decrypt the object");
    param.setNullType(NullType.Nullable);
    // $NON-NLS-1$
    param = metadataFactory.addProcedureParameter("stream", TypeFacility.RUNTIME_NAMES.BOOLEAN, Type.In, p);
    // $NON-NLS-1$
    param.setAnnotation("If the result should be streamed.");
    param.setNullType(NullType.Nullable);
    // $NON-NLS-1$
    param.setDefaultValue("false");
    // $NON-NLS-1$
    metadataFactory.addProcedureResultSetColumn("file", TypeFacility.RUNTIME_NAMES.CLOB, p);
    // $NON-NLS-1$
    metadataFactory.addProcedureResultSetColumn("endpoint", TypeFacility.RUNTIME_NAMES.STRING, p);
    // $NON-NLS-1$
    metadataFactory.addProcedureResultSetColumn("lastModified", TypeFacility.RUNTIME_NAMES.TIMESTAMP, p);
    // $NON-NLS-1$
    metadataFactory.addProcedureResultSetColumn("etag", TypeFacility.RUNTIME_NAMES.STRING, p);
    // $NON-NLS-1$
    metadataFactory.addProcedureResultSetColumn("size", TypeFacility.RUNTIME_NAMES.LONG, p);
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) Procedure(org.teiid.metadata.Procedure)

Example 2 with ProcedureParameter

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

the class CouchbaseMetadataProcessor method addProcedures.

protected void addProcedures(MetadataFactory metadataFactory, CouchbaseConnection connection) {
    Procedure getDocuments = metadataFactory.addProcedure(GETDOCUMENTS);
    // $NON-NLS-1$
    getDocuments.setAnnotation(CouchbasePlugin.Util.getString("getDocuments.Annotation"));
    ProcedureParameter param = metadataFactory.addProcedureParameter(ID, TypeFacility.RUNTIME_NAMES.STRING, Type.In, getDocuments);
    param.setNullType(No_Nulls);
    // $NON-NLS-1$
    param.setAnnotation(CouchbasePlugin.Util.getString("getDocuments.id.Annotation"));
    param = metadataFactory.addProcedureParameter(KEYSPACE, TypeFacility.RUNTIME_NAMES.STRING, Type.In, getDocuments);
    param.setNullType(No_Nulls);
    // $NON-NLS-1$
    param.setAnnotation(CouchbasePlugin.Util.getString("getDocuments.keyspace.Annotation"));
    metadataFactory.addProcedureResultSetColumn(RESULT, TypeFacility.RUNTIME_NAMES.BLOB, getDocuments);
    Procedure getDocument = metadataFactory.addProcedure(GETDOCUMENT);
    // $NON-NLS-1$
    getDocument.setAnnotation(CouchbasePlugin.Util.getString("getDocument.Annotation"));
    param = metadataFactory.addProcedureParameter(ID, TypeFacility.RUNTIME_NAMES.STRING, Type.In, getDocument);
    param.setNullType(No_Nulls);
    // $NON-NLS-1$
    param.setAnnotation(CouchbasePlugin.Util.getString("getDocument.id.Annotation"));
    param = metadataFactory.addProcedureParameter(KEYSPACE, TypeFacility.RUNTIME_NAMES.STRING, Type.In, getDocument);
    param.setNullType(No_Nulls);
    // $NON-NLS-1$
    param.setAnnotation(CouchbasePlugin.Util.getString("getDocument.keyspace.Annotation"));
    metadataFactory.addProcedureResultSetColumn(RESULT, TypeFacility.RUNTIME_NAMES.BLOB, getDocument);
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) Procedure(org.teiid.metadata.Procedure)

Example 3 with ProcedureParameter

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

the class DirectQueryMetadataRepository method loadMetadata.

@Override
public void loadMetadata(MetadataFactory factory, ExecutionFactory executionFactory, Object connectionFactory) throws TranslatorException {
    if (executionFactory != null && executionFactory.supportsDirectQueryProcedure() && factory.getSchema().getProcedure(executionFactory.getDirectQueryProcedureName()) == null) {
        Procedure p = factory.addProcedure(executionFactory.getDirectQueryProcedureName());
        // $NON-NLS-1$
        p.setAnnotation("Invokes translator with a native query that returns results in an array of values");
        // $NON-NLS-1$
        ProcedureParameter param = factory.addProcedureParameter("request", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p);
        // $NON-NLS-1$
        param.setAnnotation("The native query to execute");
        param.setNullType(NullType.No_Nulls);
        // $NON-NLS-1$
        param = factory.addProcedureParameter("variable", TypeFacility.RUNTIME_NAMES.OBJECT, Type.In, p);
        // $NON-NLS-1$
        param.setAnnotation("Any number of varaibles; usage will vary by translator");
        param.setNullType(NullType.Nullable);
        param.setVarArg(true);
        // $NON-NLS-1$
        factory.addProcedureResultSetColumn("tuple", DataTypeManager.getDataTypeName(DataTypeManager.getArrayType(TypeFacility.RUNTIME_TYPES.OBJECT)), p);
    }
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) Procedure(org.teiid.metadata.Procedure)

Example 4 with ProcedureParameter

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

the class ODataSchemaBuilder method allowedProcedure.

private static boolean allowedProcedure(Procedure proc) {
    // any number of in, but can have only one LOB if lob is present
    // only *one* result, or resultset allowed
    int inouts = 0;
    int lobs = 0;
    int outs = 0;
    for (ProcedureParameter pp : proc.getParameters()) {
        if (pp.getType().equals(ProcedureParameter.Type.Out)) {
            continue;
        }
        if (pp.getType().equals(ProcedureParameter.Type.In) || pp.getType().equals(ProcedureParameter.Type.InOut)) {
            inouts++;
            if (DataTypeManager.isLOB(pp.getRuntimeType())) {
                lobs++;
            }
        } else if (pp.getType().equals(ProcedureParameter.Type.ReturnValue)) {
            outs++;
        }
    }
    if (proc.getResultSet() != null) {
        for (Column c : proc.getResultSet().getColumns()) {
            if (DataTypeManager.isLOB(c.getRuntimeType())) {
                return false;
            }
        }
        outs++;
    }
    if (outs > 1) {
        return false;
    }
    if (inouts > 1 && lobs >= 1) {
        return false;
    }
    return true;
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) Column(org.teiid.metadata.Column)

Example 5 with ProcedureParameter

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

the class ProcedureSQLBuilder method visit.

private void visit(EdmReturnType returnType) {
    if (hasResultSet()) {
        // this is complex type
        this.procedureReturn = new ProcedureReturn(returnType, null, true);
    } else {
        // must not be null
        ProcedureParameter parameter = getReturnParameter();
        Class<?> teiidType = DataTypeManager.getDataTypeClass(parameter.getRuntimeType());
        Integer sqlType = JDBCSQLTypeInfo.getSQLType(DataTypeManager.getDataTypeName(teiidType));
        this.procedureReturn = new ProcedureReturn(returnType, sqlType, false);
    }
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter)

Aggregations

ProcedureParameter (org.teiid.metadata.ProcedureParameter)43 Procedure (org.teiid.metadata.Procedure)35 Test (org.junit.Test)12 MetadataFactory (org.teiid.metadata.MetadataFactory)9 Schema (org.teiid.metadata.Schema)8 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)8 MetadataStore (org.teiid.metadata.MetadataStore)7 Column (org.teiid.metadata.Column)6 ArrayList (java.util.ArrayList)5 QueryNode (org.teiid.query.mapping.relational.QueryNode)5 List (java.util.List)4 Table (org.teiid.metadata.Table)4 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)4 EdmPrimitiveTypeKind (org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind)2 FullQualifiedName (org.apache.olingo.commons.api.edm.FullQualifiedName)2 Argument (org.teiid.language.Argument)2 TempMetadataStore (org.teiid.query.metadata.TempMetadataStore)2 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)2 TranslatorException (org.teiid.translator.TranslatorException)2 ODataType (org.teiid.translator.odata4.ODataMetadataProcessor.ODataType)2