@Test public void testSchema() throws Exception { translator = new ODataExecutionFactory(); translator.start(); String csdl = ObjectConverterUtil.convertFileToString(UnitTestUtil.getTestDataFile("northwind.xml")); ODataMetadataProcessor processor = new ODataMetadataProcessor(); Properties props = new Properties(); props.setProperty("schemaNamespace", "ODataWeb.Northwind.Model"); props.setProperty("entityContainer", "NorthwindEntities"); MetadataFactory mf = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), props, null); processor.getMetadata(mf, new EdmxFormatParser().parseMetadata(StaxUtil.newXMLEventReader(new InputStreamReader(new ByteArrayInputStream(csdl.getBytes()))))); TransformationMetadata metadata = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "northwind", new FunctionTree("foo", new UDFSource(translator.getPushDownFunctions()))); ValidatorReport report = new MetadataValidator().validate(metadata.getVdbMetaData(), metadata.getMetadataStore()); if (report.hasItems()) { throw new RuntimeException(report.getFailureMessage()); } String ddl = DDLStringVisitor.getDDLString(mf.getSchema(), null, null); MetadataFactory mf2 = new MetadataFactory("vdb", 1, "northwind", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null); QueryParser.getQueryParser().parseDDL(mf2, ddl); Procedure p = mf.getSchema().getProcedure("executeVoid"); assertNotNull(p); assertEquals(1, p.getParameters().size()); }
public void getMetadata(MetadataFactory mf, EdmDataServices eds) throws TranslatorException { for (EdmSchema schema:eds.getSchemas()) { if (this.schemaNamespace != null && !this.schemaNamespace.equalsIgnoreCase(schema.getNamespace())) { continue; } for (EdmEntityContainer container:schema.getEntityContainers()) { if ((this.entityContainer != null && this.entityContainer.equalsIgnoreCase(container.getName())) || container.isDefault()) { for (EdmEntitySet entitySet:container.getEntitySets()) { addEntitySetAsTable(mf, entitySet); } for (EdmEntitySet entitySet:container.getEntitySets()) { addNavigationRelations(mf, entitySet.getName(), entitySet.getType()); } for (EdmFunctionImport function:container.getFunctionImports()) { addFunctionImportAsProcedure(mf, function); } } } } }
ODataMetadataProcessor implements MetadataProcessor<WSConnection> { public void getMetadata(MetadataFactory mf, EdmDataServices eds) throws TranslatorException { for (EdmSchema schema:eds.getSchemas()) { if (this.schemaNamespace != null && !this.schemaNamespace.equalsIgnoreCase(schema.getNamespace())) { continue; } for (EdmEntityContainer container:schema.getEntityContainers()) { if ((this.entityContainer != null && this.entityContainer.equalsIgnoreCase(container.getName())) || container.isDefault()) { for (EdmEntitySet entitySet:container.getEntitySets()) { addEntitySetAsTable(mf, entitySet); } for (EdmEntitySet entitySet:container.getEntitySets()) { addNavigationRelations(mf, entitySet.getName(), entitySet.getType()); } for (EdmFunctionImport function:container.getFunctionImports()) { addFunctionImportAsProcedure(mf, function); } } } } } }
ODataMetadataProcessor implements MetadataProcessor<WSConnection> { public void getMetadata(MetadataFactory mf, EdmDataServices eds) throws TranslatorException { for (EdmSchema schema:eds.getSchemas()) { if (this.schemaNamespace != null && !this.schemaNamespace.equalsIgnoreCase(schema.getNamespace())) { continue; } for (EdmEntityContainer container:schema.getEntityContainers()) { if ((this.entityContainer != null && this.entityContainer.equalsIgnoreCase(container.getName())) || container.isDefault()) { for (EdmEntitySet entitySet:container.getEntitySets()) { addEntitySetAsTable(mf, entitySet); } for (EdmEntitySet entitySet:container.getEntitySets()) { addNavigationRelations(mf, entitySet.getName(), entitySet.getType()); } for (EdmFunctionImport function:container.getFunctionImports()) { addFunctionImportAsProcedure(mf, function); } } } } }  }
ODataMetadataProcessor implements MetadataProcessor<WSConnection> { public void getMetadata(MetadataFactory mf, EdmDataServices eds) throws TranslatorException { for (EdmSchema schema:eds.getSchemas()) { if (this.schemaNamespace != null && !this.schemaNamespace.equalsIgnoreCase(schema.getNamespace())) { continue; } for (EdmEntityContainer container:schema.getEntityContainers()) { if ((this.entityContainer != null && this.entityContainer.equalsIgnoreCase(container.getName())) || container.isDefault()) { for (EdmEntitySet entitySet:container.getEntitySets()) { addEntitySetAsTable(mf, entitySet); } for (EdmEntitySet entitySet:container.getEntitySets()) { addNavigationRelations(mf, entitySet.getName(), entitySet.getType()); } for (EdmFunctionImport function:container.getFunctionImports()) { addFunctionImportAsProcedure(mf, function); } } } } }  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> { public void getMetadata(MetadataFactory mf, EdmDataServices eds) throws TranslatorException { for (EdmSchema schema:eds.getSchemas()) { if (this.schemaNamespace != null && !this.schemaNamespace.equalsIgnoreCase(schema.getNamespace())) { continue; } for (EdmEntityContainer container:schema.getEntityContainers()) { if ((this.entityContainer != null && this.entityContainer.equalsIgnoreCase(container.getName())) || container.isDefault()) { for (EdmEntitySet entitySet:container.getEntitySets()) { addEntitySetAsTable(mf, entitySet); } for (EdmEntitySet entitySet:container.getEntitySets()) { addNavigationRelations(mf, entitySet.getName(), entitySet.getType()); } for (EdmFunctionImport function:container.getFunctionImports()) { addFunctionImportAsProcedure(mf, function); } } } } }  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; }