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 2016/03/21 10:18:03 UTC
[1/3] olingo-odata4 git commit: [OLINGO-897] Cannot filter on derived
properties
Repository: olingo-odata4
Updated Branches:
refs/heads/master 7d10c60c5 -> 570f4317c
[OLINGO-897] Cannot filter on derived properties
startTypeFilter in MemberImpl is ignored. With this API change the member
is passed to the visitor an thus the starttypefilter is available.
Signed-off-by: Christian Amend <ch...@sap.com>
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/8406c58b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/8406c58b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/8406c58b
Branch: refs/heads/master
Commit: 8406c58b7f8e38a83c4735f589baa6318669c071
Parents: 7d10c60
Author: Jacek Sputowski <ja...@sollers.eu>
Authored: Wed Mar 9 11:27:02 2016 +0100
Committer: Christian Amend <ch...@sap.com>
Committed: Mon Mar 21 10:09:15 2016 +0100
----------------------------------------------------------------------
.../expression/ExpressionVisitor.java | 3 +--
.../core/debug/ExpressionJsonVisitor.java | 24 +++++++-------------
.../uri/queryoption/expression/MemberImpl.java | 2 +-
.../expression/ExpressionVisitorImpl.java | 12 +++-------
.../core/uri/testutil/FilterTreeToText.java | 12 +++-------
5 files changed, 16 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8406c58b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/ExpressionVisitor.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/ExpressionVisitor.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/ExpressionVisitor.java
index 224ddba..402db3a 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/ExpressionVisitor.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/ExpressionVisitor.java
@@ -23,7 +23,6 @@ import java.util.List;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.EdmType;
import org.apache.olingo.server.api.ODataApplicationException;
-import org.apache.olingo.server.api.uri.UriInfoResource;
/**
* Generic interface to define expression visitors with arbitrary return types.
@@ -95,7 +94,7 @@ public interface ExpressionVisitor<T> {
* @throws ExpressionVisitException Thrown if an exception while traversing occured
* @throws ODataApplicationException Thrown by the application
*/
- T visitMember(UriInfoResource member) throws ExpressionVisitException, ODataApplicationException;
+ T visitMember(Member member) throws ExpressionVisitException, ODataApplicationException;
/**
* Called for each traversed {@link Alias} expression
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8406c58b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ExpressionJsonVisitor.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ExpressionJsonVisitor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ExpressionJsonVisitor.java
index bf37973..a8b22e9 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ExpressionJsonVisitor.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ExpressionJsonVisitor.java
@@ -18,28 +18,20 @@
*/
package org.apache.olingo.server.core.debug;
-import java.util.List;
-
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.EdmType;
import org.apache.olingo.server.api.ODataApplicationException;
-import org.apache.olingo.server.api.uri.UriInfoResource;
import org.apache.olingo.server.api.uri.UriResource;
import org.apache.olingo.server.api.uri.UriResourceLambdaAll;
import org.apache.olingo.server.api.uri.UriResourceLambdaAny;
import org.apache.olingo.server.api.uri.UriResourcePartTyped;
-import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
-import org.apache.olingo.server.api.uri.queryoption.expression.Expression;
-import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
-import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor;
-import org.apache.olingo.server.api.uri.queryoption.expression.Literal;
-import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
-import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.*;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.util.List;
/**
* A custom expression visitor which converts the tree into a {@link JsonNode} tree.
@@ -134,9 +126,9 @@ public class ExpressionJsonVisitor implements ExpressionVisitor<JsonNode> {
}
@Override
- public JsonNode visitMember(final UriInfoResource member)
+ public JsonNode visitMember(final Member member)
throws ExpressionVisitException, ODataApplicationException {
- final List<UriResource> uriResourceParts = member.getUriResourceParts();
+ final List<UriResource> uriResourceParts = member.getResourcePath().getUriResourceParts();
ObjectNode result = nodeFactory.objectNode()
.put(NODE_TYPE_NAME, MEMBER_NAME)
.put(TYPE_NAME, getType(uriResourceParts));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8406c58b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java
index fe5cb87..3306565 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/expression/MemberImpl.java
@@ -52,7 +52,7 @@ public class MemberImpl implements Member {
@Override
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException {
- return visitor.visitMember(path);
+ return visitor.visitMember(this);
}
@Override
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8406c58b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
index a2ff719..3748ab8 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/expression/ExpressionVisitorImpl.java
@@ -38,13 +38,7 @@ import org.apache.olingo.server.api.uri.UriParameter;
import org.apache.olingo.server.api.uri.UriResource;
import org.apache.olingo.server.api.uri.UriResourceFunction;
import org.apache.olingo.server.api.uri.UriResourceProperty;
-import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
-import org.apache.olingo.server.api.uri.queryoption.expression.Expression;
-import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
-import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor;
-import org.apache.olingo.server.api.uri.queryoption.expression.Literal;
-import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
-import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.*;
import org.apache.olingo.server.tecsvc.data.DataProvider;
import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.TypedOperand;
import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.UntypedOperand;
@@ -184,10 +178,10 @@ public class ExpressionVisitorImpl implements ExpressionVisitor<VisitorOperand>
}
@Override
- public VisitorOperand visitMember(final UriInfoResource member) throws ExpressionVisitException,
+ public VisitorOperand visitMember(final Member member) throws ExpressionVisitException,
ODataApplicationException {
- final List<UriResource> uriResourceParts = member.getUriResourceParts();
+ final List<UriResource> uriResourceParts = member.getResourcePath().getUriResourceParts();
// UriResourceParts contains at least one UriResource.
final UriResource initialPart = uriResourceParts.get(0);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8406c58b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
----------------------------------------------------------------------
diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
index 96a3226..a083c67 100644
--- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
+++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/FilterTreeToText.java
@@ -29,13 +29,7 @@ import org.apache.olingo.server.api.uri.UriResourceLambdaAll;
import org.apache.olingo.server.api.uri.UriResourceLambdaAny;
import org.apache.olingo.server.api.uri.UriResourcePartTyped;
import org.apache.olingo.server.api.uri.queryoption.FilterOption;
-import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
-import org.apache.olingo.server.api.uri.queryoption.expression.Expression;
-import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitException;
-import org.apache.olingo.server.api.uri.queryoption.expression.ExpressionVisitor;
-import org.apache.olingo.server.api.uri.queryoption.expression.Literal;
-import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
-import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind;
+import org.apache.olingo.server.api.uri.queryoption.expression.*;
public class FilterTreeToText implements ExpressionVisitor<String> {
@@ -88,10 +82,10 @@ public class FilterTreeToText implements ExpressionVisitor<String> {
}
@Override
- public String visitMember(final UriInfoResource resource) throws ExpressionVisitException, ODataApplicationException {
+ public String visitMember(final Member member) throws ExpressionVisitException, ODataApplicationException {
String ret = "";
- for (UriResource item : resource.getUriResourceParts()) {
+ for (UriResource item : member.getResourcePath().getUriResourceParts()) {
String tmp = "";
if (item instanceof UriResourceLambdaAll) {
UriResourceLambdaAll all = (UriResourceLambdaAll) item;
[2/3] olingo-odata4 git commit: [OLINGO-904] Allow expand on
crossjoin with entity set level
Posted by ch...@apache.org.
[OLINGO-904] Allow expand on crossjoin with entity set level
Future changes still needed to support navigation/options afterwards
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/e5d1e823
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/e5d1e823
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/e5d1e823
Branch: refs/heads/master
Commit: e5d1e823c5c8a8113c17db5dfcfd3073b9d82da4
Parents: 8406c58
Author: Christian Amend <ch...@sap.com>
Authored: Fri Mar 18 14:35:06 2016 +0100
Committer: Christian Amend <ch...@sap.com>
Committed: Mon Mar 21 10:09:17 2016 +0100
----------------------------------------------------------------------
.../server/core/uri/parser/ExpandParser.java | 49 +++++++++++++++++---
.../olingo/server/core/uri/parser/Parser.java | 34 +++++++-------
.../core/uri/parser/TestFullResourcePath.java | 21 +++++++++
3 files changed, 82 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e5d1e823/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java
index 03750a5..2fc0faf 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -18,6 +18,7 @@
*/
package org.apache.olingo.server.core.uri.parser;
+import java.util.Collection;
import java.util.Map;
import org.apache.olingo.commons.api.edm.Edm;
@@ -41,6 +42,7 @@ import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind;
import org.apache.olingo.server.core.uri.UriInfoImpl;
import org.apache.olingo.server.core.uri.UriResourceComplexPropertyImpl;
import org.apache.olingo.server.core.uri.UriResourceCountImpl;
+import org.apache.olingo.server.core.uri.UriResourceEntitySetImpl;
import org.apache.olingo.server.core.uri.UriResourceNavigationPropertyImpl;
import org.apache.olingo.server.core.uri.UriResourceRefImpl;
import org.apache.olingo.server.core.uri.parser.UriTokenizer.TokenKind;
@@ -57,24 +59,58 @@ public class ExpandParser {
private final Edm edm;
private final OData odata;
private final Map<String, AliasQueryOption> aliases;
+ private final Collection<String> crossjoinEntitySetNames;
- public ExpandParser(final Edm edm, final OData odata, final Map<String, AliasQueryOption> aliases) {
+ public ExpandParser(final Edm edm, final OData odata, final Map<String, AliasQueryOption> aliases,
+ final Collection<String> crossjoinEntitySetNames) {
this.edm = edm;
this.odata = odata;
this.aliases = aliases;
+ this.crossjoinEntitySetNames = crossjoinEntitySetNames;
}
public ExpandOption parse(UriTokenizer tokenizer, final EdmStructuredType referencedType)
throws UriParserException, UriValidationException {
ExpandOptionImpl expandOption = new ExpandOptionImpl();
do {
- final ExpandItem item = parseItem(tokenizer, referencedType);
- expandOption.addExpandItem(item);
+ // In the crossjoin case the start has to be an EntitySet name which will dictate the reference type
+ if (crossjoinEntitySetNames != null && !crossjoinEntitySetNames.isEmpty()) {
+ final ExpandItem item = parseCrossJoinItem(tokenizer);
+ expandOption.addExpandItem(item);
+ } else {
+ final ExpandItem item = parseItem(tokenizer, referencedType);
+ expandOption.addExpandItem(item);
+ }
} while (tokenizer.next(TokenKind.COMMA));
return expandOption;
}
+ private ExpandItem parseCrossJoinItem(UriTokenizer tokenizer) throws UriParserSemanticException {
+ ExpandItemImpl item = new ExpandItemImpl();
+ if (tokenizer.next(TokenKind.STAR)) {
+ item.setIsStar(true);
+ } else if (tokenizer.next(TokenKind.ODataIdentifier)) {
+ String entitySetName = tokenizer.getText();
+ if (crossjoinEntitySetNames.contains(entitySetName)) {
+ UriInfoImpl resource = new UriInfoImpl().setKind(UriInfoKind.resource);
+ final UriResourceEntitySetImpl entitySetResourceSegment =
+ new UriResourceEntitySetImpl(edm.getEntityContainer().getEntitySet(entitySetName));
+ resource.addResourcePart(entitySetResourceSegment);
+
+ item.setResourcePath(resource);
+ } else {
+ throw new UriParserSemanticException("Unknown crossjoin entity set.",
+ UriParserSemanticException.MessageKeys.UNKNOWN_PART, entitySetName);
+ }
+ } else {
+ throw new UriParserSemanticException("If the target resource is a crossjoin an entity set is "
+ + "needed as the starting point.",
+ UriParserSemanticException.MessageKeys.UNKNOWN_PART);
+ }
+ return item;
+ }
+
private ExpandItem parseItem(UriTokenizer tokenizer, final EdmStructuredType referencedType)
throws UriParserException, UriValidationException {
ExpandItemImpl item = new ExpandItemImpl();
@@ -167,6 +203,7 @@ public class ExpandParser {
EdmStructuredType type = referencedType;
String name = null;
+
while (tokenizer.next(TokenKind.ODataIdentifier)) {
name = tokenizer.getText();
final EdmProperty property = referencedType.getStructuralProperty(name);
@@ -217,7 +254,7 @@ public class ExpandParser {
} else if (!forRef && !forCount && tokenizer.next(TokenKind.EXPAND)) {
ParserHelper.requireNext(tokenizer, TokenKind.EQ);
- systemQueryOption = new ExpandParser(edm, odata, aliases).parse(tokenizer, referencedType);
+ systemQueryOption = new ExpandParser(edm, odata, aliases, null).parse(tokenizer, referencedType);
} else if (tokenizer.next(TokenKind.FILTER)) {
ParserHelper.requireNext(tokenizer, TokenKind.EQ);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e5d1e823/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 e1313c1..b4469d8 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
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -98,15 +98,15 @@ public class Parser {
try {
contextUriInfo.setQueryOption(parsedOption == null ? option : parsedOption);
} catch (final ODataRuntimeException e) {
- throw new UriParserSyntaxException(
- parsedOption instanceof SystemQueryOption ?
- "Double system query option!" :
- "Alias already specified! Name: " + optionName,
- e,
- parsedOption instanceof SystemQueryOption ?
- UriParserSyntaxException.MessageKeys.DOUBLE_SYSTEM_QUERY_OPTION :
- UriParserSyntaxException.MessageKeys.DUPLICATED_ALIAS,
- optionName);
+ throw new UriParserSyntaxException(
+ parsedOption instanceof SystemQueryOption ?
+ "Double system query option!" :
+ "Alias already specified! Name: " + optionName,
+ e,
+ parsedOption instanceof SystemQueryOption ?
+ UriParserSyntaxException.MessageKeys.DOUBLE_SYSTEM_QUERY_OPTION :
+ UriParserSyntaxException.MessageKeys.DUPLICATED_ALIAS,
+ optionName);
}
}
@@ -209,7 +209,7 @@ public class Parser {
parseOrderByOption(contextUriInfo.getOrderByOption(), contextType,
contextUriInfo.getEntitySetNames(), contextUriInfo.getAliasMap());
parseExpandOption(contextUriInfo.getExpandOption(), contextType,
- !contextUriInfo.getEntitySetNames().isEmpty() || contextUriInfo.getKind() == UriInfoKind.all,
+ contextUriInfo.getKind() == UriInfoKind.all, contextUriInfo.getEntitySetNames(),
contextUriInfo.getAliasMap());
parseSelectOption(contextUriInfo.getSelectOption(), contextType, contextIsCollection);
@@ -335,16 +335,18 @@ public class Parser {
}
}
- private void parseExpandOption(ExpandOption expandOption, final EdmType contextType, final boolean isCrossjoinOrAll,
- final Map<String, AliasQueryOption> aliases) throws UriParserException, UriValidationException {
+ private void parseExpandOption(ExpandOption expandOption, final EdmType contextType, final boolean isAll,
+ final List<String> entitySetNames, final Map<String, AliasQueryOption> aliases) throws UriParserException,
+ UriValidationException {
if (expandOption != null) {
- if (!(contextType instanceof EdmStructuredType || isCrossjoinOrAll)) {
+ if (!(contextType instanceof EdmStructuredType || isAll
+ || (entitySetNames != null && !entitySetNames.isEmpty()))) {
throw new UriValidationException("Expand is only allowed on structured types!",
UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED, expandOption.getName());
}
final String optionValue = expandOption.getText();
UriTokenizer expandTokenizer = new UriTokenizer(optionValue);
- final ExpandOption option = new ExpandParser(edm, odata, aliases).parse(expandTokenizer,
+ final ExpandOption option = new ExpandParser(edm, odata, aliases, entitySetNames).parse(expandTokenizer,
contextType instanceof EdmStructuredType ? (EdmStructuredType) contextType : null);
checkOptionEOF(expandTokenizer, expandOption.getName(), optionValue);
for (final ExpandItem item : option.getExpandItems()) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/e5d1e823/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 32c56b4..64cf757 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
@@ -947,6 +947,27 @@ public class TestFullResourcePath {
}
@Test
+ public void crossjoinExpand() throws Exception {
+ testUri.run("$crossjoin(ESTwoPrim,ESAllPrim)",
+ "$expand=ESTwoPrim")
+ .goExpand()
+ .first().goPath().first().isEntitySet("ESTwoPrim");
+
+ testUri.run("$crossjoin(ESTwoPrim,ESAllPrim)",
+ "$expand=ESTwoPrim,ESAllPrim")
+ .goExpand()
+ .first().goPath().first().isEntitySet("ESTwoPrim")
+ .goUpExpandValidator().next().goPath().first().isEntitySet("ESAllPrim");
+
+ //TODO: Once crossjoin is implemented these tests should no longer result in errors
+// testUri.run("$crossjoin(ESTwoPrim,ESAllPrim)",
+// "$expand=ESAllPrim/NavPropertyETTwoPrimOne")
+// .goExpand()
+// .first().goPath().at(0).isEntitySet("ESAllPrim")
+// .at(1).isNavProperty("NavPropertyETTwoPrimOne", new FullQualifiedName("Namespace1_Alias.ETTwoPrim"), false);
+ }
+
+ @Test
public void crossjoinError() throws Exception {
testUri.runEx("$crossjoin").isExSyntax(UriParserSyntaxException.MessageKeys.SYNTAX);
testUri.runEx("$crossjoin/error").isExSyntax(UriParserSyntaxException.MessageKeys.MUST_BE_LAST_SEGMENT);
[3/3] olingo-odata4 git commit: [OLINGO-846] Trim query option values
Posted by ch...@apache.org.
[OLINGO-846] Trim query option values
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/570f4317
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/570f4317
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/570f4317
Branch: refs/heads/master
Commit: 570f4317ce857b55c3f336eae32858c88acfaf8e
Parents: e5d1e82
Author: Christian Amend <ch...@sap.com>
Authored: Fri Mar 18 14:59:00 2016 +0100
Committer: Christian Amend <ch...@sap.com>
Committed: Mon Mar 21 10:09:20 2016 +0100
----------------------------------------------------------------------
.../olingo/server/core/uri/parser/UriDecoder.java | 3 ++-
.../server/core/uri/parser/TestFullResourcePath.java | 15 +++++++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/570f4317/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java
index 1cc5ec5..4a94e85 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriDecoder.java
@@ -48,7 +48,8 @@ public class UriDecoder {
for (final String option : split(queryOptionString, '&')) {
final int pos = option.indexOf('=');
final String name = pos >= 0 ? option.substring(0, pos) : option;
- final String text = pos >= 0 ? option.substring(pos + 1) : "";
+ //OLINGO-846 We trim the query option text to be more lenient to wrong uri constructors
+ final String text = pos >= 0 ? option.substring(pos + 1).trim() : "";
queryOptions.add(new CustomQueryOptionImpl()
.setName(decode(name))
.setText(decode(text)));
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/570f4317/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 64cf757..e3c798d 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
@@ -58,6 +58,17 @@ public class TestFullResourcePath {
private final FilterValidator testFilter = new FilterValidator().setEdm(edm);
@Test
+ public void trimQueryOptionsValue() throws Exception {
+ // OLINGO-846 trim query option value
+ testUri.run("ESAllPrim", "$filter= PropertyInt16 eq 12 ")
+ .isKind(UriInfoKind.resource).goPath()
+ .first().isEntitySet("ESAllPrim");
+ // OLINGO-846 trim query option value
+ testUri.run("ESAllPrim", "$filter= PropertyInt16 eq 12 ")
+ .isKind(UriInfoKind.resource).goFilter().isBinary(BinaryOperatorKind.EQ).is("<<PropertyInt16> eq <12>>");
+ }
+
+ @Test
public void valueOnNonMediaEntity() throws Exception {
testUri.runEx("ESAllPrim/$value").isExSemantic(UriParserSemanticException.MessageKeys.ONLY_FOR_TYPED_PARTS);
testUri.runEx("ESAllPrim(1)/NavPropertyETTwoPrimMany/$value").isExSemantic(
@@ -952,14 +963,14 @@ public class TestFullResourcePath {
"$expand=ESTwoPrim")
.goExpand()
.first().goPath().first().isEntitySet("ESTwoPrim");
-
+
testUri.run("$crossjoin(ESTwoPrim,ESAllPrim)",
"$expand=ESTwoPrim,ESAllPrim")
.goExpand()
.first().goPath().first().isEntitySet("ESTwoPrim")
.goUpExpandValidator().next().goPath().first().isEntitySet("ESAllPrim");
- //TODO: Once crossjoin is implemented these tests should no longer result in errors
+ // TODO: Once crossjoin is implemented these tests should no longer result in errors
// testUri.run("$crossjoin(ESTwoPrim,ESAllPrim)",
// "$expand=ESAllPrim/NavPropertyETTwoPrimOne")
// .goExpand()