Search in sources :

Example 1 with CsdlEntityType

use of org.apache.olingo.commons.api.edm.provider.CsdlEntityType in project cxf by apache.

the class DemoEdmProvider method getEntityType.

@Override
public CsdlEntityType getEntityType(FullQualifiedName entityTypeName) {
    // this method is called for one of the EntityTypes that are configured in the Schema
    if (entityTypeName.equals(ET_PRODUCT_FQN)) {
        // create EntityType properties
        CsdlProperty id = new CsdlProperty().setName("ID").setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
        CsdlProperty name = new CsdlProperty().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
        CsdlProperty description = new CsdlProperty().setName("Description").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
        // create CsdlPropertyRef for Key element
        CsdlPropertyRef propertyRef = new CsdlPropertyRef();
        propertyRef.setName("ID");
        // configure EntityType
        CsdlEntityType entityType = new CsdlEntityType();
        entityType.setName(ET_PRODUCT_NAME);
        entityType.setProperties(Arrays.asList(id, name, description));
        entityType.setKey(Collections.singletonList(propertyRef));
        return entityType;
    }
    return null;
}
Also used : CsdlEntityType(org.apache.olingo.commons.api.edm.provider.CsdlEntityType) CsdlPropertyRef(org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef) CsdlProperty(org.apache.olingo.commons.api.edm.provider.CsdlProperty)

Example 2 with CsdlEntityType

use of org.apache.olingo.commons.api.edm.provider.CsdlEntityType in project cxf by apache.

the class DemoEdmProvider method getSchemas.

@Override
public List<CsdlSchema> getSchemas() {
    // create Schema
    CsdlSchema schema = new CsdlSchema();
    schema.setNamespace(NAMESPACE);
    // add EntityTypes
    List<CsdlEntityType> entityTypes = new ArrayList<CsdlEntityType>();
    entityTypes.add(getEntityType(ET_PRODUCT_FQN));
    schema.setEntityTypes(entityTypes);
    // add EntityContainer
    schema.setEntityContainer(getEntityContainer());
    // finally
    List<CsdlSchema> schemas = new ArrayList<CsdlSchema>();
    schemas.add(schema);
    return schemas;
}
Also used : CsdlEntityType(org.apache.olingo.commons.api.edm.provider.CsdlEntityType) ArrayList(java.util.ArrayList) CsdlSchema(org.apache.olingo.commons.api.edm.provider.CsdlSchema)

Aggregations

CsdlEntityType (org.apache.olingo.commons.api.edm.provider.CsdlEntityType)2 ArrayList (java.util.ArrayList)1 CsdlProperty (org.apache.olingo.commons.api.edm.provider.CsdlProperty)1 CsdlPropertyRef (org.apache.olingo.commons.api.edm.provider.CsdlPropertyRef)1 CsdlSchema (org.apache.olingo.commons.api.edm.provider.CsdlSchema)1