[OLINGO-566] Refactor EdmKeyPropertyRef class

This commit is contained in:
Christian Amend 2015-02-06 16:54:55 +01:00
parent 6c4b3ea408
commit 9cf9490310
18 changed files with 90 additions and 131 deletions

View File

@ -364,7 +364,7 @@ public abstract class AbstractUtility {
final Map<String, String> res = new LinkedHashMap<String, String>(); final Map<String, String> res = new LinkedHashMap<String, String>();
for (EdmKeyPropertyRef pref : baseType.getKeyPropertyRefs()) { for (EdmKeyPropertyRef pref : baseType.getKeyPropertyRefs()) {
res.put(pref.getKeyPropertyName(), res.put(pref.getName(),
getJavaType(pref.getProperty().getType().getFullQualifiedName().toString())); getJavaType(pref.getProperty().getType().getFullQualifiedName().toString()));
} }

View File

@ -32,7 +32,7 @@ public class EdmKeyPropertyRefImpl extends AbstractEdmKeyPropertyRef {
} }
@Override @Override
public String getKeyPropertyName() { public String getName() {
return propertyRef.getName(); return propertyRef.getName();
} }
@ -40,10 +40,4 @@ public class EdmKeyPropertyRefImpl extends AbstractEdmKeyPropertyRef {
public String getAlias() { public String getAlias() {
return propertyRef.getAlias(); return propertyRef.getAlias();
} }
@Override
public String getPath() {
throw new UnsupportedOperationException("Not supported in client code.");
}
} }

View File

@ -251,7 +251,7 @@ public class MetadataTest extends AbstractTest {
entity.getProperty("ProductId").getType()); entity.getProperty("ProductId").getType());
assertFalse(entity.getKeyPropertyRefs().isEmpty()); assertFalse(entity.getKeyPropertyRefs().isEmpty());
assertNotNull("ProductId", entity.getKeyPropertyRef("ProductId").getKeyPropertyName()); assertNotNull("ProductId", entity.getKeyPropertyRef("ProductId").getName());
} }
@Test @Test

View File

@ -24,20 +24,15 @@ package org.apache.olingo.commons.api.edm;
public interface EdmKeyPropertyRef { 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 * @return alias of this reference or null if not set
*/ */
String getAlias(); String getAlias();
/**
* @return path to the property
*/
String getPath();
/** /**
* @return the property this property ref points to * @return the property this property ref points to
*/ */

View File

@ -54,8 +54,8 @@ public abstract class AbstractEdmEntityType extends AbstractEdmStructuredType im
protected void setEdmKeyPropertyRef(final List<EdmKeyPropertyRef> edmKey) { protected void setEdmKeyPropertyRef(final List<EdmKeyPropertyRef> edmKey) {
for (EdmKeyPropertyRef ref : edmKey) { for (EdmKeyPropertyRef ref : edmKey) {
if (ref.getAlias() == null) { if (ref.getAlias() == null) {
keyPredicateNames.add(ref.getKeyPropertyName()); keyPredicateNames.add(ref.getName());
keyPropertyRefs.put(ref.getKeyPropertyName(), ref); keyPropertyRefs.put(ref.getName(), ref);
} else { } else {
keyPredicateNames.add(ref.getAlias()); keyPredicateNames.add(ref.getAlias());
keyPropertyRefs.put(ref.getAlias(), ref); keyPropertyRefs.put(ref.getAlias(), ref);

View File

@ -35,28 +35,25 @@ public abstract class AbstractEdmKeyPropertyRef implements EdmKeyPropertyRef {
} }
@Override @Override
public abstract String getKeyPropertyName(); public abstract String getName();
@Override @Override
public abstract String getAlias(); public abstract String getAlias();
@Override
public abstract String getPath();
@Override @Override
public EdmProperty getProperty() { public EdmProperty getProperty() {
if (property == null) { if (property == null) {
if (getAlias() == null) { if (getAlias() == null) {
property = edmEntityType.getStructuralProperty(getKeyPropertyName()); property = edmEntityType.getStructuralProperty(getName());
if (property == null) { if (property == null) {
throw new EdmException("Invalid key property ref specified. Can´t find property with name: " throw new EdmException("Invalid key property ref specified. Can´t find property with name: "
+ getKeyPropertyName()); + getName());
} }
} else { } else {
if (getPath() == null || getPath().isEmpty()) { if (getName() == null || getName().isEmpty()) {
throw new EdmException("Alias but no path specified for propertyRef"); throw new EdmException("Alias but no path specified for propertyRef");
} }
final String[] splitPath = getPath().split("/"); final String[] splitPath = getName().split("/");
EdmStructuredType structType = edmEntityType; EdmStructuredType structType = edmEntityType;
for (int i = 0; i < splitPath.length - 1; i++) { for (int i = 0; i < splitPath.length - 1; i++) {
final EdmProperty _property = structType.getStructuralProperty(splitPath[i]); final EdmProperty _property = structType.getStructuralProperty(splitPath[i]);

View File

@ -20,27 +20,16 @@ package org.apache.olingo.server.api.edm.provider;
public class PropertyRef { public class PropertyRef {
private String propertyName; private String name;
private String alias; 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() { public String getPropertyName() {
return propertyName; return name;
} }
public PropertyRef setPropertyName(final String name) { public PropertyRef setName(final String name) {
propertyName = name; this.name = name;
return this; return this;
} }

View File

@ -32,7 +32,7 @@ public class EdmKeyPropertyRefImpl extends AbstractEdmKeyPropertyRef {
} }
@Override @Override
public String getKeyPropertyName() { public String getName() {
return ref.getPropertyName(); return ref.getPropertyName();
} }
@ -40,9 +40,4 @@ public class EdmKeyPropertyRefImpl extends AbstractEdmKeyPropertyRef {
public String getAlias() { public String getAlias() {
return ref.getAlias(); return ref.getAlias();
} }
@Override
public String getPath() {
return ref.getPath();
}
} }

View File

@ -555,13 +555,8 @@ public class MetadataDocumentXmlSerializer {
writer.writeStartElement(XML_KEY); writer.writeStartElement(XML_KEY);
for (EdmKeyPropertyRef keyRef : keyPropertyRefs) { for (EdmKeyPropertyRef keyRef : keyPropertyRefs) {
writer.writeEmptyElement(XML_PROPERTY_REF); writer.writeEmptyElement(XML_PROPERTY_REF);
final String keyName;
if (keyRef.getPath() != null) { writer.writeAttribute(XML_NAME, keyRef.getName());
keyName = keyRef.getPath() + "/" + keyRef.getKeyPropertyName();
} else {
keyName = keyRef.getKeyPropertyName();
}
writer.writeAttribute(XML_NAME, keyName);
if (keyRef.getAlias() != null) { if (keyRef.getAlias() != null) {
writer.writeAttribute(XML_ALIAS, keyRef.getAlias()); writer.writeAttribute(XML_ALIAS, keyRef.getAlias());

View File

@ -621,7 +621,7 @@ public class UriValidator {
final List<String> keyPredicateNames = pathEntitySet.getEntityType().getKeyPredicateNames(); final List<String> keyPredicateNames = pathEntitySet.getEntityType().getKeyPredicateNames();
HashMap<String, EdmKeyPropertyRef> edmKeys = new HashMap<String, EdmKeyPropertyRef>(); HashMap<String, EdmKeyPropertyRef> edmKeys = new HashMap<String, EdmKeyPropertyRef>();
for (EdmKeyPropertyRef key : pathEntitySet.getEntityType().getKeyPropertyRefs()) { for (EdmKeyPropertyRef key : pathEntitySet.getEntityType().getKeyPropertyRefs()) {
edmKeys.put(key.getKeyPropertyName(), key); edmKeys.put(key.getName(), key);
final String alias = key.getAlias(); final String alias = key.getAlias();
if (alias != null) { if (alias != null) {
edmKeys.put(alias, key); edmKeys.put(alias, key);

View File

@ -49,7 +49,7 @@ public class EdmEntitySetImplTest {
final FullQualifiedName typeName = new FullQualifiedName("ns", "entityType"); final FullQualifiedName typeName = new FullQualifiedName("ns", "entityType");
final EntityType entityTypeProvider = new EntityType() final EntityType entityTypeProvider = new EntityType()
.setName(typeName.getName()) .setName(typeName.getName())
.setKey(Arrays.asList(new PropertyRef().setPropertyName("Id"))); .setKey(Arrays.asList(new PropertyRef().setName("Id")));
when(provider.getEntityType(typeName)).thenReturn(entityTypeProvider); when(provider.getEntityType(typeName)).thenReturn(entityTypeProvider);
final FullQualifiedName containerName = new FullQualifiedName("ns", "container"); final FullQualifiedName containerName = new FullQualifiedName("ns", "container");

View File

@ -67,7 +67,7 @@ public class EdmEntityTypeImplTest {
properties.add(new Property().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())); properties.add(new Property().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()));
baseType.setProperties(properties); baseType.setProperties(properties);
List<PropertyRef> key = new ArrayList<PropertyRef>(); List<PropertyRef> key = new ArrayList<PropertyRef>();
key.add(new PropertyRef().setPropertyName("Id")); key.add(new PropertyRef().setName("Id"));
baseType.setKey(key); baseType.setKey(key);
List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>(); List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
navigationProperties.add(new NavigationProperty().setName("nav1")); navigationProperties.add(new NavigationProperty().setName("nav1"));
@ -108,9 +108,8 @@ public class EdmEntityTypeImplTest {
typeWithComplexKeyProperties.add(new Property().setName("Comp").setType(complexTypeName)); typeWithComplexKeyProperties.add(new Property().setName("Comp").setType(complexTypeName));
typeWithComplexKeyProvider.setProperties(typeWithComplexKeyProperties); typeWithComplexKeyProvider.setProperties(typeWithComplexKeyProperties);
List<PropertyRef> keyForTypeWithComplexKey = new ArrayList<PropertyRef>(); List<PropertyRef> keyForTypeWithComplexKey = new ArrayList<PropertyRef>();
keyForTypeWithComplexKey.add(new PropertyRef().setPropertyName("Id")); keyForTypeWithComplexKey.add(new PropertyRef().setName("Id"));
keyForTypeWithComplexKey.add(new PropertyRef().setPropertyName("ComplexPropName").setAlias("alias").setPath( keyForTypeWithComplexKey.add(new PropertyRef().setName("Comp/ComplexPropName").setAlias("alias"));
"Comp/ComplexPropName"));
typeWithComplexKeyProvider.setKey(keyForTypeWithComplexKey); typeWithComplexKeyProvider.setKey(keyForTypeWithComplexKey);
when(provider.getEntityType(typeWithComplexKeyName)).thenReturn(typeWithComplexKeyProvider); when(provider.getEntityType(typeWithComplexKeyName)).thenReturn(typeWithComplexKeyProvider);
@ -149,7 +148,7 @@ public class EdmEntityTypeImplTest {
typeProperties.add(new Property().setName("email").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())); typeProperties.add(new Property().setName("email").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()));
type.setProperties(typeProperties); type.setProperties(typeProperties);
List<PropertyRef> key = new ArrayList<PropertyRef>(); List<PropertyRef> key = new ArrayList<PropertyRef>();
key.add(new PropertyRef().setPropertyName("email")); key.add(new PropertyRef().setName("email"));
type.setKey(key); type.setKey(key);
List<NavigationProperty> typeNavigationProperties = new ArrayList<NavigationProperty>(); List<NavigationProperty> typeNavigationProperties = new ArrayList<NavigationProperty>();
typeNavigationProperties.add(new NavigationProperty().setName("nav2")); typeNavigationProperties.add(new NavigationProperty().setName("nav2"));
@ -188,7 +187,7 @@ public class EdmEntityTypeImplTest {
properties.add(new Property().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName())); properties.add(new Property().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()));
baseType.setProperties(properties); baseType.setProperties(properties);
List<PropertyRef> key = new ArrayList<PropertyRef>(); List<PropertyRef> key = new ArrayList<PropertyRef>();
key.add(new PropertyRef().setPropertyName("Id")); key.add(new PropertyRef().setName("Id"));
baseType.setKey(key); baseType.setKey(key);
List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>(); List<NavigationProperty> navigationProperties = new ArrayList<NavigationProperty>();
navigationProperties.add(new NavigationProperty().setName("nav1")); navigationProperties.add(new NavigationProperty().setName("nav1"));
@ -242,7 +241,7 @@ public class EdmEntityTypeImplTest {
EdmKeyPropertyRef keyPropertyRef = typeWithComplexKey.getKeyPropertyRef("Id"); EdmKeyPropertyRef keyPropertyRef = typeWithComplexKey.getKeyPropertyRef("Id");
assertNotNull(keyPropertyRef); assertNotNull(keyPropertyRef);
assertEquals("Id", keyPropertyRef.getKeyPropertyName()); assertEquals("Id", keyPropertyRef.getName());
assertNull(keyPropertyRef.getAlias()); assertNull(keyPropertyRef.getAlias());
EdmProperty keyProperty = keyPropertyRef.getProperty(); EdmProperty keyProperty = keyPropertyRef.getProperty();
assertNotNull(keyProperty); assertNotNull(keyProperty);
@ -250,9 +249,8 @@ public class EdmEntityTypeImplTest {
keyPropertyRef = typeWithComplexKey.getKeyPropertyRef("alias"); keyPropertyRef = typeWithComplexKey.getKeyPropertyRef("alias");
assertNotNull(keyPropertyRef); assertNotNull(keyPropertyRef);
assertEquals("ComplexPropName", keyPropertyRef.getKeyPropertyName()); assertEquals("Comp/ComplexPropName", keyPropertyRef.getName());
assertEquals("alias", keyPropertyRef.getAlias()); assertEquals("alias", keyPropertyRef.getAlias());
assertEquals("Comp/ComplexPropName", keyPropertyRef.getPath());
keyProperty = keyPropertyRef.getProperty(); keyProperty = keyPropertyRef.getProperty();
assertNotNull(keyProperty); assertNotNull(keyProperty);
@ -270,7 +268,7 @@ public class EdmEntityTypeImplTest {
EdmKeyPropertyRef keyPropertyRef = baseType.getKeyPropertyRef("Id"); EdmKeyPropertyRef keyPropertyRef = baseType.getKeyPropertyRef("Id");
assertNotNull(keyPropertyRef); assertNotNull(keyPropertyRef);
assertEquals("Id", keyPropertyRef.getKeyPropertyName()); assertEquals("Id", keyPropertyRef.getName());
assertNull(keyPropertyRef.getAlias()); assertNull(keyPropertyRef.getAlias());
EdmProperty keyProperty = keyPropertyRef.getProperty(); EdmProperty keyProperty = keyPropertyRef.getProperty();
@ -280,7 +278,7 @@ public class EdmEntityTypeImplTest {
List<EdmKeyPropertyRef> keyPropertyRefs = baseType.getKeyPropertyRefs(); List<EdmKeyPropertyRef> keyPropertyRefs = baseType.getKeyPropertyRefs();
assertNotNull(keyPropertyRefs); assertNotNull(keyPropertyRefs);
assertEquals(1, keyPropertyRefs.size()); assertEquals(1, keyPropertyRefs.size());
assertEquals("Id", keyPropertyRefs.get(0).getKeyPropertyName()); assertEquals("Id", keyPropertyRefs.get(0).getName());
} }
@Test @Test
@ -291,13 +289,13 @@ public class EdmEntityTypeImplTest {
EdmKeyPropertyRef keyPropertyRef = typeWithBaseType.getKeyPropertyRef("Id"); EdmKeyPropertyRef keyPropertyRef = typeWithBaseType.getKeyPropertyRef("Id");
assertNotNull(keyPropertyRef); assertNotNull(keyPropertyRef);
assertEquals("Id", keyPropertyRef.getKeyPropertyName()); assertEquals("Id", keyPropertyRef.getName());
assertNull(keyPropertyRef.getAlias()); assertNull(keyPropertyRef.getAlias());
List<EdmKeyPropertyRef> keyPropertyRefs = typeWithBaseType.getKeyPropertyRefs(); List<EdmKeyPropertyRef> keyPropertyRefs = typeWithBaseType.getKeyPropertyRefs();
assertNotNull(keyPropertyRefs); assertNotNull(keyPropertyRefs);
assertEquals(1, keyPropertyRefs.size()); assertEquals(1, keyPropertyRefs.size());
assertEquals("Id", keyPropertyRefs.get(0).getKeyPropertyName()); assertEquals("Id", keyPropertyRefs.get(0).getName());
assertTrue(keyPropertyRefs == typeWithBaseType.getKeyPropertyRefs()); assertTrue(keyPropertyRefs == typeWithBaseType.getKeyPropertyRefs());
} }

View File

@ -38,14 +38,13 @@ public class EdmKeyPropertyRefImplTest {
@Test @Test
public void noAlias() { public void noAlias() {
PropertyRef providerRef = new PropertyRef().setPropertyName("Id"); PropertyRef providerRef = new PropertyRef().setName("Id");
EdmEntityType etMock = mock(EdmEntityType.class); EdmEntityType etMock = mock(EdmEntityType.class);
EdmProperty keyPropertyMock = mock(EdmProperty.class); EdmProperty keyPropertyMock = mock(EdmProperty.class);
when(etMock.getStructuralProperty("Id")).thenReturn(keyPropertyMock); when(etMock.getStructuralProperty("Id")).thenReturn(keyPropertyMock);
EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef); EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef);
assertEquals("Id", ref.getKeyPropertyName()); assertEquals("Id", ref.getName());
assertNull(ref.getAlias()); assertNull(ref.getAlias());
assertNull(ref.getPath());
EdmProperty property = ref.getProperty(); EdmProperty property = ref.getProperty();
assertNotNull(property); assertNotNull(property);
@ -55,7 +54,7 @@ public class EdmKeyPropertyRefImplTest {
@Test @Test
public void aliasForPropertyInComplexPropertyOneLevel() { 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); EdmEntityType etMock = mock(EdmEntityType.class);
EdmProperty keyPropertyMock = mock(EdmProperty.class); EdmProperty keyPropertyMock = mock(EdmProperty.class);
EdmProperty compMock = mock(EdmProperty.class); EdmProperty compMock = mock(EdmProperty.class);
@ -65,7 +64,6 @@ public class EdmKeyPropertyRefImplTest {
when(etMock.getStructuralProperty("comp")).thenReturn(compMock); when(etMock.getStructuralProperty("comp")).thenReturn(compMock);
EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef); EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef);
assertEquals("alias", ref.getAlias()); assertEquals("alias", ref.getAlias());
assertEquals("comp/Id", ref.getPath());
EdmProperty property = ref.getProperty(); EdmProperty property = ref.getProperty();
assertNotNull(property); assertNotNull(property);
@ -74,7 +72,7 @@ public class EdmKeyPropertyRefImplTest {
@Test(expected = EdmException.class) @Test(expected = EdmException.class)
public void aliasForPropertyInComplexPropertyButWrongPath() { 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); EdmEntityType etMock = mock(EdmEntityType.class);
EdmProperty keyPropertyMock = mock(EdmProperty.class); EdmProperty keyPropertyMock = mock(EdmProperty.class);
EdmElement compMock = mock(EdmProperty.class); EdmElement compMock = mock(EdmProperty.class);
@ -87,7 +85,7 @@ public class EdmKeyPropertyRefImplTest {
@Test(expected = EdmException.class) @Test(expected = EdmException.class)
public void aliasForPropertyInComplexPropertyButWrongPath2() { 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); EdmEntityType etMock = mock(EdmEntityType.class);
EdmProperty keyPropertyMock = mock(EdmProperty.class); EdmProperty keyPropertyMock = mock(EdmProperty.class);
EdmElement compMock = mock(EdmProperty.class); EdmElement compMock = mock(EdmProperty.class);
@ -100,7 +98,7 @@ public class EdmKeyPropertyRefImplTest {
@Test @Test
public void aliasForPropertyInComplexPropertyTwoLevels() { 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); EdmEntityType etMock = mock(EdmEntityType.class);
EdmProperty keyPropertyMock = mock(EdmProperty.class); EdmProperty keyPropertyMock = mock(EdmProperty.class);
EdmProperty compMock = mock(EdmProperty.class); EdmProperty compMock = mock(EdmProperty.class);
@ -121,21 +119,21 @@ public class EdmKeyPropertyRefImplTest {
@Test(expected = EdmException.class) @Test(expected = EdmException.class)
public void oneKeyNoAliasButInvalidProperty() { public void oneKeyNoAliasButInvalidProperty() {
PropertyRef providerRef = new PropertyRef().setPropertyName("Id"); PropertyRef providerRef = new PropertyRef().setName("Id");
EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(mock(EdmEntityType.class), providerRef); EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(mock(EdmEntityType.class), providerRef);
ref.getProperty(); ref.getProperty();
} }
@Test(expected = EdmException.class) @Test(expected = EdmException.class)
public void aliasButNoPath() { 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); EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(mock(EdmEntityType.class), providerRef);
ref.getProperty(); ref.getProperty();
} }
@Test(expected = EdmException.class) @Test(expected = EdmException.class)
public void aliasButEmptyPath() { 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); EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(mock(EdmEntityType.class), providerRef);
ref.getProperty(); ref.getProperty();
} }

View File

@ -50,7 +50,7 @@ public class EdmSingletonImplTest {
final FullQualifiedName typeName = new FullQualifiedName("ns", "entityType"); final FullQualifiedName typeName = new FullQualifiedName("ns", "entityType");
final EntityType entityTypeProvider = new EntityType() final EntityType entityTypeProvider = new EntityType()
.setName(typeName.getName()) .setName(typeName.getName())
.setKey(Arrays.asList(new PropertyRef().setPropertyName("Id"))); .setKey(Arrays.asList(new PropertyRef().setName("Id")));
when(provider.getEntityType(typeName)).thenReturn(entityTypeProvider); when(provider.getEntityType(typeName)).thenReturn(entityTypeProvider);
final FullQualifiedName containerName = new FullQualifiedName("ns", "container"); final FullQualifiedName containerName = new FullQualifiedName("ns", "container");

View File

@ -318,7 +318,7 @@ public class MetadataDocumentXmlSerializerTest {
return new EntityType() return new EntityType()
.setName("ETAbstractBase") .setName("ETAbstractBase")
.setBaseType(nameETAbstract) .setBaseType(nameETAbstract)
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties(Arrays.asList( .setProperties(Arrays.asList(
propertyInt16_NotNullable)); propertyInt16_NotNullable));
} }

View File

@ -84,7 +84,7 @@ public class EntityTypeProvider {
return new EntityType() return new EntityType()
.setName("ETAllPrim") .setName("ETAllPrim")
.setKey(Arrays.asList( .setKey(Arrays.asList(
new PropertyRef().setPropertyName("PropertyInt16"))) new PropertyRef().setName("PropertyInt16")))
.setProperties(Arrays.asList( .setProperties(Arrays.asList(
PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString, PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString,
PropertyProvider.propertyBoolean, PropertyProvider.propertyByte, PropertyProvider.propertySByte, PropertyProvider.propertyBoolean, PropertyProvider.propertyByte, PropertyProvider.propertySByte,
@ -99,7 +99,7 @@ public class EntityTypeProvider {
} else if (entityTypeName.equals(nameETCollAllPrim)) { } else if (entityTypeName.equals(nameETCollAllPrim)) {
return new EntityType() return new EntityType()
.setName("ETCollAllPrim") .setName("ETCollAllPrim")
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties( .setProperties(
Arrays.asList( Arrays.asList(
@ -120,7 +120,7 @@ public class EntityTypeProvider {
} else if (entityTypeName.equals(nameETTwoPrim)) { } else if (entityTypeName.equals(nameETTwoPrim)) {
return new EntityType() return new EntityType()
.setName("ETTwoPrim") .setName("ETTwoPrim")
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties(Arrays.asList( .setProperties(Arrays.asList(
PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString)) PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString))
.setNavigationProperties( .setNavigationProperties(
@ -130,7 +130,7 @@ public class EntityTypeProvider {
} else if (entityTypeName.equals(nameETMixPrimCollComp)) { } else if (entityTypeName.equals(nameETMixPrimCollComp)) {
return new EntityType() return new EntityType()
.setName("ETMixPrimCollComp") .setName("ETMixPrimCollComp")
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties(Arrays.asList( .setProperties(Arrays.asList(
PropertyProvider.propertyInt16_NotNullable, PropertyProvider.collPropertyString, PropertyProvider.propertyInt16_NotNullable, PropertyProvider.collPropertyString,
PropertyProvider.propertyComp_CTTwoPrim, PropertyProvider.collPropertyComp_CTTwoPrim)); PropertyProvider.propertyComp_CTTwoPrim, PropertyProvider.collPropertyComp_CTTwoPrim));
@ -139,10 +139,10 @@ public class EntityTypeProvider {
return new EntityType() return new EntityType()
.setName("ETTwoKeyTwoPrim") .setName("ETTwoKeyTwoPrim")
.setKey(Arrays.asList( .setKey(Arrays.asList(
new PropertyRef().setPropertyName("PropertyInt16"), new PropertyRef().setName("PropertyInt16"),
new PropertyRef().setPropertyName("PropertyString"))) new PropertyRef().setName("PropertyString")))
.setProperties(Arrays.asList( .setProperties(Arrays.asList(
PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString)); PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable));
} else if (entityTypeName.equals(nameETBaseTwoKeyTwoPrim)) { } else if (entityTypeName.equals(nameETBaseTwoKeyTwoPrim)) {
return new EntityType() return new EntityType()
@ -175,19 +175,19 @@ public class EntityTypeProvider {
return new EntityType() return new EntityType()
.setName("ETAllKey") .setName("ETAllKey")
.setKey(Arrays.asList( .setKey(Arrays.asList(
new PropertyRef().setPropertyName("PropertyString"), new PropertyRef().setName("PropertyString"),
new PropertyRef().setPropertyName("PropertyBoolean"), new PropertyRef().setName("PropertyBoolean"),
new PropertyRef().setPropertyName("PropertyByte"), new PropertyRef().setName("PropertyByte"),
new PropertyRef().setPropertyName("PropertySByte"), new PropertyRef().setName("PropertySByte"),
new PropertyRef().setPropertyName("PropertyInt16"), new PropertyRef().setName("PropertyInt16"),
new PropertyRef().setPropertyName("PropertyInt32"), new PropertyRef().setName("PropertyInt32"),
new PropertyRef().setPropertyName("PropertyInt64"), new PropertyRef().setName("PropertyInt64"),
new PropertyRef().setPropertyName("PropertyDecimal"), new PropertyRef().setName("PropertyDecimal"),
new PropertyRef().setPropertyName("PropertyDate"), new PropertyRef().setName("PropertyDate"),
new PropertyRef().setPropertyName("PropertyDateTimeOffset"), new PropertyRef().setName("PropertyDateTimeOffset"),
new PropertyRef().setPropertyName("PropertyDuration"), new PropertyRef().setName("PropertyDuration"),
new PropertyRef().setPropertyName("PropertyGuid"), new PropertyRef().setName("PropertyGuid"),
new PropertyRef().setPropertyName("PropertyTimeOfDay"))) new PropertyRef().setName("PropertyTimeOfDay")))
.setProperties( .setProperties(
Arrays.asList( Arrays.asList(
PropertyProvider.propertyString_NotNullable, PropertyProvider.propertyBoolean_NotNullable, PropertyProvider.propertyString_NotNullable, PropertyProvider.propertyBoolean_NotNullable,
@ -202,14 +202,14 @@ public class EntityTypeProvider {
} else if (entityTypeName.equals(nameETCompAllPrim)) { } else if (entityTypeName.equals(nameETCompAllPrim)) {
return new EntityType() return new EntityType()
.setName("ETCompAllPrim") .setName("ETCompAllPrim")
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties( .setProperties(
Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComp_CTAllPrim)); Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComp_CTAllPrim));
} else if (entityTypeName.equals(nameETCompCollAllPrim)) { } else if (entityTypeName.equals(nameETCompCollAllPrim)) {
return new EntityType() return new EntityType()
.setName("ETCompCollAllPrim") .setName("ETCompCollAllPrim")
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties( .setProperties(
Arrays.asList(PropertyProvider.propertyInt16_NotNullable, Arrays.asList(PropertyProvider.propertyInt16_NotNullable,
@ -218,14 +218,14 @@ public class EntityTypeProvider {
} else if (entityTypeName.equals(nameETCompComp)) { } else if (entityTypeName.equals(nameETCompComp)) {
return new EntityType() return new EntityType()
.setName("ETCompComp") .setName("ETCompComp")
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties( .setProperties(
Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComp_CTCompComp)); Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComp_CTCompComp));
} else if (entityTypeName.equals(nameETCompCollComp)) { } else if (entityTypeName.equals(nameETCompCollComp)) {
return new EntityType() return new EntityType()
.setName("ETCompCollComp") .setName("ETCompCollComp")
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties( .setProperties(
Arrays Arrays
.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComp_CTCompCollComp)); .asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComp_CTCompCollComp));
@ -233,7 +233,7 @@ public class EntityTypeProvider {
} else if (entityTypeName.equals(nameETMedia)) { } else if (entityTypeName.equals(nameETMedia)) {
return new EntityType() return new EntityType()
.setName("ETMedia") .setName("ETMedia")
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties(Arrays.asList(PropertyProvider.propertyInt16_NotNullable)) .setProperties(Arrays.asList(PropertyProvider.propertyInt16_NotNullable))
.setHasStream(true); .setHasStream(true);
@ -242,15 +242,15 @@ public class EntityTypeProvider {
.setName("ETKeyTwoKeyComp") .setName("ETKeyTwoKeyComp")
.setKey(Arrays.asList( .setKey(Arrays.asList(
new PropertyRef() new PropertyRef()
.setPropertyName("PropertyInt16"), .setName("PropertyInt16"),
new PropertyRef() new PropertyRef()
.setPropertyName("PropertyComp/PropertyInt16") .setName("PropertyComp/PropertyInt16")
.setAlias("KeyAlias1"), .setAlias("KeyAlias1"),
new PropertyRef() new PropertyRef()
.setPropertyName("PropertyComp/PropertyString") .setName("PropertyComp/PropertyString")
.setAlias("KeyAlias2"), .setAlias("KeyAlias2"),
new PropertyRef() new PropertyRef()
.setPropertyName("PropertyCompComp/PropertyComp/PropertyString") .setName("PropertyCompComp/PropertyComp/PropertyString")
.setAlias("KeyAlias3"))) .setAlias("KeyAlias3")))
.setProperties( .setProperties(
Arrays.asList( Arrays.asList(
@ -260,14 +260,14 @@ public class EntityTypeProvider {
} else if (entityTypeName.equals(nameETServerSidePaging)) { } else if (entityTypeName.equals(nameETServerSidePaging)) {
return new EntityType() return new EntityType()
.setName(nameETServerSidePaging.getName()) .setName(nameETServerSidePaging.getName())
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties(Arrays.asList(PropertyProvider.propertyInt16_NotNullable, .setProperties(Arrays.asList(PropertyProvider.propertyInt16_NotNullable,
PropertyProvider.propertyString_NotNullable)); PropertyProvider.propertyString_NotNullable));
} else if (entityTypeName.equals(nameETAllNullable)) { } else if (entityTypeName.equals(nameETAllNullable)) {
return new EntityType() return new EntityType()
.setName("ETAllNullable") .setName("ETAllNullable")
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyKey"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyKey")))
.setProperties( .setProperties(
Arrays.asList( Arrays.asList(
new Property() new Property()
@ -301,7 +301,7 @@ public class EntityTypeProvider {
} else if (entityTypeName.equals(nameETKeyNav)) { } else if (entityTypeName.equals(nameETKeyNav)) {
return new EntityType() return new EntityType()
.setName("ETKeyNav") .setName("ETKeyNav")
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties( .setProperties(
Arrays.asList( Arrays.asList(
PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable, PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable,
@ -324,7 +324,7 @@ public class EntityTypeProvider {
} else if (entityTypeName.equals(nameETKeyPrimNav)) { } else if (entityTypeName.equals(nameETKeyPrimNav)) {
return new EntityType() return new EntityType()
.setName("ETKeyPrimNav") .setName("ETKeyPrimNav")
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties(Arrays.asList( .setProperties(Arrays.asList(
PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_ExplicitNullable)) PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_ExplicitNullable))
.setNavigationProperties( .setNavigationProperties(
@ -335,8 +335,8 @@ public class EntityTypeProvider {
return new EntityType() return new EntityType()
.setName("ETTwoKeyNav") .setName("ETTwoKeyNav")
.setKey(Arrays.asList( .setKey(Arrays.asList(
new PropertyRef().setPropertyName("PropertyInt16"), new PropertyRef().setName("PropertyInt16"),
new PropertyRef().setPropertyName("PropertyString"))) new PropertyRef().setName("PropertyString")))
.setProperties( .setProperties(
Arrays.asList( Arrays.asList(
PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable, PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable,
@ -377,7 +377,7 @@ public class EntityTypeProvider {
return new EntityType() return new EntityType()
.setName("ETTwoBaseTwoKeyNav") .setName("ETTwoBaseTwoKeyNav")
.setBaseType(nameETBaseTwoKeyNav) .setBaseType(nameETBaseTwoKeyNav)
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties(Arrays.asList(PropertyProvider.propertyGuid_ExplicitNullable)) .setProperties(Arrays.asList(PropertyProvider.propertyGuid_ExplicitNullable))
.setNavigationProperties(Arrays.asList( .setNavigationProperties(Arrays.asList(
new NavigationProperty() new NavigationProperty()
@ -391,13 +391,11 @@ public class EntityTypeProvider {
.setName("ETFourKeyAlias") .setName("ETFourKeyAlias")
.setKey( .setKey(
Arrays.asList( Arrays.asList(
new PropertyRef().setPropertyName("PropertyInt16"), new PropertyRef().setName("PropertyInt16"),
new PropertyRef().setPath("PropertyComp/PropertyInt16").setPropertyName("PropertyInt16").setAlias( new PropertyRef().setName("PropertyComp/PropertyInt16").setAlias("KeyAlias1"),
"KeyAlias1"), new PropertyRef().setName("PropertyComp/PropertyString").setAlias("KeyAlias2"),
new PropertyRef().setPath("PropertyComp/PropertyString").setPropertyName("PropertyString") new PropertyRef().setName("PropertyCompComp/PropertyComp/PropertyString").setAlias("KeyAlias3")))
.setAlias("KeyAlias2"), .setProperties(
new PropertyRef().setPath("PropertyCompComp/PropertyComp/PropertyString").setPropertyName(
"PropertyString").setAlias("KeyAlias3"))).setProperties(
Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComp_CTTwoPrim, Arrays.asList(PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyComp_CTTwoPrim,
PropertyProvider.propertyCompComp_CTCompComp)); PropertyProvider.propertyCompComp_CTCompComp));
} else if (entityTypeName.equals(nameETCompMixPrimCollComp)) { } else if (entityTypeName.equals(nameETCompMixPrimCollComp)) {
@ -405,7 +403,7 @@ public class EntityTypeProvider {
.setName("ETCompMixPrimCollComp") .setName("ETCompMixPrimCollComp")
.setKey(Arrays.asList( .setKey(Arrays.asList(
new PropertyRef() new PropertyRef()
.setPropertyName("PropertyInt16"))) .setName("PropertyInt16")))
.setProperties( .setProperties(
Arrays.asList(PropertyProvider.propertyInt16_NotNullable, Arrays.asList(PropertyProvider.propertyInt16_NotNullable,
PropertyProvider.propertyMixedPrimCollComp_CTMixPrimCollComp)); PropertyProvider.propertyMixedPrimCollComp_CTMixPrimCollComp));
@ -419,13 +417,13 @@ public class EntityTypeProvider {
return new EntityType() return new EntityType()
.setName("ETAbstractBase") .setName("ETAbstractBase")
.setBaseType(nameETAbstract) .setBaseType(nameETAbstract)
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties(Arrays.asList( .setProperties(Arrays.asList(
PropertyProvider.propertyInt16_NotNullable)); PropertyProvider.propertyInt16_NotNullable));
} else if (entityTypeName.equals(nameETMixEnumDefCollComp)) { } else if (entityTypeName.equals(nameETMixEnumDefCollComp)) {
return new EntityType() return new EntityType()
.setName(nameETMixEnumDefCollComp.getName()) .setName(nameETMixEnumDefCollComp.getName())
.setKey(Arrays.asList(new PropertyRef().setPropertyName("PropertyInt16"))) .setKey(Arrays.asList(new PropertyRef().setName("PropertyInt16")))
.setProperties(Arrays.asList( .setProperties(Arrays.asList(
PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyInt16_NotNullable,
PropertyProvider.propertyEnumString_ENString, PropertyProvider.propertyEnumString_ENString,

View File

@ -83,7 +83,7 @@ public class EdmTechTestProvider extends EdmTechProvider {
@Override @Override
public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException { public EntityType getEntityType(final FullQualifiedName entityTypeName) throws ODataException {
List<PropertyRef> oneKeyPropertyInt16 = Arrays.asList(new PropertyRef().setPropertyName("a")); List<PropertyRef> oneKeyPropertyInt16 = Arrays.asList(new PropertyRef().setName("a"));
if (entityTypeName.equals(nameETabc)) { if (entityTypeName.equals(nameETabc)) {
return new EntityType() return new EntityType()

View File

@ -64,7 +64,7 @@ public class CarsEdmProvider extends EdmProvider {
return new EntityType() return new EntityType()
.setName(ET_CAR.getName()) .setName(ET_CAR.getName())
.setKey(Arrays.asList( .setKey(Arrays.asList(
new PropertyRef().setPropertyName("Id"))) new PropertyRef().setName("Id")))
.setProperties( .setProperties(
Arrays.asList( Arrays.asList(
new Property().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()), new Property().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()),
@ -85,7 +85,7 @@ public class CarsEdmProvider extends EdmProvider {
return new EntityType() return new EntityType()
.setName(ET_MANUFACTURER.getName()) .setName(ET_MANUFACTURER.getName())
.setKey(Arrays.asList( .setKey(Arrays.asList(
new PropertyRef().setPropertyName("Id"))) new PropertyRef().setName("Id")))
.setProperties(Arrays.asList( .setProperties(Arrays.asList(
new Property().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()), new Property().setName("Id").setType(EdmPrimitiveTypeKind.Int16.getFullQualifiedName()),
new Property().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()), new Property().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName()),