You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/02/19 11:32:24 UTC
[4/6] [OLINGO-63] Uri Parser: rename, cleanup, fixes
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java
index 5d748cc..d422329 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/parser/UriParseTreeVisitor.java
@@ -47,9 +47,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;
@@ -164,11 +163,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;
@@ -180,7 +179,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;
@@ -204,8 +202,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
*/
@@ -688,9 +685,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));
@@ -713,7 +710,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));
@@ -743,13 +740,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));
@@ -785,9 +782,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));
@@ -799,7 +796,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));
@@ -821,11 +818,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));
@@ -837,7 +834,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));
@@ -871,9 +868,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
@@ -890,7 +887,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;
}
@@ -928,14 +925,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));
}
@@ -990,7 +987,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));
}
@@ -1010,21 +1007,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));
}
@@ -1032,7 +1029,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));
}
@@ -1085,8 +1082,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);
}
@@ -1206,7 +1205,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));
}
@@ -1242,45 +1241,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));
}
@@ -1298,7 +1297,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;
@@ -1307,7 +1306,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));
}
@@ -1331,7 +1330,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public ExpressionImpl visitMaxDateTimeMethodCallExpr(final MaxDateTimeMethodCallExprContext ctx) {
return new MethodCallImpl()
- .setMethod(SupportedMethodCalls.MAXDATETIME);
+ .setMethod(MethodCallKind.MAXDATETIME);
}
@Override
@@ -1375,20 +1374,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));
}
@@ -1562,12 +1561,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");
}
/*
@@ -1735,14 +1734,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));
}
@@ -1999,7 +1998,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));
}
@@ -2007,7 +2006,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));
@@ -2022,7 +2021,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));
}
@@ -2038,35 +2037,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));
}
@@ -2079,7 +2078,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));
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/CountOptionImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/CountOptionImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/CountOptionImpl.java
new file mode 100644
index 0000000..0bc9e6b
--- /dev/null
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/CountOptionImpl.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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;
+
+import org.apache.olingo.odata4.server.api.uri.queryoption.InlineCountOption;
+import org.apache.olingo.odata4.server.api.uri.queryoption.SupportedQueryOptions;
+
+public class CountOptionImpl extends SystemQueryOptionImpl implements InlineCountOption {
+
+ private boolean count;
+
+ public CountOptionImpl() {
+ setKind(SupportedQueryOptions.INLINECOUNT);
+ }
+
+ @Override
+ public boolean getValue() {
+ return count;
+ }
+
+ public CountOptionImpl setValue(final boolean count) {
+ this.count = count;
+ return this;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/ExpandItemImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/ExpandItemImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/ExpandItemImpl.java
index 5d7ab42..de81c76 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/ExpandItemImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/ExpandItemImpl.java
@@ -58,7 +58,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) {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/InlineCountOptionImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/InlineCountOptionImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/InlineCountOptionImpl.java
deleted file mode 100644
index a274c0a..0000000
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/InlineCountOptionImpl.java
+++ /dev/null
@@ -1,42 +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;
-
-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 {
-
- private boolean count;
-
- public InlineCountOptionImpl() {
- setKind(SupportedQueryOptions.INLINECOUNT);
- }
-
- @Override
- public boolean getValue() {
- return count;
- }
-
- public InlineCountOptionImpl setValue(final boolean count) {
- this.count = count;
- return this;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/LevelsOptionImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/LevelsOptionImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/LevelsOptionImpl.java
index 538dc52..828dd74 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/LevelsOptionImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/LevelsOptionImpl.java
@@ -30,7 +30,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;
}
@@ -47,7 +47,7 @@ public class LevelsOptionImpl extends SystemQueryOptionImpl implements LevelsExp
}
@Override
- public int getLevel() {
+ public int getValue() {
return value;
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/SearchOptionImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/SearchOptionImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/SearchOptionImpl.java
index fcaee17..c7320bd 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/SearchOptionImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/SearchOptionImpl.java
@@ -23,7 +23,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() {
@@ -32,7 +32,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;
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/AliasImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/AliasImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/AliasImpl.java
index 1e2abff..2c10a7e 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/AliasImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/AliasImpl.java
@@ -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);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/BinaryImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/BinaryImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/BinaryImpl.java
index 73b7eb8..7f5d57e 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/BinaryImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/BinaryImpl.java
@@ -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);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/ConstantImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/ConstantImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/ConstantImpl.java
deleted file mode 100644
index 08d97aa..0000000
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/ConstantImpl.java
+++ /dev/null
@@ -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;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/EnumerationImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/EnumerationImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/EnumerationImpl.java
index 549cb3b..9a7481a 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/EnumerationImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/EnumerationImpl.java
@@ -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);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LambdaRefImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LambdaRefImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LambdaRefImpl.java
index fcf5f50..26c2295 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LambdaRefImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LambdaRefImpl.java
@@ -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);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LiteralImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LiteralImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LiteralImpl.java
index 5709d53..d068a41 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LiteralImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/LiteralImpl.java
@@ -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);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MemberImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MemberImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MemberImpl.java
index f97bad2..779be78 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MemberImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MemberImpl.java
@@ -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);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MethodCallImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MethodCallImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MethodCallImpl.java
index ef34daf..cf1b33f 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MethodCallImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/MethodCallImpl.java
@@ -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));
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/TypeLiteralImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/TypeLiteralImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/TypeLiteralImpl.java
index 538e25f..1d2ffbd 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/TypeLiteralImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/TypeLiteralImpl.java
@@ -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);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/UnaryImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/UnaryImpl.java b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/UnaryImpl.java
index 879324c..5da0983 100644
--- a/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/UnaryImpl.java
+++ b/odata4-lib/odata4-server-core/src/main/java/org/apache/olingo/odata4/server/core/uri/queryoption/expression/UnaryImpl.java
@@ -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);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java
index 1dfc7d7..5f10314 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/EdmTechProvider.java
@@ -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()
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ExpandValidator.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ExpandValidator.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ExpandValidator.java
index c5a0e29..e812f05 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ExpandValidator.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ExpandValidator.java
@@ -28,10 +28,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;
@@ -45,8 +46,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;
}
@@ -63,27 +64,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);
@@ -91,20 +109,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);
@@ -171,7 +181,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);
@@ -179,7 +189,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;
@@ -191,7 +201,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) {
@@ -202,4 +212,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;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterTreeToText.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterTreeToText.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterTreeToText.java
index c0f7ad8..a951dab 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterTreeToText.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterTreeToText.java
@@ -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() + ">";
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterValidator.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterValidator.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterValidator.java
index 6d5d2cc..2bca2e1 100644
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterValidator.java
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/FilterValidator.java
@@ -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;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserTest.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserTest.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserTest.java
deleted file mode 100644
index a5a7904..0000000
--- a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserTest.java
+++ /dev/null
@@ -1,53 +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.testutil;
-
-import org.antlr.v4.runtime.DefaultErrorStrategy;
-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 {
- TestErrorLogger errorCollector1;
- TestErrorLogger errorCollector2;
-
- public ParserTest() {
- errorCollector1 = new TestErrorLogger("Stage 1", 1);
- errorCollector2 = new TestErrorLogger("Stage 2", 1);
- }
-
- @Override
- protected void addStage2ErrorStategy(final UriParserParser parser) {
- // Don't throw an at first syntax error, so the error listener will be called
- parser.setErrorHandler(new DefaultErrorStrategy());
- }
-
- @Override
- protected void addStage1ErrorListener(final UriParserParser parser) {
- // Log error to console
- parser.removeErrorListeners();
- parser.addErrorListener(errorCollector1);
- }
-
- @Override
- protected void addStage2ErrorListener(final UriParserParser parser) {
- // Log error to console
- parser.removeErrorListeners();
- parser.addErrorListener(errorCollector2);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/d64e868f/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserWithLogging.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserWithLogging.java b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserWithLogging.java
new file mode 100644
index 0000000..f639f22
--- /dev/null
+++ b/odata4-lib/odata4-server-core/src/test/java/org/apache/olingo/odata4/server/core/testutil/ParserWithLogging.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.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 ParserWithLogging extends Parser {
+ TestErrorLogger errorCollector1;
+ TestErrorLogger errorCollector2;
+
+ public ParserWithLogging() {
+ errorCollector1 = new TestErrorLogger("Stage 1", 1);
+ errorCollector2 = new TestErrorLogger("Stage 2", 1);
+ }
+
+ @Override
+ protected void addStage2ErrorStategy(final UriParserParser parser) {
+ // Don't throw an at first syntax error, so the error listener will be called
+ parser.setErrorHandler(new DefaultErrorStrategy());
+ }
+
+ @Override
+ protected void addStage1ErrorListener(final UriParserParser parser) {
+ // Log error to console
+ parser.removeErrorListeners();
+ parser.addErrorListener(errorCollector1);
+ parser.addErrorListener(new DiagnosticErrorListener());
+ }
+
+ @Override
+ protected void addStage2ErrorListener(final UriParserParser parser) {
+ // Log error to console
+ parser.removeErrorListeners();
+ parser.addErrorListener(errorCollector2);
+ parser.addErrorListener(new DiagnosticErrorListener());
+ }
+}