org.apache.olingo.commons.api.edm.provider.CsdlEntityType Java Examples
The following examples show how to use
org.apache.olingo.commons.api.edm.provider.CsdlEntityType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetadataParser.java From olingo-odata4 with Apache License 2.0 | 6 votes |
private void readEntityType(XMLEventReader reader, StartElement element, CsdlSchema schema) throws XMLStreamException { CsdlEntityType entityType = new CsdlEntityType(); entityType.setProperties(new ArrayList<CsdlProperty>()); entityType.setNavigationProperties(new ArrayList<CsdlNavigationProperty>()); entityType.setKey(new ArrayList<CsdlPropertyRef>()); entityType.setName(attr(element, "Name")); if (attr(element, "BaseType") != null) { entityType.setBaseType(new FullQualifiedName(attr(element, "BaseType"))); } entityType.setAbstract(Boolean.parseBoolean(attr(element, "Abstract"))); entityType.setOpenType(Boolean.parseBoolean(attr(element, "OpenType"))); entityType.setHasStream(Boolean.parseBoolean(attr(element, "HasStream"))); readEntityProperties(reader, entityType); schema.getEntityTypes().add(entityType); }
Example #2
Source File: EdmEntityContainerImpl.java From olingo-odata4 with Apache License 2.0 | 6 votes |
/** Adds annotations to Entity type Properties derived from entity set * E.g of target paths * MySchema.MyEntityContainer/MyEntitySet/MyProperty * MySchema.MyEntityContainer/MyEntitySet/MyNavigationProperty * MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyProperty * MySchema.MyEntityContainer/MyEntitySet/MyComplexProperty/MyNavigationProperty * @param entitySet * @param entityContainerName * @param entityType * @return */ private void addAnnotationsToPropertiesIncludedFromES(CsdlEntitySet entitySet, FullQualifiedName entityContainerName, CsdlEntityType entityType) { for (CsdlProperty property : entityType.getProperties()) { removeAnnotationsAddedToPropertiesOfEntityType(entityType, property, entityContainerName); if (isPropertyComplex(property)) { CsdlComplexType complexType = getComplexTypeFromProperty(property); addAnnotationsToComplexTypeIncludedFromES(entitySet, entityContainerName, property, complexType); } else { addAnnotationsToETProperties(entitySet, entityContainerName, entityType, property); } } for (CsdlNavigationProperty navProperty : entityType.getNavigationProperties()) { removeAnnotationAddedToNavProperties(entityType, navProperty, entityContainerName); addAnnotationsToETNavProperties(entitySet, entityContainerName, entityType, navProperty); } }
Example #3
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override public CsdlEntityType getEntityType(FullQualifiedName entityTypeName) { // this method is called for one of the EntityTypes that are configured in the Schema if(ET_PRODUCT_FQN.equals(entityTypeName)){ //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 PropertyRef 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; }
Example #4
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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)); entityTypes.add(getEntityType(ET_CATEGORY_FQN)); schema.setEntityTypes(entityTypes); // add EntityContainer schema.setEntityContainer(getEntityContainer()); // finally List<CsdlSchema> schemas = new ArrayList<CsdlSchema>(); schemas.add(schema); return schemas; }
Example #5
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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; }
Example #6
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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; }
Example #7
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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; }
Example #8
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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; }
Example #9
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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)); entityTypes.add(getEntityType(ET_CATEGORY_FQN)); schema.setEntityTypes(entityTypes); // add EntityContainer schema.setEntityContainer(getEntityContainer()); // finally List<CsdlSchema> schemas = new ArrayList<CsdlSchema>(); schemas.add(schema); return schemas; }
Example #10
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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; }
Example #11
Source File: EdmProviderImpl.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override public EdmEntityType createEntityType(final FullQualifiedName entityTypeName) { try { CsdlEntityType entityType = provider.getEntityType(entityTypeName); if (entityType != null) { List<CsdlAnnotation> annotations = getAnnotationsMap().get(entityTypeName.getFullQualifiedNameAsString()); String aliasName = getAliasInfo(entityTypeName.getNamespace()); List<CsdlAnnotation> annotationsOnAlias = getAnnotationsMap().get(aliasName + DOT + entityTypeName.getName()); addAnnotationsOnStructuralType(entityType, annotations); addAnnotationsOnStructuralType(entityType, annotationsOnAlias); if (!isEntityDerivedFromES()) { addStructuralTypeAnnotations(entityType, entityTypeName, this.provider.getEntityContainer()); } return new EdmEntityTypeImpl(this, entityTypeName, entityType); } return null; } catch (ODataException e) { throw new EdmException(e); } }
Example #12
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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; }
Example #13
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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)); entityTypes.add(getEntityType(ET_CATEGORY_FQN)); entityTypes.add(getEntityType(ET_ADVERTISEMENT_FQN)); schema.setEntityTypes(entityTypes); // add EntityContainer schema.setEntityContainer(getEntityContainer()); // finally List<CsdlSchema> schemas = new ArrayList<CsdlSchema>(); schemas.add(schema); return schemas; }
Example #14
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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; }
Example #15
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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; }
Example #16
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override public CsdlEntityType getEntityType(FullQualifiedName entityTypeName) { // this method is called for one of the EntityTypes that are configured in the Schema if(ET_PRODUCT_FQN.equals(entityTypeName)){ //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 PropertyRef 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; }
Example #17
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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; }
Example #18
Source File: CsdlTypeValidator.java From olingo-odata4 with Apache License 2.0 | 6 votes |
/** * fetch the actual navigation property from the remaning path * @param remainingPath * @param strNavProperty * @param sourceTypeHavingNavProp * @return CsdlNavigationProperty */ private CsdlNavigationProperty fetchNavigationProperty(String remainingPath, String strNavProperty, CsdlStructuralType sourceTypeHavingNavProp) { String[] paths = remainingPath.split("/"); for (String path : paths) { FullQualifiedName fqName = null; if (sourceTypeHavingNavProp instanceof CsdlComplexType) { fqName = ((CsdlComplexType)sourceTypeHavingNavProp).getProperty(path).getTypeAsFQNObject(); } else if (sourceTypeHavingNavProp instanceof CsdlEntityType) { fqName = ((CsdlEntityType)sourceTypeHavingNavProp).getProperty(path).getTypeAsFQNObject(); } if (fqName != null) { String namespace = aliasNamespaceMap.get(fqName.getNamespace()); fqName = namespace != null ? new FullQualifiedName(namespace, fqName.getName()) : fqName; } sourceTypeHavingNavProp = csdlEntityTypesMap.get(fqName) != null ? csdlEntityTypesMap.get(fqName) : csdlComplexTypesMap.get(fqName); } return sourceTypeHavingNavProp.getNavigationProperty(strNavProperty); }
Example #19
Source File: EdmEntityTypeImplTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void hasStreamInherited() throws Exception { CsdlEdmProvider provider = mock(CsdlEdmProvider.class); EdmProviderImpl edm = new EdmProviderImpl(provider); FullQualifiedName baseName = new FullQualifiedName("namespace", "BaseTypeName"); CsdlEntityType baseType = new CsdlEntityType(); baseType.setHasStream(true); when(provider.getEntityType(baseName)).thenReturn(baseType); FullQualifiedName typeName = new FullQualifiedName("namespace", "typeName"); CsdlEntityType type = new CsdlEntityType(); type.setBaseType(baseName); EdmEntityType typeWithBaseTypeWithStream = new EdmEntityTypeImpl(edm, typeName, type); when(provider.getEntityType(typeName)).thenReturn(type); assertTrue(typeWithBaseTypeWithStream.hasStream()); }
Example #20
Source File: CsdlTypeValidator.java From olingo-odata4 with Apache License 2.0 | 6 votes |
/** * This fetches the last Base Type entity from a hierarchy of base type derived types * @param baseTypeFQName * @return CsdlNavigationProperty */ private CsdlNavigationProperty fetchLastBaseEntityHavingNavigationProperty( FullQualifiedName baseTypeFQName, String navBindingProperty) { CsdlEntityType baseEntityType = null; while (baseTypeFQName != null) { if (!(csdlEntityTypesMap.containsKey(baseTypeFQName))) { baseTypeFQName = validateCsdlEntityTypeWithAlias(baseTypeFQName); } baseEntityType = csdlEntityTypesMap.get(baseTypeFQName); if (baseEntityType != null) { if (baseEntityType.getNavigationProperty(navBindingProperty) != null) { break; } else if (baseEntityType.getBaseType() != null) { baseTypeFQName = baseEntityType.getBaseTypeFQN(); } else if (baseEntityType.getBaseType() == null) { break; } } } if (baseEntityType == null) { throw new RuntimeException("Entity Type is null with fully qualified name:" + baseTypeFQName); } return baseEntityType.getNavigationProperty(navBindingProperty); }
Example #21
Source File: CsdlTypeValidator.java From olingo-odata4 with Apache License 2.0 | 6 votes |
/** * This fetches the last Base Type entity from a hierarchy of base type derived types * @param baseTypeFQName * @return CsdlEntityType */ private CsdlEntityType fetchLastCsdlBaseType(FullQualifiedName baseTypeFQName) { CsdlEntityType baseEntityType = null; while (baseTypeFQName != null) { if (!(csdlEntityTypesMap.containsKey(baseTypeFQName))) { baseTypeFQName = validateCsdlEntityTypeWithAlias(baseTypeFQName); } baseEntityType = csdlEntityTypesMap.get(baseTypeFQName); if (baseEntityType != null) { if (baseEntityType.getKey() != null) { break; } else if (baseEntityType.getBaseType() != null) { baseTypeFQName = baseEntityType.getBaseTypeFQN(); } else if (baseEntityType.getBaseType() == null) { break; } } } return baseEntityType; }
Example #22
Source File: EdmNavigationPropertyImplTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void navigationProperty() throws Exception { CsdlEdmProvider provider = mock(CsdlEdmProvider.class); EdmProviderImpl edm = new EdmProviderImpl(provider); final FullQualifiedName entityTypeName = new FullQualifiedName("ns", "entity"); CsdlEntityType entityTypeProvider = new CsdlEntityType(); entityTypeProvider.setKey(Collections.<CsdlPropertyRef> emptyList()); when(provider.getEntityType(entityTypeName)).thenReturn(entityTypeProvider); CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty(); propertyProvider.setType(entityTypeName); propertyProvider.setNullable(false); EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider); assertFalse(property.isCollection()); assertFalse(property.isNullable()); EdmType type = property.getType(); assertEquals(EdmTypeKind.ENTITY, type.getKind()); assertEquals("ns", type.getNamespace()); assertEquals("entity", type.getName()); assertNull(property.getReferencingPropertyName("referencedPropertyName")); assertNull(property.getPartner()); assertFalse(property.containsTarget()); // Test caching EdmType cachedType = property.getType(); assertTrue(type == cachedType); }
Example #23
Source File: EdmNavigationPropertyImplTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void navigationPropertyWithPartner() throws Exception { CsdlEdmProvider provider = mock(CsdlEdmProvider.class); EdmProviderImpl edm = new EdmProviderImpl(provider); final FullQualifiedName entityTypeName = new FullQualifiedName("ns", "entity"); CsdlEntityType entityTypeProvider = new CsdlEntityType(); entityTypeProvider.setKey(Collections.<CsdlPropertyRef> emptyList()); List<CsdlNavigationProperty> navigationProperties = new ArrayList<CsdlNavigationProperty>(); navigationProperties.add(new CsdlNavigationProperty().setName("partnerName").setType(entityTypeName)); entityTypeProvider.setNavigationProperties(navigationProperties); when(provider.getEntityType(entityTypeName)).thenReturn(entityTypeProvider); CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty(); propertyProvider.setType(entityTypeName); propertyProvider.setNullable(false); propertyProvider.setPartner("partnerName"); EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider); EdmNavigationProperty partner = property.getPartner(); assertNotNull(partner); // Caching assertTrue(partner == property.getPartner()); }
Example #24
Source File: EdmNavigationPropertyImplTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test(expected = EdmException.class) public void navigationPropertyWithNonexistentPartner() throws Exception { CsdlEdmProvider provider = mock(CsdlEdmProvider.class); EdmProviderImpl edm = new EdmProviderImpl(provider); final FullQualifiedName entityTypeName = new FullQualifiedName("ns", "entity"); CsdlEntityType entityTypeProvider = new CsdlEntityType(); entityTypeProvider.setKey(Collections.<CsdlPropertyRef> emptyList()); List<CsdlNavigationProperty> navigationProperties = new ArrayList<CsdlNavigationProperty>(); navigationProperties.add(new CsdlNavigationProperty().setName("partnerName").setType(entityTypeName)); entityTypeProvider.setNavigationProperties(navigationProperties); when(provider.getEntityType(entityTypeName)).thenReturn(entityTypeProvider); CsdlNavigationProperty propertyProvider = new CsdlNavigationProperty(); propertyProvider.setType(entityTypeName); propertyProvider.setNullable(false); propertyProvider.setPartner("wrong"); EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider); property.getPartner(); }
Example #25
Source File: DemoEdmProvider.java From cxf with Apache License 2.0 | 6 votes |
@Override public List<CsdlSchema> getSchemas() { // create Schema CsdlSchema schema = new CsdlSchema(); schema.setNamespace(NAMESPACE); // add EntityTypes List<CsdlEntityType> entityTypes = new ArrayList<>(); entityTypes.add(getEntityType(ET_PRODUCT_FQN)); schema.setEntityTypes(entityTypes); // add EntityContainer schema.setEntityContainer(getEntityContainer()); // finally List<CsdlSchema> schemas = new ArrayList<>(); schemas.add(schema); return schemas; }
Example #26
Source File: MetadataDocumentXmlSerializerTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Override public CsdlEntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException { if (entityTypeName.equals(nameETAbstract)) { return new CsdlEntityType() .setName("ETAbstract") .setAbstract(true) .setProperties(Collections.singletonList(propertyString)); } else if (entityTypeName.equals(nameETAbstractBase)) { return new CsdlEntityType() .setName("ETAbstractBase") .setBaseType(nameETAbstract) .setKey(Collections.singletonList(new CsdlPropertyRef().setName("PropertyInt16"))) .setProperties(Collections.singletonList(propertyInt16_NotNullable)); } else if (entityTypeName.equals(nameET)) { return new CsdlEntityType() .setName("ET") .setKey(Collections.singletonList(new CsdlPropertyRef().setName("PropertyInt16"))) .setProperties(Collections.singletonList(propertyInt16_NotNullable)) .setNavigationProperties(Collections.singletonList(navProperty)); } return null; }
Example #27
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@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)); entityTypes.add(getEntityType(ET_CATEGORY_FQN)); schema.setEntityTypes(entityTypes); // add EntityContainer schema.setEntityContainer(getEntityContainer()); // finally List<CsdlSchema> schemas = new ArrayList<CsdlSchema>(); schemas.add(schema); return schemas; }
Example #28
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@Override public CsdlEntityType getEntityType(FullQualifiedName entityTypeName) { // this method is called for one of the EntityTypes that are configured in the Schema if (ET_PRODUCT_FQN.equals(entityTypeName)) { // 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 PropertyRef 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; }
Example #29
Source File: DemoEdmProvider.java From olingo-odata4 with Apache License 2.0 | 5 votes |
@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)); entityTypes.add(getEntityType(ET_CATEGORY_FQN)); schema.setEntityTypes(entityTypes); // add actions List<CsdlAction> actions = new ArrayList<CsdlAction>(); actions.addAll(getActions(ACTION_RESET_FQN)); actions.addAll(getActions(ACTION_PROVIDE_DISCOUNT_FQN)); actions.addAll(getActions(ACTION_PROVIDE_DISCOUNT_FOR_PRODUCT_FQN)); schema.setActions(actions); // add functions List<CsdlFunction> functions = new ArrayList<CsdlFunction>(); functions.addAll(getFunctions(FUNCTION_COUNT_CATEGORIES_FQN)); functions.addAll(getFunctions(FUNCTION_PROVIDE_DISCOUNT_FQN)); functions.addAll(getFunctions(FUNCTION_PROVIDE_DISCOUNT_FOR_PRODUCT_FQN)); schema.setFunctions(functions); // add EntityContainer schema.setEntityContainer(getEntityContainer()); // finally List<CsdlSchema> schemas = new ArrayList<CsdlSchema>(); schemas.add(schema); return schemas; }
Example #30
Source File: CsdlTypeValidator.java From olingo-odata4 with Apache License 2.0 | 5 votes |
/** * * @param aliasNamespaceMap * @param csdlContainersMap * @param csdlEntityTypesMap * @param csdlComplexTypesMap * @param csdlActionsMap * @param csdlFunctionsMap * @param csdlTermsMap */ public CsdlTypeValidator(Map<String, String> aliasNamespaceMap, Map<FullQualifiedName, CsdlEntityContainer> csdlContainersMap, Map<FullQualifiedName, CsdlEntityType> csdlEntityTypesMap, Map<FullQualifiedName, CsdlComplexType> csdlComplexTypesMap, Map<FullQualifiedName, CsdlAction> csdlActionsMap, Map<FullQualifiedName, CsdlFunction> csdlFunctionsMap) { this.aliasNamespaceMap = aliasNamespaceMap; this.csdlContainersMap = csdlContainersMap; this.csdlEntityTypesMap = csdlEntityTypesMap; this.csdlComplexTypesMap = csdlComplexTypesMap; this.csdlActionsMap = csdlActionsMap; this.csdlFunctionsMap = csdlFunctionsMap; }