Search in sources :

Example 1 with Procedure

use of org.teiid.metadata.Procedure 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 Procedure

use of org.teiid.metadata.Procedure 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 Procedure

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

the class FunctionTree method getFunctionProcedures.

public static FunctionTree getFunctionProcedures(Schema schema) {
    UDFSource dummySource = new UDFSource(Collections.EMPTY_LIST);
    FunctionTree ft = null;
    for (Procedure p : schema.getProcedures().values()) {
        if (p.isFunction() && p.getQueryPlan() != null) {
            if (ft == null) {
                ft = new FunctionTree(schema.getName(), dummySource, false);
            }
            FunctionMethod fm = SQLParserUtil.createFunctionMethod(p);
            FunctionDescriptor fd = ft.addFunction(schema.getName(), dummySource, fm, false);
            fd.setProcedure(p);
        }
    }
    return ft;
}
Also used : Procedure(org.teiid.metadata.Procedure) FunctionMethod(org.teiid.metadata.FunctionMethod)

Example 4 with Procedure

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

the class CompositeMetadataStore method assignOids.

private void assignOids(Schema schema, TreeMap<String, RecordHolder> map) {
    addOid(schema, map);
    for (Table table : schema.getTables().values()) {
        addOid(table, map);
        addOids(table.getColumns(), map);
        addOids(table.getAllKeys(), map);
    }
    for (Procedure proc : schema.getProcedures().values()) {
        addOid(proc, map);
        addOids(proc.getParameters(), map);
        if (proc.getResultSet() != null) {
            addOids(proc.getResultSet().getColumns(), map);
        }
    }
    for (FunctionMethod func : schema.getFunctions().values()) {
        addOid(func, map);
        addOids(func.getInputParameters(), map);
        addOid(func.getOutputParameter(), map);
    }
}
Also used : Table(org.teiid.metadata.Table) Procedure(org.teiid.metadata.Procedure) FunctionMethod(org.teiid.metadata.FunctionMethod)

Example 5 with Procedure

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

the class CompositeMetadataStore method getStoredProcedure.

public Collection<Procedure> getStoredProcedure(String name) throws TeiidComponentException, QueryMetadataException {
    List<Procedure> result = new LinkedList<Procedure>();
    int index = name.indexOf(TransformationMetadata.DELIMITER_STRING);
    if (index > -1) {
        String schemaName = name.substring(0, index);
        Schema schema = getSchema(schemaName);
        if (schema != null) {
            Procedure proc = schema.getProcedures().get(name.substring(index + 1));
            if (proc != null) {
                result.add(proc);
                return result;
            }
        }
    }
    // assume it's a partial name
    for (Schema schema : getSchemas().values()) {
        for (Procedure p : schema.getProcedures().values()) {
            if (matchesPartialName(name, p.getName(), schema)) {
                result.add(p);
            }
        }
    }
    return result;
}
Also used : Schema(org.teiid.metadata.Schema) Procedure(org.teiid.metadata.Procedure) LinkedList(java.util.LinkedList)

Aggregations

Procedure (org.teiid.metadata.Procedure)82 ProcedureParameter (org.teiid.metadata.ProcedureParameter)36 Test (org.junit.Test)35 MetadataFactory (org.teiid.metadata.MetadataFactory)30 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)27 Schema (org.teiid.metadata.Schema)16 Column (org.teiid.metadata.Column)14 MetadataStore (org.teiid.metadata.MetadataStore)11 Properties (java.util.Properties)10 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)10 Table (org.teiid.metadata.Table)9 QueryNode (org.teiid.query.mapping.relational.QueryNode)8 List (java.util.List)6 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)6 TempMetadataStore (org.teiid.query.metadata.TempMetadataStore)5 TranslatorException (org.teiid.translator.TranslatorException)5 ODataType (org.teiid.translator.odata4.ODataMetadataProcessor.ODataType)5 ArrayList (java.util.ArrayList)4 Call (org.teiid.language.Call)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3