Java Code Examples for org.apache.olingo.commons.api.edm.provider.CsdlEntityType#setName()
The following examples show how to use
org.apache.olingo.commons.api.edm.provider.CsdlEntityType#setName() .
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: 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 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 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 5
Source File: ProductsEdmProvider.java From syndesis 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 (entityTypeName.equals(ET_PRODUCT_FQN)) { //create EntityType properties CsdlProperty id = new CsdlProperty().setName(PRODUCT_ID).setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName()); CsdlProperty name = new CsdlProperty().setName(PRODUCT_NAME).setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()); CsdlProperty description = new CsdlProperty().setName(PRODUCT_DESCRIPTION).setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()); CsdlProperty serialNums = new CsdlProperty() .setName(PRODUCT_SERIALS) .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()) .setCollection(true); CsdlProperty specification = new CsdlProperty() .setName(PRODUCT_SPEC) .setType(ET_SPEC_FQN); // create CsdlPropertyRef for Key element CsdlPropertyRef propertyRef = new CsdlPropertyRef(); propertyRef.setName(PRODUCT_ID); // configure EntityType CsdlEntityType entityType = new CsdlEntityType(); entityType.setName(ET_PRODUCT_NAME); entityType.setProperties(Arrays.asList(id, name, description, serialNums, specification)); entityType.setKey(Collections.singletonList(propertyRef)); return entityType; } return null; }
Example 6
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 7
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 8
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(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 | 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 10
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(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 11
Source File: DemoEdmProvider.java From cxf 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 (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 12
Source File: EdmEntityTypeImplTest.java From olingo-odata4 with Apache License 2.0 | 4 votes |
@Before public void setupTypes() throws Exception { CsdlEdmProvider provider = mock(CsdlEdmProvider.class); EdmProviderImpl edm = new EdmProviderImpl(provider); FullQualifiedName baseName = new FullQualifiedName("namespace", "BaseTypeName"); CsdlEntityType baseType = new CsdlEntityType(); baseType.setName(baseName.getName()); List<CsdlProperty> properties = new ArrayList<CsdlProperty>(); properties.add(new CsdlProperty().setName("Id").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())); properties.add(new CsdlProperty().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())); baseType.setProperties(properties); List<CsdlPropertyRef> key = new ArrayList<CsdlPropertyRef>(); key.add(new CsdlPropertyRef().setName("Id")); baseType.setKey(key); List<CsdlNavigationProperty> navigationProperties = new ArrayList<CsdlNavigationProperty>(); navigationProperties.add(new CsdlNavigationProperty().setName("nav1")); baseType.setNavigationProperties(navigationProperties); when(provider.getEntityType(baseName)).thenReturn(baseType); this.baseType = new EdmEntityTypeImpl(edm, baseName, baseType); FullQualifiedName typeName = new FullQualifiedName("namespace", "typeName"); CsdlEntityType type = new CsdlEntityType(); type.setName(typeName.getName()); type.setBaseType(baseName); List<CsdlProperty> typeProperties = new ArrayList<CsdlProperty>(); typeProperties.add(new CsdlProperty().setName("address").setType( EdmPrimitiveTypeKind.String.getFullQualifiedName())); typeProperties.add(new CsdlProperty().setName("email").setType( EdmPrimitiveTypeKind.String.getFullQualifiedName())); type.setProperties(typeProperties); List<CsdlNavigationProperty> typeNavigationProperties = new ArrayList<CsdlNavigationProperty>(); typeNavigationProperties.add(new CsdlNavigationProperty().setName("nav2")); type.setNavigationProperties(typeNavigationProperties); when(provider.getEntityType(typeName)).thenReturn(type); typeWithBaseType = new EdmEntityTypeImpl(edm, typeName, type); FullQualifiedName typeWithComplexKeyName = new FullQualifiedName("namespace", "typeName"); CsdlEntityType typeWithComplexKeyProvider = new CsdlEntityType(); typeWithComplexKeyProvider.setName(typeWithComplexKeyName.getName()); List<CsdlProperty> typeWithComplexKeyProperties = new ArrayList<CsdlProperty>(); typeWithComplexKeyProperties.add(new CsdlProperty().setName("Id").setType( EdmPrimitiveTypeKind.String.getFullQualifiedName())); List<CsdlProperty> complexTypeProperties = new ArrayList<CsdlProperty>(); complexTypeProperties.add(new CsdlProperty().setName("ComplexPropName").setType( EdmPrimitiveTypeKind.String.getFullQualifiedName())); FullQualifiedName complexTypeName = new FullQualifiedName("namespace", "complexTypeName"); when(provider.getComplexType(complexTypeName)).thenReturn( new CsdlComplexType().setName("complexTypeName").setProperties(complexTypeProperties)); typeWithComplexKeyProperties.add(new CsdlProperty().setName("Comp").setType(complexTypeName)); typeWithComplexKeyProvider.setProperties(typeWithComplexKeyProperties); List<CsdlPropertyRef> keyForTypeWithComplexKey = new ArrayList<CsdlPropertyRef>(); keyForTypeWithComplexKey.add(new CsdlPropertyRef().setName("Id")); keyForTypeWithComplexKey.add(new CsdlPropertyRef().setName("Comp/ComplexPropName").setAlias("alias")); typeWithComplexKeyProvider.setKey(keyForTypeWithComplexKey); when(provider.getEntityType(typeWithComplexKeyName)).thenReturn(typeWithComplexKeyProvider); typeWithComplexKey = new EdmEntityTypeImpl(edm, typeWithComplexKeyName, typeWithComplexKeyProvider); }
Example 13
Source File: EdmEntityTypeImplTest.java From olingo-odata4 with Apache License 2.0 | 4 votes |
@Test public void testAbstractBaseTypeWithoutKey() throws Exception { CsdlEdmProvider provider = mock(CsdlEdmProvider.class); EdmProviderImpl edm = new EdmProviderImpl(provider); FullQualifiedName baseName = new FullQualifiedName("namespace", "BaseTypeName"); CsdlEntityType baseType = new CsdlEntityType(); baseType.setName(baseName.getName()); List<CsdlProperty> properties = new ArrayList<CsdlProperty>(); properties.add(new CsdlProperty().setName("Id").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())); properties.add(new CsdlProperty().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())); baseType.setProperties(properties); List<CsdlNavigationProperty> navigationProperties = new ArrayList<CsdlNavigationProperty>(); navigationProperties.add(new CsdlNavigationProperty().setName("nav1")); baseType.setNavigationProperties(navigationProperties); when(provider.getEntityType(baseName)).thenReturn(baseType); baseType.setAbstract(true); EdmEntityType edmAbstarctBaseType = new EdmEntityTypeImpl(edm, baseName, baseType); assertEquals(2, edmAbstarctBaseType.getPropertyNames().size()); assertEquals("Id", edmAbstarctBaseType.getPropertyNames().get(0)); assertEquals("Name", edmAbstarctBaseType.getPropertyNames().get(1)); FullQualifiedName typeName = new FullQualifiedName("namespace", "typeName"); CsdlEntityType type = new CsdlEntityType(); type.setName(typeName.getName()); type.setBaseType(baseName); List<CsdlProperty> typeProperties = new ArrayList<CsdlProperty>(); typeProperties.add(new CsdlProperty().setName("address").setType( EdmPrimitiveTypeKind.String.getFullQualifiedName())); typeProperties.add(new CsdlProperty().setName("email").setType( EdmPrimitiveTypeKind.String.getFullQualifiedName())); type.setProperties(typeProperties); List<CsdlPropertyRef> key = new ArrayList<CsdlPropertyRef>(); key.add(new CsdlPropertyRef().setName("email")); type.setKey(key); List<CsdlNavigationProperty> typeNavigationProperties = new ArrayList<CsdlNavigationProperty>(); typeNavigationProperties.add(new CsdlNavigationProperty().setName("nav2")); type.setNavigationProperties(typeNavigationProperties); when(provider.getEntityType(typeName)).thenReturn(type); EdmEntityType edmType = new EdmEntityTypeImpl(edm, typeName, type); assertNotNull(edmType.getBaseType()); assertEquals(2, edmAbstarctBaseType.getPropertyNames().size()); assertEquals(1, edmType.getKeyPropertyRefs().size()); assertEquals("email", edmType.getKeyPredicateNames().get(0)); assertEquals(4, edmType.getPropertyNames().size()); assertEquals("Id", edmType.getPropertyNames().get(0)); assertEquals("Name", edmType.getPropertyNames().get(1)); assertEquals("address", edmType.getPropertyNames().get(2)); assertEquals("email", edmType.getPropertyNames().get(3)); assertEquals(2, edmType.getNavigationPropertyNames().size()); assertEquals("nav1", edmType.getNavigationPropertyNames().get(0)); assertEquals("nav2", edmType.getNavigationPropertyNames().get(1)); }
Example 14
Source File: EdmEntityTypeImplTest.java From olingo-odata4 with Apache License 2.0 | 4 votes |
@Test public void testAbstractBaseTypeWithtKey() throws Exception { CsdlEdmProvider provider = mock(CsdlEdmProvider.class); EdmProviderImpl edm = new EdmProviderImpl(provider); FullQualifiedName baseName = new FullQualifiedName("namespace", "BaseTypeName"); CsdlEntityType baseType = new CsdlEntityType(); baseType.setName(baseName.getName()); List<CsdlProperty> properties = new ArrayList<CsdlProperty>(); properties.add(new CsdlProperty().setName("Id").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())); properties.add(new CsdlProperty().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())); baseType.setProperties(properties); List<CsdlPropertyRef> key = new ArrayList<CsdlPropertyRef>(); key.add(new CsdlPropertyRef().setName("Id")); baseType.setKey(key); List<CsdlNavigationProperty> navigationProperties = new ArrayList<CsdlNavigationProperty>(); navigationProperties.add(new CsdlNavigationProperty().setName("nav1")); baseType.setNavigationProperties(navigationProperties); when(provider.getEntityType(baseName)).thenReturn(baseType); baseType.setAbstract(true); EdmEntityType edmAbstarctBaseType = new EdmEntityTypeImpl(edm, baseName, baseType); FullQualifiedName typeName = new FullQualifiedName("namespace", "typeName"); CsdlEntityType type = new CsdlEntityType(); type.setName(typeName.getName()); type.setBaseType(baseName); List<CsdlProperty> typeProperties = new ArrayList<CsdlProperty>(); typeProperties.add(new CsdlProperty().setName("address").setType( EdmPrimitiveTypeKind.String.getFullQualifiedName())); typeProperties.add(new CsdlProperty().setName("email").setType( EdmPrimitiveTypeKind.String.getFullQualifiedName())); type.setProperties(typeProperties); List<CsdlNavigationProperty> typeNavigationProperties = new ArrayList<CsdlNavigationProperty>(); typeNavigationProperties.add(new CsdlNavigationProperty().setName("nav2")); type.setNavigationProperties(typeNavigationProperties); when(provider.getEntityType(typeName)).thenReturn(type); EdmEntityType edmType = new EdmEntityTypeImpl(edm, typeName, type); assertNotNull(edmType.getBaseType()); assertEquals(2, edmAbstarctBaseType.getPropertyNames().size()); assertEquals(1, edmType.getKeyPropertyRefs().size()); assertEquals("Id", edmType.getKeyPredicateNames().get(0)); assertEquals(4, edmType.getPropertyNames().size()); assertEquals("Id", edmType.getPropertyNames().get(0)); assertEquals("Name", edmType.getPropertyNames().get(1)); assertEquals("address", edmType.getPropertyNames().get(2)); assertEquals("email", edmType.getPropertyNames().get(3)); assertEquals(2, edmType.getNavigationPropertyNames().size()); assertEquals("nav1", edmType.getNavigationPropertyNames().get(0)); assertEquals("nav2", edmType.getNavigationPropertyNames().get(1)); }