You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/05/12 15:38:18 UTC
olingo-odata4 git commit: [OLINGO-659] Fix for filter parsing of
$count resources
Repository: olingo-odata4
Updated Branches:
refs/heads/master 04baf388e -> 7062aff86
[OLINGO-659] Fix for filter parsing of $count resources
Change-Id: I3359c25f233b6c18360a280b45355cf8ddd9a851
Signed-off-by: Christian Amend <ch...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/7062aff8
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/7062aff8
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/7062aff8
Branch: refs/heads/master
Commit: 7062aff86701571385d4283e011b7bc7c24ae7ed
Parents: 04baf38
Author: Klaus Straubinger <kl...@sap.com>
Authored: Tue May 12 15:23:00 2015 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Tue May 12 15:37:47 2015 +0200
----------------------------------------------------------------------
.../apache/olingo/server/core/uri/parser/Parser.java | 9 +++++++++
.../server/core/uri/antlr/TestFullResourcePath.java | 13 +++++++++++++
2 files changed, 22 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7062aff8/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
index cc788da..6391212 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java
@@ -36,7 +36,10 @@ import org.apache.olingo.commons.api.format.ODataFormat;
import org.apache.olingo.server.api.uri.UriInfo;
import org.apache.olingo.server.api.uri.UriInfoKind;
import org.apache.olingo.server.api.uri.UriResource;
+import org.apache.olingo.server.api.uri.UriResourceCount;
import org.apache.olingo.server.api.uri.UriResourcePartTyped;
+import org.apache.olingo.server.api.uri.UriResourceRef;
+import org.apache.olingo.server.api.uri.UriResourceValue;
import org.apache.olingo.server.api.uri.queryoption.SystemQueryOption;
import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
import org.apache.olingo.server.core.uri.UriInfoImpl;
@@ -144,6 +147,12 @@ public class Parser {
}
UriResource lastSegment = context.contextUriInfo.getLastResourcePart();
+ if (lastSegment instanceof UriResourceCount
+ || lastSegment instanceof UriResourceRef
+ || lastSegment instanceof UriResourceValue) {
+ final List<UriResource> parts = context.contextUriInfo.getUriResourceParts();
+ lastSegment = parts.get(parts.size() - 2);
+ }
if (lastSegment instanceof UriResourcePartTyped) {
UriResourcePartTyped typed = (UriResourcePartTyped) lastSegment;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/7062aff8/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
index e46bca7..989b058 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java
@@ -4756,7 +4756,20 @@ public class TestFullResourcePath {
.root().right().goPath()
.first().isComplex("PropertyCompMixedEnumDef")
.n().isComplex("PropertyEnumString").isType(EnumTypeProvider.nameENString).goUpFilterValidator();
+ }
+ @Test
+ public void filterOnCountAndRef() throws Exception {
+ testUri.run("ESKeyNav/$count", "$filter=PropertyInt16 ge 0")
+ .goPath().isCount()
+ .goUpUriValidator().goFilter().isBinary(BinaryOperatorKind.GE)
+ .left().goPath().first().isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false)
+ .goUpFilterValidator().root().right().isLiteral("0");
+ testUri.run("ESKeyNav/$ref", "$filter=PropertyInt16 ge 0")
+ .goPath().isRef()
+ .goUpUriValidator().goFilter().isBinary(BinaryOperatorKind.GE)
+ .left().goPath().first().isPrimitiveProperty("PropertyInt16", PropertyProvider.nameInt16, false)
+ .goUpFilterValidator().root().right().isLiteral("0");
}
@Test