Merge from origin/master
This commit is contained in:
commit
05b49fbcfc
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* 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
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.server.api.uri.optiontree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.odata4.server.api.uri.UriResourceProperty;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.FilterOption;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.InlineCountOption;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.OrderByOption;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.SearchOption;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.SkipOption;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.TopOption;
|
||||
|
||||
/**
|
||||
* Contains the merged $expand and $select options
|
||||
*/
|
||||
public interface OptionNode {
|
||||
|
||||
/**
|
||||
* Contains the list of non navigation properties which should serialized at this expand level.
|
||||
*/
|
||||
List<UriResourceProperty> getPropertyChainList();
|
||||
|
||||
List<OptionProperty> getExpandetNavigationProperties();
|
||||
|
||||
/**
|
||||
* Contains the filter which should be applied to this expand level.
|
||||
*/
|
||||
FilterOption getFilter();
|
||||
|
||||
/**
|
||||
* Contains the search information which should be applied to this expand level.
|
||||
*/
|
||||
SearchOption getSearch();
|
||||
|
||||
/**
|
||||
* Contains the orderBy information which should be applied to this expand level.
|
||||
*/
|
||||
OrderByOption getOrderBy();
|
||||
|
||||
/**
|
||||
* Contains the information about how many output entities should be skipped at this
|
||||
* expand level.
|
||||
*/
|
||||
SkipOption getSkip();
|
||||
|
||||
/**
|
||||
* Contains the information about how many output items should be serialized at this
|
||||
* expand level.
|
||||
*/
|
||||
TopOption getTop();
|
||||
|
||||
/**
|
||||
* Contains the information whether the number of output items should be serialized
|
||||
* at this expand level
|
||||
*/
|
||||
InlineCountOption getInlineCount();
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* 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
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.server.api.uri.optiontree;
|
||||
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
|
||||
|
||||
public interface OptionProperty {
|
||||
EdmNavigationProperty getNavigationProperty();
|
||||
|
||||
OptionNode getOptionNode();
|
||||
}
|
|
@ -20,6 +20,6 @@ package org.apache.olingo.odata4.server.api.uri.queryoption;
|
|||
|
||||
public interface FormatOption extends SystemQueryOption {
|
||||
|
||||
// TODO Select best representation for format
|
||||
// TODO planned: define best representation for format
|
||||
String getFormat();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,6 @@ public interface LevelsExpandOption {
|
|||
|
||||
boolean isMax();
|
||||
|
||||
int getLevel();
|
||||
int getValue();
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.olingo.odata4.server.api.uri.queryoption.expression;
|
|||
|
||||
public interface BinaryExpression extends Expression {
|
||||
|
||||
public SupportedBinaryOperators getOperator();
|
||||
public BinaryOperatorKind getOperator();
|
||||
|
||||
public Expression getLeftOperand();
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.server.api.uri.queryoption.expression;
|
||||
|
||||
public enum SupportedBinaryOperators {
|
||||
|
||||
public enum BinaryOperatorKind {
|
||||
|
||||
// enum
|
||||
HAS("has"),
|
||||
|
@ -35,12 +36,12 @@ public enum SupportedBinaryOperators {
|
|||
|
||||
private String syntax;
|
||||
|
||||
private SupportedBinaryOperators(final String syntax) {
|
||||
private BinaryOperatorKind(final String syntax) {
|
||||
this.syntax = syntax;
|
||||
}
|
||||
|
||||
public static SupportedBinaryOperators get(final String operator) {
|
||||
for (SupportedBinaryOperators op : SupportedBinaryOperators.values()) {
|
||||
public static BinaryOperatorKind get(final String operator) {
|
||||
for (BinaryOperatorKind op : BinaryOperatorKind.values()) {
|
||||
if (op.toString().equals(operator)) {
|
||||
return op;
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* 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
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.server.api.uri.queryoption.expression;
|
||||
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmType;
|
||||
|
||||
public interface Constant extends Expression {
|
||||
|
||||
public boolean isNull();
|
||||
|
||||
public boolean isTrue();
|
||||
|
||||
public boolean isFalse();
|
||||
|
||||
public SupportedConstants getKind();
|
||||
|
||||
public EdmType getType();
|
||||
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.server.api.uri.queryoption.expression;
|
||||
|
||||
public class ExceptionVisitExpression extends Exception {
|
||||
public class ExpressionVisitException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -27,30 +27,31 @@ import org.apache.olingo.odata4.server.api.uri.UriInfoResource;
|
|||
|
||||
public interface ExpressionVisitor<T> {
|
||||
|
||||
T visitBinaryOperator(SupportedBinaryOperators operator, T left, T right)
|
||||
throws ExceptionVisitExpression, ODataApplicationException;
|
||||
T visitBinaryOperator(BinaryOperatorKind operator, T left, T right)
|
||||
throws ExpressionVisitException, ODataApplicationException;
|
||||
|
||||
T visitUnaryOperator(SupportedUnaryOperators operator, T operand)
|
||||
throws ExceptionVisitExpression, ODataApplicationException;
|
||||
T visitUnaryOperator(UnaryOperatorKind operator, T operand)
|
||||
throws ExpressionVisitException, ODataApplicationException;
|
||||
|
||||
|
||||
T visitMethodCall(MethodCallKind methodCall, List<T> parameters)
|
||||
throws ExpressionVisitException, ODataApplicationException;
|
||||
|
||||
T visitMethodCall(SupportedMethodCalls methodCall, List<T> parameters)
|
||||
throws ExceptionVisitExpression, ODataApplicationException;
|
||||
|
||||
T visitLambdaExpression(String functionText, String variableText, Expression expression)
|
||||
throws ExceptionVisitExpression, ODataApplicationException;
|
||||
throws ExpressionVisitException, ODataApplicationException;
|
||||
|
||||
T visitLiteral(String literal) throws ExceptionVisitExpression, ODataApplicationException;
|
||||
T visitLiteral(String literal) throws ExpressionVisitException, ODataApplicationException;
|
||||
|
||||
T visitMember(UriInfoResource member) throws ExceptionVisitExpression, ODataApplicationException;
|
||||
T visitMember(UriInfoResource member) throws ExpressionVisitException, ODataApplicationException;
|
||||
|
||||
T visitAlias(String referenceName) throws ExceptionVisitExpression, ODataApplicationException;
|
||||
T visitAlias(String referenceName) throws ExpressionVisitException, ODataApplicationException;
|
||||
|
||||
T visitTypeLiteral(EdmType type) throws ExceptionVisitExpression, ODataApplicationException;
|
||||
T visitTypeLiteral(EdmType type) throws ExpressionVisitException, ODataApplicationException;
|
||||
|
||||
T visitLambdaReference(String variableText) throws ExceptionVisitExpression, ODataApplicationException;
|
||||
T visitLambdaReference(String variableText) throws ExpressionVisitException, ODataApplicationException;
|
||||
|
||||
T visitEnum(EdmEnumType type, List<String> enumValues) throws ExceptionVisitExpression, ODataApplicationException;
|
||||
T visitEnum(EdmEnumType type, List<String> enumValues) throws ExpressionVisitException, ODataApplicationException;
|
||||
|
||||
T visitConstant(SupportedConstants kind) throws ExceptionVisitExpression, ODataApplicationException;
|
||||
|
||||
}
|
||||
|
|
|
@ -18,8 +18,12 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.server.api.uri.queryoption.expression;
|
||||
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmType;
|
||||
|
||||
public interface Literal extends Expression {
|
||||
|
||||
public String getText();
|
||||
|
||||
public EdmType getType();
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
|||
|
||||
public interface MethodCall extends Expression {
|
||||
|
||||
public SupportedMethodCalls getMethod();
|
||||
public MethodCallKind getMethod();
|
||||
|
||||
public List<Expression> getParameters();
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.server.api.uri.queryoption.expression;
|
||||
|
||||
public enum SupportedMethodCalls {
|
||||
public enum MethodCallKind {
|
||||
CONTAINS("contains"), STARTSWITH("startswith"), ENDSWITH("endswith"), LENGTH("length"),
|
||||
INDEXOF("indexof"), SUBSTRING("substring"), TOLOWER("tolower"), TOUPPER("toupper"), TRIM("trim"),
|
||||
CONCAT("concat"),
|
||||
|
@ -35,7 +35,7 @@ public enum SupportedMethodCalls {
|
|||
|
||||
private String syntax;
|
||||
|
||||
private SupportedMethodCalls(final String syntax) {
|
||||
private MethodCallKind(final String syntax) {
|
||||
this.syntax = syntax;
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,10 @@ public enum SupportedMethodCalls {
|
|||
return syntax;
|
||||
}
|
||||
|
||||
public static SupportedMethodCalls get(final String method) {
|
||||
for (SupportedMethodCalls op : SupportedMethodCalls.values()) {
|
||||
|
||||
public static MethodCallKind get(final String method) {
|
||||
for (MethodCallKind op : MethodCallKind.values()) {
|
||||
|
||||
if (op.toString().equals(method)) {
|
||||
return op;
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* 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
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.server.api.uri.queryoption.expression;
|
||||
|
||||
public enum SupportedConstants {
|
||||
|
||||
TRUE("true"),
|
||||
FALSE("false"),
|
||||
NULL("null");
|
||||
|
||||
private String syntax;
|
||||
|
||||
private SupportedConstants(final String syntax) {
|
||||
this.syntax = syntax;
|
||||
}
|
||||
|
||||
public static SupportedConstants get(final String operator) {
|
||||
for (SupportedConstants op : SupportedConstants.values()) {
|
||||
if (op.toString().equals(operator)) {
|
||||
return op;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return syntax;
|
||||
}
|
||||
|
||||
}
|
|
@ -22,6 +22,6 @@ public interface UnaryOperator extends Expression {
|
|||
|
||||
public Expression getOperand();
|
||||
|
||||
public SupportedUnaryOperators getOperator();
|
||||
public UnaryOperatorKind getOperator();
|
||||
|
||||
}
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.server.api.uri.queryoption.expression;
|
||||
|
||||
public enum SupportedUnaryOperators {
|
||||
public enum UnaryOperatorKind {
|
||||
MINUS("-"), NOT("not");
|
||||
|
||||
private String syntax;
|
||||
|
||||
private SupportedUnaryOperators(final String syntax) {
|
||||
private UnaryOperatorKind(final String syntax) {
|
||||
this.syntax = syntax;
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,8 @@ public enum SupportedUnaryOperators {
|
|||
return syntax;
|
||||
}
|
||||
|
||||
public static SupportedUnaryOperators get(final String operator) {
|
||||
for (SupportedUnaryOperators op : SupportedUnaryOperators.values()) {
|
||||
public static UnaryOperatorKind get(final String operator) {
|
||||
for (UnaryOperatorKind op : UnaryOperatorKind.values()) {
|
||||
if (op.toString().equals(operator)) {
|
||||
return op;
|
||||
}
|
|
@ -37,11 +37,11 @@ public interface VisitableExression {
|
|||
* expression node of the expression tree.
|
||||
* @return
|
||||
* Object of type T which should be passed to the processing algorithm of the parent expression node
|
||||
* @throws ExceptionVisitExpression
|
||||
* @throws ExpressionVisitException
|
||||
* Exception occurred the OData library while traversing the tree
|
||||
* @throws ODataApplicationException
|
||||
* Exception thrown by the application who implemented the visitor
|
||||
*/
|
||||
<T> T accept(ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException;
|
||||
<T> T accept(ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException;
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@ package org.apache.olingo.odata4.server.api.uri.queryoption.search;
|
|||
|
||||
public interface SearchBinary extends SearchExpression {
|
||||
|
||||
SupportedSearchBinaryOperators getOperator();
|
||||
SearchBinaryOperatorKind getOperator();
|
||||
|
||||
SearchExpression getLeftOperand();
|
||||
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.server.api.uri.queryoption.search;
|
||||
|
||||
public enum SupportedSearchBinaryOperators {
|
||||
public enum SearchBinaryOperatorKind {
|
||||
// and/or
|
||||
AND("and"), OR("or");
|
||||
|
||||
private String syntax;
|
||||
|
||||
private SupportedSearchBinaryOperators(final String syntax) {
|
||||
private SearchBinaryOperatorKind(final String syntax) {
|
||||
this.syntax = syntax;
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,8 @@ public enum SupportedSearchBinaryOperators {
|
|||
return syntax;
|
||||
}
|
||||
|
||||
public static SupportedSearchBinaryOperators get(final String operator) {
|
||||
for (SupportedSearchBinaryOperators op : SupportedSearchBinaryOperators.values()) {
|
||||
public static SearchBinaryOperatorKind get(final String operator) {
|
||||
for (SearchBinaryOperatorKind op : SearchBinaryOperatorKind.values()) {
|
||||
if (op.toString().equals(operator)) {
|
||||
return op;
|
||||
}
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.server.api.uri.queryoption.search;
|
||||
|
||||
public enum SupportedSearchUnaryOperators {
|
||||
public enum SearchUnaryOperatorKind {
|
||||
NOT("not");
|
||||
|
||||
private String syntax;
|
||||
|
||||
private SupportedSearchUnaryOperators(final String syntax) {
|
||||
private SearchUnaryOperatorKind(final String syntax) {
|
||||
this.syntax = syntax;
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,8 @@ public enum SupportedSearchUnaryOperators {
|
|||
return syntax;
|
||||
}
|
||||
|
||||
public static SupportedSearchUnaryOperators get(final String operator) {
|
||||
for (SupportedSearchUnaryOperators op : SupportedSearchUnaryOperators.values()) {
|
||||
public static SearchUnaryOperatorKind get(final String operator) {
|
||||
for (SearchUnaryOperatorKind op : SearchUnaryOperatorKind.values()) {
|
||||
if (op.toString().equals(operator)) {
|
||||
return op;
|
||||
}
|
|
@ -134,8 +134,8 @@ BOOLEAN : T R U E | F A L S E;
|
|||
PLUS : '+';
|
||||
SIGN : PLUS | '%2B' |'-';
|
||||
INT : SIGN? DIGITS;
|
||||
DECIMAL : INT '.' DIGITS ('e' SIGN? DIGITS)?;
|
||||
|
||||
DECIMAL : INT '.' DIGITS (('e'|'E') SIGN? DIGITS)?;
|
||||
NANINFINITY : 'NaN' | '-INF' | 'INF';
|
||||
//primary types
|
||||
BINARY : B I N A R Y SQUOTE (HEXDIG HEXDIG)* SQUOTE;
|
||||
DATE : YEAR '-' MONTH '-' DAY;
|
||||
|
@ -185,7 +185,6 @@ OR : 'or';
|
|||
|
||||
NOT : 'not';
|
||||
MINUS :'-';
|
||||
NANINFINITY : 'NaN' | '-INF' | 'INF';
|
||||
|
||||
IT : '$it';
|
||||
ITSLASH : '$it/';
|
||||
|
@ -391,7 +390,7 @@ fragment DIGIT_g : '0'..'9';
|
|||
fragment DIGITS_g : DIGIT_g+;
|
||||
SIGN_g : ('+' | '%2B' |'-') -> type(SIGN);
|
||||
INT_g : SIGN_g? DIGITS_g -> type(INT);
|
||||
DECIMAL_g : INT_g '.' DIGITS_g ('e' SIGN_g? DIGITS_g)? -> type(DECIMAL);
|
||||
DECIMAL_g : 'SS' INT_g '.' DIGITS_g (('e'|'E') SIGN_g? DIGITS_g)? -> type(DECIMAL);
|
||||
COLLECTION_g : C_ O_ L_ L_ E_ C_ T_ I_ O_ N_ -> type(COLLECTION);
|
||||
LINESTRING : L_ I_ N_ E_ S_ T_ R_ I_ N_ G_ ;
|
||||
MULTILINESTRING : M_ U_ L_ T_ I_ L_ I_ N_ E_ S_ T_ R_ I_ N_ G_;
|
||||
|
|
|
@ -347,6 +347,7 @@ odataIdentifier : ODATAIDENTIFIER;
|
|||
primitiveLiteral : nullrule
|
||||
| booleanNonCase
|
||||
| DECIMAL //includes double and single literals
|
||||
| NANINFINITY
|
||||
| INT //includes int16/int32 and int64 literals
|
||||
| BINARY
|
||||
| DATE
|
||||
|
|
|
@ -46,12 +46,12 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.SkipOption;
|
|||
import org.apache.olingo.odata4.server.api.uri.queryoption.SkipTokenOption;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.TopOption;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.CountOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.CustomQueryOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.FormatOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.IdOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.InlineCountOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.QueryOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.SearchOptionImpl;
|
||||
|
@ -74,7 +74,7 @@ public class UriInfoImpl implements UriInfo {
|
|||
private FilterOptionImpl filterOption;
|
||||
private FormatOptionImpl formatOption;
|
||||
private IdOption idOption;
|
||||
private InlineCountOptionImpl inlineCountOption;
|
||||
private CountOptionImpl inlineCountOption;
|
||||
private OrderByOptionImpl orderByOption;
|
||||
private SearchOptionImpl searchOption;
|
||||
private SelectOptionImpl selectOption;
|
||||
|
@ -257,7 +257,7 @@ public class UriInfoImpl implements UriInfo {
|
|||
} else if (systemOption.getKind() == SupportedQueryOptions.ID) {
|
||||
idOption = (IdOptionImpl) systemOption;
|
||||
} else if (systemOption.getKind() == SupportedQueryOptions.INLINECOUNT) {
|
||||
inlineCountOption = (InlineCountOptionImpl) systemOption;
|
||||
inlineCountOption = (CountOptionImpl) systemOption;
|
||||
} else if (systemOption.getKind() == SupportedQueryOptions.ORDERBY) {
|
||||
orderByOption = (OrderByOptionImpl) systemOption;
|
||||
} else if (systemOption.getKind() == SupportedQueryOptions.SEARCH) {
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*******************************************************************************
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* 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
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
******************************************************************************/
|
||||
package org.apache.olingo.odata4.server.core.uri.parser;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
import org.antlr.v4.runtime.DiagnosticErrorListener;
|
||||
import org.antlr.v4.runtime.Parser;
|
||||
import org.antlr.v4.runtime.RecognitionException;
|
||||
import org.antlr.v4.runtime.Recognizer;
|
||||
import org.antlr.v4.runtime.atn.ATNConfigSet;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
|
||||
class CheckFullContextListener extends DiagnosticErrorListener {
|
||||
|
||||
@Override
|
||||
public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line,
|
||||
final int charPositionInLine,
|
||||
final String msg, final RecognitionException e) {
|
||||
// System.err.println("syntaxError detected");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportAmbiguity(final Parser recognizer, final DFA dfa, final int startIndex, final int stopIndex,
|
||||
final boolean exact,
|
||||
final BitSet ambigAlts, final ATNConfigSet configs) {
|
||||
// System.err.println("reportAmbiguity detected");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex,
|
||||
final int stopIndex,
|
||||
final BitSet conflictingAlts, final ATNConfigSet configs) {
|
||||
// System.err.println("reportAttemptingFullContext detected");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportContextSensitivity(final Parser recognizer, final DFA dfa, final int startIndex,
|
||||
final int stopIndex, final int prediction,
|
||||
final ATNConfigSet configs) {
|
||||
// System.err.println("reportContextSensitivity detected");
|
||||
}
|
||||
|
||||
}
|
|
@ -50,12 +50,12 @@ import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.PathSegmen
|
|||
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser.SelectEOFContext;
|
||||
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.CountOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.CustomQueryOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.FormatOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.IdOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.InlineCountOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.LevelsOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.SelectOptionImpl;
|
||||
|
@ -198,7 +198,7 @@ public class Parser {
|
|||
idOption.setValue(option.value);
|
||||
context.contextUriInfo.setSystemQueryOption(idOption);
|
||||
} else if (option.name.equals("$inlinecount")) {
|
||||
InlineCountOptionImpl inlineCountOption = new InlineCountOptionImpl();
|
||||
CountOptionImpl inlineCountOption = new CountOptionImpl();
|
||||
inlineCountOption.setName(option.name);
|
||||
inlineCountOption.setText(option.value);
|
||||
inlineCountOption.setValue(option.value.equals("true") ? true : false);
|
||||
|
@ -212,7 +212,7 @@ public class Parser {
|
|||
|
||||
context.contextUriInfo.setSystemQueryOption(filterOption);
|
||||
} else if (option.name.equals("$search")) {
|
||||
// TODO not supported yet
|
||||
// TODO $search is not supported yet
|
||||
} else if (option.name.equals("$select")) {
|
||||
SelectEOFContext ctxSelectEOF =
|
||||
(SelectEOFContext) parseRule(option.value, ParserEntryRules.Select);
|
||||
|
@ -241,7 +241,7 @@ public class Parser {
|
|||
context.contextUriInfo.setSystemQueryOption(inlineCountOption);
|
||||
} else if (option.name.equals("$count")) {
|
||||
// todo create CountOption
|
||||
InlineCountOptionImpl inlineCountOption = new InlineCountOptionImpl();
|
||||
CountOptionImpl inlineCountOption = new CountOptionImpl();
|
||||
inlineCountOption.setName(option.name);
|
||||
inlineCountOption.setText(option.value);
|
||||
inlineCountOption.setValue(option.value.equals("true") ? true : false);
|
||||
|
@ -253,7 +253,7 @@ public class Parser {
|
|||
if (option.value.equals("max")) {
|
||||
inlineCountOption.setMax();
|
||||
} else {
|
||||
inlineCountOption.setLevel(Integer.parseInt(option.value));
|
||||
inlineCountOption.setValue(Integer.parseInt(option.value));
|
||||
}
|
||||
|
||||
context.contextUriInfo.setSystemQueryOption(inlineCountOption);
|
||||
|
@ -428,6 +428,8 @@ public class Parser {
|
|||
protected void addStage1ErrorListener(final UriParserParser parser) {
|
||||
// No error logging to System.out or System.err, only exceptions used (depending on ErrorStrategy)
|
||||
parser.removeErrorListeners();
|
||||
parser.addErrorListener(new CheckFullContextListener());
|
||||
|
||||
}
|
||||
|
||||
protected void addStage2ErrorListener(final UriParserParser parser) {
|
||||
|
|
|
@ -45,9 +45,8 @@ import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeK
|
|||
import org.apache.olingo.odata4.server.api.uri.UriInfoKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.UriResource;
|
||||
import org.apache.olingo.odata4.server.api.uri.UriResourcePartTyped;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedBinaryOperators;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedConstants;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedMethodCalls;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind;
|
||||
import org.apache.olingo.odata4.server.core.uri.UriParserException;
|
||||
import org.apache.olingo.odata4.server.core.uri.UriParserSemanticException;
|
||||
import org.apache.olingo.odata4.server.core.uri.antlr.UriLexer;
|
||||
|
@ -162,11 +161,11 @@ import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceTypedImpl;
|
|||
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceValueImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceWithKeysImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.AliasQueryOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.CountOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandItemImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.FormatOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.InlineCountOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.LevelsOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByItemImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl;
|
||||
|
@ -178,7 +177,6 @@ import org.apache.olingo.odata4.server.core.uri.queryoption.SkipTokenOptionImpl;
|
|||
import org.apache.olingo.odata4.server.core.uri.queryoption.SystemQueryOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.TopOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.BinaryImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.ConstantImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.EnumerationImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.ExpressionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.LiteralImpl;
|
||||
|
@ -202,8 +200,7 @@ import org.apache.olingo.odata4.server.core.uri.queryoption.expression.TypeLiter
|
|||
* Not supported
|
||||
* <li>Parsing the context of $metadata
|
||||
*
|
||||
* TODO
|
||||
* <li>clean up
|
||||
* TODO planned
|
||||
* <li>Overview testcases
|
||||
* <li>search
|
||||
*/
|
||||
|
@ -686,9 +683,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
int tokenIndex = ctx.vO.getType();
|
||||
|
||||
if (tokenIndex == UriLexer.ADD) {
|
||||
binary.setOperator(SupportedBinaryOperators.ADD);
|
||||
binary.setOperator(BinaryOperatorKind.ADD);
|
||||
} else if (tokenIndex == UriLexer.SUB) {
|
||||
binary.setOperator(SupportedBinaryOperators.SUB);
|
||||
binary.setOperator(BinaryOperatorKind.SUB);
|
||||
}
|
||||
|
||||
binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this));
|
||||
|
@ -711,7 +708,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
public ExpressionImpl visitAltAnd(final AltAndContext ctx) {
|
||||
BinaryImpl binary = new BinaryImpl();
|
||||
|
||||
binary.setOperator(SupportedBinaryOperators.AND);
|
||||
binary.setOperator(BinaryOperatorKind.AND);
|
||||
binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this));
|
||||
binary.setRightOperand((ExpressionImpl) ctx.vE2.accept(this));
|
||||
|
||||
|
@ -741,13 +738,13 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
int tokenIndex = ctx.vO.getType();
|
||||
|
||||
if (tokenIndex == UriLexer.GT) {
|
||||
binary.setOperator(SupportedBinaryOperators.GT);
|
||||
binary.setOperator(BinaryOperatorKind.GT);
|
||||
} else if (tokenIndex == UriLexer.GE) {
|
||||
binary.setOperator(SupportedBinaryOperators.GE);
|
||||
binary.setOperator(BinaryOperatorKind.GE);
|
||||
} else if (tokenIndex == UriLexer.LT) {
|
||||
binary.setOperator(SupportedBinaryOperators.LT);
|
||||
binary.setOperator(BinaryOperatorKind.LT);
|
||||
} else if (tokenIndex == UriLexer.LE) {
|
||||
binary.setOperator(SupportedBinaryOperators.LE);
|
||||
binary.setOperator(BinaryOperatorKind.LE);
|
||||
}
|
||||
|
||||
binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this));
|
||||
|
@ -783,9 +780,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
int tokenIndex = ctx.vO.getType();
|
||||
|
||||
if (tokenIndex == UriLexer.EQ_ALPHA) {
|
||||
binary.setOperator(SupportedBinaryOperators.EQ);
|
||||
binary.setOperator(BinaryOperatorKind.EQ);
|
||||
} else {
|
||||
binary.setOperator(SupportedBinaryOperators.NE);
|
||||
binary.setOperator(BinaryOperatorKind.NE);
|
||||
}
|
||||
binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this));
|
||||
binary.setRightOperand((ExpressionImpl) ctx.vE2.accept(this));
|
||||
|
@ -797,7 +794,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
public Object visitAltHas(final AltHasContext ctx) {
|
||||
BinaryImpl binary = new BinaryImpl();
|
||||
|
||||
binary.setOperator(SupportedBinaryOperators.HAS);
|
||||
binary.setOperator(BinaryOperatorKind.HAS);
|
||||
binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this));
|
||||
binary.setRightOperand((ExpressionImpl) ctx.vE2.accept(this));
|
||||
|
||||
|
@ -819,11 +816,11 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
int tokenIndex = ctx.vO.getType();
|
||||
|
||||
if (tokenIndex == UriLexer.MUL) {
|
||||
binary.setOperator(SupportedBinaryOperators.MUL);
|
||||
binary.setOperator(BinaryOperatorKind.MUL);
|
||||
} else if (tokenIndex == UriLexer.DIV) {
|
||||
binary.setOperator(SupportedBinaryOperators.DIV);
|
||||
binary.setOperator(BinaryOperatorKind.DIV);
|
||||
} else {
|
||||
binary.setOperator(SupportedBinaryOperators.MOD);
|
||||
binary.setOperator(BinaryOperatorKind.MOD);
|
||||
}
|
||||
binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this));
|
||||
binary.setRightOperand((ExpressionImpl) ctx.vE2.accept(this));
|
||||
|
@ -835,7 +832,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
public ExpressionImpl visitAltOr(final AltOrContext ctx) {
|
||||
BinaryImpl binary = new BinaryImpl();
|
||||
|
||||
binary.setOperator(SupportedBinaryOperators.OR);
|
||||
binary.setOperator(BinaryOperatorKind.OR);
|
||||
binary.setLeftOperand((ExpressionImpl) ctx.vE1.accept(this));
|
||||
binary.setRightOperand((ExpressionImpl) ctx.vE2.accept(this));
|
||||
|
||||
|
@ -869,9 +866,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
String text = ctx.getText().toLowerCase();
|
||||
|
||||
if (text.equals("false")) {
|
||||
return new ConstantImpl().setKind(SupportedConstants.FALSE);
|
||||
return new LiteralImpl().setText("false").setType(EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance());
|
||||
}
|
||||
return new ConstantImpl().setKind(SupportedConstants.TRUE);
|
||||
return new LiteralImpl().setText("true").setType(EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -888,7 +885,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
|
||||
FullQualifiedName fullName = new FullQualifiedName(namespace, ctx.vODI.getText());
|
||||
EdmType type = getType(fullName);
|
||||
method.setMethod(SupportedMethodCalls.CAST);
|
||||
method.setMethod(MethodCallKind.CAST);
|
||||
method.addParameter(new TypeLiteralImpl().setType(type));
|
||||
return method;
|
||||
}
|
||||
|
@ -926,14 +923,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitCeilingMethodCallExpr(final CeilingMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.CEILING)
|
||||
.setMethod(MethodCallKind.CEILING)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitConcatMethodCallExpr(final ConcatMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.CONCAT)
|
||||
.setMethod(MethodCallKind.CONCAT)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
|
||||
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
|
||||
}
|
||||
|
@ -988,7 +985,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitContainsMethodCallExpr(final ContainsMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.CONTAINS)
|
||||
.setMethod(MethodCallKind.CONTAINS)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
|
||||
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
|
||||
}
|
||||
|
@ -1008,21 +1005,21 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public Object visitDateMethodCallExpr(final DateMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.DATE)
|
||||
.setMethod(MethodCallKind.DATE)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitDayMethodCallExpr(final DayMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.DAY)
|
||||
.setMethod(MethodCallKind.DAY)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitGeoDistanceMethodCallExpr(final GeoDistanceMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.GEODISTANCE)
|
||||
.setMethod(MethodCallKind.GEODISTANCE)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
|
||||
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
|
||||
}
|
||||
|
@ -1030,7 +1027,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public Object visitEndsWithMethodCallExpr(final EndsWithMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.ENDSWITH)
|
||||
.setMethod(MethodCallKind.ENDSWITH)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
|
||||
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
|
||||
}
|
||||
|
@ -1083,8 +1080,10 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
expandItem.setSystemQueryOption(levels);
|
||||
} else if (ctx.vL != null) {
|
||||
// TODO set value as integer
|
||||
LevelsOptionImpl levels = new LevelsOptionImpl().setMax();
|
||||
levels.setText(ctx.vL.getText());
|
||||
LevelsOptionImpl levels = new LevelsOptionImpl();
|
||||
String text = ctx.vL.getText();
|
||||
levels.setText(text);
|
||||
levels.setValue(Integer.parseInt(text));
|
||||
expandItem.setSystemQueryOption(levels);
|
||||
}
|
||||
|
||||
|
@ -1204,7 +1203,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitFloorMethodCallExpr(final FloorMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.FLOOR)
|
||||
.setMethod(MethodCallKind.FLOOR)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
|
@ -1240,45 +1239,45 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitFractionalsecondsMethodCallExpr(final FractionalsecondsMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.FRACTIONALSECONDS)
|
||||
.setMethod(MethodCallKind.FRACTIONALSECONDS)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitGeoLengthMethodCallExpr(final GeoLengthMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.GEOLENGTH)
|
||||
.setMethod(MethodCallKind.GEOLENGTH)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitHourMethodCallExpr(final HourMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.HOUR)
|
||||
.setMethod(MethodCallKind.HOUR)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitIndexOfMethodCallExpr(final IndexOfMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.INDEXOF)
|
||||
.setMethod(MethodCallKind.INDEXOF)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
|
||||
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitInlinecount(final InlinecountContext ctx) {
|
||||
InlineCountOptionImpl inlineCount = new InlineCountOptionImpl();
|
||||
CountOptionImpl inlineCount = new CountOptionImpl();
|
||||
|
||||
String text = ctx.children.get(2).getText();
|
||||
|
||||
return inlineCount.setValue(text.equals("true") ? true : false).setText(text);
|
||||
return inlineCount.setValue(text.toLowerCase().equals("true") ? true : false).setText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitGeoIntersectsMethodCallExpr(final GeoIntersectsMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.GEOINTERSECTS)
|
||||
.setMethod(MethodCallKind.GEOINTERSECTS)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
|
||||
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
|
||||
}
|
||||
|
@ -1296,7 +1295,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
|
||||
FullQualifiedName fullName = new FullQualifiedName(namespace, ctx.vODI.getText());
|
||||
EdmType type = getType(fullName);
|
||||
method.setMethod(SupportedMethodCalls.ISOF);
|
||||
method.setMethod(MethodCallKind.ISOF);
|
||||
method.addParameter(new TypeLiteralImpl().setType(type));
|
||||
|
||||
return method;
|
||||
|
@ -1305,7 +1304,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitLengthMethodCallExpr(final LengthMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.LENGTH)
|
||||
.setMethod(MethodCallKind.LENGTH)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
|
@ -1329,7 +1328,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitMaxDateTimeMethodCallExpr(final MaxDateTimeMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.MAXDATETIME);
|
||||
.setMethod(MethodCallKind.MAXDATETIME);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1373,20 +1372,20 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitMinDateTimeMethodCallExpr(final MinDateTimeMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.MINDATETIME);
|
||||
.setMethod(MethodCallKind.MINDATETIME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitMinuteMethodCallExpr(final MinuteMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.MINUTE)
|
||||
.setMethod(MethodCallKind.MINUTE)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitMonthMethodCallExpr(final MonthMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.MONTH)
|
||||
.setMethod(MethodCallKind.MONTH)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
|
@ -1560,12 +1559,12 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitNowMethodCallExpr(final NowMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.NOW);
|
||||
.setMethod(MethodCallKind.NOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitNullrule(final NullruleContext ctx) {
|
||||
return new ConstantImpl().setKind(SupportedConstants.NULL);
|
||||
return new LiteralImpl().setText("null");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1733,14 +1732,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitRoundMethodCallExpr(final RoundMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.ROUND)
|
||||
.setMethod(MethodCallKind.ROUND)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitSecondMethodCallExpr(final SecondMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.SECOND)
|
||||
.setMethod(MethodCallKind.SECOND)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
|
@ -1997,7 +1996,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitStartsWithMethodCallExpr(final StartsWithMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.STARTSWITH)
|
||||
.setMethod(MethodCallKind.STARTSWITH)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this))
|
||||
.addParameter((ExpressionImpl) ctx.vE2.accept(this));
|
||||
}
|
||||
|
@ -2005,7 +2004,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitSubstringMethodCallExpr(final SubstringMethodCallExprContext ctx) {
|
||||
MethodCallImpl ret = new MethodCallImpl();
|
||||
ret.setMethod(SupportedMethodCalls.SUBSTRING);
|
||||
ret.setMethod(MethodCallKind.SUBSTRING);
|
||||
ret.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
ret.addParameter((ExpressionImpl) ctx.vE2.accept(this));
|
||||
|
||||
|
@ -2020,7 +2019,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitTimeMethodCallExpr(final TimeMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.TIME)
|
||||
.setMethod(MethodCallKind.TIME)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
|
@ -2036,35 +2035,35 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitToLowerMethodCallExpr(final ToLowerMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.TOLOWER)
|
||||
.setMethod(MethodCallKind.TOLOWER)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitTotalOffsetMinutesMethodCallExpr(final TotalOffsetMinutesMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.TOTALOFFSETMINUTES)
|
||||
.setMethod(MethodCallKind.TOTALOFFSETMINUTES)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitTotalsecondsMethodCallExpr(final TotalsecondsMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.TOTALSECONDS)
|
||||
.setMethod(MethodCallKind.TOTALSECONDS)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitToUpperMethodCallExpr(final ToUpperMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.TOUPPER)
|
||||
.setMethod(MethodCallKind.TOUPPER)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitTrimMethodCallExpr(final TrimMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.TRIM)
|
||||
.setMethod(MethodCallKind.TRIM)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
|
@ -2077,7 +2076,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
@Override
|
||||
public ExpressionImpl visitYearMethodCallExpr(final YearMethodCallExprContext ctx) {
|
||||
return new MethodCallImpl()
|
||||
.setMethod(SupportedMethodCalls.YEAR)
|
||||
.setMethod(MethodCallKind.YEAR)
|
||||
.addParameter((ExpressionImpl) ctx.vE1.accept(this));
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,11 @@ package org.apache.olingo.odata4.server.core.uri.queryoption;
|
|||
import org.apache.olingo.odata4.server.api.uri.queryoption.InlineCountOption;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions;
|
||||
|
||||
public class InlineCountOptionImpl extends SystemQueryOptionImpl implements InlineCountOption {
|
||||
public class CountOptionImpl extends SystemQueryOptionImpl implements InlineCountOption {
|
||||
|
||||
private boolean count;
|
||||
|
||||
public InlineCountOptionImpl() {
|
||||
public CountOptionImpl() {
|
||||
setKind(SupportedQueryOptions.INLINECOUNT);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class InlineCountOptionImpl extends SystemQueryOptionImpl implements Inli
|
|||
return count;
|
||||
}
|
||||
|
||||
public InlineCountOptionImpl setValue(final boolean count) {
|
||||
public CountOptionImpl setValue(final boolean count) {
|
||||
this.count = count;
|
||||
return this;
|
||||
}
|
|
@ -57,7 +57,7 @@ public class ExpandItemImpl implements ExpandItem {
|
|||
} else if (sysItem.getKind() == SupportedQueryOptions.FILTER) {
|
||||
filterOption = (FilterOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.INLINECOUNT) {
|
||||
inlineCountOption = (InlineCountOptionImpl) sysItem;
|
||||
inlineCountOption = (CountOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.ORDERBY) {
|
||||
orderByOption = (OrderByOptionImpl) sysItem;
|
||||
} else if (sysItem.getKind() == SupportedQueryOptions.SEARCH) {
|
||||
|
|
|
@ -29,7 +29,7 @@ public class LevelsOptionImpl extends SystemQueryOptionImpl implements LevelsExp
|
|||
setKind(SupportedQueryOptions.LEVELS);
|
||||
}
|
||||
|
||||
public LevelsOptionImpl setLevel(final int value) {
|
||||
public LevelsOptionImpl setValue(final int value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class LevelsOptionImpl extends SystemQueryOptionImpl implements LevelsExp
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.SearchOption;
|
|||
import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.search.SearchExpression;
|
||||
|
||||
/* TODO implement */
|
||||
// TODO $search is not supported yet
|
||||
public class SearchOptionImpl extends SystemQueryOptionImpl implements SearchOption {
|
||||
|
||||
public SearchOptionImpl() {
|
||||
|
@ -31,7 +31,7 @@ public class SearchOptionImpl extends SystemQueryOptionImpl implements SearchOpt
|
|||
|
||||
@Override
|
||||
public SearchExpression getSearchExpression() {
|
||||
// TODO $search not supported yet
|
||||
// TODO $search is not supported yet
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.olingo.odata4.server.core.uri.queryoption.expression;
|
|||
|
||||
import org.apache.olingo.odata4.commons.api.ODataApplicationException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.AliasExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor;
|
||||
|
||||
public class AliasImpl extends ExpressionImpl implements AliasExpression {
|
||||
|
@ -37,7 +37,7 @@ public class AliasImpl extends ExpressionImpl implements AliasExpression {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException {
|
||||
return visitor.visitAlias(parameterName);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,23 +20,23 @@ package org.apache.olingo.odata4.server.core.uri.queryoption.expression;
|
|||
|
||||
import org.apache.olingo.odata4.commons.api.ODataApplicationException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedBinaryOperators;
|
||||
|
||||
public class BinaryImpl extends ExpressionImpl implements BinaryExpression {
|
||||
|
||||
private SupportedBinaryOperators operator;
|
||||
private BinaryOperatorKind operator;
|
||||
private ExpressionImpl left;
|
||||
private ExpressionImpl right;
|
||||
|
||||
@Override
|
||||
public SupportedBinaryOperators getOperator() {
|
||||
public BinaryOperatorKind getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public BinaryExpression setOperator(final SupportedBinaryOperators operator) {
|
||||
public BinaryExpression setOperator(final BinaryOperatorKind operator) {
|
||||
this.operator = operator;
|
||||
return this;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class BinaryImpl extends ExpressionImpl implements BinaryExpression {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException {
|
||||
T left = this.left.accept(visitor);
|
||||
T right = this.right.accept(visitor);
|
||||
return visitor.visitBinaryOperator(operator, left, right);
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* 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
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.odata4.server.core.uri.queryoption.expression;
|
||||
|
||||
import org.apache.olingo.odata4.commons.api.ODataApplicationException;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmType;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Constant;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedConstants;
|
||||
|
||||
public class ConstantImpl extends ExpressionImpl implements Constant {
|
||||
|
||||
EdmType type;
|
||||
SupportedConstants kind;
|
||||
|
||||
@Override
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
|
||||
return visitor.visitConstant(kind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNull() {
|
||||
return kind == SupportedConstants.NULL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrue() {
|
||||
return kind == SupportedConstants.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFalse() {
|
||||
return kind == SupportedConstants.FALSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public ConstantImpl setType(final EdmType type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SupportedConstants getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
public ConstantImpl setKind(final SupportedConstants kind) {
|
||||
this.kind = kind;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||
import org.apache.olingo.odata4.commons.api.ODataApplicationException;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEnumType;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Enumeration;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor;
|
||||
|
||||
public class EnumerationImpl extends ExpressionImpl implements Enumeration {
|
||||
|
@ -53,7 +53,7 @@ public class EnumerationImpl extends ExpressionImpl implements Enumeration {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException {
|
||||
return visitor.visitEnum(type, values);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.apache.olingo.odata4.server.core.uri.queryoption.expression;
|
||||
|
||||
import org.apache.olingo.odata4.commons.api.ODataApplicationException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.LambdaRef;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableExression;
|
||||
|
@ -39,7 +39,7 @@ public class LambdaRefImpl extends ExpressionImpl implements LambdaRef, Visitabl
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException {
|
||||
return visitor.visitLambdaReference(variableText);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
package org.apache.olingo.odata4.server.core.uri.queryoption.expression;
|
||||
|
||||
import org.apache.olingo.odata4.commons.api.ODataApplicationException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmType;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Literal;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableExression;
|
||||
|
@ -27,6 +28,7 @@ import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableE
|
|||
public class LiteralImpl extends ExpressionImpl implements Literal, VisitableExression {
|
||||
|
||||
private String text;
|
||||
private EdmType type;
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
|
@ -39,7 +41,17 @@ public class LiteralImpl extends ExpressionImpl implements Literal, VisitableExr
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public EdmType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public LiteralImpl setType(final EdmType type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException {
|
||||
return visitor.visitLiteral(text);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.olingo.odata4.server.core.uri.queryoption.expression;
|
|||
import org.apache.olingo.odata4.commons.api.ODataApplicationException;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmType;
|
||||
import org.apache.olingo.odata4.server.api.uri.UriInfoResource;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Member;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableExression;
|
||||
|
@ -45,7 +45,7 @@ public class MemberImpl extends ExpressionImpl implements Member, VisitableExres
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException {
|
||||
return visitor.visitMember(path);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,24 +22,24 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.olingo.odata4.commons.api.ODataApplicationException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCall;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedMethodCalls;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableExression;
|
||||
|
||||
public class MethodCallImpl extends ExpressionImpl implements MethodCall, VisitableExression {
|
||||
|
||||
private SupportedMethodCalls method;
|
||||
private MethodCallKind method;
|
||||
private List<ExpressionImpl> parameters = new ArrayList<ExpressionImpl>();
|
||||
|
||||
@Override
|
||||
public SupportedMethodCalls getMethod() {
|
||||
public MethodCallKind getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public MethodCallImpl setMethod(final SupportedMethodCalls methodCalls) {
|
||||
public MethodCallImpl setMethod(final MethodCallKind methodCalls) {
|
||||
method = methodCalls;
|
||||
return this;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class MethodCallImpl extends ExpressionImpl implements MethodCall, Visita
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException {
|
||||
List<T> userParameters = new ArrayList<T>();
|
||||
for (ExpressionImpl parameter : parameters) {
|
||||
userParameters.add(parameter.accept(visitor));
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.olingo.odata4.server.core.uri.queryoption.expression;
|
|||
|
||||
import org.apache.olingo.odata4.commons.api.ODataApplicationException;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmType;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.TypeLiteral;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableExression;
|
||||
|
@ -40,7 +40,7 @@ public class TypeLiteralImpl extends ExpressionImpl implements TypeLiteral, Visi
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException {
|
||||
return visitor.visitTypeLiteral(type);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,24 +19,24 @@
|
|||
package org.apache.olingo.odata4.server.core.uri.queryoption.expression;
|
||||
|
||||
import org.apache.olingo.odata4.commons.api.ODataApplicationException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedUnaryOperators;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.UnaryOperator;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.UnaryOperatorKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.VisitableExression;
|
||||
|
||||
public class UnaryImpl extends ExpressionImpl implements UnaryOperator, VisitableExression {
|
||||
|
||||
private SupportedUnaryOperators operator;
|
||||
private UnaryOperatorKind operator;
|
||||
private ExpressionImpl expression;
|
||||
|
||||
@Override
|
||||
public SupportedUnaryOperators getOperator() {
|
||||
public UnaryOperatorKind getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(final SupportedUnaryOperators operator) {
|
||||
public void setOperator(final UnaryOperatorKind operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class UnaryImpl extends ExpressionImpl implements UnaryOperator, Visitabl
|
|||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public <T> T accept(final ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException {
|
||||
T operand = expression.accept(visitor);
|
||||
return visitor.visitUnaryOperator(operator, operand);
|
||||
}
|
||||
|
|
|
@ -374,11 +374,12 @@ public class EdmTechProvider extends EdmProvider {
|
|||
.setType(nameETMedia);
|
||||
|
||||
/*
|
||||
* TODO add stream property
|
||||
* TODO add propertyStream
|
||||
* Property propertyStream = new Property()
|
||||
* .setName("PropertyStream")
|
||||
* .setType(EdmStream.getFullQualifiedName());
|
||||
*/
|
||||
|
||||
NavigationProperty navPropertyETKeyPrimNavOne = new NavigationProperty()
|
||||
.setName("NavPropertyETKeyPrimNavOne")
|
||||
.setType(nameETKeyPrimNav);
|
||||
|
@ -678,7 +679,7 @@ public class EdmTechProvider extends EdmProvider {
|
|||
propertyDecimal, propertySingle, propertyDouble,
|
||||
propertyDuration, propertyGuid, propertyInt16,
|
||||
propertyInt32, propertyInt64, propertySByte,
|
||||
propertyTimeOfDay/* TODO add steam property */));
|
||||
propertyTimeOfDay/* TODO add propertyStream */));
|
||||
|
||||
} else if (complexTypeName.equals(nameCTCollAllPrim)) {
|
||||
return new ComplexType()
|
||||
|
@ -928,7 +929,7 @@ public class EdmTechProvider extends EdmProvider {
|
|||
propertySingle, propertyDouble, propertyDecimal,
|
||||
propertyBinary, propertyDate, propertyDateTimeOffset,
|
||||
propertyDuration, propertyGuid,
|
||||
propertyTimeOfDay /* TODO add stream property */));
|
||||
propertyTimeOfDay /* TODO add propertyStream */));
|
||||
|
||||
} else if (entityTypeName.equals(nameETCollAllPrim)) {
|
||||
return new EntityType()
|
||||
|
@ -942,7 +943,7 @@ public class EdmTechProvider extends EdmProvider {
|
|||
collPropertyInt16, collPropertyInt32, collPropertyInt64,
|
||||
collPropertySingle, collPropertyDouble, collPropertyDecimal,
|
||||
collPropertyBinary, collPropertyDate, collPropertyDateTimeOffset,
|
||||
collPropertyDuration, collPropertyGuid, collPropertyTimeOfDay /* TODO add stream property */));
|
||||
collPropertyDuration, collPropertyGuid, collPropertyTimeOfDay /* TODO add propertyStream */));
|
||||
|
||||
} else if (entityTypeName.equals(nameETTwoPrim)) {
|
||||
return new EntityType()
|
||||
|
@ -1021,7 +1022,7 @@ public class EdmTechProvider extends EdmProvider {
|
|||
propertyDecimal, propertyDate,
|
||||
propertySingle, propertyDouble, propertyDateTimeOffset,
|
||||
propertyDuration, propertyGuid,
|
||||
propertyTimeOfDay /* TODO add stream property */));
|
||||
propertyTimeOfDay /* TODO add propertyStream */));
|
||||
|
||||
} else if (entityTypeName.equals(nameETCompAllPrim)) {
|
||||
return new EntityType()
|
||||
|
@ -1093,7 +1094,7 @@ public class EdmTechProvider extends EdmProvider {
|
|||
propertySingle, propertyDouble,
|
||||
propertyDecimal, propertyBinary, propertyDate,
|
||||
propertyDateTimeOffset,
|
||||
propertyDuration, propertyGuid, propertyTimeOfDay /* TODO add stream property */,
|
||||
propertyDuration, propertyGuid, propertyTimeOfDay /* TODO add propertyStream */,
|
||||
collPropertyString, collPropertyBoolean,
|
||||
collPropertyByte, collPropertySByte,
|
||||
collPropertyInt16,
|
||||
|
@ -1101,7 +1102,7 @@ public class EdmTechProvider extends EdmProvider {
|
|||
collPropertySingle, collPropertyDouble,
|
||||
collPropertyDecimal, collPropertyBinary, collPropertyDate,
|
||||
collPropertyDateTimeOffset,
|
||||
collPropertyDuration, collPropertyGuid, collPropertyTimeOfDay /* TODO add stream property */));
|
||||
collPropertyDuration, collPropertyGuid, collPropertyTimeOfDay /* TODO add propertyStream */));
|
||||
|
||||
} else if (entityTypeName.equals(nameETKeyNav)) {
|
||||
return new EntityType()
|
||||
|
|
|
@ -27,10 +27,11 @@ import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
|||
import org.apache.olingo.odata4.server.api.uri.UriInfoKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.ExpandItem;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.SelectItem;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.QueryOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.SelectOptionImpl;
|
||||
|
||||
|
@ -44,8 +45,8 @@ public class ExpandValidator implements Validator {
|
|||
|
||||
// --- Setup ---
|
||||
|
||||
public ExpandValidator setGoUpValidator(final Validator parentValidator) {
|
||||
invokedByValidator = parentValidator;
|
||||
public ExpandValidator setUpValidator(final Validator validator) {
|
||||
invokedByValidator = validator;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -62,27 +63,44 @@ public class ExpandValidator implements Validator {
|
|||
|
||||
// --- Navigation ---
|
||||
|
||||
public UriResourceValidator goPath() {
|
||||
public ExpandValidator goUpToExpandValidator() {
|
||||
return (ExpandValidator) invokedByValidator;
|
||||
}
|
||||
|
||||
public ResourceValidator goUpToUriResourceValidator() {
|
||||
return (ResourceValidator) invokedByValidator;
|
||||
}
|
||||
|
||||
public ResourceValidator goPath() {
|
||||
UriInfoImpl uriInfo = (UriInfoImpl) expandItem.getResourceInfo();
|
||||
|
||||
if (uriInfo.getKind() != UriInfoKind.resource) {
|
||||
fail("goPath() can only be used on UriInfoKind.resource");
|
||||
}
|
||||
|
||||
return new UriResourceValidator()
|
||||
return new ResourceValidator()
|
||||
.setUpValidator(this)
|
||||
.setEdm(edm)
|
||||
.setUriInfoImplPath(uriInfo);
|
||||
|
||||
}
|
||||
|
||||
public UriResourceValidator goSelectItemPath(final int index) {
|
||||
public FilterValidator goOrder(final int index) {
|
||||
OrderByOptionImpl orderBy = (OrderByOptionImpl) expandItem.getOrderByOption();
|
||||
|
||||
return new FilterValidator()
|
||||
.setValidator(this)
|
||||
.setEdm(edm)
|
||||
.setExpression(orderBy.getOrders().get(index).getExpression());
|
||||
}
|
||||
|
||||
public ResourceValidator goSelectItem(final int index) {
|
||||
SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
|
||||
|
||||
SelectItem item = select.getSelectItems().get(index);
|
||||
UriInfoImpl uriInfo = (UriInfoImpl) item.getResourceInfo();
|
||||
|
||||
return new UriResourceValidator()
|
||||
return new ResourceValidator()
|
||||
.setUpValidator(this)
|
||||
.setEdm(edm)
|
||||
.setUriInfoImplPath(uriInfo);
|
||||
|
@ -90,20 +108,12 @@ public class ExpandValidator implements Validator {
|
|||
}
|
||||
|
||||
public ExpandValidator goExpand() {
|
||||
ExpandValidator val = new ExpandValidator();
|
||||
val.setExpand((ExpandOptionImpl) expandItem.getExpandOption());
|
||||
val.setGoUpValidator(this);
|
||||
ExpandValidator val = new ExpandValidator()
|
||||
.setExpand((ExpandOptionImpl) expandItem.getExpandOption())
|
||||
.setUpValidator(this);
|
||||
return val;
|
||||
}
|
||||
|
||||
public ExpandValidator goUpToExpandValidator() {
|
||||
return (ExpandValidator) invokedByValidator;
|
||||
}
|
||||
|
||||
public UriResourceValidator goUpToUriResourceValidator() {
|
||||
return (UriResourceValidator) invokedByValidator;
|
||||
}
|
||||
|
||||
public ExpandValidator first() {
|
||||
expandItemIndex = 0;
|
||||
expandItem = expandOption.getExpandItems().get(expandItemIndex);
|
||||
|
@ -170,7 +180,7 @@ public class ExpandValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ExpandValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) {
|
||||
public ExpandValidator isSelectItemAllOperations(final int index, final FullQualifiedName fqn) {
|
||||
SelectOptionImpl select = (SelectOptionImpl) expandItem.getSelectOption();
|
||||
|
||||
SelectItem item = select.getSelectItems().get(index);
|
||||
|
@ -178,7 +188,7 @@ public class ExpandValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ExpandValidator isFilterText(final String text) {
|
||||
public ExpandValidator isFilterOptionText(final String text) {
|
||||
QueryOptionImpl option = (QueryOptionImpl) expandItem.getFilterOption();
|
||||
assertEquals(text, option.getText());
|
||||
return this;
|
||||
|
@ -190,7 +200,7 @@ public class ExpandValidator implements Validator {
|
|||
try {
|
||||
String tmp = FilterTreeToText.Serialize(filter);
|
||||
assertEquals(serialized, tmp);
|
||||
} catch (ExceptionVisitExpression e) {
|
||||
} catch (ExpressionVisitException e) {
|
||||
fail("Exception occured while converting the filterTree into text" + "\n"
|
||||
+ " Exception: " + e.getMessage());
|
||||
} catch (ODataApplicationException e) {
|
||||
|
@ -201,4 +211,10 @@ public class ExpandValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ExpandValidator isSortOrder(final int index, final boolean descending) {
|
||||
OrderByOptionImpl orderBy = (OrderByOptionImpl) expandItem.getOrderByOption();
|
||||
assertEquals(descending, orderBy.getOrders().get(index).isDescending());
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,46 +29,45 @@ import org.apache.olingo.odata4.server.api.uri.UriResourceLambdaAll;
|
|||
import org.apache.olingo.odata4.server.api.uri.UriResourceLambdaAny;
|
||||
import org.apache.olingo.odata4.server.api.uri.UriResourcePartTyped;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.FilterOption;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitor;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedBinaryOperators;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedConstants;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedMethodCalls;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedUnaryOperators;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.UnaryOperatorKind;
|
||||
|
||||
public class FilterTreeToText implements ExpressionVisitor<String> {
|
||||
|
||||
public static String Serialize(final FilterOption filter)
|
||||
throws ExceptionVisitExpression, ODataApplicationException {
|
||||
throws ExpressionVisitException, ODataApplicationException {
|
||||
|
||||
Expression expression = filter.getExpression();
|
||||
return expression.accept(new FilterTreeToText());
|
||||
}
|
||||
|
||||
public static String Serialize(final Expression expression)
|
||||
throws ExceptionVisitExpression, ODataApplicationException {
|
||||
throws ExpressionVisitException, ODataApplicationException {
|
||||
|
||||
return expression.accept(new FilterTreeToText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitBinaryOperator(final SupportedBinaryOperators operator, final String left, final String right)
|
||||
throws ExceptionVisitExpression {
|
||||
public String visitBinaryOperator(final BinaryOperatorKind operator, final String left, final String right)
|
||||
throws ExpressionVisitException {
|
||||
|
||||
return "<" + left + " " + operator.toString() + " " + right + ">";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitUnaryOperator(final SupportedUnaryOperators operator, final String operand)
|
||||
throws ExceptionVisitExpression {
|
||||
public String visitUnaryOperator(final UnaryOperatorKind operator, final String operand)
|
||||
throws ExpressionVisitException {
|
||||
|
||||
return "<" + operator + " " + operand.toString() + ">";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitMethodCall(final SupportedMethodCalls methodCall, final List<String> parameters)
|
||||
throws ExceptionVisitExpression {
|
||||
public String visitMethodCall(final MethodCallKind methodCall, final List<String> parameters)
|
||||
throws ExpressionVisitException {
|
||||
|
||||
String text = "<" + methodCall + "(";
|
||||
int i = 0;
|
||||
|
@ -83,12 +82,12 @@ public class FilterTreeToText implements ExpressionVisitor<String> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String visitLiteral(final String literal) throws ExceptionVisitExpression {
|
||||
public String visitLiteral(final String literal) throws ExpressionVisitException {
|
||||
return "<" + literal + ">";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitMember(final UriInfoResource resource) throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public String visitMember(final UriInfoResource resource) throws ExpressionVisitException, ODataApplicationException {
|
||||
String ret = "";
|
||||
|
||||
UriInfoResource path = resource;
|
||||
|
@ -100,7 +99,6 @@ public class FilterTreeToText implements ExpressionVisitor<String> {
|
|||
tmp = visitLambdaExpression("ALL", all.getLamdaVariable(), all.getExpression());
|
||||
} else if (item instanceof UriResourceLambdaAny) {
|
||||
UriResourceLambdaAny any = (UriResourceLambdaAny) item;
|
||||
// TODO create enum
|
||||
tmp = visitLambdaExpression("ANY", any.getLamdaVariable(), any.getExpression());
|
||||
} else if (item instanceof UriResourcePartTyped) {
|
||||
UriResourcePartTyped typed = (UriResourcePartTyped) item;
|
||||
|
@ -117,13 +115,13 @@ public class FilterTreeToText implements ExpressionVisitor<String> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String visitAlias(final String referenceName) throws ExceptionVisitExpression {
|
||||
public String visitAlias(final String referenceName) throws ExpressionVisitException {
|
||||
return "<" + referenceName + ">";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitLambdaExpression(final String functionText, final String string, final Expression expression)
|
||||
throws ExceptionVisitExpression, ODataApplicationException {
|
||||
throws ExpressionVisitException, ODataApplicationException {
|
||||
|
||||
return "<" + functionText + ";" + ((expression == null) ? "" : expression.accept(this)) + ">";
|
||||
}
|
||||
|
@ -140,7 +138,7 @@ public class FilterTreeToText implements ExpressionVisitor<String> {
|
|||
|
||||
@Override
|
||||
public String visitEnum(final EdmEnumType type, final List<String> enumValues)
|
||||
throws ExceptionVisitExpression, ODataApplicationException {
|
||||
throws ExpressionVisitException, ODataApplicationException {
|
||||
String tmp = "";
|
||||
|
||||
for (String item : enumValues) {
|
||||
|
@ -153,10 +151,4 @@ public class FilterTreeToText implements ExpressionVisitor<String> {
|
|||
return "<" + type.getNamespace() + "." + type.getName() + "<" + tmp + ">>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitConstant(final SupportedConstants kind)
|
||||
throws ExceptionVisitExpression, ODataApplicationException {
|
||||
// TODO Auto-generated method stub
|
||||
return "<" + kind.toString() + ">";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,12 +29,11 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
|
|||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.server.api.uri.UriInfo;
|
||||
import org.apache.olingo.odata4.server.api.uri.UriInfoKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Expression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.Member;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedBinaryOperators;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedConstants;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedMethodCalls;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind;
|
||||
import org.apache.olingo.odata4.server.core.uri.UriParserException;
|
||||
import org.apache.olingo.odata4.server.core.uri.UriParserSemanticException;
|
||||
import org.apache.olingo.odata4.server.core.uri.UriParserSyntaxException;
|
||||
|
@ -43,7 +42,6 @@ import org.apache.olingo.odata4.server.core.uri.parser.Parser;
|
|||
import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.BinaryImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.ConstantImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.EnumerationImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.LiteralImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.MemberImpl;
|
||||
|
@ -64,7 +62,7 @@ public class FilterValidator implements Validator {
|
|||
private UriParserException exception;
|
||||
|
||||
// --- Setup ---
|
||||
public FilterValidator setUriResourcePathValidator(final UriResourceValidator uriResourcePathValidator) {
|
||||
public FilterValidator setUriResourcePathValidator(final ResourceValidator uriResourcePathValidator) {
|
||||
invokedByValidator = uriResourcePathValidator;
|
||||
return this;
|
||||
}
|
||||
|
@ -74,6 +72,11 @@ public class FilterValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public FilterValidator setValidator(final Validator uriValidator) {
|
||||
invokedByValidator = uriValidator;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterValidator setEdm(final Edm edm) {
|
||||
this.edm = edm;
|
||||
return this;
|
||||
|
@ -118,14 +121,17 @@ public class FilterValidator implements Validator {
|
|||
}
|
||||
|
||||
public FilterValidator runOnETTwoKeyNav(final String filter) throws UriParserException {
|
||||
// TODO change to ESTwoKeyNav
|
||||
String uri = "ESTwoKeyNav?$filter=" + filter.trim();
|
||||
return runUri(uri);
|
||||
}
|
||||
|
||||
public FilterValidator runOnETTwoKeyNavSingle(final String filter) throws UriParserException {
|
||||
String uri = "SINav?$filter=" + filter.trim();
|
||||
return runUri(uri);
|
||||
}
|
||||
|
||||
public FilterValidator runOnETTwoKeyNavEx(final String filter) throws UriParserException {
|
||||
// TODO change to ESTwoKeyNav
|
||||
String uri = "SINav?$filter=" + filter.trim();
|
||||
String uri = "ESTwoKeyNav?$filter=" + filter.trim();
|
||||
return runUriEx(uri);
|
||||
}
|
||||
|
||||
|
@ -249,27 +255,31 @@ public class FilterValidator implements Validator {
|
|||
|
||||
// --- Navigation ---
|
||||
|
||||
public Validator goUp() {
|
||||
return invokedByValidator;
|
||||
public ExpandValidator goUpToExpandValidator() {
|
||||
return (ExpandValidator) invokedByValidator;
|
||||
}
|
||||
|
||||
public UriResourceValidator goPath() {
|
||||
public ResourceValidator goUpToResourceValidator() {
|
||||
return (ResourceValidator) invokedByValidator;
|
||||
}
|
||||
|
||||
public ResourceValidator goPath() {
|
||||
if (!(curExpression instanceof MemberImpl)) {
|
||||
fail("Current expression not a member");
|
||||
}
|
||||
|
||||
MemberImpl member = (MemberImpl) curExpression;
|
||||
UriResourceValidator uriValidator = new UriResourceValidator();
|
||||
uriValidator.setEdm(edm);
|
||||
uriValidator.setUriInfoImplPath((UriInfoImpl) member.getPath());
|
||||
uriValidator.setUpValidator(this);
|
||||
return uriValidator;
|
||||
|
||||
return new ResourceValidator()
|
||||
.setEdm(edm)
|
||||
.setUriInfoImplPath((UriInfoImpl) member.getPath())
|
||||
.setUpValidator(this);
|
||||
|
||||
}
|
||||
|
||||
public FilterValidator goParameter(final int parameterIndex) {
|
||||
if (curExpression instanceof MethodCallImpl) {
|
||||
MethodCallImpl methodCall = (MethodCallImpl) curExpression;
|
||||
|
||||
curExpression = methodCall.getParameters().get(parameterIndex);
|
||||
} else {
|
||||
fail("Current expression not a methodCall");
|
||||
|
@ -293,7 +303,7 @@ public class FilterValidator implements Validator {
|
|||
try {
|
||||
String actualFilterAsText = FilterTreeToText.Serialize((FilterOptionImpl) filter);
|
||||
assertEquals(expectedFilterAsString, actualFilterAsText);
|
||||
} catch (ExceptionVisitExpression e) {
|
||||
} catch (ExpressionVisitException e) {
|
||||
fail("Exception occured while converting the filterTree into text" + "\n"
|
||||
+ " Exception: " + e.getMessage());
|
||||
} catch (ODataApplicationException e) {
|
||||
|
@ -375,7 +385,7 @@ public class FilterValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public FilterValidator isMethod(final SupportedMethodCalls methodKind, final int parameterCount) {
|
||||
public FilterValidator isMethod(final MethodCallKind methodKind, final int parameterCount) {
|
||||
if (!(curExpression instanceof MethodCallImpl)) {
|
||||
fail("Current expression is not a methodCall");
|
||||
}
|
||||
|
@ -388,7 +398,7 @@ public class FilterValidator implements Validator {
|
|||
}
|
||||
|
||||
public FilterValidator isParameterText(final int parameterIndex, final String parameterText)
|
||||
throws ExceptionVisitExpression, ODataApplicationException {
|
||||
throws ExpressionVisitException, ODataApplicationException {
|
||||
|
||||
if (!(curExpression instanceof MethodCallImpl)) {
|
||||
fail("Current expression is not a method");
|
||||
|
@ -403,7 +413,7 @@ public class FilterValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public FilterValidator isBinary(final SupportedBinaryOperators binaryOperator) {
|
||||
public FilterValidator isBinary(final BinaryOperatorKind binaryOperator) {
|
||||
if (!(curExpression instanceof BinaryImpl)) {
|
||||
fail("Current expression is not a binary operator");
|
||||
}
|
||||
|
@ -455,16 +465,6 @@ public class FilterValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public FilterValidator isConstant(final SupportedConstants kind) {
|
||||
if (!(curExpression instanceof ConstantImpl)) {
|
||||
fail("Current expression not a constant");
|
||||
}
|
||||
|
||||
assertEquals(kind, ((ConstantImpl) curExpression).getKind());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterValidator isSortOrder(final int index, final boolean descending) {
|
||||
assertEquals(descending, orderBy.getOrders().get(index).isDescending());
|
||||
return this;
|
||||
|
@ -485,4 +485,34 @@ public class FilterValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public FilterValidator isNull() {
|
||||
if (!(curExpression instanceof LiteralImpl)) {
|
||||
fail("Current expression is not a literal");
|
||||
}
|
||||
|
||||
String actualLiteralText = ((LiteralImpl) curExpression).getText();
|
||||
assertEquals("null", actualLiteralText);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterValidator isTrue() {
|
||||
if (!(curExpression instanceof LiteralImpl)) {
|
||||
fail("Current expression is not a literal");
|
||||
}
|
||||
|
||||
String actualLiteralText = ((LiteralImpl) curExpression).getText();
|
||||
assertEquals("true", actualLiteralText);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FilterValidator isFalse() {
|
||||
if (!(curExpression instanceof LiteralImpl)) {
|
||||
fail("Current expression is not a literal");
|
||||
}
|
||||
|
||||
String actualLiteralText = ((LiteralImpl) curExpression).getText();
|
||||
assertEquals("false", actualLiteralText);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,14 +19,15 @@
|
|||
package org.apache.olingo.odata4.server.core.testutil;
|
||||
|
||||
import org.antlr.v4.runtime.DefaultErrorStrategy;
|
||||
import org.antlr.v4.runtime.DiagnosticErrorListener;
|
||||
import org.apache.olingo.odata4.server.core.uri.antlr.UriParserParser;
|
||||
import org.apache.olingo.odata4.server.core.uri.parser.Parser;
|
||||
|
||||
public class ParserTest extends Parser {
|
||||
public class ParserWithLogging extends Parser {
|
||||
TestErrorLogger errorCollector1;
|
||||
TestErrorLogger errorCollector2;
|
||||
|
||||
public ParserTest() {
|
||||
public ParserWithLogging() {
|
||||
errorCollector1 = new TestErrorLogger("Stage 1", 1);
|
||||
errorCollector2 = new TestErrorLogger("Stage 2", 1);
|
||||
}
|
||||
|
@ -42,6 +43,7 @@ public class ParserTest extends Parser {
|
|||
// Log error to console
|
||||
parser.removeErrorListeners();
|
||||
parser.addErrorListener(errorCollector1);
|
||||
parser.addErrorListener(new DiagnosticErrorListener());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,5 +51,6 @@ public class ParserTest extends Parser {
|
|||
// Log error to console
|
||||
parser.removeErrorListeners();
|
||||
parser.addErrorListener(errorCollector2);
|
||||
parser.addErrorListener(new DiagnosticErrorListener());
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ import org.apache.olingo.odata4.server.api.uri.UriResourceKind;
|
|||
import org.apache.olingo.odata4.server.api.uri.UriResourcePartTyped;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.CustomQueryOption;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.SelectItem;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.core.uri.UriParserException;
|
||||
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceActionImpl;
|
||||
|
@ -55,7 +55,7 @@ import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl;
|
|||
import org.apache.olingo.odata4.server.core.uri.queryoption.SelectOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.ExpressionImpl;
|
||||
|
||||
public class UriResourceValidator implements Validator {
|
||||
public class ResourceValidator implements Validator {
|
||||
private Edm edm;
|
||||
private Validator invokedBy;
|
||||
private UriInfo uriInfo = null;
|
||||
|
@ -65,17 +65,17 @@ public class UriResourceValidator implements Validator {
|
|||
|
||||
// --- Setup ---
|
||||
|
||||
public UriResourceValidator setUpValidator(final Validator uriValidator) {
|
||||
public ResourceValidator setUpValidator(final Validator uriValidator) {
|
||||
invokedBy = uriValidator;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator setEdm(final Edm edm) {
|
||||
public ResourceValidator setEdm(final Edm edm) {
|
||||
this.edm = edm;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator setUriInfoImplPath(final UriInfoImpl uriInfoPath) {
|
||||
public ResourceValidator setUriInfoImplPath(final UriInfoImpl uriInfoPath) {
|
||||
uriInfo = uriInfoPath;
|
||||
last();
|
||||
return this;
|
||||
|
@ -83,16 +83,16 @@ public class UriResourceValidator implements Validator {
|
|||
|
||||
// --- Execution ---
|
||||
|
||||
public UriResourceValidator run(final String uri) {
|
||||
ParserTest testParser = new ParserTest();
|
||||
// testParser.setLogLevel(1);
|
||||
public ResourceValidator run(final String uri) {
|
||||
ParserWithLogging testParser = new ParserWithLogging();
|
||||
|
||||
UriInfoImpl uriInfoTmp = null;
|
||||
uriPathInfo = null;
|
||||
try {
|
||||
uriInfoTmp = (UriInfoImpl) testParser.parseUri(uri, edm);
|
||||
} catch (UriParserException e) {
|
||||
fail("Exception occured while parsing the URI: " + uri + "\n"
|
||||
+ " Exception: " + e.getMessage());
|
||||
+ " Message: " + e.getMessage());
|
||||
}
|
||||
|
||||
if (uriInfoTmp.getKind() != UriInfoKind.resource) {
|
||||
|
@ -118,24 +118,98 @@ public class UriResourceValidator implements Validator {
|
|||
return (FilterValidator) invokedBy;
|
||||
}
|
||||
|
||||
public FilterValidator goParameter(final int index) {
|
||||
assertEquals(UriResourceKind.function, uriPathInfo.getKind());
|
||||
UriResourceFunctionImpl function = (UriResourceFunctionImpl) uriPathInfo;
|
||||
|
||||
return new FilterValidator()
|
||||
.setEdm(edm)
|
||||
.setExpression(function.getParameters().get(index).getExression())
|
||||
.setValidator(this);
|
||||
}
|
||||
|
||||
public FilterValidator goLambdaExpression() {
|
||||
if (uriPathInfo.getKind() == UriResourceKind.lambdaAll) {
|
||||
FilterValidator val = new FilterValidator();
|
||||
val.setEdm(edm);
|
||||
val.setExpression(((UriResourceLambdaAllImpl) uriPathInfo).getExpression());
|
||||
return (val);
|
||||
return new FilterValidator()
|
||||
.setEdm(edm)
|
||||
.setExpression(((UriResourceLambdaAllImpl) uriPathInfo).getExpression());
|
||||
|
||||
} else if (uriPathInfo.getKind() == UriResourceKind.lambdaAny) {
|
||||
FilterValidator val = new FilterValidator();
|
||||
val.setEdm(edm);
|
||||
val.setExpression(((UriResourceLambdaAnyImpl) uriPathInfo).getExpression());
|
||||
return (val);
|
||||
return new FilterValidator()
|
||||
.setEdm(edm)
|
||||
.setExpression(((UriResourceLambdaAnyImpl) uriPathInfo).getExpression());
|
||||
} else {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public UriResourceValidator isLambdaVar(final String var) {
|
||||
public ResourceValidator goSelectItem(final int index) {
|
||||
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
|
||||
|
||||
SelectItem item = select.getSelectItems().get(index);
|
||||
UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourceInfo();
|
||||
|
||||
return new ResourceValidator()
|
||||
.setUpValidator(this)
|
||||
.setEdm(edm)
|
||||
.setUriInfoImplPath(uriInfo1);
|
||||
|
||||
}
|
||||
|
||||
public ExpandValidator goExpand() {
|
||||
ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption();
|
||||
if (expand == null) {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
}
|
||||
|
||||
return new ExpandValidator().setUpValidator(this).setExpand(expand);
|
||||
}
|
||||
|
||||
public ResourceValidator first() {
|
||||
uriResourceIndex = 0;
|
||||
uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(0);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResourceValidator last() {
|
||||
uriResourceIndex = 0;
|
||||
|
||||
try {
|
||||
uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
|
||||
uriResourceIndex = uriInfo.getUriResourceParts().size() - 1;
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
fail("not enough segments");
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResourceValidator n() {
|
||||
uriResourceIndex++;
|
||||
|
||||
try {
|
||||
uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriResourceIndex);
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
fail("not enough segments");
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResourceValidator at(final int index) {
|
||||
uriResourceIndex = index;
|
||||
try {
|
||||
uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(index);
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
fail("not enough segments");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// --- Validation ---
|
||||
|
||||
public ResourceValidator isLambdaVar(final String var) {
|
||||
String actualVar = null;
|
||||
if (uriPathInfo.getKind() == UriResourceKind.lambdaAll) {
|
||||
actualVar = ((UriResourceLambdaAllImpl) uriPathInfo).getLamdaVariable();
|
||||
|
@ -149,72 +223,7 @@ public class UriResourceValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator goSelectItemPath(final int index) {
|
||||
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
|
||||
|
||||
SelectItem item = select.getSelectItems().get(index);
|
||||
UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourceInfo();
|
||||
|
||||
return new UriResourceValidator()
|
||||
.setUpValidator(this)
|
||||
.setEdm(edm)
|
||||
.setUriInfoImplPath(uriInfo1);
|
||||
|
||||
}
|
||||
|
||||
public ExpandValidator goExpand() {
|
||||
ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption();
|
||||
if (expand == null) {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
}
|
||||
|
||||
return new ExpandValidator().setGoUpValidator(this).setExpand(expand);
|
||||
}
|
||||
|
||||
public UriResourceValidator first() {
|
||||
uriResourceIndex = 0;
|
||||
uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(0);
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator last() {
|
||||
uriResourceIndex = 0;
|
||||
|
||||
try {
|
||||
uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriInfo.getUriResourceParts().size() - 1);
|
||||
uriResourceIndex = uriInfo.getUriResourceParts().size() - 1;
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
fail("not enough segments");
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator n() {
|
||||
uriResourceIndex++;
|
||||
|
||||
try {
|
||||
uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(uriResourceIndex);
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
fail("not enough segments");
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator at(final int index) {
|
||||
uriResourceIndex = index;
|
||||
try {
|
||||
uriPathInfo = (UriResourceImpl) uriInfo.getUriResourceParts().get(index);
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
fail("not enough segments");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// --- Validation ---
|
||||
|
||||
public UriResourceValidator isTypeFilter(final FullQualifiedName expectedType) {
|
||||
public ResourceValidator isTypeFilter(final FullQualifiedName expectedType) {
|
||||
|
||||
if (uriPathInfo.getKind() != UriResourceKind.complexProperty &&
|
||||
uriPathInfo.getKind() != UriResourceKind.singleton &&
|
||||
|
@ -239,7 +248,7 @@ public class UriResourceValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isType(final FullQualifiedName type) {
|
||||
public ResourceValidator isType(final FullQualifiedName type) {
|
||||
if (!(uriPathInfo instanceof UriResourcePartTyped)) {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
}
|
||||
|
@ -257,13 +266,13 @@ public class UriResourceValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isType(final FullQualifiedName type, final boolean isFinallyACollection) {
|
||||
public ResourceValidator isType(final FullQualifiedName type, final boolean isFinallyACollection) {
|
||||
isType(type);
|
||||
assertEquals(isFinallyACollection, ((UriResourcePartTyped) uriPathInfo).isCollection());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isTypeFilterOnEntry(final FullQualifiedName type) {
|
||||
public ResourceValidator isTypeFilterOnEntry(final FullQualifiedName type) {
|
||||
if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
}
|
||||
|
@ -281,7 +290,7 @@ public class UriResourceValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isTypeFilterOnCollection(final FullQualifiedName expectedType) {
|
||||
public ResourceValidator isTypeFilterOnCollection(final FullQualifiedName expectedType) {
|
||||
if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
}
|
||||
|
@ -300,7 +309,7 @@ public class UriResourceValidator implements Validator {
|
|||
}
|
||||
|
||||
// other functions
|
||||
public UriResourceValidator checkCustomParameter(final int index, final String name, final String value) {
|
||||
public ResourceValidator checkCustomParameter(final int index, final String name, final String value) {
|
||||
if (uriInfo == null) {
|
||||
fail("hasQueryParameter: uriInfo == null");
|
||||
}
|
||||
|
@ -317,7 +326,7 @@ public class UriResourceValidator implements Validator {
|
|||
}
|
||||
|
||||
// TODO remove
|
||||
public UriResourceValidator isCollection(final boolean isCollection) {
|
||||
public ResourceValidator isCollection(final boolean isCollection) {
|
||||
if (!(uriPathInfo instanceof UriResourcePartTyped)) {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
}
|
||||
|
@ -331,13 +340,13 @@ public class UriResourceValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isFilterString(final String expectedFilterTreeAsString) {
|
||||
public ResourceValidator isFilterString(final String expectedFilterTreeAsString) {
|
||||
|
||||
ExpressionImpl filterTree = (ExpressionImpl) uriInfo.getFilterOption().getExpression();
|
||||
try {
|
||||
String filterTreeAsString = filterTree.accept(new FilterTreeToText());
|
||||
assertEquals(expectedFilterTreeAsString, filterTreeAsString);
|
||||
} catch (ExceptionVisitExpression e) {
|
||||
} catch (ExpressionVisitException e) {
|
||||
fail("isFilterString: Exception " + e.getMessage() + " occured");
|
||||
} catch (ODataApplicationException e) {
|
||||
fail("isFilterString: Exception " + e.getMessage() + " occured");
|
||||
|
@ -346,7 +355,7 @@ public class UriResourceValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isKeyPredicateRef(final int index, final String name, final String refencedProperty) {
|
||||
public ResourceValidator isKeyPredicateRef(final int index, final String name, final String refencedProperty) {
|
||||
if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
}
|
||||
|
@ -359,7 +368,7 @@ public class UriResourceValidator implements Validator {
|
|||
|
||||
}
|
||||
|
||||
public UriResourceValidator isKeyPredicate(final int index, final String name, final String text) {
|
||||
public ResourceValidator isKeyPredicate(final int index, final String name, final String text) {
|
||||
if (!(uriPathInfo instanceof UriResourceWithKeysImpl)) {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
}
|
||||
|
@ -372,7 +381,7 @@ public class UriResourceValidator implements Validator {
|
|||
|
||||
}
|
||||
|
||||
public UriResourceValidator isParameter(final int index, final String name, final String text) {
|
||||
public ResourceValidator isParameter(final int index, final String name, final String text) {
|
||||
if (!(uriPathInfo instanceof UriResourceFunctionImpl)) {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
}
|
||||
|
@ -385,7 +394,7 @@ public class UriResourceValidator implements Validator {
|
|||
|
||||
}
|
||||
|
||||
public UriResourceValidator isParameterAlias(final int index, final String name, final String alias) {
|
||||
public ResourceValidator isParameterAlias(final int index, final String name, final String alias) {
|
||||
if (!(uriPathInfo instanceof UriResourceFunctionImpl)) {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
}
|
||||
|
@ -398,12 +407,12 @@ public class UriResourceValidator implements Validator {
|
|||
|
||||
}
|
||||
|
||||
public UriResourceValidator isKind(final UriInfoKind kind) {
|
||||
public ResourceValidator isKind(final UriInfoKind kind) {
|
||||
assertEquals(kind, uriInfo.getKind());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isPrimitiveProperty(final String name,
|
||||
public ResourceValidator isPrimitiveProperty(final String name,
|
||||
final FullQualifiedName type, final boolean isCollection) {
|
||||
if (!(uriPathInfo instanceof UriResourcePrimitivePropertyImpl)) {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
|
@ -419,8 +428,8 @@ public class UriResourceValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isComplexProperty(final String name, final FullQualifiedName type,
|
||||
final boolean isCollection) {
|
||||
public ResourceValidator
|
||||
isComplexProperty(final String name, final FullQualifiedName type, final boolean isCollection) {
|
||||
if (!(uriPathInfo instanceof UriResourceComplexPropertyImpl)) {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
}
|
||||
|
@ -435,8 +444,7 @@ public class UriResourceValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator
|
||||
isNavProperty(final String name, final FullQualifiedName type, final boolean isCollection) {
|
||||
public ResourceValidator isNavProperty(final String name, final FullQualifiedName type, final boolean isCollection) {
|
||||
if (!(uriPathInfo instanceof UriResourceNavigationPropertyImpl)) {
|
||||
fail("invalid resource kind: " + uriPathInfo.getKind().toString());
|
||||
}
|
||||
|
@ -451,100 +459,100 @@ public class UriResourceValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isUriPathInfoKind(final UriResourceKind infoType) {
|
||||
public ResourceValidator isUriPathInfoKind(final UriResourceKind infoType) {
|
||||
assertNotNull(uriPathInfo);
|
||||
assertEquals(infoType, uriPathInfo.getKind());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isAction(final String name) {
|
||||
public ResourceValidator isAction(final String name) {
|
||||
assertEquals(UriResourceKind.action, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceActionImpl) uriPathInfo).getAction().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isFunction(final String name) {
|
||||
public ResourceValidator isFunction(final String name) {
|
||||
assertEquals(UriResourceKind.function, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunction().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isFunctionImport(final String name) {
|
||||
public ResourceValidator isFunctionImport(final String name) {
|
||||
assertEquals(UriResourceKind.function, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunctionImport().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isEntitySet(final String name) {
|
||||
public ResourceValidator isEntitySet(final String name) {
|
||||
assertEquals(UriResourceKind.entitySet, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceEntitySetImpl) uriPathInfo).getEntitySet().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isComplex(final String name) {
|
||||
public ResourceValidator isComplex(final String name) {
|
||||
assertEquals(UriResourceKind.complexProperty, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceComplexPropertyImpl) uriPathInfo).getProperty().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isSingleton(final String name) {
|
||||
public ResourceValidator isSingleton(final String name) {
|
||||
assertEquals(UriResourceKind.singleton, uriPathInfo.getKind());
|
||||
assertEquals(name, ((UriResourceSingletonImpl) uriPathInfo).getSingleton().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isValue() {
|
||||
public ResourceValidator isValue() {
|
||||
assertEquals(UriResourceKind.value, uriPathInfo.getKind());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isCount() {
|
||||
public ResourceValidator isCount() {
|
||||
assertEquals(UriResourceKind.count, uriPathInfo.getKind());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isRef() {
|
||||
public ResourceValidator isRef() {
|
||||
assertEquals(UriResourceKind.ref, uriPathInfo.getKind());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isActionImport(final String actionName) {
|
||||
public ResourceValidator isActionImport(final String actionName) {
|
||||
assertEquals(UriResourceKind.action, uriPathInfo.getKind());
|
||||
assertEquals(actionName, ((UriResourceActionImpl) uriPathInfo).getActionImport().getName());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isIt() {
|
||||
public ResourceValidator isIt() {
|
||||
assertEquals(UriResourceKind.it, uriPathInfo.getKind());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isTopText(final String topText) {
|
||||
public ResourceValidator isTopText(final String topText) {
|
||||
assertEquals(topText, uriInfo.getTopOption().getText());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isFormatText(final String formatText) {
|
||||
public ResourceValidator isFormatText(final String formatText) {
|
||||
assertEquals(formatText, uriInfo.getFormatOption().getText());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isInlineCountText(final String inlineCountText) {
|
||||
public ResourceValidator isInlineCountText(final String inlineCountText) {
|
||||
assertEquals(inlineCountText, uriInfo.getInlineCountOption().getText());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isSkipText(final String skipText) {
|
||||
public ResourceValidator isSkipText(final String skipText) {
|
||||
assertEquals(skipText, uriInfo.getSkipOption().getText());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isSkipTokenText(final String skipTokenText) {
|
||||
public ResourceValidator isSkipTokenText(final String skipTokenText) {
|
||||
assertEquals(skipTokenText, uriInfo.getSkipTokenOption().getText());
|
||||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isSelectItemStar(final int index) {
|
||||
public ResourceValidator isSelectItemStar(final int index) {
|
||||
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
|
||||
|
||||
SelectItem item = select.getSelectItems().get(index);
|
||||
|
@ -552,7 +560,7 @@ public class UriResourceValidator implements Validator {
|
|||
return this;
|
||||
}
|
||||
|
||||
public UriResourceValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) {
|
||||
public ResourceValidator isSelectItemAllOp(final int index, final FullQualifiedName fqn) {
|
||||
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
|
||||
|
||||
SelectItem item = select.getSelectItems().get(index);
|
|
@ -28,6 +28,7 @@ import org.antlr.v4.runtime.RecognitionException;
|
|||
import org.antlr.v4.runtime.Recognizer;
|
||||
import org.antlr.v4.runtime.atn.ATNConfigSet;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
import org.apache.olingo.odata4.server.core.uri.antlr.UriLexer;
|
||||
|
||||
class TestErrorLogger implements ANTLRErrorListener {
|
||||
|
||||
|
@ -44,7 +45,6 @@ class TestErrorLogger implements ANTLRErrorListener {
|
|||
final int charPositionInLine,
|
||||
final String msg, final RecognitionException e) {
|
||||
|
||||
// Collect the exception
|
||||
if (logLevel > 0) {
|
||||
System.out.println("\n" + prefix + " -- SyntaxError");
|
||||
trace(recognizer, offendingSymbol, line, charPositionInLine, msg, e);
|
||||
|
@ -57,64 +57,22 @@ class TestErrorLogger implements ANTLRErrorListener {
|
|||
final boolean exact,
|
||||
final BitSet ambigAlts, final ATNConfigSet configs) {
|
||||
|
||||
/*
|
||||
* if (tokenValidator.logLevel > 0) {
|
||||
* System.out.println("reportAmbiguity: ");
|
||||
* System.out.println(" ambigAlts: " + ambigAlts);
|
||||
* System.out.println(" configs: " + configs);
|
||||
* System.out.println(" input: " + recognizer.getTokenStream().getText(Interval.of(startIndex, stopIndex)));
|
||||
* }
|
||||
*/
|
||||
/*
|
||||
* if (!tokenValidator.allowAmbiguity) {
|
||||
* printStack(recognizer);
|
||||
* fail("reportAmbiguity");
|
||||
* }
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportAttemptingFullContext(final Parser recognizer, final DFA dfa, final int startIndex,
|
||||
final int stopIndex,
|
||||
final BitSet conflictingAlts, final ATNConfigSet configs) {
|
||||
/*
|
||||
* // The grammar should be written in order to avoid attempting a full context parse because its negative
|
||||
* // impact on the performance, so trace and stop here
|
||||
* if (tokenValidator.logLevel > 0) {
|
||||
* System.out.println("allowed AttemptingFullContext");
|
||||
* }
|
||||
*
|
||||
* if (!tokenValidator.allowFullContext) {
|
||||
* printStack(recognizer);
|
||||
* fail("reportAttemptingFullContext");
|
||||
* }
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reportContextSensitivity(final Parser recognizer, final DFA dfa, final int startIndex,
|
||||
final int stopIndex, final int prediction,
|
||||
final ATNConfigSet configs) {
|
||||
/*
|
||||
* if (tokenValidator.logLevel > 0) {
|
||||
* System.out.println("allowed ContextSensitivity");
|
||||
* }
|
||||
*
|
||||
* if (!tokenValidator.allowContextSensitifity) {
|
||||
* printStack(recognizer);
|
||||
* fail("reportContextSensitivity");
|
||||
* }
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* private void printStack(final Parser recognizer) {
|
||||
* List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
|
||||
* Collections.reverse(stack);
|
||||
*
|
||||
* System.out.println(" Rule stack: " + stack);
|
||||
* }
|
||||
*/
|
||||
private void printStack(final Recognizer<?, ?> recognizer) {
|
||||
List<String> stack = ((Parser) recognizer).getRuleInvocationStack();
|
||||
Collections.reverse(stack);
|
||||
|
@ -125,50 +83,23 @@ class TestErrorLogger implements ANTLRErrorListener {
|
|||
final int line, final int charPositionInLine, final String msg, final RecognitionException e) {
|
||||
|
||||
System.out.println("Error message: " + msg);
|
||||
// TODO check also http://stackoverflow.com/questions/14747952/ll-exact-ambig-detection-interpetation
|
||||
|
||||
printStack(recognizer);
|
||||
|
||||
System.out.println(" line/char :" + line + " / " + charPositionInLine);
|
||||
System.out.println(" sym :" + offendingSymbol);
|
||||
if (e != null && e.getOffendingToken() != null) {
|
||||
|
||||
// String lexerTokenName = TestSuiteLexer.tokenNames[e.getOffendingToken().getType()];
|
||||
String lexerTokenName = "";
|
||||
try {
|
||||
// TODO check how the Lexer is accessed in the new package structure
|
||||
// lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()];
|
||||
lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()];
|
||||
} catch (ArrayIndexOutOfBoundsException es) {
|
||||
lexerTokenName = "token error";
|
||||
}
|
||||
System.out.println(" line " + line + ":" + charPositionInLine + " at " +
|
||||
offendingSymbol + "/" + lexerTokenName + ": " + msg);
|
||||
} else {
|
||||
System.out.println(" line " + line + ":" + charPositionInLine + " at " + offendingSymbol + ": " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getDecisionRule(final Recognizer<?, ?> recognizer, final int decision) {
|
||||
if (recognizer == null || decision < 0) {
|
||||
return -1;
|
||||
System.out.println(" tokenname:" + lexerTokenName);
|
||||
}
|
||||
|
||||
if (decision >= recognizer.getATN().decisionToState.size()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return recognizer.getATN().decisionToState.get(decision).ruleIndex;
|
||||
}
|
||||
|
||||
public static String getRuleDisplayName(final Recognizer<?, ?> recognizer, final int ruleIndex) {
|
||||
if (recognizer == null || ruleIndex < 0) {
|
||||
return Integer.toString(ruleIndex);
|
||||
}
|
||||
|
||||
String[] ruleNames = recognizer.getRuleNames();
|
||||
if (ruleIndex < 0 || ruleIndex >= ruleNames.length) {
|
||||
return Integer.toString(ruleIndex);
|
||||
}
|
||||
|
||||
return ruleNames[ruleIndex];
|
||||
}
|
||||
|
||||
}
|
|
@ -72,7 +72,7 @@ public class UriValidator implements Validator {
|
|||
try {
|
||||
// uriInfoTmp = new UriParserImpl(edm).ParseUri(uri);
|
||||
uriInfo = (UriInfoImpl) parser.parseUri(uri, edm);
|
||||
|
||||
fail("Exception expected");
|
||||
} catch (UriParserException e) {
|
||||
exception = e;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class UriValidator implements Validator {
|
|||
}
|
||||
|
||||
public UriValidator log(final String uri) {
|
||||
ParserTest parserTest = new ParserTest();
|
||||
ParserWithLogging parserTest = new ParserWithLogging();
|
||||
parserTest.setLogLevel(1);
|
||||
uriInfo = null;
|
||||
try {
|
||||
|
@ -96,12 +96,12 @@ public class UriValidator implements Validator {
|
|||
}
|
||||
|
||||
// Navigation
|
||||
public UriResourceValidator goPath() {
|
||||
public ResourceValidator goPath() {
|
||||
if (uriInfo.getKind() != UriInfoKind.resource) {
|
||||
fail("invalid resource kind: " + uriInfo.getKind().toString());
|
||||
}
|
||||
|
||||
return new UriResourceValidator()
|
||||
return new ResourceValidator()
|
||||
.setUpValidator(this)
|
||||
.setEdm(edm)
|
||||
.setUriInfoImplPath(uriInfo);
|
||||
|
@ -122,16 +122,16 @@ public class UriValidator implements Validator {
|
|||
fail("invalid resource kind: " + uriInfo.getKind().toString());
|
||||
}
|
||||
|
||||
return new ExpandValidator().setGoUpValidator(this).setExpand(expand);
|
||||
return new ExpandValidator().setUpValidator(this).setExpand(expand);
|
||||
}
|
||||
|
||||
public UriResourceValidator goSelectItemPath(final int index) {
|
||||
public ResourceValidator goSelectItemPath(final int index) {
|
||||
SelectOptionImpl select = (SelectOptionImpl) uriInfo.getSelectOption();
|
||||
|
||||
SelectItem item = select.getSelectItems().get(index);
|
||||
UriInfoImpl uriInfo1 = (UriInfoImpl) item.getResourceInfo();
|
||||
|
||||
return new UriResourceValidator()
|
||||
return new ResourceValidator()
|
||||
.setUpValidator(this)
|
||||
.setEdm(edm)
|
||||
.setUriInfoImplPath(uriInfo1);
|
||||
|
|
|
@ -41,12 +41,12 @@ import org.apache.olingo.odata4.server.core.testutil.EdmTechTestProvider;
|
|||
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceActionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriResourceEntitySetImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.CountOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.CustomQueryOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.ExpandOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.FilterOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.FormatOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.IdOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.InlineCountOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.LevelsOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.OrderByOptionImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.QueryOptionImpl;
|
||||
|
@ -135,7 +135,7 @@ public class UriInfoImplTest {
|
|||
FilterOptionImpl filter = new FilterOptionImpl();
|
||||
FormatOptionImpl format = new FormatOptionImpl();
|
||||
IdOptionImpl id = new IdOptionImpl();
|
||||
InlineCountOptionImpl inlinecount = new InlineCountOptionImpl();
|
||||
CountOptionImpl inlinecount = new CountOptionImpl();
|
||||
OrderByOptionImpl orderby = new OrderByOptionImpl();
|
||||
SearchOptionImpl search = new SearchOptionImpl();
|
||||
SelectOptionImpl select = new SelectOptionImpl();
|
||||
|
|
|
@ -299,7 +299,6 @@ public class UriParameterImplTest {
|
|||
impl.toString(true));
|
||||
|
||||
// set entry
|
||||
// TODO remove ???
|
||||
impl = new Mock();
|
||||
impl.setType(entityType);
|
||||
impl.setEntryTypeFilter(entityTypeBaseEntry);
|
||||
|
@ -308,7 +307,6 @@ public class UriParameterImplTest {
|
|||
assertEquals("mock/com.sap.odata.test1.ETTwoBaseTwoKeyNav", impl.toString(true));
|
||||
|
||||
// set collection
|
||||
// TODO remove ???
|
||||
impl = new Mock();
|
||||
impl.setType(entityType);
|
||||
impl.setCollectionTypeFilter(entityTypeBaseColl);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -41,6 +41,7 @@ public class TestLexer {
|
|||
@Test
|
||||
public void test() {
|
||||
|
||||
// test.log(1).run("ESAllPrim?$orderby=PropertyDouble eq 3.5E+38");
|
||||
}
|
||||
|
||||
// ;------------------------------------------------------------------------------
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.apache.olingo.odata4.server.core.uri.antlr;
|
||||
|
||||
// TODO after adding the external API to the URI processing class this unit test require a mayor rework
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Arrays;
|
||||
|
@ -28,12 +26,12 @@ import org.apache.olingo.odata4.commons.api.edm.Edm;
|
|||
import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.odata4.server.api.uri.UriInfoKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.UriResourceKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedMethodCalls;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind;
|
||||
import org.apache.olingo.odata4.server.core.edm.provider.EdmProviderImpl;
|
||||
import org.apache.olingo.odata4.server.core.testutil.EdmTechProvider;
|
||||
import org.apache.olingo.odata4.server.core.testutil.EdmTechTestProvider;
|
||||
import org.apache.olingo.odata4.server.core.testutil.FilterValidator;
|
||||
import org.apache.olingo.odata4.server.core.testutil.UriResourceValidator;
|
||||
import org.apache.olingo.odata4.server.core.testutil.ResourceValidator;
|
||||
import org.apache.olingo.odata4.server.core.testutil.UriValidator;
|
||||
import org.apache.olingo.odata4.server.core.uri.UriParserException;
|
||||
import org.junit.Test;
|
||||
|
@ -60,13 +58,13 @@ public class TestUriParserImpl {
|
|||
+ "," + PropertyDateTimeOffset + "," + PropertyDuration + "," + PropertyGuid + "," + PropertyTimeOfDay;
|
||||
|
||||
UriValidator testUri = null;
|
||||
UriResourceValidator testRes = null;
|
||||
ResourceValidator testRes = null;
|
||||
FilterValidator testFilter = null;
|
||||
|
||||
public TestUriParserImpl() {
|
||||
edm = new EdmProviderImpl(new EdmTechTestProvider());
|
||||
testUri = new UriValidator().setEdm(edm);
|
||||
testRes = new UriResourceValidator().setEdm(edm);
|
||||
testRes = new ResourceValidator().setEdm(edm);
|
||||
testFilter = new FilterValidator().setEdm(edm);
|
||||
}
|
||||
|
||||
|
@ -204,10 +202,7 @@ public class TestUriParserImpl {
|
|||
.isAction("UARTETParam")
|
||||
.isType(EdmTechProvider.nameETTwoKeyTwoPrim, false);
|
||||
|
||||
// TODO add error test
|
||||
// testUri.run("AIRTPrimParam/invalidElement").isKind(UriInfoKind.resource).goPath().
|
||||
// isUriPathInfoKind(UriResourceKind.action);
|
||||
// testUri.run("InvalidAction");
|
||||
testUri.runEx("AIRTPrimParam/invalidElement").isExSemantic(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1008,7 +1003,6 @@ public class TestUriParserImpl {
|
|||
@Test
|
||||
public void testMemberStartingWithCast() {
|
||||
// on EntityType entry
|
||||
// TODO inform OTTO
|
||||
testUri.run("ESTwoKeyNav(ParameterInt16=1,PropertyString='ABC')?"
|
||||
+ "$filter=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyDate")
|
||||
.goFilter().root().isMember().goPath()
|
||||
|
@ -1036,7 +1030,7 @@ public class TestUriParserImpl {
|
|||
.isTypeFilterOnEntry(EdmTechProvider.nameCTBase)
|
||||
.at(1).isType(EdmTechProvider.nameString);
|
||||
|
||||
// on Complex collection
|
||||
// on Complex collection
|
||||
testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')?"
|
||||
+ "$filter=com.sap.odata.test1.CTBase/AdditionalPropString")
|
||||
.goFilter().root().isMember().goPath()
|
||||
|
@ -1050,9 +1044,7 @@ public class TestUriParserImpl {
|
|||
|
||||
@Test
|
||||
public void testComplexTypeCastFollowingAsCollection() {
|
||||
// TODO inform OTTO
|
||||
testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')/com.sap.odata.test1.CTBase");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1086,13 +1078,13 @@ public class TestUriParserImpl {
|
|||
// TODO sync
|
||||
testFilter.runOnETAllPrim("geo.distance(PropertySByte,PropertySByte)")
|
||||
.is("<geo.distance(<PropertySByte>,<PropertySByte>)>")
|
||||
.isMethod(SupportedMethodCalls.GEODISTANCE, 2);
|
||||
.isMethod(MethodCallKind.GEODISTANCE, 2);
|
||||
testFilter.runOnETAllPrim("geo.length(PropertySByte)")
|
||||
.is("<geo.length(<PropertySByte>)>")
|
||||
.isMethod(SupportedMethodCalls.GEOLENGTH, 1);
|
||||
.isMethod(MethodCallKind.GEOLENGTH, 1);
|
||||
testFilter.runOnETAllPrim("geo.intersects(PropertySByte,PropertySByte)")
|
||||
.is("<geo.intersects(<PropertySByte>,<PropertySByte>)>")
|
||||
.isMethod(SupportedMethodCalls.GEOINTERSECTS, 2);
|
||||
.isMethod(MethodCallKind.GEOINTERSECTS, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.apache.olingo.odata4.commons.api.edm.FullQualifiedName;
|
|||
import org.apache.olingo.odata4.server.api.uri.UriInfoResource;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions;
|
||||
import org.apache.olingo.odata4.server.core.edm.provider.EdmProviderImpl;
|
||||
import org.apache.olingo.odata4.server.core.testutil.EdmTechProvider;
|
||||
import org.apache.olingo.odata4.server.core.testutil.EdmTechTestProvider;
|
||||
import org.apache.olingo.odata4.server.core.uri.apiimpl.UriInfoImpl;
|
||||
import org.apache.olingo.odata4.server.core.uri.queryoption.expression.AliasImpl;
|
||||
|
@ -58,7 +57,7 @@ public class QueryOptionTest {
|
|||
// input options
|
||||
ExpandOptionImpl expand = new ExpandOptionImpl();
|
||||
FilterOptionImpl filter = new FilterOptionImpl();
|
||||
InlineCountOptionImpl inlinecount = new InlineCountOptionImpl();
|
||||
CountOptionImpl inlinecount = new CountOptionImpl();
|
||||
OrderByOptionImpl orderby = new OrderByOptionImpl();
|
||||
SearchOptionImpl search = new SearchOptionImpl();
|
||||
SelectOptionImpl select = new SelectOptionImpl();
|
||||
|
@ -161,7 +160,7 @@ public class QueryOptionTest {
|
|||
|
||||
@Test
|
||||
public void testInlineCountImpl() {
|
||||
InlineCountOptionImpl option = new InlineCountOptionImpl();
|
||||
CountOptionImpl option = new CountOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.INLINECOUNT, option.getKind());
|
||||
|
||||
assertEquals(false, option.getValue());
|
||||
|
@ -174,9 +173,9 @@ public class QueryOptionTest {
|
|||
LevelsOptionImpl option = new LevelsOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.LEVELS, option.getKind());
|
||||
|
||||
assertEquals(0, option.getLevel());
|
||||
option.setLevel(1);
|
||||
assertEquals(1, option.getLevel());
|
||||
assertEquals(0, option.getValue());
|
||||
option.setValue(1);
|
||||
assertEquals(1, option.getValue());
|
||||
|
||||
option = new LevelsOptionImpl();
|
||||
option.setMax();
|
||||
|
@ -223,15 +222,13 @@ public class QueryOptionTest {
|
|||
public void testSearchOptionImpl() {
|
||||
SearchOptionImpl option = new SearchOptionImpl();
|
||||
assertEquals(SupportedQueryOptions.SEARCH, option.getKind());
|
||||
// TODO $search not supported yet
|
||||
// TODO $search is not supported yet
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectItemImpl() {
|
||||
SelectItemImpl option = new SelectItemImpl();
|
||||
|
||||
edm.getEntityType(EdmTechProvider.nameETKeyNav);
|
||||
|
||||
// no typed collection else case ( e.g. if not path is added)
|
||||
option = new SelectItemImpl();
|
||||
|
||||
|
|
|
@ -29,14 +29,12 @@ import org.apache.olingo.odata4.commons.api.edm.EdmAction;
|
|||
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmEnumType;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmFunction;
|
||||
import org.apache.olingo.odata4.commons.api.edm.EdmType;
|
||||
import org.apache.olingo.odata4.server.api.uri.UriInfoKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.UriInfoResource;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExceptionVisitExpression;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedBinaryOperators;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedConstants;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedMethodCalls;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.SupportedUnaryOperators;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.BinaryOperatorKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.ExpressionVisitException;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.MethodCallKind;
|
||||
import org.apache.olingo.odata4.server.api.uri.queryoption.expression.UnaryOperatorKind;
|
||||
import org.apache.olingo.odata4.server.core.edm.provider.EdmProviderImpl;
|
||||
import org.apache.olingo.odata4.server.core.testutil.EdmTechProvider;
|
||||
import org.apache.olingo.odata4.server.core.testutil.EdmTechTestProvider;
|
||||
|
@ -51,21 +49,18 @@ public class ExpressionTest {
|
|||
|
||||
@Test
|
||||
public void testSupportedOperators() {
|
||||
assertEquals(SupportedUnaryOperators.MINUS, SupportedUnaryOperators.get("-"));
|
||||
assertEquals(null, SupportedUnaryOperators.get("XXX"));
|
||||
assertEquals(UnaryOperatorKind.MINUS, UnaryOperatorKind.get("-"));
|
||||
assertEquals(null, UnaryOperatorKind.get("XXX"));
|
||||
|
||||
assertEquals(SupportedBinaryOperators.MOD, SupportedBinaryOperators.get("mod"));
|
||||
assertEquals(null, SupportedBinaryOperators.get("XXX"));
|
||||
assertEquals(BinaryOperatorKind.MOD, BinaryOperatorKind.get("mod"));
|
||||
assertEquals(null, BinaryOperatorKind.get("XXX"));
|
||||
|
||||
assertEquals(SupportedMethodCalls.CONCAT, SupportedMethodCalls.get("concat"));
|
||||
assertEquals(null, SupportedMethodCalls.get("XXX"));
|
||||
|
||||
assertEquals(SupportedConstants.TRUE, SupportedConstants.get("true"));
|
||||
assertEquals(null, SupportedConstants.get("XXX"));
|
||||
assertEquals(MethodCallKind.CONCAT, MethodCallKind.get("concat"));
|
||||
assertEquals(null, MethodCallKind.get("XXX"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAliasExpression() throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public void testAliasExpression() throws ExpressionVisitException, ODataApplicationException {
|
||||
AliasImpl expression = new AliasImpl();
|
||||
|
||||
expression.setParameter("Test");
|
||||
|
@ -78,7 +73,7 @@ public class ExpressionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testBinaryExpression() throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public void testBinaryExpression() throws ExpressionVisitException, ODataApplicationException {
|
||||
BinaryImpl expression = new BinaryImpl();
|
||||
|
||||
ExpressionImpl expressionLeft = new LiteralImpl().setText("A");
|
||||
|
@ -86,48 +81,18 @@ public class ExpressionTest {
|
|||
|
||||
expression.setLeftOperand(expressionLeft);
|
||||
expression.setRightOperand(expressionRight);
|
||||
expression.setOperator(SupportedBinaryOperators.SUB);
|
||||
expression.setOperator(BinaryOperatorKind.SUB);
|
||||
|
||||
assertEquals(expressionLeft, expression.getLeftOperand());
|
||||
assertEquals(expressionRight, expression.getRightOperand());
|
||||
assertEquals(SupportedBinaryOperators.SUB, expression.getOperator());
|
||||
assertEquals(BinaryOperatorKind.SUB, expression.getOperator());
|
||||
|
||||
String output = expression.accept(new FilterTreeToText());
|
||||
assertEquals("<<A> sub <B>>", output);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstantExpression() throws ExceptionVisitExpression, ODataApplicationException {
|
||||
ConstantImpl expression = new ConstantImpl();
|
||||
EdmType type = edm.getEntityType(EdmTechProvider.nameETKeyNav);
|
||||
assertNotNull(type);
|
||||
expression.setType(type);
|
||||
assertEquals(type, expression.getType());
|
||||
|
||||
expression.setKind(SupportedConstants.FALSE);
|
||||
assertEquals(SupportedConstants.FALSE, expression.getKind());
|
||||
assertEquals(true, expression.isFalse());
|
||||
assertEquals(false, expression.isTrue());
|
||||
assertEquals(false, expression.isNull());
|
||||
assertEquals("<false>", expression.accept(new FilterTreeToText()));
|
||||
|
||||
expression.setKind(SupportedConstants.TRUE);
|
||||
assertEquals(SupportedConstants.TRUE, expression.getKind());
|
||||
assertEquals(false, expression.isFalse());
|
||||
assertEquals(true, expression.isTrue());
|
||||
assertEquals(false, expression.isNull());
|
||||
assertEquals("<true>", expression.accept(new FilterTreeToText()));
|
||||
|
||||
expression.setKind(SupportedConstants.NULL);
|
||||
assertEquals(SupportedConstants.NULL, expression.getKind());
|
||||
assertEquals(false, expression.isFalse());
|
||||
assertEquals(false, expression.isTrue());
|
||||
assertEquals(true, expression.isNull());
|
||||
assertEquals("<null>", expression.accept(new FilterTreeToText()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnumerationExpression() throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public void testEnumerationExpression() throws ExpressionVisitException, ODataApplicationException {
|
||||
EnumerationImpl expression = new EnumerationImpl();
|
||||
EdmEnumType type = (EdmEnumType) edm.getEnumType(EdmTechProvider.nameENString);
|
||||
assertNotNull(type);
|
||||
|
@ -143,7 +108,7 @@ public class ExpressionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLambdaRefExpression() throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public void testLambdaRefExpression() throws ExpressionVisitException, ODataApplicationException {
|
||||
LambdaRefImpl expression = new LambdaRefImpl();
|
||||
expression.setVariableText("A");
|
||||
assertEquals("A", expression.getVariableName());
|
||||
|
@ -153,7 +118,7 @@ public class ExpressionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLiteralExpresion() throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public void testLiteralExpresion() throws ExpressionVisitException, ODataApplicationException {
|
||||
LiteralImpl expression = new LiteralImpl();
|
||||
expression.setText("A");
|
||||
assertEquals("A", expression.getText());
|
||||
|
@ -162,11 +127,11 @@ public class ExpressionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMemberExpression() throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public void testMemberExpression() throws ExpressionVisitException, ODataApplicationException {
|
||||
MemberImpl expression = new MemberImpl();
|
||||
EdmEntityType entityType = edm.getEntityType(EdmTechProvider.nameETKeyNav);
|
||||
|
||||
new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||
// UriResourceImplTyped
|
||||
EdmAction action = edm.getAction(EdmTechProvider.nameUARTPrimParam, null, null);
|
||||
UriInfoResource uriInfo = new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
|
||||
new UriResourceActionImpl().setAction(action)).asUriInfoResource();
|
||||
|
@ -180,28 +145,28 @@ public class ExpressionTest {
|
|||
// UriResourceImplTyped check collection = false case
|
||||
assertEquals(false, expression.isCollection());
|
||||
|
||||
new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||
// UriResourceImplTyped check collection = true case
|
||||
action = edm.getAction(EdmTechProvider.nameUARTPrimCollParam, null, null);
|
||||
expression.setPath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
|
||||
new UriResourceActionImpl().setAction(action))
|
||||
.asUriInfoResource());
|
||||
assertEquals(true, expression.isCollection());
|
||||
|
||||
new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||
// UriResourceImplTyped with filter
|
||||
action = edm.getAction(EdmTechProvider.nameUARTPrimParam, null, null);
|
||||
expression.setPath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
|
||||
new UriResourceActionImpl().setAction(action).setTypeFilter(entityType))
|
||||
.asUriInfoResource());
|
||||
assertEquals(entityType, expression.getType());
|
||||
|
||||
new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||
// UriResourceImplKeyPred
|
||||
EdmFunction function = edm.getFunction(EdmTechProvider.nameUFCRTETKeyNav, null, null, null);
|
||||
expression.setPath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
|
||||
new UriResourceFunctionImpl().setFunction(function))
|
||||
.asUriInfoResource());
|
||||
assertEquals(function.getReturnType().getType(), expression.getType());
|
||||
|
||||
new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||
// UriResourceImplKeyPred typeFilter on entry
|
||||
EdmEntityType entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav);
|
||||
function = edm.getFunction(EdmTechProvider.nameUFCRTESTwoKeyNavParam, null, null,
|
||||
Arrays.asList(("ParameterInt16")));
|
||||
|
@ -210,7 +175,7 @@ public class ExpressionTest {
|
|||
.asUriInfoResource());
|
||||
assertEquals(entityBaseType, expression.getType());
|
||||
|
||||
new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||
// UriResourceImplKeyPred typeFilter on entry
|
||||
entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav);
|
||||
function = edm.getFunction(EdmTechProvider.nameUFCRTESTwoKeyNavParam, null, null,
|
||||
Arrays.asList(("ParameterInt16")));
|
||||
|
@ -219,7 +184,7 @@ public class ExpressionTest {
|
|||
.asUriInfoResource());
|
||||
assertEquals(entityBaseType, expression.getType());
|
||||
|
||||
new UriInfoImpl().setKind(UriInfoKind.resource);
|
||||
// no typed
|
||||
entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav);
|
||||
function = edm.getFunction(EdmTechProvider.nameUFCRTESTwoKeyNavParam, null, null,
|
||||
Arrays.asList(("ParameterInt16")));
|
||||
|
@ -231,16 +196,16 @@ public class ExpressionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMethodCallExpression() throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public void testMethodCallExpression() throws ExpressionVisitException, ODataApplicationException {
|
||||
MethodCallImpl expression = new MethodCallImpl();
|
||||
expression.setMethod(SupportedMethodCalls.CONCAT);
|
||||
expression.setMethod(MethodCallKind.CONCAT);
|
||||
|
||||
ExpressionImpl p0 = new LiteralImpl().setText("A");
|
||||
ExpressionImpl p1 = new LiteralImpl().setText("B");
|
||||
expression.addParameter(p0);
|
||||
expression.addParameter(p1);
|
||||
|
||||
assertEquals(SupportedMethodCalls.CONCAT, expression.getMethod());
|
||||
assertEquals(MethodCallKind.CONCAT, expression.getMethod());
|
||||
assertEquals("<concat(<A>,<B>)>", expression.accept(new FilterTreeToText()));
|
||||
|
||||
assertEquals(p0, expression.getParameters().get(0));
|
||||
|
@ -248,7 +213,7 @@ public class ExpressionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTypeLiteralExpression() throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public void testTypeLiteralExpression() throws ExpressionVisitException, ODataApplicationException {
|
||||
TypeLiteralImpl expression = new TypeLiteralImpl();
|
||||
EdmEntityType entityBaseType = edm.getEntityType(EdmTechProvider.nameETBaseTwoKeyNav);
|
||||
expression.setType(entityBaseType);
|
||||
|
@ -258,14 +223,14 @@ public class ExpressionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testUnaryExpression() throws ExceptionVisitExpression, ODataApplicationException {
|
||||
public void testUnaryExpression() throws ExpressionVisitException, ODataApplicationException {
|
||||
UnaryImpl expression = new UnaryImpl();
|
||||
expression.setOperator(SupportedUnaryOperators.MINUS);
|
||||
expression.setOperator(UnaryOperatorKind.MINUS);
|
||||
|
||||
ExpressionImpl operand = new LiteralImpl().setText("A");
|
||||
expression.setOperand(operand);
|
||||
|
||||
assertEquals(SupportedUnaryOperators.MINUS, expression.getOperator());
|
||||
assertEquals(UnaryOperatorKind.MINUS, expression.getOperator());
|
||||
assertEquals(operand, expression.getOperand());
|
||||
|
||||
assertEquals("<- <A>>", expression.accept(new FilterTreeToText()));
|
||||
|
|
Loading…
Reference in New Issue