olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject olingo-odata4 git commit: [OLINGO-756] Added expand with star support in TecSvc
Date Wed, 12 Aug 2015 16:21:54 GMT
Repository: olingo-odata4
Updated Branches:
  refs/heads/master 2ca8e0d9d -> 970086ee9


[OLINGO-756] Added expand with star support in TecSvc


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/970086ee
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/970086ee
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/970086ee

Branch: refs/heads/master
Commit: 970086ee981c9083394efb054bcbb43d8ba96d05
Parents: 2ca8e0d
Author: mibo <mibo@apache.org>
Authored: Wed Aug 12 17:50:20 2015 +0200
Committer: mibo <mibo@apache.org>
Committed: Wed Aug 12 17:50:20 2015 +0200

----------------------------------------------------------------------
 .../ExpandSystemQueryOptionHandler.java         | 34 ++++++++++++++++----
 1 file changed, 28 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/970086ee/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
index e8c3a80..21e60d4 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
@@ -18,6 +18,7 @@
  */
 package org.apache.olingo.server.tecsvc.processor.queryoptions;
 
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
@@ -27,9 +28,11 @@ import org.apache.olingo.commons.api.data.Entity;
 import org.apache.olingo.commons.api.data.EntityCollection;
 import org.apache.olingo.commons.api.data.Link;
 import org.apache.olingo.commons.api.edm.EdmBindingTarget;
+import org.apache.olingo.commons.api.edm.EdmElement;
 import org.apache.olingo.commons.api.edm.EdmEntitySet;
 import org.apache.olingo.commons.api.edm.EdmEntityType;
 import org.apache.olingo.commons.api.edm.EdmNavigationProperty;
+import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding;
 import org.apache.olingo.commons.api.http.HttpStatusCode;
 import org.apache.olingo.server.api.ODataApplicationException;
 import org.apache.olingo.server.api.uri.UriResource;
@@ -75,9 +78,27 @@ public class ExpandSystemQueryOptionHandler {
     final EdmEntityType entityType = edmBindingTarget.getEntityType();
 
     for (ExpandItem item : expandOption.getExpandItems()) {
-      final List<UriResource> uriResourceParts = item.getResourcePath().getUriResourceParts();
-      if (uriResourceParts.size() == 1 && uriResourceParts.get(0) instanceof UriResourceNavigation)
{
-        final String navPropertyName = ((UriResourceNavigation) uriResourceParts.get(0)).getProperty().getName();
+      List<EdmNavigationProperty> navigationProperties = new ArrayList<EdmNavigationProperty>();
+      if(item.isStar()) {
+        List<EdmNavigationPropertyBinding> bindings = edmBindingTarget.getNavigationPropertyBindings();
+        for (EdmNavigationPropertyBinding binding : bindings) {
+          EdmElement property = entityType.getProperty(binding.getPath());
+          if(property instanceof EdmNavigationProperty) {
+            navigationProperties.add((EdmNavigationProperty) property);
+          }
+        }
+      } else {
+        final List<UriResource> uriResourceParts = item.getResourcePath().getUriResourceParts();
+        if (uriResourceParts.size() == 1 && uriResourceParts.get(0) instanceof UriResourceNavigation)
{
+          navigationProperties.add(((UriResourceNavigation) uriResourceParts.get(0)).getProperty());
+        } else {
+          throw new ODataApplicationException("Not supported resource part in expand system
query option",
+              HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+        }
+      }
+
+      for(EdmNavigationProperty navigationProperty: navigationProperties) {
+        final String navPropertyName = navigationProperty.getName();
         final EdmBindingTarget targetEdmEntitySet = edmBindingTarget.getRelatedBindingTarget(navPropertyName);
 
         final Link link = entity.getNavigationLink(navPropertyName);
@@ -91,9 +112,6 @@ public class ExpandSystemQueryOptionHandler {
               item.getTopOption(),
               item.getExpandOption());
         }
-      } else {
-        throw new ODataApplicationException("Not supported resource part in expand system
query option",
-            HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
       }
     }
   }
@@ -238,6 +256,10 @@ public class ExpandSystemQueryOptionHandler {
 
   private ExpandOption getInnerExpandOption(final ExpandOption expand, final String propertyName)
{
     for (final ExpandItem item : expand.getExpandItems()) {
+      if(item.isStar()) {
+        return item.getExpandOption();
+      }
+
       final UriResource resource = item.getResourcePath().getUriResourceParts().get(0);
       if (resource instanceof UriResourceNavigation
           && propertyName.equals(((UriResourceNavigation) resource).getProperty().getName()))
{


Mime
View raw message