Search in sources :

Example 1 with ClientCsdlEdmx

use of org.apache.olingo.client.core.edm.xml.ClientCsdlEdmx in project teiid by teiid.

the class TestODataMetadataProcessor method buildXmlMetadata.

static XMLMetadata buildXmlMetadata(Object... schemaElements) {
    final CsdlSchema schema = new CsdlSchema();
    schema.setNamespace("namespace");
    schema.setEntityContainer(new CsdlEntityContainer());
    ArrayList<CsdlEntitySet> entitySets = new ArrayList<CsdlEntitySet>();
    ArrayList<CsdlEntityType> entityTypes = new ArrayList<CsdlEntityType>();
    ArrayList<CsdlComplexType> complexTypes = new ArrayList<CsdlComplexType>();
    ArrayList<CsdlFunctionImport> functionImports = new ArrayList<CsdlFunctionImport>();
    ArrayList<CsdlFunction> functions = new ArrayList<CsdlFunction>();
    ArrayList<CsdlActionImport> actionImports = new ArrayList<CsdlActionImport>();
    ArrayList<CsdlAction> actions = new ArrayList<CsdlAction>();
    for (Object obj : schemaElements) {
        if (obj instanceof CsdlEntitySet) {
            entitySets.add((CsdlEntitySet) obj);
        } else if (obj instanceof CsdlEntityType) {
            entityTypes.add((CsdlEntityType) obj);
        } else if (obj instanceof CsdlComplexType) {
            complexTypes.add((CsdlComplexType) obj);
        } else if (obj instanceof CsdlFunctionImport) {
            functionImports.add((CsdlFunctionImport) obj);
        } else if (obj instanceof CsdlFunction) {
            functions.add((CsdlFunction) obj);
        } else if (obj instanceof CsdlActionImport) {
            actionImports.add((CsdlActionImport) obj);
        } else if (obj instanceof CsdlAction) {
            actions.add((CsdlAction) obj);
        }
    }
    schema.setEntityTypes(entityTypes);
    schema.setComplexTypes(complexTypes);
    schema.setActions(actions);
    schema.setFunctions(functions);
    schema.getEntityContainer().setEntitySets(entitySets);
    schema.getEntityContainer().setFunctionImports(functionImports);
    schema.getEntityContainer().setActionImports(actionImports);
    ClientCsdlEdmx edmx = new ClientCsdlEdmx();
    edmx.setVersion("1.0");
    edmx.setDataServices(new DataServices() {

        @Override
        public List<CsdlSchema> getSchemas() {
            return Arrays.asList(schema);
        }

        @Override
        public String getMaxDataServiceVersion() {
            return "4.0";
        }

        @Override
        public String getDataServiceVersion() {
            return "4.0";
        }
    });
    return new ClientCsdlXMLMetadata(edmx);
}
Also used : ClientCsdlEdmx(org.apache.olingo.client.core.edm.xml.ClientCsdlEdmx) ArrayList(java.util.ArrayList) ClientCsdlXMLMetadata(org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata) DataServices(org.apache.olingo.client.api.edm.xml.DataServices) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 DataServices (org.apache.olingo.client.api.edm.xml.DataServices)1 ClientCsdlXMLMetadata (org.apache.olingo.client.core.edm.ClientCsdlXMLMetadata)1 ClientCsdlEdmx (org.apache.olingo.client.core.edm.xml.ClientCsdlEdmx)1