Search in sources :

Example 6 with XMLMetadata

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

Example 7 with XMLMetadata

use of org.apache.olingo.client.api.edm.xml.XMLMetadata in project teiid by teiid.

the class TestODataMetadataProcessor method functionMetadata.

static MetadataFactory functionMetadata(String name, CsdlReturnType returnType, Object other) throws TranslatorException {
    ODataMetadataProcessor processor = new ODataMetadataProcessor();
    MetadataFactory mf = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
    CsdlFunction func = function(name, returnType);
    CsdlFunctionImport funcImport = new CsdlFunctionImport();
    funcImport.setFunction(new FullQualifiedName("namespace." + name));
    funcImport.setName(name);
    XMLMetadata metadata = buildXmlMetadata(funcImport, func, other);
    processor.getMetadata(mf, metadata);
    return mf;
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) FullQualifiedName(org.apache.olingo.commons.api.edm.FullQualifiedName) XMLMetadata(org.apache.olingo.client.api.edm.xml.XMLMetadata) ClientCsdlXMLMetadata(org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata) Properties(java.util.Properties)

Example 8 with XMLMetadata

use of org.apache.olingo.client.api.edm.xml.XMLMetadata in project teiid by teiid.

the class TestODataMetadataProcessor method multiplePKMetadata.

static MetadataFactory multiplePKMetadata() throws TranslatorException {
    ODataMetadataProcessor processor = new ODataMetadataProcessor();
    MetadataFactory mf = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
    CsdlEntityType entityType = multipleKeyEntityType("g1");
    CsdlEntitySet entitySet = createES("G1", "namespace.g1");
    XMLMetadata metadata = buildXmlMetadata(entityType, entitySet);
    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 9 with XMLMetadata

use of org.apache.olingo.client.api.edm.xml.XMLMetadata in project teiid by teiid.

the class TestODataMetadataProcessor method testEnititySet.

@Test
public void testEnititySet() throws Exception {
    ODataMetadataProcessor processor = new ODataMetadataProcessor();
    MetadataFactory mf = new MetadataFactory("vdb", 1, "trippin", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
    ArrayList<CsdlProperty> properties = new ArrayList<CsdlProperty>();
    properties.add(createProperty("name", EdmPrimitiveTypeKind.String).setMaxLength(25).setNullable(false));
    properties.add(createProperty("dob", EdmPrimitiveTypeKind.DateTimeOffset).setNullable(true));
    properties.add(createProperty("ssn", EdmPrimitiveTypeKind.Int64).setNullable(false));
    CsdlEntityType entityType = new CsdlEntityType();
    entityType.setName("Person");
    entityType.setProperties(properties);
    entityType.setKey(Arrays.asList(new CsdlPropertyRef().setName("ssn")));
    CsdlEntitySet es = createES("Persons", "namespace.Person");
    XMLMetadata metadata = buildXmlMetadata(es, entityType);
    processor.getMetadata(mf, metadata);
    assertNotNull(mf.getSchema().getTable("Persons"));
    Table person = mf.getSchema().getTable("Persons");
    assertEquals(3, person.getColumns().size());
    assertNotNull(person.getColumnByName("name"));
    assertNotNull(person.getColumnByName("dob"));
    assertNotNull(person.getColumnByName("ssn"));
    Column name = person.getColumnByName("name");
    Column dob = person.getColumnByName("dob");
    Column ssn = person.getColumnByName("ssn");
    assertEquals("string", name.getDatatype().getRuntimeTypeName());
    assertEquals("timestamp", dob.getDatatype().getRuntimeTypeName());
    assertEquals("long", ssn.getDatatype().getRuntimeTypeName());
    assertTrue(name.getNullType() == NullType.No_Nulls);
    assertTrue(dob.getNullType() == NullType.Nullable);
    assertTrue(ssn.getNullType() == NullType.No_Nulls);
    assertEquals(25, name.getLength());
    assertNotNull(person.getPrimaryKey());
    assertEquals(1, person.getPrimaryKey().getColumns().size());
    assertEquals("ssn", person.getPrimaryKey().getColumns().get(0).getName());
    assertTrue(person.getForeignKeys().isEmpty());
}
Also used : Table(org.teiid.metadata.Table) RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) Column(org.teiid.metadata.Column) ArrayList(java.util.ArrayList) XMLMetadata(org.apache.olingo.client.api.edm.xml.XMLMetadata) ClientCsdlXMLMetadata(org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata) Properties(java.util.Properties) Test(org.junit.Test)

Example 10 with XMLMetadata

use of org.apache.olingo.client.api.edm.xml.XMLMetadata in project teiid by teiid.

the class TestODataMetadataProcessor method actionMetadata.

static MetadataFactory actionMetadata(String name, CsdlReturnType returnType, Object other) throws TranslatorException {
    ODataMetadataProcessor processor = new ODataMetadataProcessor();
    MetadataFactory mf = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null);
    CsdlAction func = action(name, returnType);
    CsdlActionImport funcImport = new CsdlActionImport();
    funcImport.setAction(new FullQualifiedName("namespace." + name));
    funcImport.setName(name);
    XMLMetadata metadata = buildXmlMetadata(funcImport, func, other);
    processor.getMetadata(mf, metadata);
    return mf;
}
Also used : RealMetadataFactory(org.teiid.query.unittest.RealMetadataFactory) MetadataFactory(org.teiid.metadata.MetadataFactory) FullQualifiedName(org.apache.olingo.commons.api.edm.FullQualifiedName) 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