Search in sources :

Example 91 with MetadataFactory

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

the class TestODataMetadataProcessor method oneToOneRelationMetadata.

static MetadataFactory oneToOneRelationMetadata(boolean bothDirections) throws TranslatorException {
    ODataMetadataProcessor processor = new ODataMetadataProcessor();
    MetadataFactory mf = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
    CsdlEntityType g1Entity = entityType("g1");
    CsdlEntityType g2Entity = entityType("g2");
    CsdlNavigationProperty navProperty = new CsdlNavigationProperty();
    navProperty.setName("one_2_one");
    navProperty.setType("namespace.g2");
    navProperty.setNullable(false);
    navProperty.setPartner("PartnerPath");
    g1Entity.setNavigationProperties(Arrays.asList(navProperty));
    if (bothDirections) {
        CsdlNavigationProperty nav2Property = new CsdlNavigationProperty();
        nav2Property.setName("one_2_one");
        nav2Property.setType("namespace.g1");
        nav2Property.setNullable(false);
        nav2Property.setPartner("PartnerPath");
        g2Entity.setNavigationProperties(Arrays.asList(nav2Property));
    }
    CsdlEntitySet g1Set = createES("G1", "namespace.g1");
    CsdlEntitySet g2Set = createES("G2", "namespace.g2");
    CsdlNavigationPropertyBinding navBinding = new CsdlNavigationPropertyBinding();
    navBinding.setPath("one_2_one");
    navBinding.setTarget("G2");
    g1Set.setNavigationPropertyBindings(Arrays.asList(navBinding));
    if (bothDirections) {
        CsdlNavigationPropertyBinding nav2Binding = new CsdlNavigationPropertyBinding();
        nav2Binding.setPath("one_2_one");
        nav2Binding.setTarget("G1");
        g2Set.setNavigationPropertyBindings(Arrays.asList(nav2Binding));
    }
    XMLMetadata metadata = buildXmlMetadata(g1Entity, g1Set, g2Entity, g2Set);
    processor.getMetadata(mf, metadata);
    return mf;
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) XMLMetadata(org.apache.olingo.client.api.edm.xml.XMLMetadata) ClientCsdlXMLMetadata(org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata) Properties(java.util.Properties)

Example 92 with MetadataFactory

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

the class TestODataMetadataProcessor method testOneToManyAssosiation.

@Test
public void testOneToManyAssosiation() throws Exception {
    MetadataFactory mf = oneToManyRelationMetadata();
    Table g1 = mf.getSchema().getTable("G1");
    Table g2 = mf.getSchema().getTable("G2");
    ForeignKey fk = g2.getForeignKeys().get(0);
    assertEquals("G1_one_2_many", fk.getName());
    assertNotNull(fk.getColumnByName("e1"));
}
Also used : Table(org.teiid.metadata.Table) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) ForeignKey(org.teiid.metadata.ForeignKey) Test(org.junit.Test)

Example 93 with MetadataFactory

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

the class TestODataMetadataProcessor method getEntityWithComplexProperty.

static MetadataFactory getEntityWithComplexProperty() throws TranslatorException {
    ODataMetadataProcessor processor = new ODataMetadataProcessor();
    MetadataFactory mf = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
    CsdlComplexType address = complexType("Address");
    XMLMetadata metadata = buildXmlMetadata(createES("Persons", "namespace.Person"), buildPersonEntity(address), address);
    processor.getMetadata(mf, metadata);
    return mf;
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) XMLMetadata(org.apache.olingo.client.api.edm.xml.XMLMetadata) ClientCsdlXMLMetadata(org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata) Properties(java.util.Properties)

Example 94 with MetadataFactory

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

the class TestODataMetadataProcessor method testOlderSchema.

@Test(expected = TranslatorException.class)
public void testOlderSchema() throws Exception {
    translator = new ODataExecutionFactory();
    translator.start();
    MetadataFactory mf = createMetadata("northwind_v2.xml", "northwind", "NorthwindModel");
    getTransformationMetadata(mf, this.translator);
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Test(org.junit.Test)

Example 95 with MetadataFactory

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

Aggregations

MetadataFactory (org.teiid.metadata.MetadataFactory)159 Test (org.junit.Test)116 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)91 Properties (java.util.Properties)74 Table (org.teiid.metadata.Table)59 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)35 Procedure (org.teiid.metadata.Procedure)30 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)21 Column (org.teiid.metadata.Column)20 Connection (java.sql.Connection)18 FunctionTree (org.teiid.query.function.FunctionTree)15 UDFSource (org.teiid.query.function.UDFSource)14 CouchbaseMetadataProcessor (org.teiid.translator.couchbase.CouchbaseMetadataProcessor)14 Dimension (org.teiid.translator.couchbase.CouchbaseMetadataProcessor.Dimension)14 CouchbaseProperties (org.teiid.translator.couchbase.CouchbaseProperties)14 TranslationUtility (org.teiid.cdk.api.TranslationUtility)13 ValidatorReport (org.teiid.query.validator.ValidatorReport)13 XMLMetadata (org.apache.olingo.client.api.edm.xml.XMLMetadata)12 ClientCsdlXMLMetadata (org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata)12 ForeignKey (org.teiid.metadata.ForeignKey)12