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