Search in sources :

Example 11 with XMLMetadata

use of org.apache.olingo.client.api.edm.xml.XMLMetadata 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 12 with XMLMetadata

use of org.apache.olingo.client.api.edm.xml.XMLMetadata 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)

Aggregations

Properties (java.util.Properties)12 XMLMetadata (org.apache.olingo.client.api.edm.xml.XMLMetadata)12 ClientCsdlXMLMetadata (org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata)12 MetadataFactory (org.teiid.metadata.MetadataFactory)12 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)12 Test (org.junit.Test)4 Table (org.teiid.metadata.Table)4 FullQualifiedName (org.apache.olingo.commons.api.edm.FullQualifiedName)2 ForeignKey (org.teiid.metadata.ForeignKey)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 ClientODataDeserializerImpl (org.apache.olingo.client.core.serialization.ClientODataDeserializerImpl)1 Column (org.teiid.metadata.Column)1 WSConnection (org.teiid.translator.WSConnection)1