Search in sources :

Example 31 with MetadataFactory

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

the class TestODataMetadataProcessor method testMultikeyPK.

@Test
public void testMultikeyPK() throws Exception {
    MetadataFactory mf = multiplePKMetadata();
    Table g1 = mf.getSchema().getTable("G1");
    assertNotNull(g1.getPrimaryKey().getColumnByName("e1"));
    assertNotNull(g1.getPrimaryKey().getColumnByName("e2"));
    assertNull(g1.getPrimaryKey().getColumnByName("e3"));
}
Also used : Table(org.teiid.metadata.Table) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Test(org.junit.Test)

Example 32 with MetadataFactory

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

the class TestODataMetadataProcessor method testMultipleNavigationProperties.

@Test
public void testMultipleNavigationProperties() throws Exception {
    MetadataFactory mf = multipleNavigationProperties();
    String metadataDDL = DDLStringVisitor.getDDLString(mf.getSchema(), null, null);
    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 33 with MetadataFactory

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

the class TestODataMetadataProcessor method testFunctionReturnPrimitiveCollection.

@Test
public void testFunctionReturnPrimitiveCollection() throws Exception {
    CsdlReturnType returnType = new CsdlReturnType();
    returnType.setType("Edm.String");
    returnType.setCollection(true);
    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 34 with MetadataFactory

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

the class TestODataMetadataProcessor method oneToManyRelationMetadata.

static MetadataFactory oneToManyRelationMetadata() 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 = multipleKeyEntityType("g2");
    CsdlNavigationProperty navProperty = new CsdlNavigationProperty();
    navProperty.setName("one_2_many");
    navProperty.setType("Collection(namespace.g2)");
    navProperty.setNullable(false);
    navProperty.setPartner("PartnerPath");
    navProperty.setCollection(true);
    g1Entity.setNavigationProperties(Arrays.asList(navProperty));
    CsdlEntitySet g1Set = createES("G1", "namespace.g1");
    CsdlEntitySet g2Set = createES("G2", "namespace.g2");
    CsdlNavigationPropertyBinding navBinding = new CsdlNavigationPropertyBinding();
    navBinding.setPath("one_2_many");
    navBinding.setTarget("G2");
    g1Set.setNavigationPropertyBindings(Arrays.asList(navBinding));
    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 35 with MetadataFactory

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

the class TestODataMetadataProcessor method testMultipleEnititySetWithSameComplexType.

@Test
public void testMultipleEnititySetWithSameComplexType() throws Exception {
    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, createES("Corporate", "namespace.Business"), buildBusinessEntity(address));
    processor.getMetadata(mf, metadata);
    assertEquals(5, mf.getSchema().getTables().size());
    assertNotNull(mf.getSchema().getTable("Persons"));
    assertNotNull(mf.getSchema().getTable("Corporate"));
    assertNotNull(mf.getSchema().getTable("Persons_address"));
    assertNotNull(mf.getSchema().getTable("Corporate_address"));
    Table personTable = mf.getSchema().getTable("Persons");
    assertEquals(2, personTable.getColumns().size());
    Table personAddress = mf.getSchema().getTable("Persons_address");
    assertEquals(4, personAddress.getColumns().size());
    ForeignKey fk = personAddress.getForeignKeys().get(0);
    assertNotNull(fk.getColumnByName("Persons_ssn"));
    Table businessTable = mf.getSchema().getTable("Corporate");
    assertEquals(1, businessTable.getColumns().size());
    Table corporateAddress = mf.getSchema().getTable("Corporate_address");
    assertEquals(4, corporateAddress.getColumns().size());
    fk = corporateAddress.getForeignKeys().get(0);
    assertNotNull(fk.getColumnByName("Corporate_name"));
}
Also used : Table(org.teiid.metadata.Table) 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) ForeignKey(org.teiid.metadata.ForeignKey) 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