Search in sources :

Example 76 with Procedure

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

the class RestASMBasedWebArchiveBuilder method findContentType.

private String findContentType(Procedure procedure) {
    String contentType = "plain";
    ColumnSet<Procedure> rs = procedure.getResultSet();
    if (rs != null) {
        Column returnColumn = rs.getColumns().get(0);
        if (returnColumn.getDatatype().getRuntimeTypeName().equals(DataTypeManager.DefaultDataTypes.XML)) {
            // $NON-NLS-1$
            contentType = "xml";
        } else if (returnColumn.getDatatype().getRuntimeTypeName().equals(DataTypeManager.DefaultDataTypes.CLOB)) {
            contentType = "json";
        }
    } else {
        for (ProcedureParameter pp : procedure.getParameters()) {
            if (pp.getType().equals(ProcedureParameter.Type.ReturnValue)) {
                if (pp.getDatatype().getRuntimeTypeName().equals(DataTypeManager.DefaultDataTypes.XML)) {
                    // $NON-NLS-1$
                    contentType = "xml";
                } else if (pp.getDatatype().getRuntimeTypeName().equals(DataTypeManager.DefaultDataTypes.CLOB)) {
                    // $NON-NLS-1$
                    contentType = "json";
                }
            }
        }
    }
    return contentType;
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) Column(org.teiid.metadata.Column) Procedure(org.teiid.metadata.Procedure)

Example 77 with Procedure

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

the class RestASMBasedWebArchiveBuilder method hasRestMetadata.

@Override
public boolean hasRestMetadata(VDBMetaData vdb) {
    // $NON-NLS-1$
    String generate = vdb.getPropertyValue(REST_NAMESPACE + "auto-generate");
    if (generate == null || !Boolean.parseBoolean(generate)) {
        return false;
    }
    // $NON-NLS-1$
    String securityType = vdb.getPropertyValue(REST_NAMESPACE + "security-type");
    if (securityType != null && !securityType.equalsIgnoreCase("none") && !securityType.equalsIgnoreCase("httpbasic")) {
        // $NON-NLS-1$ //$NON-NLS-2$
        return false;
    }
    MetadataStore metadataStore = vdb.getAttachment(TransformationMetadata.class).getMetadataStore();
    for (ModelMetaData model : vdb.getModelMetaDatas().values()) {
        Schema schema = metadataStore.getSchema(model.getName());
        if (schema == null) {
            // OTHER type, which does not have a corresponding Teiid schema
            continue;
        }
        Collection<Procedure> procedures = schema.getProcedures().values();
        for (Procedure procedure : procedures) {
            // $NON-NLS-1$
            String uri = procedure.getProperty(REST_NAMESPACE + "URI", false);
            // $NON-NLS-1$
            String method = procedure.getProperty(REST_NAMESPACE + "METHOD", false);
            if (uri != null && method != null) {
                return true;
            }
        }
    }
    return false;
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) Schema(org.teiid.metadata.Schema) Procedure(org.teiid.metadata.Procedure) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Example 78 with Procedure

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

the class EventDistributorImpl method setProcedureDefinition.

@Override
public void setProcedureDefinition(String vdbName, String vdbVersion, String schema, String procName, String definition) {
    Schema s = getSchema(vdbName, vdbVersion, schema);
    if (s == null) {
        return;
    }
    Procedure p = s.getProcedures().get(procName);
    if (p == null) {
        return;
    }
    DdlPlan.alterProcedureDefinition(getVdbRepository().getLiveVDB(vdbName, vdbVersion), p, definition, true);
}
Also used : Schema(org.teiid.metadata.Schema) Procedure(org.teiid.metadata.Procedure)

Example 79 with Procedure

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

the class MultiSourceMetadataRepository method loadMetadata.

@Override
public void loadMetadata(MetadataFactory factory, ExecutionFactory<Object, Object> executionFactory, Object connectionFactory) throws TranslatorException {
    Schema s = factory.getSchema();
    for (Table t : s.getTables().values()) {
        if (!t.isPhysical()) {
            continue;
        }
        Column c = t.getColumnByName(multiSourceColumnName);
        if (c == null) {
            c = factory.addColumn(multiSourceColumnName, DataTypeManager.DefaultDataTypes.STRING, t);
            MultiSourceMetadataWrapper.setMultiSourceElementMetadata(c);
        }
    }
    outer: for (Procedure p : s.getProcedures().values()) {
        if (p.isVirtual()) {
            continue;
        }
        for (ProcedureParameter pp : p.getParameters()) {
            if (multiSourceColumnName.equalsIgnoreCase(pp.getName())) {
                continue outer;
            }
        }
        ProcedureParameter pp = factory.addProcedureParameter(multiSourceColumnName, DataTypeManager.DefaultDataTypes.STRING, Type.In, p);
        pp.setNullType(NullType.Nullable);
    }
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) Table(org.teiid.metadata.Table) Column(org.teiid.metadata.Column) Schema(org.teiid.metadata.Schema) Procedure(org.teiid.metadata.Procedure)

Example 80 with Procedure

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

the class TestMetadataObject method helpTestProcedureID.

public void helpTestProcedureID(String procName, String shortName, int inputParamCount, String[] paramNames, String rsParamName, TranslationUtility transUtil) throws Exception {
    Procedure procID = getProcedureID(procName, inputParamCount, transUtil);
    assertEquals(procName, procID.getFullName());
    assertEquals(shortName, procID.getName());
    // Check children
    List<ProcedureParameter> children = procID.getParameters();
    int i = 0;
    for (ProcedureParameter childID : children) {
        assertEquals(procID, childID.getParent());
        // $NON-NLS-1$
        assertTrue(childID.getFullName() + " " + procID.getFullName(), childID.getFullName().startsWith(procID.getFullName()));
        assertEquals(paramNames[i++], childID.getName());
    }
    if (rsParamName != null) {
        assertEquals(rsParamName, procID.getResultSet().getName());
    } else {
        assertNull(procID.getResultSet());
    }
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) Procedure(org.teiid.metadata.Procedure)

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