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"));
}
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"));
}
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);
}
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;
}
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"));
}
Aggregations