Search in sources :

Example 46 with Procedure

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

the class TestODataMetadataProcessor method testFunctionReturnComplex.

@Test
public void testFunctionReturnComplex() throws Exception {
    CsdlComplexType complex = complexType("Address");
    CsdlReturnType returnType = new CsdlReturnType();
    returnType.setType("namespace.Address");
    MetadataFactory mf = functionMetadata("invoke", returnType, complex);
    Procedure p = mf.getSchema().getProcedure("invoke");
    assertNotNull(p);
    assertEquals(2, p.getParameters().size());
    assertNotNull(p.getResultSet());
    assertNull(getReturnParameter(p));
    ColumnSet<Procedure> table = p.getResultSet();
    ODataType type = ODataType.valueOf(p.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
    assertEquals(ODataType.FUNCTION, type);
    type = ODataType.valueOf(table.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
    assertEquals(ODataType.COMPLEX, type);
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) ODataType(org.teiid.translator.odata4.ODataMetadataProcessor.ODataType) Procedure(org.teiid.metadata.Procedure) Test(org.junit.Test)

Example 47 with Procedure

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

the class TestODataMetadataProcessor method testFunction.

@Test
public void testFunction() throws Exception {
    CsdlReturnType returnType = new CsdlReturnType();
    returnType.setType("Edm.String");
    MetadataFactory mf = functionMetadata("invoke", returnType, null);
    Procedure p = mf.getSchema().getProcedure("invoke");
    assertNotNull(p);
    assertEquals(3, p.getParameters().size());
    assertNull(p.getResultSet());
    assertNotNull(getReturnParameter(p));
    ProcedureParameter pp = getReturnParameter(p);
    assertEquals("string", pp.getRuntimeType());
    ODataType type = ODataType.valueOf(p.getProperty(ODataMetadataProcessor.ODATA_TYPE, false));
    assertEquals(ODataType.FUNCTION, type);
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) ODataType(org.teiid.translator.odata4.ODataMetadataProcessor.ODataType) Procedure(org.teiid.metadata.Procedure) Test(org.junit.Test)

Example 48 with Procedure

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

the class TestDataEntitySchemaBuilder method testArrayType.

@Test
public void testArrayType() throws Exception {
    ModelMetaData model = new ModelMetaData();
    model.setName("nw");
    model.setModelType(Type.PHYSICAL);
    MetadataFactory mf = new MetadataFactory("northwind", 1, SystemMetadata.getInstance().getRuntimeTypeMap(), model);
    EdmDataServices edm = new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new FileReader(UnitTestUtil.getTestDataFile("arraytest.xml"))));
    ODataMetadataProcessor metadataProcessor = new ODataMetadataProcessor();
    // $NON-NLS-1$
    PropertiesUtils.setBeanProperties(metadataProcessor, mf.getModelProperties(), "importer");
    metadataProcessor.getMetadata(mf, edm);
    Column c = mf.getSchema().getTable("G2").getColumnByName("e3");
    assertEquals("integer[]", c.getRuntimeType());
    Procedure p = mf.getSchema().getProcedure("ARRAYITERATE");
    assertEquals("varbinary[]", p.getParameters().get(0).getRuntimeType());
    assertEquals("varbinary", p.getResultSet().getColumns().get(0).getRuntimeType());
// String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
// System.out.println(ddl);
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Column(org.teiid.metadata.Column) EdmxFormatParser(org.odata4j.format.xml.EdmxFormatParser) Procedure(org.teiid.metadata.Procedure) FileReader(java.io.FileReader) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 49 with Procedure

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

the class SalesForceExecutionFactory method createProcedureExecution.

@Override
public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, SalesforceConnection connection) throws TranslatorException {
    Procedure metadataObject = command.getMetadataObject();
    String nativeQuery = metadataObject.getProperty(SQLStringVisitor.TEIID_NATIVE_QUERY, false);
    if (nativeQuery != null) {
        return new DirectQueryExecution(command.getArguments(), command, connection, metadata, executionContext, nativeQuery, false);
    }
    return new ProcedureExecutionParentImpl(command, connection, metadata, executionContext);
}
Also used : DirectQueryExecution(org.teiid.translator.salesforce.execution.DirectQueryExecution) ProcedureExecutionParentImpl(org.teiid.translator.salesforce.execution.ProcedureExecutionParentImpl) Procedure(org.teiid.metadata.Procedure)

Example 50 with Procedure

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

the class SalesForceMetadataProcessor method addProcedrues.

public static void addProcedrues(MetadataFactory metadataFactory) {
    // $NON-NLS-1$
    Procedure p1 = metadataFactory.addProcedure("GetUpdated");
    // $NON-NLS-1$
    p1.setAnnotation("Gets the updated objects");
    // $NON-NLS-1$
    ProcedureParameter param = metadataFactory.addProcedureParameter("ObjectName", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p1);
    // $NON-NLS-1$
    param.setAnnotation("ObjectName");
    // $NON-NLS-1$
    param = metadataFactory.addProcedureParameter("StartDate", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p1);
    // $NON-NLS-1$
    param.setAnnotation("Start Time");
    // $NON-NLS-1$
    param = metadataFactory.addProcedureParameter("EndDate", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p1);
    // $NON-NLS-1$
    param.setAnnotation("End Time");
    // $NON-NLS-1$
    param = metadataFactory.addProcedureParameter("LatestDateCovered", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p1);
    // $NON-NLS-1$
    param.setAnnotation("Latest Date Covered");
    // $NON-NLS-1$
    metadataFactory.addProcedureResultSetColumn("ID", TypeFacility.RUNTIME_NAMES.STRING, p1);
    // $NON-NLS-1$
    Procedure p2 = metadataFactory.addProcedure("GetDeleted");
    // $NON-NLS-1$
    p2.setAnnotation("Gets the deleted objects");
    // $NON-NLS-1$
    param = metadataFactory.addProcedureParameter("ObjectName", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p2);
    // $NON-NLS-1$
    param.setAnnotation("ObjectName");
    // $NON-NLS-1$
    param = metadataFactory.addProcedureParameter("StartDate", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p2);
    // $NON-NLS-1$
    param.setAnnotation("Start Time");
    // $NON-NLS-1$
    param = metadataFactory.addProcedureParameter("EndDate", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p2);
    // $NON-NLS-1$
    param.setAnnotation("End Time");
    // $NON-NLS-1$
    param = metadataFactory.addProcedureParameter("EarliestDateAvailable", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p2);
    // $NON-NLS-1$
    param.setAnnotation("Earliest Date Available");
    // $NON-NLS-1$
    param = metadataFactory.addProcedureParameter("LatestDateCovered", TypeFacility.RUNTIME_NAMES.TIMESTAMP, Type.In, p2);
    // $NON-NLS-1$
    param.setAnnotation("Latest Date Covered");
    // $NON-NLS-1$
    metadataFactory.addProcedureResultSetColumn("ID", TypeFacility.RUNTIME_NAMES.STRING, p2);
    // $NON-NLS-1$
    metadataFactory.addProcedureResultSetColumn("DeletedDate", TypeFacility.RUNTIME_NAMES.TIMESTAMP, p2);
}
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