[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:
parent
7d10c60c57
commit
8406c58b7f
|
@ -23,7 +23,6 @@ import java.util.List;
|
||||||
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
import org.apache.olingo.commons.api.edm.EdmEnumType;
|
||||||
import org.apache.olingo.commons.api.edm.EdmType;
|
import org.apache.olingo.commons.api.edm.EdmType;
|
||||||
import org.apache.olingo.server.api.ODataApplicationException;
|
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.
|
* 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 ExpressionVisitException Thrown if an exception while traversing occured
|
||||||
* @throws ODataApplicationException Thrown by the application
|
* @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
|
* Called for each traversed {@link Alias} expression
|
||||||
|
|
|
@ -18,28 +18,20 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.olingo.server.core.debug;
|
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.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
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.
|
* A custom expression visitor which converts the tree into a {@link JsonNode} tree.
|
||||||
|
@ -134,9 +126,9 @@ public class ExpressionJsonVisitor implements ExpressionVisitor<JsonNode> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonNode visitMember(final UriInfoResource member)
|
public JsonNode visitMember(final Member member)
|
||||||
throws ExpressionVisitException, ODataApplicationException {
|
throws ExpressionVisitException, ODataApplicationException {
|
||||||
final List<UriResource> uriResourceParts = member.getUriResourceParts();
|
final List<UriResource> uriResourceParts = member.getResourcePath().getUriResourceParts();
|
||||||
ObjectNode result = nodeFactory.objectNode()
|
ObjectNode result = nodeFactory.objectNode()
|
||||||
.put(NODE_TYPE_NAME, MEMBER_NAME)
|
.put(NODE_TYPE_NAME, MEMBER_NAME)
|
||||||
.put(TYPE_NAME, getType(uriResourceParts));
|
.put(TYPE_NAME, getType(uriResourceParts));
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class MemberImpl implements Member {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException {
|
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException {
|
||||||
return visitor.visitMember(path);
|
return visitor.visitMember(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -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.UriResource;
|
||||||
import org.apache.olingo.server.api.uri.UriResourceFunction;
|
import org.apache.olingo.server.api.uri.UriResourceFunction;
|
||||||
import org.apache.olingo.server.api.uri.UriResourceProperty;
|
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.*;
|
||||||
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.tecsvc.data.DataProvider;
|
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.TypedOperand;
|
||||||
import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.UntypedOperand;
|
import org.apache.olingo.server.tecsvc.processor.queryoptions.expression.operand.UntypedOperand;
|
||||||
|
@ -184,10 +178,10 @@ public class ExpressionVisitorImpl implements ExpressionVisitor<VisitorOperand>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VisitorOperand visitMember(final UriInfoResource member) throws ExpressionVisitException,
|
public VisitorOperand visitMember(final Member member) throws ExpressionVisitException,
|
||||||
ODataApplicationException {
|
ODataApplicationException {
|
||||||
|
|
||||||
final List<UriResource> uriResourceParts = member.getUriResourceParts();
|
final List<UriResource> uriResourceParts = member.getResourcePath().getUriResourceParts();
|
||||||
|
|
||||||
// UriResourceParts contains at least one UriResource.
|
// UriResourceParts contains at least one UriResource.
|
||||||
final UriResource initialPart = uriResourceParts.get(0);
|
final UriResource initialPart = uriResourceParts.get(0);
|
||||||
|
|
|
@ -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.UriResourceLambdaAny;
|
||||||
import org.apache.olingo.server.api.uri.UriResourcePartTyped;
|
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.FilterOption;
|
||||||
import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
|
import org.apache.olingo.server.api.uri.queryoption.expression.*;
|
||||||
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;
|
|
||||||
|
|
||||||
public class FilterTreeToText implements ExpressionVisitor<String> {
|
public class FilterTreeToText implements ExpressionVisitor<String> {
|
||||||
|
|
||||||
|
@ -88,10 +82,10 @@ public class FilterTreeToText implements ExpressionVisitor<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String visitMember(final UriInfoResource resource) throws ExpressionVisitException, ODataApplicationException {
|
public String visitMember(final Member member) throws ExpressionVisitException, ODataApplicationException {
|
||||||
String ret = "";
|
String ret = "";
|
||||||
|
|
||||||
for (UriResource item : resource.getUriResourceParts()) {
|
for (UriResource item : member.getResourcePath().getUriResourceParts()) {
|
||||||
String tmp = "";
|
String tmp = "";
|
||||||
if (item instanceof UriResourceLambdaAll) {
|
if (item instanceof UriResourceLambdaAll) {
|
||||||
UriResourceLambdaAll all = (UriResourceLambdaAll) item;
|
UriResourceLambdaAll all = (UriResourceLambdaAll) item;
|
||||||
|
|
Loading…
Reference in New Issue