Repository: olingo-odata4 Updated Branches: refs/heads/master 5dee97f76 -> f7c18f744
[OLINGO-905] Add system query option access to $all Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/f7c18f74 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/f7c18f74 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/f7c18f74 Branch: refs/heads/master Commit: f7c18f7445e1f205553a93da39ccf4df76f62735 Parents: 5dee97f Author: Christian Amend <[email protected]> Authored: Thu Mar 24 14:50:08 2016 +0100 Committer: Christian Amend <[email protected]> Committed: Thu Mar 24 14:50:08 2016 +0100 ---------------------------------------------------------------------- .../olingo/server/api/uri/UriInfoAll.java | 46 +++++++++++++++++++- .../olingo/server/api/uri/UriInfoCrossjoin.java | 6 +++ .../core/uri/parser/TestFullResourcePath.java | 34 ++++++++++++++- .../core/uri/testutil/TestUriValidator.java | 4 ++ 4 files changed, 88 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7c18f74/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoAll.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoAll.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoAll.java index b249b67..cc63abd 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoAll.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoAll.java @@ -18,10 +18,54 @@ */ package org.apache.olingo.server.api.uri; +import java.util.List; + +import org.apache.olingo.server.api.uri.queryoption.CountOption; +import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption; +import org.apache.olingo.server.api.uri.queryoption.FormatOption; +import org.apache.olingo.server.api.uri.queryoption.SearchOption; +import org.apache.olingo.server.api.uri.queryoption.SkipOption; +import org.apache.olingo.server.api.uri.queryoption.SkipTokenOption; +import org.apache.olingo.server.api.uri.queryoption.TopOption; + /** * Used for URI info kind {@link UriInfoKind#all} to describe URIs like * http://.../serviceroot/$all */ public interface UriInfoAll { - // No additional methods needed for now. + + /** + * @return List of custom query options used in the URI (without alias definitions) + */ + List<CustomQueryOption> getCustomQueryOptions(); + + /** + * @return Object containing information of the $format option + */ + FormatOption getFormatOption(); + + /** + * @return Object containing information of the $count option + */ + CountOption getCountOption(); + + /** + * @return Object containing information of the $search option + */ + SearchOption getSearchOption(); + + /** + * @return Object containing information of the $skip option + */ + SkipOption getSkipOption(); + + /** + * @return Object containing information of the $skiptoken option + */ + SkipTokenOption getSkipTokenOption(); + + /** + * @return Object containing information of the $top option + */ + TopOption getTopOption(); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7c18f74/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoCrossjoin.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoCrossjoin.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoCrossjoin.java index 657c120..8fdba84 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoCrossjoin.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoCrossjoin.java @@ -25,6 +25,7 @@ import org.apache.olingo.server.api.uri.queryoption.ExpandOption; import org.apache.olingo.server.api.uri.queryoption.FilterOption; import org.apache.olingo.server.api.uri.queryoption.FormatOption; import org.apache.olingo.server.api.uri.queryoption.OrderByOption; +import org.apache.olingo.server.api.uri.queryoption.SearchOption; import org.apache.olingo.server.api.uri.queryoption.SelectOption; import org.apache.olingo.server.api.uri.queryoption.SkipOption; import org.apache.olingo.server.api.uri.queryoption.SkipTokenOption; @@ -65,6 +66,11 @@ public interface UriInfoCrossjoin { * @return Object containing information of the $orderby option */ OrderByOption getOrderByOption(); + + /** + * @return Object containing information of the $search option + */ + SearchOption getSearchOption(); /** * @return Object containing information of the $select option http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7c18f74/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java index e3c798d..2596f5c 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java @@ -18,6 +18,8 @@ */ package org.apache.olingo.server.core.uri.parser; +import static org.junit.Assert.assertNotNull; + import java.util.Arrays; import java.util.Collections; @@ -27,12 +29,13 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.server.api.OData; import org.apache.olingo.server.api.edmx.EdmxReference; +import org.apache.olingo.server.api.uri.UriInfoAll; +import org.apache.olingo.server.api.uri.UriInfoCrossjoin; import org.apache.olingo.server.api.uri.UriInfoKind; import org.apache.olingo.server.api.uri.UriResourceKind; import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind; import org.apache.olingo.server.core.uri.parser.UriParserSemanticException.MessageKeys; -import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException; import org.apache.olingo.server.core.uri.parser.search.SearchParserException; import org.apache.olingo.server.core.uri.testutil.FilterValidator; import org.apache.olingo.server.core.uri.testutil.TestUriValidator; @@ -58,6 +61,35 @@ public class TestFullResourcePath { private final FilterValidator testFilter = new FilterValidator().setEdm(edm); @Test + public void allowedSystemQueryOptionsOnAll() throws Exception { + UriInfoAll uriInfoAll = testUri.run("$all", "$count=true&$format=json&$search=abc&$skip=5&$top=5&$skiptoken=abc") + .getUriInfoRoot().asUriInfoAll(); + assertNotNull(uriInfoAll.getCountOption()); + assertNotNull(uriInfoAll.getFormatOption()); + assertNotNull(uriInfoAll.getSearchOption()); + assertNotNull(uriInfoAll.getSkipOption()); + assertNotNull(uriInfoAll.getTopOption()); + assertNotNull(uriInfoAll.getSkipTokenOption()); + } + + @Test + public void allowedSystemQueryOptionsOnCrossjoin() throws Exception { + UriInfoCrossjoin uriInfoCrossjoin = + testUri.run("$crossjoin(ESAllPrim,ESTwoPrim)", "$count=true&$expand=ESAllPrim" + + "&$filter=ESAllPrim/PropertyInt16 eq 2&$format=json&$orderby=ESAllPrim/PropertyInt16" + + "&$search=abc&$skip=5&$top=5&$skiptoken=abc").getUriInfoRoot().asUriInfoCrossjoin(); + assertNotNull(uriInfoCrossjoin.getCountOption()); + assertNotNull(uriInfoCrossjoin.getExpandOption()); + assertNotNull(uriInfoCrossjoin.getFilterOption()); + assertNotNull(uriInfoCrossjoin.getFormatOption()); + assertNotNull(uriInfoCrossjoin.getOrderByOption()); + assertNotNull(uriInfoCrossjoin.getSearchOption()); + assertNotNull(uriInfoCrossjoin.getSkipOption()); + assertNotNull(uriInfoCrossjoin.getTopOption()); + assertNotNull(uriInfoCrossjoin.getSkipTokenOption()); + } + + @Test public void trimQueryOptionsValue() throws Exception { // OLINGO-846 trim query option value testUri.run("ESAllPrim", "$filter= PropertyInt16 eq 12 ") http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7c18f74/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java ---------------------------------------------------------------------- diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java index fbce5c9..bee3401 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java @@ -238,4 +238,8 @@ public class TestUriValidator implements TestValidator { assertEquals(fullName, uriInfo.getEntityTypeCast().getFullQualifiedName()); return this; } + + public UriInfo getUriInfoRoot() { + return uriInfo; + } }
