use of org.apache.olingo.client.api.edm.xml.DataServices 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);
}
Aggregations