Search in sources :

Example 41 with ProcedureParameter

use of org.teiid.metadata.ProcedureParameter 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 42 with ProcedureParameter

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

Example 43 with ProcedureParameter

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

the class TestParams method checkParameter.

private void checkParameter(Argument param, String name, String fullName, Direction direction, String nameInSource, String defaultValue, NullType nullability, Class<?> javaType, int length, int precision, int scale) throws Exception {
    ProcedureParameter p = param.getMetadataObject();
    assertEquals(name, p.getName());
    assertEquals(fullName, p.getFullName());
    assertEquals(direction, param.getDirection());
    assertEquals(nameInSource, p.getNameInSource());
    assertEquals(defaultValue, p.getDefaultValue());
    assertEquals(nullability, p.getNullType());
    assertEquals(javaType, p.getJavaType());
    assertEquals(javaType, param.getType());
    assertEquals(length, p.getLength());
    assertEquals(precision, p.getPrecision());
    assertEquals(scale, p.getScale());
    assertEquals(null, param.getArgumentValue().getValue());
}
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