From a11cb6d65988d6602961b9e3452dde7850b6573a Mon Sep 17 00:00:00 2001 From: Christian Amend Date: Tue, 17 Nov 2015 10:36:57 +0100 Subject: [PATCH] [OLINGO-826] Add Containment EntitySet --- .../tecsvc/provider/ComplexTypeProvider.java | 9 ++-- .../tecsvc/provider/ContainerProvider.java | 39 ++++++++++++--- .../tecsvc/provider/EntityTypeProvider.java | 22 +++++++-- .../tecsvc/provider/PropertyProvider.java | 49 ++++++++++++++----- .../tecsvc/provider/SchemaProvider.java | 1 + 5 files changed, 93 insertions(+), 27 deletions(-) diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ComplexTypeProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ComplexTypeProvider.java index 7db6fcfc7..a7e10f97c 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ComplexTypeProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ComplexTypeProvider.java @@ -155,10 +155,11 @@ public class ComplexTypeProvider { .setName("CTNavCont") .setProperties(new ArrayList()) .setNavigationProperties(Arrays.asList( - PropertyProvider.collectionNavPropertyETKeyNavContMany_CT_ETKeyNav, - PropertyProvider.navPropertyETKeyNavContOne_CT_ETeyNav, - PropertyProvider.collectionNavPropertyETTwoKeyNavContMany_CT_ETKeyNav, - PropertyProvider.navPropertyETTwoKeyNavContOne_CT_ETKeyNav)); + PropertyProvider.navPropertyETKeyNavOne_CT_ETeyNav, + PropertyProvider.collectionNavPropertyETKeyNavMany_CT_ETKeyNav, + PropertyProvider.navPropertyETTwoKeyNavOne_CT_ETTwoKeyNav, + PropertyProvider.collectionNavPropertyETTwoKeyNavMany_CT_ETTwoKeyNav + )); } else if (complexTypeName.equals(nameCTBasePrimCompNav)) { return new CsdlComplexType() diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java index e9c879e6f..c9db21e0c 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/ContainerProvider.java @@ -99,6 +99,7 @@ public class ContainerProvider { entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESMixEnumDefCollComp")); entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESTwoBaseTwoKeyNav")); entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESKeyNavCont")); + entitySets.add(prov.getEntitySet(ContainerProvider.nameContainer, "ESTwoKeyNavCont")); // Singletons List singletons = new ArrayList(); @@ -524,24 +525,48 @@ public class ContainerProvider { .setType(EntityTypeProvider.nameETKeyNavCont) .setNavigationPropertyBindings(Arrays.asList( new CsdlNavigationPropertyBinding() - .setPath("NavPropertyETTwoKeyNavContOne/NavPropertyETKeyNavOne") + .setPath("NavPropertyETTwoKeyNavOne/NavPropertyETKeyNavOne") .setTarget("ESKeyNav"), new CsdlNavigationPropertyBinding() - .setPath("NavPropertyETTwoKeyNavContMany/NavPropertyETKeyNavOne") + .setPath("NavPropertyETTwoKeyNavMany/NavPropertyETKeyNavOne") .setTarget("ESKeyNav"), new CsdlNavigationPropertyBinding() - .setPath("PropertyCompNavCont/NavPropertyETKeyNavContMany/NavPropertyETKeyNavOne") + .setPath("NavPropertyETTwoKeyNavContOne") + .setTarget("ESTwoKeyNavCont"), + new CsdlNavigationPropertyBinding() + .setPath("NavPropertyETTwoKeyNavContMany") + .setTarget("ESTwoKeyNavCont"), + new CsdlNavigationPropertyBinding() + .setPath("PropertyCompNavCont/NavPropertyETKeyNavOne/NavPropertyETKeyNavOne") .setTarget("ESKeyNav"), new CsdlNavigationPropertyBinding() - .setPath("PropertyCompNavCont/NavPropertyETKeyNavContOne/NavPropertyETKeyNavOne") + .setPath("PropertyCompNavCont/NavPropertyETKeyNavMany/NavPropertyETKeyNavOne") .setTarget("ESKeyNav"), new CsdlNavigationPropertyBinding() - .setPath("PropertyCompNavCont/NavPropertyETTwoKeyNavContMany/NavPropertyETKeyNavOne") + .setPath("PropertyCompNavCont/NavPropertyETTwoKeyNavOne/NavPropertyETKeyNavOne") .setTarget("ESKeyNav"), new CsdlNavigationPropertyBinding() - .setPath("PropertyCompNavCont/NavPropertyETTwoKeyNavContOne/NavPropertyETKeyNavOne") + .setPath("PropertyCompNavCont/NavPropertyETTwoKeyNavMany/NavPropertyETKeyNavOne") .setTarget("ESKeyNav"))); - + + } else if (name.equals("ESTwoKeyNavCont")) { + return new CsdlEntitySet() + .setName("ESTwoKeyNavCont") + .setType(EntityTypeProvider.nameETTwoKeyNavCont) + .setNavigationPropertyBindings(Arrays.asList( + new CsdlNavigationPropertyBinding() + .setPath("NavPropertyETKeyNavContOne/NavPropertyETTwoKeyNavContOne") + .setTarget("ESTwoKeyNavCont"), + new CsdlNavigationPropertyBinding() + .setPath("NavPropertyETKeyNavContMany/NavPropertyETTwoKeyNavContOne") + .setTarget("ESTwoKeyNavCont"), + new CsdlNavigationPropertyBinding() + .setPath("NavPropertyETKeyNavContOne/NavPropertyETTwoKeyNavOne/NavPropertyETKeyNavOne") + .setTarget("ESKeyNav"), + new CsdlNavigationPropertyBinding() + .setPath("NavPropertyETKeyNavContMany/NavPropertyETTwoKeyNavMany/NavPropertyETKeyNavOne") + .setTarget("ESKeyNav"))); + } else if (name.equals("ESBaseTwoKeyNav")) { return new CsdlEntitySet() .setName("ESBaseTwoKeyNav") 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 1ba33c184..b8410b197 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 @@ -57,6 +57,8 @@ public class EntityTypeProvider { "ETKeyPrimNav"); public static final FullQualifiedName nameETKeyNavCont = new FullQualifiedName(SchemaProvider.NAMESPACE, "ETKeyNavCont"); + public static final FullQualifiedName nameETTwoKeyNavCont = new FullQualifiedName(SchemaProvider.NAMESPACE, + "ETTwoKeyNavCont"); public static final FullQualifiedName nameETKeyTwoKeyComp = new FullQualifiedName(SchemaProvider.NAMESPACE, "ETKeyTwoKeyComp"); public static final FullQualifiedName nameETMedia = new FullQualifiedName(SchemaProvider.NAMESPACE, "ETMedia"); @@ -339,11 +341,25 @@ public class EntityTypeProvider { PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable, PropertyProvider.propertyCompNavCont)) .setNavigationProperties(Arrays.asList( - PropertyProvider.navPropertyETTwoKeyNavContOneCT_ETTwoKeyNav, - PropertyProvider.collectionNavPropertyETTwoKeyNavContMany_CT_ETTwoKeyNav + PropertyProvider.navPropertyETTwoKeyNavOneCT_ETTwoKeyNav, + PropertyProvider.collectionNavPropertyETTwoKeyNavMany_CT_ETTwoKeyNav, + PropertyProvider.navPropertyETTwoKeyNavContOne_ETTwoKeyNav, + PropertyProvider.collectionNavPropertyETTwoKeyNavContMany_ETTwoKeyNav )); - } else if (entityTypeName.equals(nameETTwoKeyNav)) { + } else if (entityTypeName.equals(nameETTwoKeyNavCont)) { + return new CsdlEntityType() + .setName("ETTwoKeyNavCont") + .setKey(Arrays.asList( + new CsdlPropertyRef().setName("PropertyInt16"), + new CsdlPropertyRef().setName("PropertyString"))) + .setProperties(Arrays.asList( + PropertyProvider.propertyInt16_NotNullable, PropertyProvider.propertyString_NotNullable)) + .setNavigationProperties(Arrays.asList( + PropertyProvider.navPropertyETTwoKeyNavContOneCT_ETTwoKeyNav, + PropertyProvider.collectionNavPropertyETTwoKeyNavContMany_CT_ETTwoKeyNav + )); +} else if (entityTypeName.equals(nameETTwoKeyNav)) { return new CsdlEntityType() .setName("ETTwoKeyNav") .setKey(Arrays.asList( diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java index 05fb93ae8..c163d594d 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/PropertyProvider.java @@ -692,19 +692,19 @@ public class PropertyProvider { .setCollection(false) .setType(EntityTypeProvider.nameETTwoKeyNav); - public static final CsdlNavigationProperty collectionNavPropertyETKeyNavContMany_CT_ETKeyNav = + public static final CsdlNavigationProperty collectionNavPropertyETKeyNavMany_CT_ETKeyNav = new CsdlNavigationProperty() - .setName("NavPropertyETKeyNavContMany") + .setName("NavPropertyETKeyNavMany") .setCollection(true) .setContainsTarget(true) .setType(EntityTypeProvider.nameETKeyNav); - public static final CsdlNavigationProperty collectionNavPropertyETTwoKeyNavContMany_CT_ETKeyNav = - new CsdlNavigationProperty() - .setName("NavPropertyETTwoKeyNavContMany") - .setCollection(true) - .setContainsTarget(true) - .setType(EntityTypeProvider.nameETKeyNav); +// public static final CsdlNavigationProperty collectionNavPropertyETTwoKeyNavContMany_CT_ETKeyNav = +// new CsdlNavigationProperty() +// .setName("NavPropertyETTwoKeyNavContMany") +// .setCollection(true) +// .setContainsTarget(true) +// .setType(EntityTypeProvider.nameETKeyNav); public static final CsdlNavigationProperty navPropertyETKeyNavOne_ETKeyNav = new CsdlNavigationProperty() .setName("NavPropertyETKeyNavOne") @@ -737,24 +737,47 @@ public class PropertyProvider { .setName("NavPropertyETAllPrimOne") .setType(EntityTypeProvider.nameETAllPrim); - public static final CsdlNavigationProperty navPropertyETKeyNavContOne_CT_ETeyNav = new CsdlNavigationProperty() - .setName("NavPropertyETKeyNavContOne") + public static final CsdlNavigationProperty navPropertyETKeyNavOne_CT_ETeyNav = new CsdlNavigationProperty() + .setName("NavPropertyETKeyNavOne") .setContainsTarget(true) .setType(EntityTypeProvider.nameETKeyNav); - public static final CsdlNavigationProperty navPropertyETTwoKeyNavContOne_CT_ETKeyNav = new CsdlNavigationProperty() - .setName("NavPropertyETTwoKeyNavContOne") + public static final CsdlNavigationProperty navPropertyETTwoKeyNavOne_CT_ETTwoKeyNav = new CsdlNavigationProperty() + .setName("NavPropertyETTwoKeyNavOne") .setContainsTarget(true) - .setType(EntityTypeProvider.nameETKeyNav); + .setType(EntityTypeProvider.nameETTwoKeyNav); + + public static final CsdlNavigationProperty navPropertyETTwoKeyNavContOne_ETTwoKeyNav = new CsdlNavigationProperty() + .setName("NavPropertyETTwoKeyNavContOne") + .setType(EntityTypeProvider.nameETTwoKeyNav); public static final CsdlNavigationProperty navPropertyETTwoKeyNavContOneCT_ETTwoKeyNav = new CsdlNavigationProperty() .setName("NavPropertyETTwoKeyNavContOne") .setContainsTarget(true) .setType(EntityTypeProvider.nameETTwoKeyNav); + public static final CsdlNavigationProperty collectionNavPropertyETTwoKeyNavContMany_ETTwoKeyNav = + new CsdlNavigationProperty() + .setName("NavPropertyETTwoKeyNavContMany") + .setContainsTarget(false) + .setCollection(true) + .setType(EntityTypeProvider.nameETTwoKeyNav); + public static final CsdlNavigationProperty collectionNavPropertyETTwoKeyNavContMany_CT_ETTwoKeyNav = new CsdlNavigationProperty() .setName("NavPropertyETTwoKeyNavContMany") + .setContainsTarget(false) + .setCollection(true) + .setType(EntityTypeProvider.nameETTwoKeyNav); + + public static final CsdlNavigationProperty navPropertyETTwoKeyNavOneCT_ETTwoKeyNav = new CsdlNavigationProperty() + .setName("NavPropertyETTwoKeyNavOne") + .setContainsTarget(true) + .setType(EntityTypeProvider.nameETTwoKeyNav); + + public static final CsdlNavigationProperty collectionNavPropertyETTwoKeyNavMany_CT_ETTwoKeyNav = + new CsdlNavigationProperty() + .setName("NavPropertyETTwoKeyNavMany") .setContainsTarget(true) .setCollection(true) .setType(EntityTypeProvider.nameETTwoKeyNav); diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java index 5a4ee5b75..e5fe953a5 100644 --- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java +++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/provider/SchemaProvider.java @@ -79,6 +79,7 @@ public class SchemaProvider { entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETBaseTwoKeyNav)); entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETTwoBaseTwoKeyNav)); entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETKeyNavCont)); + entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETTwoKeyNavCont)); entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETCompMixPrimCollComp)); entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETKeyPrimNav)); entityTypes.add(prov.getEntityType(EntityTypeProvider.nameETAbstract));