@Test public void testMultipleEnititySetWithSameComplexType() throws Exception { ODataMetadataProcessor processor = new ODataMetadataProcessor(); MetadataFactory mf = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null); EdmEntitySet es = EdmEntitySet.newBuilder().setName("Person").setEntityType(buildPersonEntity(buildAddressEntity().build())).build(); processor.addEntitySetAsTable(mf, es); es = EdmEntitySet.newBuilder().setName("Business").setEntityType(buildBusinessEntity(buildAddressEntity().build())).build(); processor.addEntitySetAsTable(mf, es); assertEquals(2, mf.getSchema().getTables().size()); assertNotNull(mf.getSchema().getTable("Person")); assertNotNull(mf.getSchema().getTable("Business")); Table personTable = mf.getSchema().getTable("Person"); assertEquals(5, personTable.getColumns().size()); Table businessTable = mf.getSchema().getTable("Business"); assertEquals(4, businessTable.getColumns().size()); assertNotNull(personTable.getColumnByName("address_street")); assertNotNull(businessTable.getColumnByName("address_street")); }
protected Table addEntitySetAsTable(MetadataFactory mf, EdmEntitySet entitySet) throws TranslatorException { Table table = buildTable(mf, entitySet); table.setProperty(ENTITY_TYPE, entitySet.getType().getFullyQualifiedTypeName()); for (EdmProperty ep:entitySet.getType().getProperties().toList()) { if (ep.getType().isSimple() || (ep.getType() instanceof EdmCollectionType && ((EdmCollectionType)ep.getType()).getItemType().isSimple())) { addPropertyAsColumn(mf, table, ep, entitySet); } else { EdmComplexType embedded = (EdmComplexType)ep.getType(); for (EdmProperty property:embedded.getProperties().toList()) { if (property.getType().isSimple() || (property.getType() instanceof EdmCollectionType && ((EdmCollectionType)property.getType()).getItemType().isSimple())) { Column column = addPropertyAsColumn(mf, table, property, entitySet, ep.getName()); column.setProperty(COMPLEX_TYPE, embedded.getFullyQualifiedTypeName()); column.setProperty(COLUMN_GROUP, ep.getName()); } else { throw new TranslatorException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17002, entitySet.getName(), ep.getName())); } } } } mf.addPrimaryKey("PK", entitySet.getType().getKeys(), table); return table; }
ODataMetadataProcessor implements MetadataProcessor<WSConnection> { protected Table addEntitySetAsTable(MetadataFactory mf, EdmEntitySet entitySet) throws TranslatorException { Table table = buildTable(mf, entitySet); table.setProperty(ENTITY_TYPE, entitySet.getType().getFullyQualifiedTypeName()); for (EdmProperty ep:entitySet.getType().getProperties().toList()) { if (ep.getType().isSimple() || (ep.getType() instanceof EdmCollectionType && ((EdmCollectionType)ep.getType()).getItemType().isSimple())) { addPropertyAsColumn(mf, table, ep, entitySet); } else { EdmComplexType embedded = (EdmComplexType)ep.getType(); for (EdmProperty property:embedded.getProperties().toList()) { if (property.getType().isSimple() || (property.getType() instanceof EdmCollectionType && ((EdmCollectionType)property.getType()).getItemType().isSimple())) { Column column = addPropertyAsColumn(mf, table, property, entitySet, ep.getName()); column.setProperty(COMPLEX_TYPE, embedded.getFullyQualifiedTypeName()); column.setProperty(COLUMN_GROUP, ep.getName()); } else { throw new TranslatorException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17002, entitySet.getName(), ep.getName())); } } } } mf.addPrimaryKey("PK", entitySet.getType().getKeys(), table); return table; } }
ODataMetadataProcessor implements MetadataProcessor<WSConnection> { protected Table addEntitySetAsTable(MetadataFactory mf, EdmEntitySet entitySet) throws TranslatorException { Table table = buildTable(mf, entitySet); table.setProperty(ENTITY_TYPE, entitySet.getType().getFullyQualifiedTypeName()); for (EdmProperty ep:entitySet.getType().getProperties().toList()) { if (ep.getType().isSimple() || (ep.getType() instanceof EdmCollectionType && ((EdmCollectionType)ep.getType()).getItemType().isSimple())) { addPropertyAsColumn(mf, table, ep, entitySet); } else { EdmComplexType embedded = (EdmComplexType)ep.getType(); for (EdmProperty property:embedded.getProperties().toList()) { if (property.getType().isSimple() || (property.getType() instanceof EdmCollectionType && ((EdmCollectionType)property.getType()).getItemType().isSimple())) { Column column = addPropertyAsColumn(mf, table, property, entitySet, ep.getName()); column.setProperty(COMPLEX_TYPE, embedded.getFullyQualifiedTypeName()); column.setProperty(COLUMN_GROUP, ep.getName()); } else { throw new TranslatorException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17002, entitySet.getName(), ep.getName())); } } } } mf.addPrimaryKey("PK", entitySet.getType().getKeys(), table); return table; }  }
ODataMetadataProcessor implements MetadataProcessor<WSConnection> { protected Table addEntitySetAsTable(MetadataFactory mf, EdmEntitySet entitySet) throws TranslatorException { Table table = buildTable(mf, entitySet); table.setProperty(ENTITY_TYPE, entitySet.getType().getFullyQualifiedTypeName()); for (EdmProperty ep:entitySet.getType().getProperties().toList()) { if (ep.getType().isSimple() || (ep.getType() instanceof EdmCollectionType && ((EdmCollectionType)ep.getType()).getItemType().isSimple())) { addPropertyAsColumn(mf, table, ep, entitySet); } else { EdmComplexType embedded = (EdmComplexType)ep.getType(); for (EdmProperty property:embedded.getProperties().toList()) { if (property.getType().isSimple() || (property.getType() instanceof EdmCollectionType && ((EdmCollectionType)property.getType()).getItemType().isSimple())) { Column column = addPropertyAsColumn(mf, table, property, entitySet, ep.getName()); column.setProperty(COMPLEX_TYPE, embedded.getFullyQualifiedTypeName()); column.setProperty(COLUMN_GROUP, ep.getName()); } else { throw new TranslatorException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17002, entitySet.getName(), ep.getName())); } } } } mf.addPrimaryKey("PK", entitySet.getType().getKeys(), table); return table; }  void setExecutionfactory(ODataExecutionFactory ef); @Override void process(MetadataFactory mf, WSConnection conn); void getMetadata(MetadataFactory mf, EdmDataServices eds); void setEntityContainer(String entityContainer); void setSchemaNamespace(String namespace); @TranslatorProperty(display="Entity Container Name", category=PropertyType.IMPORT, description="Entity Container Name to import") String getEntityContainer(); @TranslatorProperty(display="Schema Namespace", category=PropertyType.IMPORT, description="Namespace of the schema to import") String getSchemaNamespace(); }
ODataMetadataProcessor implements MetadataProcessor<WSConnection> { protected Table addEntitySetAsTable(MetadataFactory mf, EdmEntitySet entitySet) throws TranslatorException { Table table = buildTable(mf, entitySet); table.setProperty(ENTITY_TYPE, entitySet.getType().getFullyQualifiedTypeName()); for (EdmProperty ep:entitySet.getType().getProperties().toList()) { if (ep.getType().isSimple() || (ep.getType() instanceof EdmCollectionType && ((EdmCollectionType)ep.getType()).getItemType().isSimple())) { addPropertyAsColumn(mf, table, ep, entitySet); } else { EdmComplexType embedded = (EdmComplexType)ep.getType(); for (EdmProperty property:embedded.getProperties().toList()) { if (property.getType().isSimple() || (property.getType() instanceof EdmCollectionType && ((EdmCollectionType)property.getType()).getItemType().isSimple())) { Column column = addPropertyAsColumn(mf, table, property, entitySet, ep.getName()); column.setProperty(COMPLEX_TYPE, embedded.getFullyQualifiedTypeName()); column.setProperty(COLUMN_GROUP, ep.getName()); } else { throw new TranslatorException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17002, entitySet.getName(), ep.getName())); } } } } mf.addPrimaryKey("PK", entitySet.getType().getKeys(), table); return table; }  void setExecutionfactory(ODataExecutionFactory ef); @Override void process(MetadataFactory mf, WSConnection conn); void getMetadata(MetadataFactory mf, EdmDataServices eds); void setEntityContainer(String entityContainer); void setSchemaNamespace(String namespace); @TranslatorProperty(display="Entity Container Name", category=PropertyType.IMPORT, description="Entity Container Name to import") String getEntityContainer(); @TranslatorProperty(display="Schema Namespace", category=PropertyType.IMPORT, description="Namespace of the schema to import") String getSchemaNamespace(); @ExtensionMetadataProperty(applicable=Table.class, datatype=String.class, display="Link Tables", description="Used to define navigation relationship in many to many case")
    static final String LINK_TABLES; @ExtensionMetadataProperty(applicable=Procedure.class, datatype=String.class, display="Http Method", description="Http method used for procedure invocation", required=true)
    static final String HTTP_METHOD; @ExtensionMetadataProperty(applicable=Column.class, datatype=Boolean.class, display="Join Column", description="On Link tables this property defines the join column")
    static final String JOIN_COLUMN; @ExtensionMetadataProperty(applicable= {Table.class, Procedure.class}, datatype=String.class, display="Entity Type Name", description="Name of the Entity Type in EDM", required=true)
    static final String ENTITY_TYPE; @ExtensionMetadataProperty(applicable=Column.class, datatype=String.class, display="Complex Type Name", description="Name of the Complex Type in EDM")
    static final String COMPLEX_TYPE; @ExtensionMetadataProperty(applicable=Column.class, datatype=String.class, display="Column Group", description="Name of the Column Group")
    static final String COLUMN_GROUP; }