From 9cf9490310b74368f6977b15d8bde300a55af89f Mon Sep 17 00:00:00 2001 From: Christian Amend Date: Fri, 6 Feb 2015 16:54:55 +0100 Subject: [PATCH] [OLINGO-566] Refactor EdmKeyPropertyRef class --- .../olingo/ext/pojogen/AbstractUtility.java | 2 +- .../core/edm/EdmKeyPropertyRefImpl.java | 8 +- .../olingo/client/core/v3/MetadataTest.java | 2 +- .../commons/api/edm/EdmKeyPropertyRef.java | 9 +- .../core/edm/AbstractEdmEntityType.java | 4 +- .../core/edm/AbstractEdmKeyPropertyRef.java | 13 ++- .../server/api/edm/provider/PropertyRef.java | 19 +--- .../edm/provider/EdmKeyPropertyRefImpl.java | 7 +- .../xml/MetadataDocumentXmlSerializer.java | 9 +- .../core/uri/validator/UriValidator.java | 2 +- .../edm/provider/EdmEntitySetImplTest.java | 2 +- .../edm/provider/EdmEntityTypeImplTest.java | 24 +++-- .../provider/EdmKeyPropertyRefImplTest.java | 20 ++--- .../edm/provider/EdmSingletonImplTest.java | 2 +- .../MetadataDocumentXmlSerializerTest.java | 2 +- .../tecsvc/provider/EntityTypeProvider.java | 90 +++++++++---------- .../uri/testutil/EdmTechTestProvider.java | 2 +- .../sample/edmprovider/CarsEdmProvider.java | 4 +- 18 files changed, 90 insertions(+), 131 deletions(-) diff --git a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java index 57550e351..16e4402c7 100644 --- a/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java +++ b/ext/pojogen-maven-plugin/src/main/java/org/apache/olingo/ext/pojogen/AbstractUtility.java @@ -364,7 +364,7 @@ public abstract class AbstractUtility { final Map res = new LinkedHashMap(); for (EdmKeyPropertyRef pref : baseType.getKeyPropertyRefs()) { - res.put(pref.getKeyPropertyName(), + res.put(pref.getName(), getJavaType(pref.getProperty().getType().getFullQualifiedName().toString())); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmKeyPropertyRefImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmKeyPropertyRefImpl.java index a44b4c536..9dca19981 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmKeyPropertyRefImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmKeyPropertyRefImpl.java @@ -32,7 +32,7 @@ public class EdmKeyPropertyRefImpl extends AbstractEdmKeyPropertyRef { } @Override - public String getKeyPropertyName() { + public String getName() { return propertyRef.getName(); } @@ -40,10 +40,4 @@ public class EdmKeyPropertyRefImpl extends AbstractEdmKeyPropertyRef { public String getAlias() { return propertyRef.getAlias(); } - - @Override - public String getPath() { - throw new UnsupportedOperationException("Not supported in client code."); - } - } diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java index b84e11549..9bdcaef34 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java @@ -251,7 +251,7 @@ public class MetadataTest extends AbstractTest { entity.getProperty("ProductId").getType()); assertFalse(entity.getKeyPropertyRefs().isEmpty()); - assertNotNull("ProductId", entity.getKeyPropertyRef("ProductId").getKeyPropertyName()); + assertNotNull("ProductId", entity.getKeyPropertyRef("ProductId").getName()); } @Test diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmKeyPropertyRef.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmKeyPropertyRef.java index 43393a030..bcf6cb92d 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmKeyPropertyRef.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmKeyPropertyRef.java @@ -24,20 +24,15 @@ package org.apache.olingo.commons.api.edm; public interface EdmKeyPropertyRef { /** - * @return name of the key predicate + * @return name of the key predicate. Can be a path in case the alias is set. */ - String getKeyPropertyName(); + String getName(); /** * @return alias of this reference or null if not set */ String getAlias(); - /** - * @return path to the property - */ - String getPath(); - /** * @return the property this property ref points to */ diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityType.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityType.java index 469a7db1e..626304794 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityType.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityType.java @@ -54,8 +54,8 @@ public abstract class AbstractEdmEntityType extends AbstractEdmStructuredType im protected void setEdmKeyPropertyRef(final List edmKey) { for (EdmKeyPropertyRef ref : edmKey) { if (ref.getAlias() == null) { - keyPredicateNames.add(ref.getKeyPropertyName()); - keyPropertyRefs.put(ref.getKeyPropertyName(), ref); + keyPredicateNames.add(ref.getName()); + keyPropertyRefs.put(ref.getName(), ref); } else { keyPredicateNames.add(ref.getAlias()); keyPropertyRefs.put(ref.getAlias(), ref); diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmKeyPropertyRef.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmKeyPropertyRef.java index 414a7068f..05af9cb1d 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmKeyPropertyRef.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmKeyPropertyRef.java @@ -35,28 +35,25 @@ public abstract class AbstractEdmKeyPropertyRef implements EdmKeyPropertyRef { } @Override - public abstract String getKeyPropertyName(); + public abstract String getName(); @Override public abstract String getAlias(); - @Override - public abstract String getPath(); - @Override public EdmProperty getProperty() { if (property == null) { if (getAlias() == null) { - property = edmEntityType.getStructuralProperty(getKeyPropertyName()); + property = edmEntityType.getStructuralProperty(getName()); if (property == null) { throw new EdmException("Invalid key property ref specified. CanĀ“t find property with name: " - + getKeyPropertyName()); + + getName()); } } else { - if (getPath() == null || getPath().isEmpty()) { + if (getName() == null || getName().isEmpty()) { throw new EdmException("Alias but no path specified for propertyRef"); } - final String[] splitPath = getPath().split("/"); + final String[] splitPath = getName().split("/"); EdmStructuredType structType = edmEntityType; for (int i = 0; i < splitPath.length - 1; i++) { final EdmProperty _property = structType.getStructuralProperty(splitPath[i]); diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/edm/provider/PropertyRef.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/edm/provider/PropertyRef.java index 3c08e203f..3c98a426d 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/edm/provider/PropertyRef.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/edm/provider/PropertyRef.java @@ -20,27 +20,16 @@ package org.apache.olingo.server.api.edm.provider; public class PropertyRef { - private String propertyName; + private String name; private String alias; - private String path; - - public String getPath() { - return path; - } - - public PropertyRef setPath(final String path) { - this.path = path; - return this; - } - public String getPropertyName() { - return propertyName; + return name; } - public PropertyRef setPropertyName(final String name) { - propertyName = name; + public PropertyRef setName(final String name) { + this.name = name; return this; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmKeyPropertyRefImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmKeyPropertyRefImpl.java index 0660ac0af..564e74508 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmKeyPropertyRefImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmKeyPropertyRefImpl.java @@ -32,7 +32,7 @@ public class EdmKeyPropertyRefImpl extends AbstractEdmKeyPropertyRef { } @Override - public String getKeyPropertyName() { + public String getName() { return ref.getPropertyName(); } @@ -40,9 +40,4 @@ public class EdmKeyPropertyRefImpl extends AbstractEdmKeyPropertyRef { public String getAlias() { return ref.getAlias(); } - - @Override - public String getPath() { - return ref.getPath(); - } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java index 25610fbad..915115808 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializer.java @@ -555,13 +555,8 @@ public class MetadataDocumentXmlSerializer { writer.writeStartElement(XML_KEY); for (EdmKeyPropertyRef keyRef : keyPropertyRefs) { writer.writeEmptyElement(XML_PROPERTY_REF); - final String keyName; - if (keyRef.getPath() != null) { - keyName = keyRef.getPath() + "/" + keyRef.getKeyPropertyName(); - } else { - keyName = keyRef.getKeyPropertyName(); - } - writer.writeAttribute(XML_NAME, keyName); + + writer.writeAttribute(XML_NAME, keyRef.getName()); if (keyRef.getAlias() != null) { writer.writeAttribute(XML_ALIAS, keyRef.getAlias()); diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java index 5db1d112c..aa32c838a 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/validator/UriValidator.java @@ -621,7 +621,7 @@ public class UriValidator { final List keyPredicateNames = pathEntitySet.getEntityType().getKeyPredicateNames(); HashMap edmKeys = new HashMap(); for (EdmKeyPropertyRef key : pathEntitySet.getEntityType().getKeyPropertyRefs()) { - edmKeys.put(key.getKeyPropertyName(), key); + edmKeys.put(key.getName(), key); final String alias = key.getAlias(); if (alias != null) { edmKeys.put(alias, key); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntitySetImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntitySetImplTest.java index 539e48625..90563d683 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntitySetImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntitySetImplTest.java @@ -49,7 +49,7 @@ public class EdmEntitySetImplTest { final FullQualifiedName typeName = new FullQualifiedName("ns", "entityType"); final EntityType entityTypeProvider = new EntityType() .setName(typeName.getName()) - .setKey(Arrays.asList(new PropertyRef().setPropertyName("Id"))); + .setKey(Arrays.asList(new PropertyRef().setName("Id"))); when(provider.getEntityType(typeName)).thenReturn(entityTypeProvider); final FullQualifiedName containerName = new FullQualifiedName("ns", "container"); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntityTypeImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntityTypeImplTest.java index 42af891fc..46ef67de5 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntityTypeImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntityTypeImplTest.java @@ -67,7 +67,7 @@ public class EdmEntityTypeImplTest { properties.add(new Property().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())); baseType.setProperties(properties); List key = new ArrayList(); - key.add(new PropertyRef().setPropertyName("Id")); + key.add(new PropertyRef().setName("Id")); baseType.setKey(key); List navigationProperties = new ArrayList(); navigationProperties.add(new NavigationProperty().setName("nav1")); @@ -108,9 +108,8 @@ public class EdmEntityTypeImplTest { typeWithComplexKeyProperties.add(new Property().setName("Comp").setType(complexTypeName)); typeWithComplexKeyProvider.setProperties(typeWithComplexKeyProperties); List keyForTypeWithComplexKey = new ArrayList(); - keyForTypeWithComplexKey.add(new PropertyRef().setPropertyName("Id")); - keyForTypeWithComplexKey.add(new PropertyRef().setPropertyName("ComplexPropName").setAlias("alias").setPath( - "Comp/ComplexPropName")); + keyForTypeWithComplexKey.add(new PropertyRef().setName("Id")); + keyForTypeWithComplexKey.add(new PropertyRef().setName("Comp/ComplexPropName").setAlias("alias")); typeWithComplexKeyProvider.setKey(keyForTypeWithComplexKey); when(provider.getEntityType(typeWithComplexKeyName)).thenReturn(typeWithComplexKeyProvider); @@ -149,7 +148,7 @@ public class EdmEntityTypeImplTest { typeProperties.add(new Property().setName("email").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())); type.setProperties(typeProperties); List key = new ArrayList(); - key.add(new PropertyRef().setPropertyName("email")); + key.add(new PropertyRef().setName("email")); type.setKey(key); List typeNavigationProperties = new ArrayList(); typeNavigationProperties.add(new NavigationProperty().setName("nav2")); @@ -188,7 +187,7 @@ public class EdmEntityTypeImplTest { properties.add(new Property().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())); baseType.setProperties(properties); List key = new ArrayList(); - key.add(new PropertyRef().setPropertyName("Id")); + key.add(new PropertyRef().setName("Id")); baseType.setKey(key); List navigationProperties = new ArrayList(); navigationProperties.add(new NavigationProperty().setName("nav1")); @@ -242,7 +241,7 @@ public class EdmEntityTypeImplTest { EdmKeyPropertyRef keyPropertyRef = typeWithComplexKey.getKeyPropertyRef("Id"); assertNotNull(keyPropertyRef); - assertEquals("Id", keyPropertyRef.getKeyPropertyName()); + assertEquals("Id", keyPropertyRef.getName()); assertNull(keyPropertyRef.getAlias()); EdmProperty keyProperty = keyPropertyRef.getProperty(); assertNotNull(keyProperty); @@ -250,9 +249,8 @@ public class EdmEntityTypeImplTest { keyPropertyRef = typeWithComplexKey.getKeyPropertyRef("alias"); assertNotNull(keyPropertyRef); - assertEquals("ComplexPropName", keyPropertyRef.getKeyPropertyName()); + assertEquals("Comp/ComplexPropName", keyPropertyRef.getName()); assertEquals("alias", keyPropertyRef.getAlias()); - assertEquals("Comp/ComplexPropName", keyPropertyRef.getPath()); keyProperty = keyPropertyRef.getProperty(); assertNotNull(keyProperty); @@ -270,7 +268,7 @@ public class EdmEntityTypeImplTest { EdmKeyPropertyRef keyPropertyRef = baseType.getKeyPropertyRef("Id"); assertNotNull(keyPropertyRef); - assertEquals("Id", keyPropertyRef.getKeyPropertyName()); + assertEquals("Id", keyPropertyRef.getName()); assertNull(keyPropertyRef.getAlias()); EdmProperty keyProperty = keyPropertyRef.getProperty(); @@ -280,7 +278,7 @@ public class EdmEntityTypeImplTest { List keyPropertyRefs = baseType.getKeyPropertyRefs(); assertNotNull(keyPropertyRefs); assertEquals(1, keyPropertyRefs.size()); - assertEquals("Id", keyPropertyRefs.get(0).getKeyPropertyName()); + assertEquals("Id", keyPropertyRefs.get(0).getName()); } @Test @@ -291,13 +289,13 @@ public class EdmEntityTypeImplTest { EdmKeyPropertyRef keyPropertyRef = typeWithBaseType.getKeyPropertyRef("Id"); assertNotNull(keyPropertyRef); - assertEquals("Id", keyPropertyRef.getKeyPropertyName()); + assertEquals("Id", keyPropertyRef.getName()); assertNull(keyPropertyRef.getAlias()); List keyPropertyRefs = typeWithBaseType.getKeyPropertyRefs(); assertNotNull(keyPropertyRefs); assertEquals(1, keyPropertyRefs.size()); - assertEquals("Id", keyPropertyRefs.get(0).getKeyPropertyName()); + assertEquals("Id", keyPropertyRefs.get(0).getName()); assertTrue(keyPropertyRefs == typeWithBaseType.getKeyPropertyRefs()); } diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmKeyPropertyRefImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmKeyPropertyRefImplTest.java index 2bb62e944..629d272ef 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmKeyPropertyRefImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmKeyPropertyRefImplTest.java @@ -38,14 +38,13 @@ public class EdmKeyPropertyRefImplTest { @Test public void noAlias() { - PropertyRef providerRef = new PropertyRef().setPropertyName("Id"); + PropertyRef providerRef = new PropertyRef().setName("Id"); EdmEntityType etMock = mock(EdmEntityType.class); EdmProperty keyPropertyMock = mock(EdmProperty.class); when(etMock.getStructuralProperty("Id")).thenReturn(keyPropertyMock); EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef); - assertEquals("Id", ref.getKeyPropertyName()); + assertEquals("Id", ref.getName()); assertNull(ref.getAlias()); - assertNull(ref.getPath()); EdmProperty property = ref.getProperty(); assertNotNull(property); @@ -55,7 +54,7 @@ public class EdmKeyPropertyRefImplTest { @Test public void aliasForPropertyInComplexPropertyOneLevel() { - PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias").setPath("comp/Id"); + PropertyRef providerRef = new PropertyRef().setName("comp/Id").setAlias("alias"); EdmEntityType etMock = mock(EdmEntityType.class); EdmProperty keyPropertyMock = mock(EdmProperty.class); EdmProperty compMock = mock(EdmProperty.class); @@ -65,7 +64,6 @@ public class EdmKeyPropertyRefImplTest { when(etMock.getStructuralProperty("comp")).thenReturn(compMock); EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef); assertEquals("alias", ref.getAlias()); - assertEquals("comp/Id", ref.getPath()); EdmProperty property = ref.getProperty(); assertNotNull(property); @@ -74,7 +72,7 @@ public class EdmKeyPropertyRefImplTest { @Test(expected = EdmException.class) public void aliasForPropertyInComplexPropertyButWrongPath() { - PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias").setPath("comp/wrong"); + PropertyRef providerRef = new PropertyRef().setName("comp/wrong").setAlias("alias"); EdmEntityType etMock = mock(EdmEntityType.class); EdmProperty keyPropertyMock = mock(EdmProperty.class); EdmElement compMock = mock(EdmProperty.class); @@ -87,7 +85,7 @@ public class EdmKeyPropertyRefImplTest { @Test(expected = EdmException.class) public void aliasForPropertyInComplexPropertyButWrongPath2() { - PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias").setPath("wrong/Id"); + PropertyRef providerRef = new PropertyRef().setName("wrong/Id").setAlias("alias"); EdmEntityType etMock = mock(EdmEntityType.class); EdmProperty keyPropertyMock = mock(EdmProperty.class); EdmElement compMock = mock(EdmProperty.class); @@ -100,7 +98,7 @@ public class EdmKeyPropertyRefImplTest { @Test public void aliasForPropertyInComplexPropertyTwoLevels() { - PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias").setPath("comp/comp2/Id"); + PropertyRef providerRef = new PropertyRef().setName("comp/comp2/Id").setAlias("alias"); EdmEntityType etMock = mock(EdmEntityType.class); EdmProperty keyPropertyMock = mock(EdmProperty.class); EdmProperty compMock = mock(EdmProperty.class); @@ -121,21 +119,21 @@ public class EdmKeyPropertyRefImplTest { @Test(expected = EdmException.class) public void oneKeyNoAliasButInvalidProperty() { - PropertyRef providerRef = new PropertyRef().setPropertyName("Id"); + PropertyRef providerRef = new PropertyRef().setName("Id"); EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(mock(EdmEntityType.class), providerRef); ref.getProperty(); } @Test(expected = EdmException.class) public void aliasButNoPath() { - PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias"); + PropertyRef providerRef = new PropertyRef().setName("Id").setAlias("alias"); EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(mock(EdmEntityType.class), providerRef); ref.getProperty(); } @Test(expected = EdmException.class) public void aliasButEmptyPath() { - PropertyRef providerRef = new PropertyRef().setPropertyName("Id").setAlias("alias").setPath(""); + PropertyRef providerRef = new PropertyRef().setName("").setAlias("alias"); EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(mock(EdmEntityType.class), providerRef); ref.getProperty(); } diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmSingletonImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmSingletonImplTest.java index 4611d6ffc..56fa982b0 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmSingletonImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmSingletonImplTest.java @@ -50,7 +50,7 @@ public class EdmSingletonImplTest { final FullQualifiedName typeName = new FullQualifiedName("ns", "entityType"); final EntityType entityTypeProvider = new EntityType() .setName(typeName.getName()) - .setKey(Arrays.asList(new PropertyRef().setPropertyName("Id"))); + .setKey(Arrays.asList(new PropertyRef().setName("Id"))); when(provider.getEntityType(typeName)).thenReturn(entityTypeProvider); final FullQualifiedName containerName = new FullQualifiedName("ns", "container"); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java index 8b54fdf6a..a7480cb1b 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/serializer/xml/MetadataDocumentXmlSerializerTest.java @@ -318,7 +318,7 @@ public class MetadataDocumentXmlSerializerTest { return new EntityType() .setName("ETAbstractBase") .setBaseType(nameETAbstract) - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties(Arrays.asList( propertyInt16_NotNullable)); } diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EntityTypeProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EntityTypeProvider.java index 55ec15f88..b64734002 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EntityTypeProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/EntityTypeProvider.java @@ -84,7 +84,7 @@ public class EntityTypeProvider { return new EntityType() .setName("ETAllPrim") .setKey(Arrays.asList( - new PropertyRef().setPropertyName("PropertyInt16"))) + new PropertyRef().setName("PropertyInt16"))) .setProperties(Arrays.asList( PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString, PropertyProvider.propertyBoolean, PropertyProvider.propertyByte, PropertyProvider.propertySByte, @@ -99,7 +99,7 @@ public class EntityTypeProvider { } else if (entityTypeName.equals(nameETCollAllPrim)) { return new EntityType() .setName("ETCollAllPrim") - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties( Arrays.asList( @@ -120,7 +120,7 @@ public class EntityTypeProvider { } else if (entityTypeName.equals(nameETTwoPrim)) { return new EntityType() .setName("ETTwoPrim") - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties(Arrays.asList( PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString)) .setNavigationProperties( @@ -130,7 +130,7 @@ public class EntityTypeProvider { } else if (entityTypeName.equals(nameETMixPrimCollComp)) { return new EntityType() .setName("ETMixPrimCollComp") - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties(Arrays.asList( PropertyProvider.propertyInt16_NotNullable, PropertyProvider.collPropertyString, PropertyProvider.propertyComp_CTTwoPrim, PropertyProvider.collPropertyComp_CTTwoPrim)); @@ -139,10 +139,10 @@ public class EntityTypeProvider { return new EntityType() .setName("ETTwoKeyTwoPrim") .setKey(Arrays.asList( - new PropertyRef().setPropertyName("PropertyInt16"), - new PropertyRef().setPropertyName("PropertyString"))) + new PropertyRef().setName("PropertyInt16"), + new PropertyRef().setName("PropertyString"))) .setProperties(Arrays.asList( - PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString)); + PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable)); } else if (entityTypeName.equals(nameETBaseTwoKeyTwoPrim)) { return new EntityType() @@ -175,19 +175,19 @@ public class EntityTypeProvider { return new EntityType() .setName("ETAllKey") .setKey(Arrays.asList( - new PropertyRef().setPropertyName("PropertyString"), - new PropertyRef().setPropertyName("PropertyBoolean"), - new PropertyRef().setPropertyName("PropertyByte"), - new PropertyRef().setPropertyName("PropertySByte"), - new PropertyRef().setPropertyName("PropertyInt16"), - new PropertyRef().setPropertyName("PropertyInt32"), - new PropertyRef().setPropertyName("PropertyInt64"), - new PropertyRef().setPropertyName("PropertyDecimal"), - new PropertyRef().setPropertyName("PropertyDate"), - new PropertyRef().setPropertyName("PropertyDateTimeOffset"), - new PropertyRef().setPropertyName("PropertyDuration"), - new PropertyRef().setPropertyName("PropertyGuid"), - new PropertyRef().setPropertyName("PropertyTimeOfDay"))) + new PropertyRef().setName("PropertyString"), + new PropertyRef().setName("PropertyBoolean"), + new PropertyRef().setName("PropertyByte"), + new PropertyRef().setName("PropertySByte"), + new PropertyRef().setName("PropertyInt16"), + new PropertyRef().setName("PropertyInt32"), + new PropertyRef().setName("PropertyInt64"), + new PropertyRef().setName("PropertyDecimal"), + new PropertyRef().setName("PropertyDate"), + new PropertyRef().setName("PropertyDateTimeOffset"), + new PropertyRef().setName("PropertyDuration"), + new PropertyRef().setName("PropertyGuid"), + new PropertyRef().setName("PropertyTimeOfDay"))) .setProperties( Arrays.asList( PropertyProvider.propertyString_NotNullable, PropertyProvider.propertyBoolean_NotNullable, @@ -202,14 +202,14 @@ public class EntityTypeProvider { } else if (entityTypeName.equals(nameETCompAllPrim)) { return new EntityType() .setName("ETCompAllPrim") - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties( Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComp_CTAllPrim)); } else if (entityTypeName.equals(nameETCompCollAllPrim)) { return new EntityType() .setName("ETCompCollAllPrim") - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties( Arrays.asList(PropertyProvider.propertyInt16_NotNullable, @@ -218,14 +218,14 @@ public class EntityTypeProvider { } else if (entityTypeName.equals(nameETCompComp)) { return new EntityType() .setName("ETCompComp") - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties( Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComp_CTCompComp)); } else if (entityTypeName.equals(nameETCompCollComp)) { return new EntityType() .setName("ETCompCollComp") - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties( Arrays .asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComp_CTCompCollComp)); @@ -233,7 +233,7 @@ public class EntityTypeProvider { } else if (entityTypeName.equals(nameETMedia)) { return new EntityType() .setName("ETMedia") - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties(Arrays.asList(PropertyProvider.propertyInt16_NotNullable)) .setHasStream(true); @@ -242,15 +242,15 @@ public class EntityTypeProvider { .setName("ETKeyTwoKeyComp") .setKey(Arrays.asList( new PropertyRef() - .setPropertyName("PropertyInt16"), + .setName("PropertyInt16"), new PropertyRef() - .setPropertyName("PropertyComp/PropertyInt16") + .setName("PropertyComp/PropertyInt16") .setAlias("KeyAlias1"), new PropertyRef() - .setPropertyName("PropertyComp/PropertyString") + .setName("PropertyComp/PropertyString") .setAlias("KeyAlias2"), new PropertyRef() - .setPropertyName("PropertyCompComp/PropertyComp/PropertyString") + .setName("PropertyCompComp/PropertyComp/PropertyString") .setAlias("KeyAlias3"))) .setProperties( Arrays.asList( @@ -260,14 +260,14 @@ public class EntityTypeProvider { } else if (entityTypeName.equals(nameETServerSidePaging)) { return new EntityType() .setName(nameETServerSidePaging.getName()) - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties(Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable)); } else if (entityTypeName.equals(nameETAllNullable)) { return new EntityType() .setName("ETAllNullable") - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyKey"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyKey"))) .setProperties( Arrays.asList( new Property() @@ -301,7 +301,7 @@ public class EntityTypeProvider { } else if (entityTypeName.equals(nameETKeyNav)) { return new EntityType() .setName("ETKeyNav") - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties( Arrays.asList( PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable, @@ -324,7 +324,7 @@ public class EntityTypeProvider { } else if (entityTypeName.equals(nameETKeyPrimNav)) { return new EntityType() .setName("ETKeyPrimNav") - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties(Arrays.asList( PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_ExplicitNullable)) .setNavigationProperties( @@ -335,8 +335,8 @@ public class EntityTypeProvider { return new EntityType() .setName("ETTwoKeyNav") .setKey(Arrays.asList( - new PropertyRef().setPropertyName("PropertyInt16"), - new PropertyRef().setPropertyName("PropertyString"))) + new PropertyRef().setName("PropertyInt16"), + new PropertyRef().setName("PropertyString"))) .setProperties( Arrays.asList( PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable, @@ -377,7 +377,7 @@ public class EntityTypeProvider { return new EntityType() .setName("ETTwoBaseTwoKeyNav") .setBaseType(nameETBaseTwoKeyNav) - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties(Arrays.asList(PropertyProvider.propertyGuid_ExplicitNullable)) .setNavigationProperties(Arrays.asList( new NavigationProperty() @@ -391,13 +391,11 @@ public class EntityTypeProvider { .setName("ETFourKeyAlias") .setKey( Arrays.asList( - new PropertyRef().setPropertyName("PropertyInt16"), - new PropertyRef().setPath("PropertyComp/PropertyInt16").setPropertyName("PropertyInt16").setAlias( - "KeyAlias1"), - new PropertyRef().setPath("PropertyComp/PropertyString").setPropertyName("PropertyString") - .setAlias("KeyAlias2"), - new PropertyRef().setPath("PropertyCompComp/PropertyComp/PropertyString").setPropertyName( - "PropertyString").setAlias("KeyAlias3"))).setProperties( + new PropertyRef().setName("PropertyInt16"), + new PropertyRef().setName("PropertyComp/PropertyInt16").setAlias("KeyAlias1"), + new PropertyRef().setName("PropertyComp/PropertyString").setAlias("KeyAlias2"), + new PropertyRef().setName("PropertyCompComp/PropertyComp/PropertyString").setAlias("KeyAlias3"))) + .setProperties( Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComp_CTTwoPrim, PropertyProvider.propertyCompComp_CTCompComp)); } else if (entityTypeName.equals(nameETCompMixPrimCollComp)) { @@ -405,7 +403,7 @@ public class EntityTypeProvider { .setName("ETCompMixPrimCollComp") .setKey(Arrays.asList( new PropertyRef() - .setPropertyName("PropertyInt16"))) + .setName("PropertyInt16"))) .setProperties( Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyMixedPrimCollComp_CTMixPrimCollComp)); @@ -419,13 +417,13 @@ public class EntityTypeProvider { return new EntityType() .setName("ETAbstractBase") .setBaseType(nameETAbstract) - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties(Arrays.asList( PropertyProvider.propertyInt16_NotNullable)); } else if (entityTypeName.equals(nameETMixEnumDefCollComp)) { return new EntityType() .setName(nameETMixEnumDefCollComp.getName()) - .setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) + .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16"))) .setProperties(Arrays.asList( PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyEnumString_ENString, diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/EdmTechTestProvider.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/EdmTechTestProvider.java index a5d2e0f16..8b834b3f8 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/EdmTechTestProvider.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/EdmTechTestProvider.java @@ -83,7 +83,7 @@ public class EdmTechTestProvider extends EdmTechProvider { @Override public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException { - List oneKeyPropertyInt16 = Arrays.asList(new PropertyRef().setPropertyName("a")); + List oneKeyPropertyInt16 = Arrays.asList(new PropertyRef().setName("a")); if (entityTypeName.equals(nameETabc)) { return new EntityType() diff --git a/samples/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java b/samples/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java index 8f1b24848..f5ba2a27b 100644 --- a/samples/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java +++ b/samples/server/src/main/java/org/apache/olingo/server/sample/edmprovider/CarsEdmProvider.java @@ -64,7 +64,7 @@ public class CarsEdmProvider extends EdmProvider { return new EntityType() .setName(ET_CAR.getName()) .setKey(Arrays.asList( - new PropertyRef().setPropertyName("Id"))) + new PropertyRef().setName("Id"))) .setProperties( Arrays.asList( new Property().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()), @@ -85,7 +85,7 @@ public class CarsEdmProvider extends EdmProvider { return new EntityType() .setName(ET_MANUFACTURER.getName()) .setKey(Arrays.asList( - new PropertyRef().setPropertyName("Id"))) + new PropertyRef().setName("Id"))) .setProperties(Arrays.asList( new Property().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()), new Property().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),