[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 <christian.amend@sap.com>
This commit is contained in:
Jacek Sputowski 2016-03-09 11:27:02 +01:00 committed by Christian Amend
parent 7d10c60c57
commit 8406c58b7f
5 changed files with 20 additions and 41 deletions

View File

@ -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

View File

@ -18,28 +18,20 @@
*/
package org.apache.olingo.server.core.debug;
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;
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 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.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.*;
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));

View File

@ -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

View File

@ -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);

View File

@ -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;