From 1ef03f92f491c5b17b085349a046f335e6a5124f Mon Sep 17 00:00:00 2001 From: Sven Kobler Date: Fri, 24 Jan 2014 14:05:20 +0100 Subject: [PATCH] [OLINGO-63] Uri Parser: Add test cases for key predicates, select,expand and code cleanup --- .../exception/ODataApplicationException.java} | 18 +- .../odata4/producer/api/uri/UriInfo.java | 2 +- .../odata4/producer/api/uri/UriInfoAll.java | 2 +- .../odata4/producer/api/uri/UriInfoBatch.java | 2 +- .../producer/api/uri/UriInfoEntityId.java | 2 +- .../producer/api/uri/UriInfoMetadata.java | 2 + .../producer/api/uri/UriInfoResource.java | 4 +- .../odata4/producer/api/uri/UriParameter.java | 11 +- .../producer/api/uri/UriResourceAction.java | 2 +- .../producer/api/uri/UriResourceAll.java | 3 + .../producer/api/uri/UriResourceAny.java | 3 + .../api/uri/UriResourceComplexProperty.java | 1 + .../producer/api/uri/UriResourceCount.java | 3 +- .../api/uri/UriResourceEntitySet.java | 1 - .../producer/api/uri/UriResourceFunction.java | 3 +- .../producer/api/uri/UriResourceIt.java | 10 +- .../producer/api/uri/UriResourceKind.java | 5 +- ...Visitor.java => UriResourceLambdaRef.java} | 21 +- .../api/uri/UriResourceNavigation.java | 7 +- .../producer/api/uri/UriResourcePart.java | 6 +- .../api/uri/UriResourcePartTyped.java | 2 + .../producer/api/uri/UriResourceProperty.java | 2 + .../producer/api/uri/UriResourceRef.java | 3 +- .../api/uri/UriResourceSimpleProperty.java | 3 +- .../api/uri/UriResourceSingleton.java | 6 +- .../producer/api/uri/UriResourceValue.java | 3 +- .../api/uri/queryoption/AliasQueryOption.java | 3 +- .../uri/queryoption/ExceptionVisitExpand.java | 5 +- .../api/uri/queryoption/ExpandItem.java | 14 +- .../api/uri/queryoption/ExpandOption.java | 2 + .../api/uri/queryoption/FilterOption.java | 1 + .../api/uri/queryoption/FormatOption.java | 3 +- .../api/uri/queryoption/IdOption.java | 2 + .../uri/queryoption/InlineCountOption.java | 4 +- .../uri/queryoption/LevelExpandOption.java | 2 +- .../api/uri/queryoption/OrderByItem.java | 2 +- .../api/uri/queryoption/OrderByOption.java | 4 +- .../api/uri/queryoption/QueryOption.java | 1 + .../api/uri/queryoption/SearchOption.java | 3 +- .../api/uri/queryoption/SelectItem.java | 5 +- .../api/uri/queryoption/SelectOption.java | 4 +- .../api/uri/queryoption/SkipOption.java | 4 +- .../api/uri/queryoption/SkipTokenOption.java | 26 - ...ortOrderEnum.java => SkiptokenOption.java} | 6 + ...onEnum.java => SupportedQueryOptions.java} | 4 +- .../uri/queryoption/SystemQueryOption.java | 2 +- .../api/uri/queryoption/TopOption.java | 4 +- .../api/uri/queryoption/VisitableExpand.java | 48 - .../expression/BinaryExpression.java | 2 +- .../expression/ExceptionVisitExpression.java | 7 +- .../queryoption/expression/Expression.java | 2 +- .../expression/ExpressionVisitor.java | 32 +- .../uri/queryoption/expression/LambdaRef.java | 4 +- .../uri/queryoption/expression/Literal.java | 4 +- .../uri/queryoption/expression/Member.java | 6 +- .../queryoption/expression/MethodCall.java | 4 +- .../expression/SupportedBinaryOperators.java | 17 +- .../expression/SupportedMethodCalls.java | 26 +- .../expression/SupportedUnaryOperators.java | 4 +- .../queryoption/expression/TypeLiteral.java | 6 +- .../queryoption/expression/UnaryOperator.java | 6 +- .../expression/VisitableExression.java | 29 +- .../uri/queryoption/search/SearchBinary.java | 1 + .../uri/queryoption/search/SearchTerm.java | 2 + .../uri/queryoption/search/SearchUnary.java | 2 + .../SupportedSearchBinaryOperators.java | 12 +- .../search/SupportedSearchUnaryOperators.java | 2 +- .../producer/core/uri/antlr/UriParser.g4 | 8 +- .../producer/core/uri/ErrorCollector.java | 80 +- .../producer/core/uri/ExpandSegmentCount.java | 25 - .../producer/core/uri/ExpandSegmentIt.java | 25 - .../producer/core/uri/ExpandSegmentRef.java | 25 - .../producer/core/uri/ParserAdapter.java | 5 +- .../odata4/producer/core/uri/UriInfoImpl.java | 73 +- .../producer/core/uri/UriParameterImpl.java | 8 +- .../core/uri/UriParseTreeVisitor.java | 1307 ++++++++--------- .../producer/core/uri/UriParserException.java | 8 +- .../core/uri/UriParserSemanticException.java | 10 +- .../core/uri/UriParserSyntaxException.java | 6 +- .../core/uri/UriResourceActionImpl.java | 22 +- .../producer/core/uri/UriResourceAllImpl.java | 15 +- .../producer/core/uri/UriResourceAnyImpl.java | 15 +- .../uri/UriResourceComplexPropertyImpl.java | 9 +- .../core/uri/UriResourceCountImpl.java | 5 + .../core/uri/UriResourceEntitySetImpl.java | 20 +- .../core/uri/UriResourceFunctionImpl.java | 29 +- .../core/uri/UriResourceImplKeyPred.java | 9 +- .../core/uri/UriResourceImplTyped.java | 10 +- .../producer/core/uri/UriResourceItImpl.java | 23 +- .../core/uri/UriResourceLambdaRefImpl.java | 67 + .../UriResourceNavigationPropertyImpl.java | 23 +- .../core/uri/UriResourcePartImpl.java | 4 +- .../core/uri/UriResourcePropertyImpl.java | 10 +- .../producer/core/uri/UriResourceRefImpl.java | 8 +- .../core/uri/UriResourceRootImpl.java | 7 +- .../uri/UriResourceSimplePropertyImpl.java | 18 +- .../core/uri/UriResourceSingletonImpl.java | 26 +- .../core/uri/UriResourceValueImpl.java | 9 +- .../uri/queryoption/AliasQueryOptionImpl.java | 8 +- .../queryoption/CustomQueryOptionImpl.java | 1 - .../core/uri/queryoption/ExpandItemImpl.java | 140 +- .../uri/queryoption/ExpandOptionImpl.java | 20 +- .../uri/queryoption/FilterOptionImpl.java | 11 +- .../uri/queryoption/FormatOptionImpl.java | 10 +- .../core/uri/queryoption/IdOptionImpl.java | 16 +- ...ntImpl.java => InlineCountOptionImpl.java} | 24 +- ...onImpl.java => LevelExpandOptionImpl.java} | 28 +- .../core/uri/queryoption/LevelOption.java | 23 - .../core/uri/queryoption/OrderByImpl.java | 22 +- .../uri/queryoption/OrderByOptionImpl.java | 11 +- .../core/uri/queryoption/QueryOptionImpl.java | 8 +- .../uri/queryoption/SearchOptionImpl.java | 7 +- .../uri/queryoption/SelectItemOptionImpl.java | 180 +-- .../uri/queryoption/SelectOptionImpl.java | 8 +- ...andSegment.java => SelectSegmentImpl.java} | 55 +- .../core/uri/queryoption/SkipOptionImpl.java | 20 +- ...tionImpl.java => SkiptokenOptionImpl.java} | 38 +- .../queryoption/SystemQueryOptionImpl.java | 17 +- .../core/uri/queryoption/TopOptionImpl.java | 14 +- .../uri/queryoption/expression/AliasImpl.java | 8 +- .../queryoption/expression/BinaryImpl.java | 17 +- .../expression/ExpressionImpl.java | 8 +- .../queryoption/expression/LambdaRefImpl.java | 17 +- .../queryoption/expression/LiteralImpl.java | 8 +- .../queryoption/expression/MemberImpl.java | 23 +- .../expression/MethodCallImpl.java | 22 +- .../expression/TypeLiteralImpl.java | 14 +- .../expression/UnaryOperatorImpl.java | 10 +- .../core/testutil/EdmTechProvider.java | 18 +- .../producer/core/testutil/ExpandToText.java | 68 - .../core/testutil/ExpandValidator.java | 180 +++ .../core/testutil/FilterTreeToText.java | 89 +- .../core/testutil/FilterValidator.java | 6 +- .../core/testutil/UriResourceValidator.java | 77 +- .../producer/core/testutil/UriValidator.java | 2 +- .../uri/antlr/TestByAbapResourcePath.java | 839 +++++++++-- .../core/uri/antlr/TestUriParserImpl.java | 2 +- 137 files changed, 2504 insertions(+), 1918 deletions(-) rename odata4-lib/{odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/antlr/ParserException.java => odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/exception/ODataApplicationException.java} (76%) rename odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/{queryoption/ExpandVisitor.java => UriResourceLambdaRef.java} (68%) delete mode 100644 odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SkipTokenOption.java rename odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/{SortOrderEnum.java => SkiptokenOption.java} (92%) rename odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/{SystemQueryOptionEnum.java => SupportedQueryOptions.java} (93%) delete mode 100644 odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/VisitableExpand.java rename odata4-lib/{odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core => odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api}/uri/queryoption/expression/ExceptionVisitExpression.java (86%) rename odata4-lib/{odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core => odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api}/uri/queryoption/expression/ExpressionVisitor.java (57%) rename odata4-lib/{odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core => odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api}/uri/queryoption/expression/VisitableExression.java (70%) delete mode 100644 odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ExpandSegmentCount.java delete mode 100644 odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ExpandSegmentIt.java delete mode 100644 odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ExpandSegmentRef.java create mode 100644 odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaRefImpl.java rename odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/{InlineCountImpl.java => InlineCountOptionImpl.java} (72%) rename odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/{LevelOptionImpl.java => LevelExpandOptionImpl.java} (69%) delete mode 100644 odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/LevelOption.java rename odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/{ExpandSegment.java => SelectSegmentImpl.java} (61%) rename odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/{SkipTokenOptionImpl.java => SkiptokenOptionImpl.java} (66%) delete mode 100644 odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ExpandToText.java create mode 100644 odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ExpandValidator.java diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/antlr/ParserException.java b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/exception/ODataApplicationException.java similarity index 76% rename from odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/antlr/ParserException.java rename to odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/exception/ODataApplicationException.java index aeca7068e..fed88618d 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/antlr/ParserException.java +++ b/odata4-lib/odata4-commons-api/src/main/java/org/apache/olingo/odata4/commons/api/exception/ODataApplicationException.java @@ -16,28 +16,20 @@ * specific language governing permissions and limitations * under the License. ******************************************************************************/ -package org.apache.olingo.odata4.producer.core.uri.antlr; +package org.apache.olingo.odata4.commons.api.exception; -public class ParserException extends Exception { - - /** - * - */ +public class ODataApplicationException extends Exception { private static final long serialVersionUID = 1L; - public ParserException() { - super(); - } - - public ParserException(final String msg) { + public ODataApplicationException(final String msg) { super(msg); } - public ParserException(final String msg, final Throwable e) { + public ODataApplicationException(final String msg, final Throwable e) { super(msg, e); } - public ParserException(final Throwable e) { + public ODataApplicationException(final Throwable e) { super(e); } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfo.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfo.java index 5a01c971d..96e5172e3 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfo.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfo.java @@ -22,7 +22,7 @@ package org.apache.olingo.odata4.producer.api.uri; public interface UriInfo extends UriInfoService, UriInfoAll, UriInfoBatch, UriInfoCrossjoin, UriInfoEntityId, UriInfoMetadata, UriInfoResource { - + public UriInfoService asUriInfoService(); public UriInfoAll asUriInfoAll(); diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoAll.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoAll.java index aab9524b0..b2e236a57 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoAll.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoAll.java @@ -19,6 +19,6 @@ package org.apache.olingo.odata4.producer.api.uri; -public interface UriInfoAll { +public interface UriInfoAll { } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoBatch.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoBatch.java index accdffe1b..13b6673b6 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoBatch.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoBatch.java @@ -19,6 +19,6 @@ package org.apache.olingo.odata4.producer.api.uri; -public interface UriInfoBatch { +public interface UriInfoBatch { } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoEntityId.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoEntityId.java index 2afacb387..7a8a31782 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoEntityId.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoEntityId.java @@ -32,7 +32,7 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption; * Indicates a URL access to an single Entity */ public interface UriInfoEntityId { - + public List getCustomQueryOptions(); public EdmEntityType getEntityTypeCast(); diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoMetadata.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoMetadata.java index cf734122a..ad46a2a02 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoMetadata.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoMetadata.java @@ -22,7 +22,9 @@ package org.apache.olingo.odata4.producer.api.uri; import org.apache.olingo.odata4.producer.api.uri.queryoption.FormatOption; public interface UriInfoMetadata { + public String getContext(); public FormatOption getFormatOption(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoResource.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoResource.java index 9be2b1c9f..aa9c0a8db 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoResource.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriInfoResource.java @@ -30,7 +30,7 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByOption; import org.apache.olingo.odata4.producer.api.uri.queryoption.SearchOption; import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption; import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipTokenOption; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SkiptokenOption; import org.apache.olingo.odata4.producer.api.uri.queryoption.TopOption; public interface UriInfoResource { @@ -55,7 +55,7 @@ public interface UriInfoResource { SkipOption getSkipOption(); - SkipTokenOption getSkipTokenOption(); + SkiptokenOption getSkipTokenOption(); TopOption getTopOption(); diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriParameter.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriParameter.java index c4deb50a9..7a47585c6 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriParameter.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriParameter.java @@ -22,9 +22,12 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expressi public interface UriParameter { - public String getAlias(); - public String getText(); - public Expression getExression(); - public String getName(); + public String getAlias(); + + public String getText(); + + public Expression getExression(); + + public String getName(); } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceAction.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceAction.java index 321d14300..b96d13e88 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceAction.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceAction.java @@ -26,7 +26,7 @@ public interface UriResourceAction extends UriResourcePartTyped { EdmAction getAction(); /** - * Convenience method which return the {@link EdmActionImport} which was used in + * Convenience method which returns the {@link EdmActionImport} which was used in * the resource path to define the {@link EdmAction}. * @return */ diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceAll.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceAll.java index 95c0e0075..660a0a5dc 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceAll.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceAll.java @@ -21,6 +21,9 @@ package org.apache.olingo.odata4.producer.api.uri; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression; public interface UriResourceAll extends UriResourcePartTyped { + public String getLamdaVariable(); + public Expression getExpression(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceAny.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceAny.java index 2405cbfb0..25e9ce90d 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceAny.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceAny.java @@ -21,6 +21,9 @@ package org.apache.olingo.odata4.producer.api.uri; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression; public interface UriResourceAny extends UriResourcePartTyped { + public String getLamdaVariable(); + public Expression getExpression(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceComplexProperty.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceComplexProperty.java index ce7d61455..ffca62477 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceComplexProperty.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceComplexProperty.java @@ -21,6 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri; import org.apache.olingo.odata4.commons.api.edm.EdmComplexType; public interface UriResourceComplexProperty extends UriResourceProperty { + EdmComplexType getComplexType(); EdmComplexType getComplexTypeFilter(); diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceCount.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceCount.java index d4be146eb..e120d2785 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceCount.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceCount.java @@ -18,7 +18,6 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri; - public interface UriResourceCount extends UriResourcePart { - + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceEntitySet.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceEntitySet.java index 349e45e84..1b2417030 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceEntitySet.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceEntitySet.java @@ -26,7 +26,6 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType; public interface UriResourceEntitySet extends UriResourcePartTyped { - EdmEntitySet getEntitySet(); EdmEntityType getEntityType(); diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceFunction.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceFunction.java index 45d2b31d8..8e4c6de90 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceFunction.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceFunction.java @@ -26,11 +26,10 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType; public interface UriResourceFunction extends UriResourcePartTyped { - EdmFunction getFunction(); /** - * Convenience method which return the {@link EdmFunctionImport} which was used in + * Convenience method which returns the {@link EdmFunctionImport} which was used in * the resource path to define the {@link EdmFunction}. * @return */ diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceIt.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceIt.java index cd86f1d7e..7812b71c2 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceIt.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceIt.java @@ -22,11 +22,15 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType; /** * Class indicating the $it reference. $it may be used within filter to - * refer to the last EDM object reference in the resource path. + * refer to the last EDM object reference in the resource path. Since $it is + * optional in some cases ( e.g. first member expressions) the {@link #isExplicitIt()} + * method can be used to check if $it was explicitly noted in the URI */ public interface UriResourceIt extends UriResourcePartTyped { - + EdmType getTypeFilterOnCollection(); + EdmType getTypeFilterOnEntry(); - boolean isExplicitIt(); + + boolean isExplicitIt(); } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceKind.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceKind.java index 3acf57e3c..aac5c4184 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceKind.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceKind.java @@ -20,7 +20,6 @@ package org.apache.olingo.odata4.producer.api.uri; public enum UriResourceKind { - action, entitySet, function, it, singleton, navigationProperty, - simpleProperty, complexProperty, value, count, ref, root, lamdaAll, lamdaAny - + action, complexProperty, count, entitySet, function, it, lambdaAll, lambdaAny, + lambdaVariable, navigationProperty, ref, root, simpleProperty, singleton, value, } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExpandVisitor.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceLambdaRef.java similarity index 68% rename from odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExpandVisitor.java rename to odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceLambdaRef.java index fdd72d7b2..dddf34c93 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExpandVisitor.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceLambdaRef.java @@ -1,5 +1,4 @@ /******************************************************************************* - * * 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 @@ -17,20 +16,18 @@ * specific language governing permissions and limitations * under the License. ******************************************************************************/ -package org.apache.olingo.odata4.producer.api.uri.queryoption; +package org.apache.olingo.odata4.producer.api.uri; -import java.util.List; - -import org.apache.olingo.odata4.commons.api.edm.EdmElement; import org.apache.olingo.odata4.commons.api.edm.EdmType; -public interface ExpandVisitor { +/** + * Class indicating the $it reference. $it may be used within filter to + * refer to the last EDM object reference in the resource path. Since $it is + * optional in some cases ( e.g. first member expressions) the {@link #isExplicitIt()} + * method can be used to check if $it was explicitly noted in the URI + */ +public interface UriResourceLambdaRef extends UriResourcePartTyped { - T visitExpandSegment(EdmElement property, EdmType initialType, EdmType finalType); - - T visitExpandItem(List expandSegments, boolean isStar, boolean isRef, EdmType finalType); - - T visitExpand(List expandItems); - + public String getVariableText(); } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceNavigation.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceNavigation.java index de80fd96b..9fd3c8693 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceNavigation.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceNavigation.java @@ -24,10 +24,13 @@ import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty; import org.apache.olingo.odata4.commons.api.edm.EdmType; public interface UriResourceNavigation extends UriResourcePartTyped { - + List getKeyPredicates(); + EdmNavigationProperty getNavigationProperty(); - + EdmType getTypeFilterOnCollection(); + EdmType getTypeFilterOnEntry(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourcePart.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourcePart.java index 0a3312abf..20b101008 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourcePart.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourcePart.java @@ -18,7 +18,11 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri; - public interface UriResourcePart { + UriResourceKind getKind(); + + @Override + String toString(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourcePartTyped.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourcePartTyped.java index a44093d81..54771e9f5 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourcePartTyped.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourcePartTyped.java @@ -22,7 +22,9 @@ package org.apache.olingo.odata4.producer.api.uri; import org.apache.olingo.odata4.commons.api.edm.EdmType; public interface UriResourcePartTyped extends UriResourcePart { + EdmType getType(); boolean isCollection(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceProperty.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceProperty.java index 04cbbf10b..5ff0fcad9 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceProperty.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceProperty.java @@ -21,5 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri; import org.apache.olingo.odata4.commons.api.edm.EdmProperty; public interface UriResourceProperty extends UriResourcePartTyped { + EdmProperty getProperty(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceRef.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceRef.java index bb800325e..8104a361f 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceRef.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceRef.java @@ -18,7 +18,6 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri; - public interface UriResourceRef extends UriResourcePart { - + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceSimpleProperty.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceSimpleProperty.java index 8730e05a1..bfb3868fd 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceSimpleProperty.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceSimpleProperty.java @@ -18,7 +18,6 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri; +public interface UriResourceSimpleProperty extends UriResourceProperty { -public interface UriResourceSimpleProperty extends UriResourceProperty{ - } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceSingleton.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceSingleton.java index 2e0232b3f..2f888db8f 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceSingleton.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceSingleton.java @@ -18,15 +18,15 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri; -import org.apache.olingo.odata4.commons.api.edm.EdmComplexType; import org.apache.olingo.odata4.commons.api.edm.EdmEntityType; import org.apache.olingo.odata4.commons.api.edm.EdmSingleton; -import org.apache.olingo.odata4.commons.api.edm.EdmType; public interface UriResourceSingleton extends UriResourcePartTyped { - EdmSingleton getSingleton(); + EdmEntityType getEntityType(); + EdmEntityType getEntityTypeFilter(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceValue.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceValue.java index d5c8734a6..ea1a15af8 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceValue.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceValue.java @@ -18,7 +18,6 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri; - public interface UriResourceValue extends UriResourcePart { - + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/AliasQueryOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/AliasQueryOption.java index d9fc82816..1b98aba63 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/AliasQueryOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/AliasQueryOption.java @@ -21,6 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression; public interface AliasQueryOption extends QueryOption { - public Expression getAliasValue(); + public Expression getAliasValue(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExceptionVisitExpand.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExceptionVisitExpand.java index 433f5f09f..4e9f332e3 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExceptionVisitExpand.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExceptionVisitExpand.java @@ -20,9 +20,6 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption; public class ExceptionVisitExpand extends Exception { - /** - * - */ - private static final long serialVersionUID = 822365726050299076L; + private static final long serialVersionUID = 1L; } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExpandItem.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExpandItem.java index 55d6b80d2..b22464f9e 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExpandItem.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExpandItem.java @@ -18,14 +18,9 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri.queryoption; -import java.util.List; - -import org.apache.olingo.odata4.producer.api.uri.UriResourceProperty; +import org.apache.olingo.odata4.producer.api.uri.UriInfoResource; public interface ExpandItem { - boolean isStar(); - - List getPropertyChainList(); LevelExpandOption getLevel(); @@ -44,4 +39,11 @@ public interface ExpandItem { SelectOption getSelect(); ExpandOption getExpand(); + + UriInfoResource getPath(); + + boolean isStar(); + + boolean isRef(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExpandOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExpandOption.java index 5ccefd817..ccfb3944d 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExpandOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExpandOption.java @@ -21,5 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption; import java.util.List; public interface ExpandOption extends SystemQueryOption { + List getExpandItems(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/FilterOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/FilterOption.java index b632742dc..98b260bce 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/FilterOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/FilterOption.java @@ -21,5 +21,6 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression; public interface FilterOption extends SystemQueryOption { + Expression getExpression(); } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/FormatOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/FormatOption.java index e6d24b937..2d490ee74 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/FormatOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/FormatOption.java @@ -19,6 +19,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption; public interface FormatOption extends SystemQueryOption { - // TODO select best representation for format + + // TODO Select best representation for format Object getFormat(); } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/IdOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/IdOption.java index f9fa2546b..4024ea8fe 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/IdOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/IdOption.java @@ -19,5 +19,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption; public interface IdOption extends SystemQueryOption { + String getIdValue(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/InlineCountOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/InlineCountOption.java index 032a086ce..cf08cfc30 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/InlineCountOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/InlineCountOption.java @@ -19,5 +19,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption; public interface InlineCountOption extends SystemQueryOption { - boolean getInlineCountValue(); + + boolean getvalue(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/LevelExpandOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/LevelExpandOption.java index 450fd7702..ae569256b 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/LevelExpandOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/LevelExpandOption.java @@ -22,6 +22,6 @@ public interface LevelExpandOption { boolean isMax(); - String getLevel(); + int getLevel(); } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/OrderByItem.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/OrderByItem.java index 7b18473a6..d5aae4574 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/OrderByItem.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/OrderByItem.java @@ -28,7 +28,7 @@ public interface OrderByItem { * @return if false (default) the sort order is ascending, if true the sort order is descending */ boolean isDescending(); - + Expression getExpression(); } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/OrderByOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/OrderByOption.java index 717fac47b..609306fe9 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/OrderByOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/OrderByOption.java @@ -21,7 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption; import java.util.List; public interface OrderByOption extends SystemQueryOption { - + List getOrders(); - + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/QueryOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/QueryOption.java index 01d8f6658..e1e70d47a 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/QueryOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/QueryOption.java @@ -23,4 +23,5 @@ public interface QueryOption { public String getName(); public String getText(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SearchOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SearchOption.java index 903b8c6e0..a3b2e5bba 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SearchOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SearchOption.java @@ -21,6 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption; import org.apache.olingo.odata4.producer.api.uri.queryoption.search.SearchExpression; public interface SearchOption extends SystemQueryOption { - + SearchExpression getSearchExpression(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SelectItem.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SelectItem.java index 20407da97..1a03d316b 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SelectItem.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SelectItem.java @@ -35,9 +35,6 @@ public interface SelectItem { EdmEntityType getEntityTypeCast(); - EdmAction getAction(); - - EdmFunction getFunction(); - List getPropertyChainList(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SelectOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SelectOption.java index 11b5edfe8..7b301fa83 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SelectOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SelectOption.java @@ -21,7 +21,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption; import java.util.List; public interface SelectOption extends SystemQueryOption { - + List getSelectItems(); - + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SkipOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SkipOption.java index f9fc91c08..e9a64e339 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SkipOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SkipOption.java @@ -20,6 +20,6 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption; public interface SkipOption extends SystemQueryOption { - String getSkipValue(); - + String getValue(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SkipTokenOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SkipTokenOption.java deleted file mode 100644 index 995fcbc2f..000000000 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SkipTokenOption.java +++ /dev/null @@ -1,26 +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.producer.api.uri.queryoption; - -public interface SkipTokenOption extends SystemQueryOption{ - - String getSkipTokenValue(); - -} diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SortOrderEnum.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SkiptokenOption.java similarity index 92% rename from odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SortOrderEnum.java rename to odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SkiptokenOption.java index a38fc8c73..8d8259f1d 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SortOrderEnum.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SkiptokenOption.java @@ -18,3 +18,9 @@ * under the License. ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri.queryoption; + +public interface SkiptokenOption extends SystemQueryOption { + + String getValue(); + +} diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SystemQueryOptionEnum.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SupportedQueryOptions.java similarity index 93% rename from odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SystemQueryOptionEnum.java rename to odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SupportedQueryOptions.java index 5ab11dd07..69548182c 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SystemQueryOptionEnum.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SupportedQueryOptions.java @@ -18,7 +18,7 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri.queryoption; -public enum SystemQueryOptionEnum { +public enum SupportedQueryOptions { FILTER("$filter"), FORMAT("$format"), EXPAND("$expand"), @@ -34,7 +34,7 @@ public enum SystemQueryOptionEnum { String syntax; - private SystemQueryOptionEnum(final String syntax) { + private SupportedQueryOptions(final String syntax) { this.syntax = syntax; } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SystemQueryOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SystemQueryOption.java index a6b367710..8abafbd23 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SystemQueryOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SystemQueryOption.java @@ -20,6 +20,6 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption; public interface SystemQueryOption extends QueryOption { - SystemQueryOptionEnum getKind(); + SupportedQueryOptions getKind(); } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/TopOption.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/TopOption.java index a97292968..31d67f1c7 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/TopOption.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/TopOption.java @@ -18,6 +18,8 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri.queryoption; -public interface TopOption extends SystemQueryOption{ +public interface TopOption extends SystemQueryOption { + String getTopValue(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/VisitableExpand.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/VisitableExpand.java deleted file mode 100644 index ebfa4a434..000000000 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/VisitableExpand.java +++ /dev/null @@ -1,48 +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.producer.api.uri.queryoption; - - -/* TODO update documentation*/ -public interface VisitableExpand { - - /** - * Method {@link #accept(ExpressionVisitor)} is called when traversing the expression tree. This method is invoked on - * each - * expression used as node in an expression tree. The implementations should - * behave as follows: - *
  • Call accept on all sub nodes and store the returned Objects - *
  • Call the appropriate method on the {@link ExpressionVisitor} instance and provide the stored objects to that - * instance - *
  • Return the object which should be passed to the processing algorithm of the parent expression node - *
    - *
    - * @param visitor - * Object ( implementing {@link ExpressionVisitor}) whose methods are called during traversing a expression node of - * the expression tree. - * @return - * Object which should be passed to the processing algorithm of the parent expression node - * @throws ExceptionVisitExpression - * Exception occurred the OData library while traversing the tree - * @throws ODataApplicationException - * Exception thrown by the application who implemented the visitor - */ - T accept(ExpandVisitor visitor) throws ExceptionVisitExpand; -} - diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/BinaryExpression.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/BinaryExpression.java index 4d417b021..bd4d1595b 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/BinaryExpression.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/BinaryExpression.java @@ -18,7 +18,7 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri.queryoption.expression; -public interface BinaryExpression { +public interface BinaryExpression extends Expression { public SupportedBinaryOperators getOperator(); diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExceptionVisitExpression.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/ExceptionVisitExpression.java similarity index 86% rename from odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExceptionVisitExpression.java rename to odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/ExceptionVisitExpression.java index c0ff33819..f722ec073 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExceptionVisitExpression.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/ExceptionVisitExpression.java @@ -16,13 +16,10 @@ * specific language governing permissions and limitations * under the License. ******************************************************************************/ -package org.apache.olingo.odata4.producer.core.uri.queryoption.expression; +package org.apache.olingo.odata4.producer.api.uri.queryoption.expression; public class ExceptionVisitExpression extends Exception { - /** - * - */ - private static final long serialVersionUID = 822365726050299076L; + private static final long serialVersionUID = 1L; } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/Expression.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/Expression.java index cbea81df9..5a1b8b1c0 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/Expression.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/Expression.java @@ -18,6 +18,6 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri.queryoption.expression; -public interface Expression { +public interface Expression extends VisitableExression { } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExpressionVisitor.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/ExpressionVisitor.java similarity index 57% rename from odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExpressionVisitor.java rename to odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/ExpressionVisitor.java index 62838652a..ce74805bd 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExpressionVisitor.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/ExpressionVisitor.java @@ -16,25 +16,37 @@ * specific language governing permissions and limitations * under the License. ******************************************************************************/ -package org.apache.olingo.odata4.producer.core.uri.queryoption.expression; +package org.apache.olingo.odata4.producer.api.uri.queryoption.expression; import java.util.List; -import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedBinaryOperators; -import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedMethodCalls; -import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedUnaryOperators; +import org.apache.olingo.odata4.commons.api.edm.EdmType; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; +import org.apache.olingo.odata4.producer.api.uri.UriInfoResource; public interface ExpressionVisitor { - T visitBinaryOperator(SupportedBinaryOperators operator, T left, T right) throws ExceptionVisitExpression; + T visitBinaryOperator(SupportedBinaryOperators operator, T left, T right) + throws ExceptionVisitExpression, ODataApplicationException; - T visitUnaryOperator(SupportedUnaryOperators operator, T operand) throws ExceptionVisitExpression; + T visitUnaryOperator(SupportedUnaryOperators operator, T operand) + throws ExceptionVisitExpression, ODataApplicationException; - T visitMethodCall(SupportedMethodCalls methodCall, List parameters) throws ExceptionVisitExpression; + T visitMethodCall(SupportedMethodCalls methodCall, List parameters) + throws ExceptionVisitExpression, ODataApplicationException; + + T visitLambdaExpression(String variableText, Expression expression) + throws ExceptionVisitExpression, ODataApplicationException; - T visitLiteral(String literal) throws ExceptionVisitExpression; + T visitLiteral(String literal) throws ExceptionVisitExpression, ODataApplicationException; - T visitMember(MemberImpl member) throws ExceptionVisitExpression; + T visitMember(UriInfoResource member) throws ExceptionVisitExpression, ODataApplicationException; - T visitAlias(String referenceName) throws ExceptionVisitExpression; + T visitAlias(String referenceName) throws ExceptionVisitExpression, ODataApplicationException; + + T visitTypeLiteral(EdmType type) throws ExceptionVisitExpression, ODataApplicationException; + + T visitLambdaReference(String variableText) throws ExceptionVisitExpression, ODataApplicationException; + + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/LambdaRef.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/LambdaRef.java index 8a9a966a3..67a18b692 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/LambdaRef.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/LambdaRef.java @@ -18,8 +18,8 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri.queryoption.expression; -public interface LambdaRef { +public interface LambdaRef extends Expression { - public String getVariableText(); + public String getVariableName(); } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/Literal.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/Literal.java index 75dc75324..1d9a76cf1 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/Literal.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/Literal.java @@ -18,8 +18,8 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri.queryoption.expression; -public interface Literal { +public interface Literal extends Expression { - public String getText(); + public String getText(); } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/Member.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/Member.java index be2685810..2af920eb6 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/Member.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/Member.java @@ -20,10 +20,8 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption.expression; import org.apache.olingo.odata4.producer.api.uri.UriInfoResource; -public interface Member { +public interface Member extends Expression { - public boolean isIT(); - - public UriInfoResource getPath(); + public UriInfoResource getPath(); } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/MethodCall.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/MethodCall.java index be82a216f..31dfe9be9 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/MethodCall.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/MethodCall.java @@ -20,12 +20,10 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption.expression; import java.util.List; -public interface MethodCall { +public interface MethodCall extends Expression { public SupportedMethodCalls getMethod(); public List getParameters(); - - } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/SupportedBinaryOperators.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/SupportedBinaryOperators.java index ce85956f3..c6863623a 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/SupportedBinaryOperators.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/SupportedBinaryOperators.java @@ -19,17 +19,17 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption.expression; public enum SupportedBinaryOperators { - //multiplicative + // multiplicative MUL("mul"), DIV("div"), MOD("mod"), - //additive + // additive ADD("add"), SUB("sub"), - //comparism + // comparism GT("gt"), GE("ge"), LT("lt"), LE("le"), - //isof + // isof ISOF("isof"), - //equality + // equality EQ("eq"), NE("ne"), - //and/or + // and/or AND("and"), OR("or"); private String syntax; @@ -38,7 +38,7 @@ public enum SupportedBinaryOperators { this.syntax = syntax; } - public static SupportedBinaryOperators get(String operator) { + public static SupportedBinaryOperators get(final String operator) { for (SupportedBinaryOperators op : SupportedBinaryOperators.values()) { if (op.toString().equals(operator)) { return op; @@ -46,11 +46,10 @@ public enum SupportedBinaryOperators { } return null; } - + @Override public String toString() { return syntax; } - } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/SupportedMethodCalls.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/SupportedMethodCalls.java index db9f3f9b5..55056deb8 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/SupportedMethodCalls.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/SupportedMethodCalls.java @@ -19,18 +19,18 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption.expression; public enum SupportedMethodCalls { - CONTAINS("contains"),STARTSWITH("startswith"),ENDSWITH("endswith"),LENGTH("length"), - INDEXOF("indexof"),SUBSTRING("substring"),TOLOWER("tolower"),TOUPPER("toupper"),TRIM("trim"), + CONTAINS("contains"), STARTSWITH("startswith"), ENDSWITH("endswith"), LENGTH("length"), + INDEXOF("indexof"), SUBSTRING("substring"), TOLOWER("tolower"), TOUPPER("toupper"), TRIM("trim"), CONCAT("concat"), - - YEAR("year"),MONTH("month"),DAY("day"),HOUR("hour"),MINUTE("minute"),SECOND("second"), - FRACTIONALSECOND("fractionalsecond"),TOTALSECONDS("totalseconds"),DATE("date"),TIME("time"), - TOTALOFFSETMINUTES("totaloffsetminutes"),MINDATETIME("mindatetime"),MAXDATETIME("maxdatetime"),NOW("now"), - - ROUND("round"),FLOOR("floor"), - - - CEILING("ceiling"),DISTANCE("distance"),GEOLENGTH("geolength"),INTERSECTS("intersects"), CAST("cast"), ISOF("isof"); + + YEAR("year"), MONTH("month"), DAY("day"), HOUR("hour"), MINUTE("minute"), SECOND("second"), + FRACTIONALSECOND("fractionalsecond"), TOTALSECONDS("totalseconds"), DATE("date"), TIME("time"), + TOTALOFFSETMINUTES("totaloffsetminutes"), MINDATETIME("mindatetime"), MAXDATETIME("maxdatetime"), NOW("now"), + + ROUND("round"), FLOOR("floor"), + + CEILING("ceiling"), DISTANCE("distance"), GEOLENGTH("geolength"), INTERSECTS("intersects"), CAST("cast"), + ISOF("isof"); private String syntax; @@ -43,9 +43,9 @@ public enum SupportedMethodCalls { return syntax; } - public static SupportedMethodCalls get(String operator) { + public static SupportedMethodCalls get(final String operator) { for (SupportedMethodCalls op : SupportedMethodCalls.values()) { - if (op.toString().equals(operator+'(')) { + if (op.toString().equals(operator + '(')) { return op; } } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/SupportedUnaryOperators.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/SupportedUnaryOperators.java index ed6abaa39..cd4a932a9 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/SupportedUnaryOperators.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/SupportedUnaryOperators.java @@ -32,7 +32,7 @@ public enum SupportedUnaryOperators { return syntax; } - public static SupportedUnaryOperators get(String operator) { + public static SupportedUnaryOperators get(final String operator) { for (SupportedUnaryOperators op : SupportedUnaryOperators.values()) { if (op.toString().equals(operator)) { return op; @@ -40,5 +40,5 @@ public enum SupportedUnaryOperators { } return null; } - + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/TypeLiteral.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/TypeLiteral.java index 96cc22832..4aa6bcfbb 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/TypeLiteral.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/TypeLiteral.java @@ -20,10 +20,8 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption.expression; import org.apache.olingo.odata4.commons.api.edm.EdmType; -public interface TypeLiteral { - - public EdmType getType(); - +public interface TypeLiteral extends Expression { + public EdmType getType(); } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/UnaryOperator.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/UnaryOperator.java index 6e85d6baf..62d935c1a 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/UnaryOperator.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/UnaryOperator.java @@ -18,10 +18,10 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.api.uri.queryoption.expression; -public interface UnaryOperator { +public interface UnaryOperator extends Expression { - public abstract Expression getOperand(); + public Expression getOperand(); - public abstract SupportedUnaryOperators getOperator(); + public SupportedUnaryOperators getOperator(); } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/VisitableExression.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/VisitableExression.java similarity index 70% rename from odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/VisitableExression.java rename to odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/VisitableExression.java index e4a223503..ab31dd74f 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/VisitableExression.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/expression/VisitableExression.java @@ -16,39 +16,32 @@ * specific language governing permissions and limitations * under the License. ******************************************************************************/ -package org.apache.olingo.odata4.producer.core.uri.queryoption.expression; +package org.apache.olingo.odata4.producer.api.uri.queryoption.expression; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; - - - - - - -/* TODO update documentation*/ public interface VisitableExression { /** * Method {@link #accept(ExpressionVisitor)} is called when traversing the expression tree. This method is invoked on - * each - * expression used as node in an expression tree. The implementations should + * each expression used as node in an expression tree. The implementations should * behave as follows: - *
  • Call accept on all sub nodes and store the returned Objects - *
  • Call the appropriate method on the {@link ExpressionVisitor} instance and provide the stored objects to that - * instance + *
  • Call accept on all sub nodes and store the returned Objects which are of the generic type T + *
  • Call the appropriate method on the {@link ExpressionVisitor} instance and provide the stored return objects + * to that instance *
  • Return the object which should be passed to the processing algorithm of the parent expression node *
    *
    * @param visitor - * Object ( implementing {@link ExpressionVisitor}) whose methods are called during traversing a expression node of - * the expression tree. + * Object (implementing {@link ExpressionVisitor}) whose methods are called during traversing a + * expression node of the expression tree. * @return - * Object which should be passed to the processing algorithm of the parent expression node + * Object of type T which should be passed to the processing algorithm of the parent expression node * @throws ExceptionVisitExpression * Exception occurred the OData library while traversing the tree * @throws ODataApplicationException * Exception thrown by the application who implemented the visitor */ - T accept(ExpressionVisitor visitor) throws ExceptionVisitExpression; -} + T accept(ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException; +} \ No newline at end of file diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SearchBinary.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SearchBinary.java index b3fe8ce44..c6b123b1a 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SearchBinary.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SearchBinary.java @@ -25,4 +25,5 @@ public interface SearchBinary extends SearchExpression { SearchExpression getLeftOperand(); SearchExpression getRightOperand(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SearchTerm.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SearchTerm.java index 07a35cda6..7979917fb 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SearchTerm.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SearchTerm.java @@ -19,5 +19,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption.search; public interface SearchTerm extends SearchExpression { + String getSearchTerm(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SearchUnary.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SearchUnary.java index 5d02544ae..422641a11 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SearchUnary.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SearchUnary.java @@ -19,5 +19,7 @@ package org.apache.olingo.odata4.producer.api.uri.queryoption.search; public interface SearchUnary { + SearchExpression getOperand(); + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SupportedSearchBinaryOperators.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SupportedSearchBinaryOperators.java index d0810db72..76702b5cc 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SupportedSearchBinaryOperators.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SupportedSearchBinaryOperators.java @@ -27,8 +27,13 @@ public enum SupportedSearchBinaryOperators { private SupportedSearchBinaryOperators(final String syntax) { this.syntax = syntax; } + + @Override + public String toString() { + return syntax; + } - public static SupportedSearchBinaryOperators get(String operator) { + public static SupportedSearchBinaryOperators get(final String operator) { for (SupportedSearchBinaryOperators op : SupportedSearchBinaryOperators.values()) { if (op.toString().equals(operator)) { return op; @@ -37,8 +42,5 @@ public enum SupportedSearchBinaryOperators { return null; } - @Override - public String toString() { - return syntax; - } + } diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SupportedSearchUnaryOperators.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SupportedSearchUnaryOperators.java index add58031a..d62941c28 100644 --- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SupportedSearchUnaryOperators.java +++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/search/SupportedSearchUnaryOperators.java @@ -32,7 +32,7 @@ public enum SupportedSearchUnaryOperators { return syntax; } - public static SupportedSearchUnaryOperators get(String operator) { + public static SupportedSearchUnaryOperators get(final String operator) { for (SupportedSearchUnaryOperators op : SupportedSearchUnaryOperators.values()) { if (op.toString().equals(operator)) { return op; diff --git a/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriParser.g4 b/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriParser.g4 index caf8d5aac..c49d0bc3b 100644 --- a/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriParser.g4 +++ b/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriParser.g4 @@ -110,7 +110,7 @@ valueOnly : vV=commonExpr ; nameValueList : WSP* vlNVP+=nameValuePair WSP* ( COMMA WSP* vlNVP+=nameValuePair WSP*)* ; nameValuePair : vODI=odataIdentifier EQ (AT vALI=odataIdentifier | vCOM=commonExpr /*TODO | val2=enumX*/); -constSegment : SLASH (vV=value | vC=count | vR=ref ); +constSegment : SLASH (vV=value | vC=count | vR=ref | vAll=allExpr | vAny=anyExpr); count : COUNT; ref : REF; @@ -159,8 +159,10 @@ expand : EXPAND EQ vlEI+=expandItem ( COMMA vlEI+=expandItem )*; expandItem : vS=STAR ( SLASH vR=ref | OPEN LEVELS EQ ( vL=INT | vM=MAX) CLOSE )? | vEP=expandPath vEPE=expandPathExtension?; -expandPath : expandPathSegment ( SLASH expandPathSegment )*; -expandPathSegment : vNS=namespace? vODI=odataIdentifier; + +expandPath : vlPS+=pathSegment (SLASH vlPS+=pathSegment)*; +//expandPath : expandPathSegment ( SLASH expandPathSegment )*; +//expandPathSegment : vNS=namespace? vODI=odataIdentifier; expandPathExtension : OPEN vlEO+=expandOption ( SEMI vlEO+=expandOption )* CLOSE | SLASH vR=ref ( OPEN vlEOR+=expandRefOption ( SEMI vlEOR+=expandRefOption )* CLOSE )? diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ErrorCollector.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ErrorCollector.java index 32c9c2e18..834e743b9 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ErrorCollector.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ErrorCollector.java @@ -18,7 +18,6 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri; - import java.util.ArrayList; import java.util.BitSet; import java.util.Collections; @@ -32,11 +31,10 @@ import org.antlr.v4.runtime.atn.ATNConfigSet; import org.antlr.v4.runtime.dfa.DFA; class ErrorCollector implements ANTLRErrorListener { - - private List exceptions = new ArrayList(); - //private ParserValidator tokenValidator; - + private List exceptions = new ArrayList(); + + // private ParserValidator tokenValidator; @Override public void syntaxError(final Recognizer recognizer, final Object offendingSymbol, final int line, @@ -49,7 +47,7 @@ class ErrorCollector implements ANTLRErrorListener { System.out.println("syntaxError"); trace(recognizer, offendingSymbol, line, charPositionInLine, msg, e); - //fail("syntaxError"); + // fail("syntaxError"); } @Override @@ -58,49 +56,53 @@ class ErrorCollector implements ANTLRErrorListener { 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"); - }*/ + * 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"); - }*/ + /* + * // 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"); - }*/ + /* + * if (tokenValidator.logLevel > 0) { + * System.out.println("allowed ContextSensitivity"); + * } + * + * if (!tokenValidator.allowContextSensitifity) { + * printStack(recognizer); + * fail("reportContextSensitivity"); + * } + */ } /* @@ -130,8 +132,8 @@ class ErrorCollector implements ANTLRErrorListener { // 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()]; + // TODO check how the Lexer is accessed in the new package structure + // lexerTokenName = UriLexer.tokenNames[e.getOffendingToken().getType()]; } catch (ArrayIndexOutOfBoundsException es) { lexerTokenName = "token error"; } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ExpandSegmentCount.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ExpandSegmentCount.java deleted file mode 100644 index 5c7e922fd..000000000 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ExpandSegmentCount.java +++ /dev/null @@ -1,25 +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.producer.core.uri; - -import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandSegment; - -public class ExpandSegmentCount extends ExpandSegment { - -} diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ExpandSegmentIt.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ExpandSegmentIt.java deleted file mode 100644 index 0d89c99bc..000000000 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ExpandSegmentIt.java +++ /dev/null @@ -1,25 +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.producer.core.uri; - -import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandSegment; - -public class ExpandSegmentIt extends ExpandSegment { - -} diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ExpandSegmentRef.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ExpandSegmentRef.java deleted file mode 100644 index 9422db0ac..000000000 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ExpandSegmentRef.java +++ /dev/null @@ -1,25 +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.producer.core.uri; - -import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandSegment; - -public class ExpandSegmentRef extends ExpandSegment { - -} diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ParserAdapter.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ParserAdapter.java index ae248e740..3e9ce98a1 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ParserAdapter.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ParserAdapter.java @@ -29,7 +29,7 @@ import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser; import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.OdataRelativeUriEOFContext; public class ParserAdapter { - public static UriInfoImpl parseUri(final String input, UriParseTreeVisitor uriParseTreeVisitor) + public static UriInfoImpl parseUri(final String input, final UriParseTreeVisitor uriParseTreeVisitor) throws UriParserException { try { @@ -61,10 +61,9 @@ public class ParserAdapter { // create parser lexer = new UriLexer(new ANTLRInputStream(input)); parser = new UriParserParser(new CommonTokenStream(lexer)); - + // TODO create better error collector parser.addErrorListener(new ErrorCollector()); - // bail out of parser at first syntax error. --> proceeds in catch block with step 2 parser.setErrorHandler(new BailErrorStrategy()); diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriInfoImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriInfoImpl.java index f60e0ffc6..abcbc32c8 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriInfoImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriInfoImpl.java @@ -44,21 +44,21 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByOption; import org.apache.olingo.odata4.producer.api.uri.queryoption.SearchOption; import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption; import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipTokenOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SkiptokenOption; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; import org.apache.olingo.odata4.producer.api.uri.queryoption.TopOption; import org.apache.olingo.odata4.producer.core.uri.queryoption.CustomQueryOptionImpl; import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandOptionImpl; import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl; import org.apache.olingo.odata4.producer.core.uri.queryoption.FormatOptionImpl; import org.apache.olingo.odata4.producer.core.uri.queryoption.IdOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.InlineCountImpl; +import org.apache.olingo.odata4.producer.core.uri.queryoption.InlineCountOptionImpl; import org.apache.olingo.odata4.producer.core.uri.queryoption.OrderByImpl; import org.apache.olingo.odata4.producer.core.uri.queryoption.QueryOptionImpl; import org.apache.olingo.odata4.producer.core.uri.queryoption.SearchOptionImpl; import org.apache.olingo.odata4.producer.core.uri.queryoption.SelectOptionImpl; import org.apache.olingo.odata4.producer.core.uri.queryoption.SkipOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.SkipTokenOptionImpl; +import org.apache.olingo.odata4.producer.core.uri.queryoption.SkiptokenOptionImpl; import org.apache.olingo.odata4.producer.core.uri.queryoption.SystemQueryOptionImpl; import org.apache.olingo.odata4.producer.core.uri.queryoption.TopOptionImpl; @@ -75,21 +75,17 @@ public class UriInfoImpl implements UriInfo { private FilterOptionImpl filterOption; private FormatOptionImpl formatOption; private IdOption idOption; - private InlineCountImpl inlineCountOption; + private InlineCountOptionImpl inlineCountOption; private OrderByImpl orderByOption; private SearchOptionImpl searchOption; private SelectOptionImpl selectOption; private SkipOptionImpl skipOption; - private SkipTokenOptionImpl skipTokenOption; + private SkiptokenOptionImpl skipTokenOption; private TopOptionImpl topOption; - private UriResourcePart lastPathPart; + private UriResourcePart lastResourcePart; private List pathParts = new ArrayList(); - public UriInfoImpl(Edm edm) { - // this.edm = edm; - } - @Override public UriInfoAll asUriInfoAll() { return this; @@ -125,26 +121,27 @@ public class UriInfoImpl implements UriInfo { return Collections.unmodifiableList(entitySetNames); } - public void addEntitySetName(String entitySet) { + public void addEntitySetName(final String entitySet) { entitySetNames.add(entitySet); } @Override public List getUriResourceParts() { List returnList = new ArrayList(); - for (UriResourcePart part : pathParts) { - returnList.add(part); + for (UriResourcePart item : pathParts) { + returnList.add(item); } return Collections.unmodifiableList(returnList); } - public void addPathInfo(UriResourcePartImpl uriPathInfo) { + public void addPathInfo(final UriResourcePartImpl uriPathInfo) { pathParts.add(uriPathInfo); - lastPathPart = uriPathInfo; + lastResourcePart = uriPathInfo; } @Override public String getContext() { + // TODO add support for UTI context part return null; } @@ -192,13 +189,12 @@ public class UriInfoImpl implements UriInfo { return kind; } - public UriResourcePart getLastUriPathInfo() { - return lastPathPart; + public UriResourcePart getLastResourcePart() { + return lastResourcePart; } @Override public OrderByOption getOrderByOption() { - return orderByOption; } @@ -219,7 +215,7 @@ public class UriInfoImpl implements UriInfo { } @Override - public SkipTokenOption getSkipTokenOption() { + public SkiptokenOption getSkipTokenOption() { return skipTokenOption; } @@ -228,13 +224,12 @@ public class UriInfoImpl implements UriInfo { return topOption; } - public UriInfoImpl setEntityTypeCast(EdmEntityType type) { - + public UriInfoImpl setEntityTypeCast(final EdmEntityType type) { entityTypeCast = type; return this; } - public UriInfoImpl setFormat(FormatOptionImpl formatOption) { + public UriInfoImpl setFormat(final FormatOptionImpl formatOption) { this.formatOption = formatOption; return this; } @@ -244,33 +239,33 @@ public class UriInfoImpl implements UriInfo { return this; } - public UriInfoImpl setQueryOptions(List list) { + public UriInfoImpl setQueryOptions(final List list) { for (QueryOptionImpl item : list) { if (item instanceof SystemQueryOptionImpl) { SystemQueryOptionImpl sysItem = (SystemQueryOptionImpl) item; - if (sysItem.getKind() == SystemQueryOptionEnum.EXPAND) { + if (sysItem.getKind() == SupportedQueryOptions.EXPAND) { expandOption = (ExpandOptionImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.FILTER) { + } else if (sysItem.getKind() == SupportedQueryOptions.FILTER) { filterOption = (FilterOptionImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.FORMAT) { + } else if (sysItem.getKind() == SupportedQueryOptions.FORMAT) { formatOption = (FormatOptionImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.ID) { + } else if (sysItem.getKind() == SupportedQueryOptions.ID) { idOption = (IdOptionImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.INLINECOUNT) { - inlineCountOption = (InlineCountImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.ORDERBY) { + } else if (sysItem.getKind() == SupportedQueryOptions.INLINECOUNT) { + inlineCountOption = (InlineCountOptionImpl) sysItem; + } else if (sysItem.getKind() == SupportedQueryOptions.ORDERBY) { orderByOption = (OrderByImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.SEARCH) { + } else if (sysItem.getKind() == SupportedQueryOptions.SEARCH) { searchOption = (SearchOptionImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.SELECT) { + } else if (sysItem.getKind() == SupportedQueryOptions.SELECT) { selectOption = (SelectOptionImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.SKIP) { + } else if (sysItem.getKind() == SupportedQueryOptions.SKIP) { skipOption = (SkipOptionImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.SKIPTOKEN) { - skipTokenOption = (SkipTokenOptionImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.TOP) { + } else if (sysItem.getKind() == SupportedQueryOptions.SKIPTOKEN) { + skipTokenOption = (SkiptokenOptionImpl) sysItem; + } else if (sysItem.getKind() == SupportedQueryOptions.TOP) { topOption = (TopOptionImpl) sysItem; } } else if (item instanceof CustomQueryOptionImpl) { @@ -287,7 +282,5 @@ public class UriInfoImpl implements UriInfo { public void clearPathInfo() { pathParts.clear(); - } - -} +} \ No newline at end of file diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParameterImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParameterImpl.java index 2fd0ef0ef..8f5e10f93 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParameterImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParameterImpl.java @@ -33,7 +33,7 @@ public class UriParameterImpl implements UriParameter { return name; } - public UriParameterImpl setName(String name) { + public UriParameterImpl setName(final String name) { this.name = name; return this; } @@ -43,7 +43,7 @@ public class UriParameterImpl implements UriParameter { return alias; } - public UriParameterImpl setAlias(String alias) { + public UriParameterImpl setAlias(final String alias) { this.alias = alias; return this; } @@ -53,7 +53,7 @@ public class UriParameterImpl implements UriParameter { return text; } - public UriParameterImpl setText(String text) { + public UriParameterImpl setText(final String text) { this.text = text; return this; } @@ -64,7 +64,7 @@ public class UriParameterImpl implements UriParameter { return expression; } - public UriParameterImpl setExpression(Expression expression) { + public UriParameterImpl setExpression(final Expression expression) { this.expression = expression; return this; } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParseTreeVisitor.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParseTreeVisitor.java index 2ae567529..4e07ae475 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParseTreeVisitor.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParseTreeVisitor.java @@ -46,115 +46,17 @@ import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName; import org.apache.olingo.odata4.producer.api.uri.UriInfoKind; import org.apache.olingo.odata4.producer.api.uri.UriResourcePart; import org.apache.olingo.odata4.producer.api.uri.UriResourcePartTyped; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectItem; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedBinaryOperators; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedMethodCalls; import org.apache.olingo.odata4.producer.core.uri.antlr.UriLexer; import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserBaseVisitor; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AliasAndValueContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AllExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltAddContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltAllContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltAndContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltAnyContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltBatchContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltComparismContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltEntityCastContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltEntityContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltEqualityContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltLiteralContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltMetadataContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltMultContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltOrContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AltResourcePathContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.AnyExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.CastExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.CeilingMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ConcatMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ConstSegmentContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ContainsMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.CrossjoinContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.CustomQueryOptionContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.DayMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.DistanceMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.EndsWithMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.EntityOptionCastContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.EntityOptionContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.EntityOptionsCastContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.EntityOptionsContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ExpandContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ExpandCountOptionContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ExpandItemContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ExpandOptionContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ExpandPathContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ExpandPathExtensionContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ExpandPathSegmentContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ExpandRefOptionContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.FilterContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.FloorMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.FormatContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.FractionalsecondsMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.GeoLengthMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.HourMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.IdContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.IndexOfMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.InlinecountContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.IntersectsMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.IsofExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.LengthMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.MaxDateTimeMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.MemberExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.MinDateTimeMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.MinuteMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.MonthMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.NameValueOptListContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.NameValuePairContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.NamespaceContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.NowMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.OdataIdentifierContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.OdataRelativeUriEOFContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.OrderByContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.PathSegmentContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.PathSegmentsContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.QueryOptionContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.QueryOptionsContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ResourcePathContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.RootExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.RoundMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.SecondMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.SelectContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.SelectItemContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.SelectSegmentContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.StartsWithMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.SubstringMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.TimeMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ToLowerMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.ToUpperMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.TotalOffsetMinutesMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.TotalsecondsMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.TrimMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.UnaryContext; -import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.YearMethodCallExprContext; -import org.apache.olingo.odata4.producer.core.uri.queryoption.AliasQueryOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.CustomQueryOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandItemImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandSegment; -import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.FormatOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.IdOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.LevelOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.OrderByOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.QueryOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.SelectItemOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.SelectOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.SystemQueryOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.BinaryImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.LambdaRefImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.LiteralImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.MemberImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.MethodCallImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.TypeLiteralImpl; +import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.SkipContext; +import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.SkiptokenContext; +import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.TopContext; +import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.*; +import org.apache.olingo.odata4.producer.core.uri.queryoption.*; +import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.*; /** * UriVisitor @@ -173,21 +75,20 @@ import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.TypeLit * - Parsing the context of $metadata */ public class UriParseTreeVisitor extends UriParserBaseVisitor { - private Edm edm; + private EdmEntityContainer edmEntityContainer; - // --- context --- - private SelectItemOptionImpl contextSelectItem; - private UriInfoImpl contextUriInfo; - /** - * Set within method {@link #visitExpandPath(ExpandPathContext ctx)} to allow nodes - * deeper in the parse tree appending path segments to the currently processed {@link ExpandItemImpl}. - *
  • The context is required because the following path segments depend on the successor.
  • - *
  • A stack is used because the $expand system query option can be nested.
  • + * Hold all currently allowed lambda variables + * As lambda functions can be nested there may be more than one allowed lambda variables while parsing a + * $filter or $orderby expression. */ - private Stack contextExpandItemPath = new Stack(); + private class LambdaVariables { + public boolean isCollection; + public String name; + public EdmType type; + } /** * Set to allow nodes deeper in the parse tree appending path segments to the currently @@ -196,91 +97,165 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { *
  • A stack is used because some system query options which are applied to the last type can * be nested ($expand, $filter)
  • */ - private Stack contextType = new Stack(); - private Stack lambdaVariables = new Stack(); - private LambdaRefImpl contextDetectedLambda; + private class LastTypeColl { + private boolean isCollection; + private EdmType type; - public UriParseTreeVisitor(Edm edm) { - this.edm = edm; - this.edmEntityContainer = edm.getEntityContainer(null); + LastTypeColl(EdmType type, boolean isCollection) { + this.type = type; + this.isCollection = isCollection; + } } - public UriResourceImplTyped readFirstPathInfoSegment(PathSegmentContext ctx) { - UriInfoImpl uriInfoResource = this.contextUriInfo; + // --- context --- + private Stack allowedLambdaVariables = new Stack(); + + /** + * Set within method {@link #visitExpandItem(ExpandPathContext ctx)} and {@link #visitExpandPathExtension(final + * ExpandPathExtensionContext ctx)} to allow nodes + * deeper in the expand tree at {@link #visitExpandPathExtension(ExpandPathExtensionContext ctx)} appending path + * segments to the currently processed {@link ExpandItemImpl}. + */ + private ExpandItemImpl contextExpandItemPath; + + /** + * Set within method {@link #visitSelectItem(SelectItemContext ctx)} to allow nodes + * deeper in the expand tree at {@link #visitSelectSegment(SelectSegmentContext ctx)} appending path segments to the + * currently processed {@link SelectItemOptionImpl}. + */ + private SelectItemOptionImpl contextSelectItem; + + private Stack contextTypes = new Stack(); + + /** + * Stores the currently processed UriInfo objects. There is one URI Info object for the resource path + * and one for each new first member access within $filter and $orderBy options. + */ + private UriInfoImpl contextUriInfo; + + // --- class --- + + public UriParseTreeVisitor(final Edm edm) { + this.edm = edm; + edmEntityContainer = edm.getEntityContainer(null); + } + + private FullQualifiedName getFullName(final NamespaceContext vNS, final String odi) { + if (vNS != null) { + String namespace = vNS.getText(); + namespace = namespace.substring(0, namespace.length() - 1); + + return new FullQualifiedName(namespace, odi); + } + return null; + + } + + /* here */ + private LambdaVariables getLambdaVar(String odi) { + for (LambdaVariables item : this.allowedLambdaVariables) { + if (item.name.equals(odi)) { + return item; + } + } + return null; + } + + private EdmType getLastType(final UriResourceImplTyped lastResourceSegment) { + if (lastResourceSegment instanceof UriResourceImplKeyPred) { + UriResourceImplKeyPred lastKeyPred = (UriResourceImplKeyPred) lastResourceSegment; + if (lastKeyPred.getTypeFilterOnEntry() != null) { + return lastKeyPred.getTypeFilterOnEntry(); + } else if (lastKeyPred.getTypeFilterOnCollection() != null) { + return lastKeyPred.getTypeFilterOnCollection(); + } + } + EdmType type = lastResourceSegment.getTypeFilter(); + if (type != null) { + return type; + } + + return lastResourceSegment.getType(); + } + + public UriResourceImplTyped readFirstPathInfoSegment(final PathSegmentContext ctx) { String odi = ctx.vODI.getText(); // check EntitySet - EdmEntitySet edmES = edmEntityContainer.getEntitySet(odi); - if (edmES != null) { - UriResourceEntitySetImpl uriPathInfo = new UriResourceEntitySetImpl(); - uriPathInfo.setEntitSet(edmES); - uriInfoResource.addPathInfo(uriPathInfo); + EdmEntitySet edmEntitySet = edmEntityContainer.getEntitySet(odi); + if (edmEntitySet != null) { + UriResourceEntitySetImpl uriResource = new UriResourceEntitySetImpl(); + uriResource.setEntitSet(edmEntitySet); + contextUriInfo.addPathInfo(uriResource); return null; } // check Singleton - EdmSingleton edmSI = edmEntityContainer.getSingleton(odi); - if (edmSI != null) { - UriResourceSingletonImpl uriPathInfo = new UriResourceSingletonImpl(); - uriPathInfo.setSingleton(edmSI); - uriInfoResource.addPathInfo(uriPathInfo); + EdmSingleton edmSingleton = edmEntityContainer.getSingleton(odi); + if (edmSingleton != null) { + UriResourceSingletonImpl uriResource = new UriResourceSingletonImpl(); + uriResource.setSingleton(edmSingleton); + contextUriInfo.addPathInfo(uriResource); return null; } // check ActionImport - EdmActionImport edmAI = edmEntityContainer.getActionImport(odi); - if (edmAI != null) { - UriResourceActionImpl uriPathInfo = new UriResourceActionImpl(); - uriPathInfo.setActionImport(edmAI); - - uriInfoResource.addPathInfo(uriPathInfo); + EdmActionImport edmActionImport = edmEntityContainer.getActionImport(odi); + if (edmActionImport != null) { + UriResourceActionImpl uriResource = new UriResourceActionImpl(); + uriResource.setActionImport(edmActionImport); + contextUriInfo.addPathInfo(uriResource); return null; } // check FunctionImport - EdmFunctionImport edmFI = edmEntityContainer.getFunctionImport(odi); - if (edmFI != null) { + EdmFunctionImport edmFunctionImport = edmEntityContainer.getFunctionImport(odi); + if (edmFunctionImport != null) { // read the URI parameters List parameters = (List) ctx.vlNVO.get(0).accept(this); ctx.vlNVO.remove(0); // parameters are consumed - UriResourceFunctionImpl uriPathInfo = new UriResourceFunctionImpl(); - uriPathInfo.setFunctionImport(edmFI, parameters); - uriInfoResource.addPathInfo(uriPathInfo); + UriResourceFunctionImpl uriResource = new UriResourceFunctionImpl(); + uriResource.setFunctionImport(edmFunctionImport, parameters); + contextUriInfo.addPathInfo(uriResource); return null; } - throw wrap(new UriParserSemanticException("Unkown path segment found: " + odi)); + throw wrap(new UriParserSemanticException("Unkown path segment: " + odi)); } - public UriResourceImplTyped readNextPathInfoSegment(PathSegmentContext ctx) { + public UriResourceImplTyped readNextPathInfoSegment(final PathSegmentContext ctx) { String odi = ctx.vODI.getText(); - if (!(this.contextUriInfo.getLastUriPathInfo() instanceof UriResourceImplTyped)) { + UriResourcePart lastResource = contextUriInfo.getLastResourcePart(); + if (!(lastResource instanceof UriResourceImplTyped)) { throw wrap(new UriParserSemanticException("Previous path segment not typed")); } - UriResourceImplTyped lastSegment = (UriResourceImplTyped) this.contextUriInfo.getLastUriPathInfo(); - // TODO add check for type filters + UriResourceImplTyped lastTyped = (UriResourceImplTyped) lastResource; - if (ctx.vNS == null) { + if (ctx.vNS == null) { // without namespace - //first check for lamda variable because a newly add property should not shaddow a long used lamdavarable - - if (this.lambdaVariables.contains(odi)) { - contextDetectedLambda = new LambdaRefImpl().setVariableText(odi); + // first check for lambda variable because a newly add property should not shadow a long used lambda variable + LambdaVariables lVar = getLambdaVar(odi); + if (lVar != null) { + UriResourceLambdaRefImpl lambdaResource = new UriResourceLambdaRefImpl(); + lambdaResource.setVariableText(lVar.name); + lambdaResource.setType(lVar.type); + lambdaResource.isCollection(lVar.isCollection); + contextUriInfo.addPathInfo(lambdaResource); return null; } - - // - EdmType targetType = getLastType(lastSegment); + + EdmType targetType = getLastType(lastTyped); if (!(targetType instanceof EdmStructuralType)) { - throw wrap(new UriParserSemanticException("Property " + odi + " not found")); + throw wrap(new UriParserSemanticException("Previous path segment not a structural type")); } EdmStructuralType structType = (EdmStructuralType) targetType; + EdmElement property = structType.getProperty(odi); if (property == null) { throw wrap(new UriParserSemanticException("Unkown property: " + odi)); @@ -288,100 +263,109 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (property instanceof EdmProperty) { if (((EdmProperty) property).isPrimitive() == true) { - UriResourceSimplePropertyImpl uriPropertyImpl = new UriResourceSimplePropertyImpl(); - uriPropertyImpl.setProperty((EdmProperty) property); - this.contextUriInfo.addPathInfo(uriPropertyImpl); + // create simple property + UriResourceSimplePropertyImpl simpleResource = new UriResourceSimplePropertyImpl(); + simpleResource.setProperty((EdmProperty) property); + contextUriInfo.addPathInfo(simpleResource); return null; } else { - UriResourceComplexPropertyImpl uriPropertyImpl = new UriResourceComplexPropertyImpl(); - uriPropertyImpl.setProperty((EdmProperty) property); - this.contextUriInfo.addPathInfo(uriPropertyImpl); + // create complex property + UriResourceComplexPropertyImpl complexResource = new UriResourceComplexPropertyImpl(); + complexResource.setProperty((EdmProperty) property); + contextUriInfo.addPathInfo(complexResource); return null; } } else if (property instanceof EdmNavigationProperty) { - UriResourceNavigationPropertyImpl uriPathInfoNavigation = new UriResourceNavigationPropertyImpl(); - uriPathInfoNavigation.addNavigationProperty((EdmNavigationProperty) property); - contextUriInfo.addPathInfo(uriPathInfoNavigation); + // create navigation property + UriResourceNavigationPropertyImpl navigationResource = new UriResourceNavigationPropertyImpl(); + navigationResource.setNavigationProperty((EdmNavigationProperty) property); + contextUriInfo.addPathInfo(navigationResource); return null; } else { throw wrap(new UriParserSemanticException("Unkown property type")); } - } else { - FullQualifiedName fullName = getFullName(ctx.vNS, odi); - EdmType lastType = getLastType(lastSegment); + } else { // with namespace + + FullQualifiedName fullFilterName = getFullName(ctx.vNS, odi); + + EdmType lastType = getLastType(lastTyped); if (lastType instanceof EdmEntityType) { - EdmEntityType et = edm.getEntityType(fullName); - if (et != null) { - // is simple entity type cast - if (!(et.compatibleTo(lastType))) { - throw wrap(new UriParserSemanticException("Types not kompatible")); + EdmEntityType filterEntityType = edm.getEntityType(fullFilterName); + if (filterEntityType != null) { + + // is entity type cast + if (!(filterEntityType.compatibleTo(lastType))) { + throw wrap(new UriParserSemanticException( + "Entity typefilter not compatible to previous path segment: " + fullFilterName.toString())); } - // check if last segement may contain key properties - if (lastSegment instanceof UriResourceImplKeyPred) { - UriResourceImplKeyPred lastKeyPred = (UriResourceImplKeyPred) lastSegment; + // check if last segment may contain key properties + if (lastTyped instanceof UriResourceImplKeyPred) { + UriResourceImplKeyPred lastKeyPred = (UriResourceImplKeyPred) lastTyped; if (lastKeyPred.isCollection() == false) { if (lastKeyPred.getTypeFilterOnEntry() != null) { - throw wrap(new UriParserSemanticException("Single typeFilter are not chainable")); + throw wrap(new UriParserSemanticException("Single type filters are not chainable")); } - lastKeyPred.setSingleTypeFilter(et); + lastKeyPred.setSingleTypeFilter(filterEntityType); return null; } else { if (lastKeyPred.getTypeFilterOnCollection() != null) { - throw wrap(new UriParserSemanticException("Collection typeFilters are not chainable")); + throw wrap(new UriParserSemanticException("Collection type filters are not chainable")); } - lastKeyPred.setCollectionTypeFilter(et); + lastKeyPred.setCollectionTypeFilter(filterEntityType); return null; } - } else { - // is - if (lastSegment.getTypeFilter() != null) { - throw wrap(new UriParserSemanticException("Chaining typefilters not allowed")); + if (lastTyped.getTypeFilter() != null) { + throw wrap(new UriParserSemanticException("type filters are not chainable")); } - lastSegment.setTypeFilter(et); + lastTyped.setTypeFilter(filterEntityType); return null; } - } - } else if (lastType instanceof EdmComplexType) { - EdmComplexType ct = edm.getComplexType(fullName); - if (ct != null) { - if (!(ct.compatibleTo(lastType))) { - throw wrap(new UriParserSemanticException("Types not kompatible")); + } else if (lastType instanceof EdmComplexType) { + + EdmComplexType filterComplexType = edm.getComplexType(fullFilterName); + + if (filterComplexType != null) { + + // is complex type cast + if (!(filterComplexType.compatibleTo(lastType))) { + throw wrap(new UriParserSemanticException( + "Complex typefilter not compatible to previous path segment: " + fullFilterName.toString())); } // is simple complex type cast - if (lastSegment instanceof UriResourceImplKeyPred) { - UriResourceImplKeyPred lastKeyPred = (UriResourceImplKeyPred) lastSegment; + if (lastTyped instanceof UriResourceImplKeyPred) { + // e.g. in case of function returning complex data or a list of complex data + UriResourceImplKeyPred lastKeyPred = (UriResourceImplKeyPred) lastTyped; if (lastKeyPred.isCollection() == false) { if (lastKeyPred.getTypeFilterOnEntry() != null) { throw wrap(new UriParserSemanticException("Single TypeFilter are not chainable")); } - lastKeyPred.setSingleTypeFilter(ct); + lastKeyPred.setSingleTypeFilter(filterComplexType); return null; } else { if (lastKeyPred.getTypeFilterOnCollection() != null) { throw wrap(new UriParserSemanticException("Collection TypeFilter are not chainable")); } - lastKeyPred.setCollectionTypeFilter(ct); + lastKeyPred.setCollectionTypeFilter(filterComplexType); return null; } } else { - - if (lastSegment.getTypeFilter() != null) { + if (lastTyped.getTypeFilter() != null) { throw wrap(new UriParserSemanticException("Chaining Typefilters not allowed")); } - lastSegment.setTypeFilter(ct); + lastTyped.setTypeFilter(filterComplexType); return null; } } @@ -390,15 +374,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { FullQualifiedName fullBindingTypeName = new FullQualifiedName(lastType.getNamespace(), lastType.getName()); // check for action - EdmAction action = edm.getAction(fullName, fullBindingTypeName, lastSegment.isCollection()); + EdmAction action = edm.getAction(fullFilterName, fullBindingTypeName, lastTyped.isCollection()); if (action != null) { UriResourceActionImpl pathInfoAction = new UriResourceActionImpl(); pathInfoAction.setAction(action); - this.contextUriInfo.addPathInfo(pathInfoAction); + contextUriInfo.addPathInfo(pathInfoAction); return null; } - // path segemend is not a complex type and not a entity type // do a check for bound functions (which requires the parameter list) if (ctx.vlNVO.size() == 0) { @@ -407,81 +390,75 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { List parameters = (List) ctx.vlNVO.get(0).accept(this); - // handle bound function - // get names of function parameters List names = new ArrayList(); for (UriParameterImpl item : parameters) { names.add(item.getName()); } - EdmFunction function = - edm.getFunction(fullName, fullBindingTypeName, lastSegment.isCollection(), names); + EdmFunction function = edm.getFunction(fullFilterName, fullBindingTypeName, lastTyped.isCollection(), names); if (function != null) { UriResourceFunctionImpl pathInfoFunction = new UriResourceFunctionImpl(); pathInfoFunction.setFunction(function); pathInfoFunction.setParameters(parameters); - this.contextUriInfo.addPathInfo(pathInfoFunction); - ctx.vlNVO.remove(0);// as the parameters are consumed + contextUriInfo.addPathInfo(pathInfoFunction); + ctx.vlNVO.remove(0);// parameters are consumed return null; } - // check for special case - if (lastSegment instanceof UriResourceItImpl) { - if (((UriResourceItImpl) lastSegment).isExplicitIt() == false) { + // check for unbound function in the $filter case ( where the previous resource segment is a $it) + if (lastTyped instanceof UriResourceItImpl) { + if (((UriResourceItImpl) lastTyped).isExplicitIt() == false) { // check for unbound function - EdmFunction functionUnbound = - edm.getFunction(fullName, null, lastSegment.isCollection(), names); + EdmFunction functionUnbound = edm.getFunction(fullFilterName, null, lastTyped.isCollection(), names); if (functionUnbound != null) { - this.contextUriInfo.clearPathInfo(); // replace the $it + contextUriInfo.clearPathInfo(); // replace the $it + // TODO maybe add $root pathinfo first UriResourceFunctionImpl pathInfoFunction = new UriResourceFunctionImpl(); pathInfoFunction.setFunction(functionUnbound); pathInfoFunction.setParameters(parameters); - this.contextUriInfo.addPathInfo(pathInfoFunction); - ctx.vlNVO.remove(0);// as the parameters are consumed + contextUriInfo.addPathInfo(pathInfoFunction); + ctx.vlNVO.remove(0);// parameters are consumed return null; } } } - throw wrap(new UriParserSemanticException("Unknown resource path segment:" + fullName.toString())); + throw wrap(new UriParserSemanticException("Unknown resource path segment:" + fullFilterName.toString())); } - - } - - private EdmType getLastType(UriResourceImplTyped lastSegment) { - if (lastSegment instanceof UriResourceImplKeyPred) { - UriResourceImplKeyPred lastKeyPred = (UriResourceImplKeyPred) lastSegment; - if (lastKeyPred.getTypeFilterOnEntry() != null) { - return lastKeyPred.getTypeFilterOnEntry(); - } else if (lastKeyPred.getTypeFilterOnCollection() != null) { - return lastKeyPred.getTypeFilterOnCollection(); - } - } - EdmType type = lastSegment.getTypeFilter(); - if (type != null) { - return type; - } - - return lastSegment.getType(); } @Override - public Object visitAliasAndValue(AliasAndValueContext ctx) { - + public Object visitAliasAndValue(final AliasAndValueContext ctx) { AliasQueryOptionImpl alias = new AliasQueryOptionImpl(); - alias.setName(ctx.vODI.getText()); alias.setText(ctx.vV.getText()); alias.setAliasValue((ExpressionImpl) ctx.vV.accept(this)); - return alias; } @Override - public ExpressionImpl visitAltAdd(AltAddContext ctx) { + public Object visitAllExpr(final AllExprContext ctx) { + UriResourceAllImpl all = new UriResourceAllImpl(); + + LastTypeColl lastTypeInfo = this.contextTypes.peek(); + + LambdaVariables var = new LambdaVariables(); + var.name = ctx.vLV.getText(); + var.type = lastTypeInfo.type; + var.isCollection = lastTypeInfo.isCollection; + + all.setLamdaVariable(ctx.vLV.getText()); + allowedLambdaVariables.push(var); + all.setExpression((ExpressionImpl) ctx.vLE.accept(this)); + allowedLambdaVariables.pop(); + return all; + } + + @Override + public ExpressionImpl visitAltAdd(final AltAddContext ctx) { BinaryImpl binary = new BinaryImpl(); int tokenIndex = ctx.vO.getType(); @@ -498,7 +475,23 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public ExpressionImpl visitAltAnd(AltAndContext ctx) { + public Object visitAltAll(final AltAllContext ctx) { + UriInfoImpl uriInfoImplpath = new UriInfoImpl().setKind(UriInfoKind.resource); + + UriResourceItImpl pathInfoIT = new UriResourceItImpl(); + LastTypeColl lastTypeInfo = this.contextTypes.peek(); + pathInfoIT.setType(lastTypeInfo.type); + pathInfoIT.setCollection(lastTypeInfo.isCollection); + + uriInfoImplpath.addPathInfo(pathInfoIT); + uriInfoImplpath.addPathInfo((UriResourcePartImpl) super.visitAltAll(ctx)); + + return new MemberImpl() + .setPath(uriInfoImplpath); + } + + @Override + public ExpressionImpl visitAltAnd(final AltAndContext ctx) { BinaryImpl binary = new BinaryImpl(); binary.setOperator(SupportedBinaryOperators.AND); @@ -508,13 +501,28 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitAltBatch(AltBatchContext ctx) { - this.contextUriInfo = new UriInfoImpl(edm).setKind(UriInfoKind.batch); + public Object visitAltAny(final AltAnyContext ctx) { + UriInfoImpl uriInfoImplpath = new UriInfoImpl().setKind(UriInfoKind.resource); + + UriResourceItImpl pathInfoIT = new UriResourceItImpl(); + pathInfoIT.setType(contextTypes.peek().type); + pathInfoIT.setCollection(contextTypes.peek().isCollection); + + uriInfoImplpath.addPathInfo(pathInfoIT); + uriInfoImplpath.addPathInfo((UriResourcePartImpl) super.visitAltAny(ctx)); + + return new MemberImpl() + .setPath(uriInfoImplpath); + } + + @Override + public Object visitAltBatch(final AltBatchContext ctx) { + contextUriInfo = new UriInfoImpl().setKind(UriInfoKind.batch); return null; } @Override - public ExpressionImpl visitAltComparism(AltComparismContext ctx) { + public ExpressionImpl visitAltComparism(final AltComparismContext ctx) { BinaryImpl binary = new BinaryImpl(); int tokenIndex = ctx.vO.getType(); @@ -537,19 +545,19 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitAltEntity(AltEntityContext ctx) { - UriInfoImpl uriInfo = new UriInfoImpl(edm).setKind(UriInfoKind.entityId); + public Object visitAltEntity(final AltEntityContext ctx) { + UriInfoImpl uriInfo = new UriInfoImpl().setKind(UriInfoKind.entityId); List list = (List) ctx.vEO.accept(this); uriInfo.setQueryOptions(list); - this.contextUriInfo = uriInfo; + contextUriInfo = uriInfo; return null; } @Override - public Object visitAltEntityCast(AltEntityCastContext ctx) { - UriInfoImpl uriInfo = new UriInfoImpl(edm).setKind(UriInfoKind.entityId); + public Object visitAltEntityCast(final AltEntityCastContext ctx) { + UriInfoImpl uriInfo = new UriInfoImpl().setKind(UriInfoKind.entityId); String odi = ctx.vODI.getText(); FullQualifiedName fullName = getFullName(ctx.vNS, odi); @@ -559,9 +567,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { throw wrap(new UriParserSemanticException("Expected EntityTypeName")); } uriInfo.setEntityTypeCast(type); - + contextUriInfo = uriInfo; - contextType.push(uriInfo.getEntityTypeCast()); + contextTypes.push(new LastTypeColl(uriInfo.getEntityTypeCast(), true)); List list = (List) ctx.vEO.accept(this); uriInfo.setQueryOptions(list); @@ -569,12 +577,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { return null; } - private ParseCancellationException wrap(UriParserException uriParserException) { - return new ParseCancellationException(uriParserException); - } - @Override - public ExpressionImpl visitAltEquality(AltEqualityContext ctx) { + public ExpressionImpl visitAltEquality(final AltEqualityContext ctx) { BinaryImpl binary = new BinaryImpl(); int tokenIndex = ctx.vO.getType(); @@ -591,13 +595,13 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitAltLiteral(AltLiteralContext ctx) { + public Object visitAltLiteral(final AltLiteralContext ctx) { return new LiteralImpl().setText(ctx.getText()); } @Override - public Object visitAltMetadata(AltMetadataContext ctx) { - UriInfoImpl uriInfo = new UriInfoImpl(edm).setKind(UriInfoKind.metadata); + public Object visitAltMetadata(final AltMetadataContext ctx) { + UriInfoImpl uriInfo = new UriInfoImpl().setKind(UriInfoKind.metadata); if (ctx.vF != null) { FormatOptionImpl format = (FormatOptionImpl) ctx.vF.accept(this); @@ -608,12 +612,12 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { throw wrap(new UriParserException("Fragment for $metadata not supported")); } - this.contextUriInfo = uriInfo; + contextUriInfo = uriInfo; return null; } @Override - public ExpressionImpl visitAltMult(AltMultContext ctx) { + public ExpressionImpl visitAltMult(final AltMultContext ctx) { BinaryImpl binary = new BinaryImpl(); int tokenIndex = ctx.vO.getType(); @@ -632,7 +636,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public ExpressionImpl visitAltOr(AltOrContext ctx) { + public ExpressionImpl visitAltOr(final AltOrContext ctx) { BinaryImpl binary = new BinaryImpl(); binary.setOperator(SupportedBinaryOperators.OR); @@ -643,14 +647,15 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitAltResourcePath(AltResourcePathContext ctx) { + public Object visitAltResourcePath(final AltResourcePathContext ctx) { ctx.vRP.accept(this); if (ctx.vQO != null) { - UriResourcePart lastSegment = contextUriInfo.getLastUriPathInfo(); + UriResourcePart lastSegment = contextUriInfo.getLastResourcePart(); if (lastSegment instanceof UriResourceImplTyped) { - contextType.push(getLastType((UriResourceImplTyped) lastSegment)); + UriResourceImplTyped typed = (UriResourceImplTyped) lastSegment; + contextTypes.push(new LastTypeColl(getLastType(typed), typed.isCollection())); } contextUriInfo.setQueryOptions((List) ctx.vQO.accept(this)); } @@ -658,9 +663,29 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public ExpressionImpl visitCastExpr(CastExprContext ctx) { + public Object visitAnyExpr(final AnyExprContext ctx) { + UriResourceAnyImpl any = new UriResourceAnyImpl(); + if (ctx.vLV != null) { + LastTypeColl lastTypeInfo = this.contextTypes.peek(); + + LambdaVariables var = new LambdaVariables(); + var.name = ctx.vLV.getText(); + var.type = lastTypeInfo.type; + var.isCollection = lastTypeInfo.isCollection; + + any.setLamdaVariable(ctx.vLV.getText()); + allowedLambdaVariables.push(var); + any.setExpression((ExpressionImpl) ctx.vLE.accept(this)); + allowedLambdaVariables.pop(); + } + return any; + } + + @Override + public ExpressionImpl visitCastExpr(final CastExprContext ctx) { MethodCallImpl method = new MethodCallImpl(); if (ctx.vE1 != null) { + // is optional parameter ExpressionImpl onExpression = (ExpressionImpl) ctx.vE1.accept(this); method.addParameter(onExpression); } @@ -674,14 +699,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public ExpressionImpl visitCeilingMethodCallExpr(CeilingMethodCallExprContext ctx) { + public ExpressionImpl visitCeilingMethodCallExpr(final CeilingMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.CEILING) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public ExpressionImpl visitConcatMethodCallExpr(ConcatMethodCallExprContext ctx) { + public ExpressionImpl visitConcatMethodCallExpr(final ConcatMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.CONCAT) .addParameter((ExpressionImpl) ctx.vE1.accept(this)) @@ -689,7 +714,54 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public ExpressionImpl visitContainsMethodCallExpr(ContainsMethodCallExprContext ctx) { + public Object visitConstSegment(final ConstSegmentContext ctx) { + UriInfoImpl uriInfoResource = contextUriInfo; + UriResourcePart pathInfo = uriInfoResource.getLastResourcePart(); + + if (ctx.vV != null) { + if (pathInfo instanceof UriResourcePartTyped) { + if (!((UriResourcePartTyped) pathInfo).isCollection()) { + contextUriInfo.addPathInfo(new UriResourceValueImpl()); + } else { + throw wrap(new UriParserSemanticException("$value only allowed on typed path segments")); + } + return null; + } else { + throw wrap(new UriParserSemanticException("$value only allowed on typed path segments")); + } + + } else if (ctx.vC != null) { + if (pathInfo instanceof UriResourceImplTyped) { + if (((UriResourceImplTyped) pathInfo).isCollection()) { + contextUriInfo.addPathInfo(new UriResourceCountImpl()); + } else { + throw wrap(new UriParserSemanticException("$count only allowed on collection properties")); + } + } else { + throw wrap(new UriParserSemanticException("$count only allowed on typed properties")); + } + } else if (ctx.vR != null) { + if (pathInfo instanceof UriResourceImplTyped) { + EdmType type = ((UriResourceImplTyped) pathInfo).getType(); + if (type instanceof EdmEntityType) { + contextUriInfo.addPathInfo(new UriResourceRefImpl()); + } else { + throw wrap(new UriParserSemanticException("$ref only allowd on endity types")); + } + } else { + throw wrap(new UriParserSemanticException("$ref only allowed on typed properties")); + } + + } else if (ctx.vAll != null) { + contextUriInfo.addPathInfo((UriResourceAllImpl) ctx.vAll.accept(this)); + } else if (ctx.vAny != null) { + contextUriInfo.addPathInfo((UriResourceAnyImpl) ctx.vAny.accept(this)); + } + return null; + } + + @Override + public ExpressionImpl visitContainsMethodCallExpr(final ContainsMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.CONTAINS) .addParameter((ExpressionImpl) ctx.vE1.accept(this)) @@ -697,19 +769,19 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitCrossjoin(CrossjoinContext ctx) { - UriInfoImpl crossJoin = new UriInfoImpl(edm).setKind(UriInfoKind.crossjoin); + public Object visitCrossjoin(final CrossjoinContext ctx) { + UriInfoImpl crossJoin = new UriInfoImpl().setKind(UriInfoKind.crossjoin); for (OdataIdentifierContext obj : ctx.vlODI) { crossJoin.addEntitySetName(obj.getText()); } - this.contextUriInfo = crossJoin; + contextUriInfo = crossJoin; return null; } @Override - public Object visitCustomQueryOption(CustomQueryOptionContext ctx) { + public Object visitCustomQueryOption(final CustomQueryOptionContext ctx) { CustomQueryOptionImpl queryOption = new CustomQueryOptionImpl(); queryOption.setName(ctx.getChild(0).getText()); @@ -722,14 +794,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public ExpressionImpl visitDayMethodCallExpr(DayMethodCallExprContext ctx) { + public ExpressionImpl visitDayMethodCallExpr(final DayMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.DAY) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public ExpressionImpl visitDistanceMethodCallExpr(DistanceMethodCallExprContext ctx) { + public ExpressionImpl visitDistanceMethodCallExpr(final DistanceMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.DISTANCE) .addParameter((ExpressionImpl) ctx.vE1.accept(this)) @@ -737,14 +809,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitEndsWithMethodCallExpr(EndsWithMethodCallExprContext ctx) { + public Object visitEndsWithMethodCallExpr(final EndsWithMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.ENDSWITH) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public Object visitEntityOptions(EntityOptionsContext ctx) { + public Object visitEntityOptions(final EntityOptionsContext ctx) { List queryOptionList = new ArrayList(); for (EntityOptionContext entityOption : ctx.vlEOb) { @@ -760,7 +832,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitEntityOptionsCast(EntityOptionsCastContext ctx) { + public Object visitEntityOptionsCast(final EntityOptionsCastContext ctx) { List queryOptionList = new ArrayList(); for (EntityOptionCastContext entityOption : ctx.vlEOb) { queryOptionList.add((QueryOptionImpl) entityOption.accept(this)); @@ -775,7 +847,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitExpand(ExpandContext ctx) { + public Object visitExpand(final ExpandContext ctx) { ExpandOptionImpl expand = new ExpandOptionImpl(); for (ExpandItemContext eI : ctx.vlEI) { expand.addExpandItem((ExpandItemImpl) eI.accept(this)); @@ -785,33 +857,32 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitExpandItem(ExpandItemContext ctx) { + public Object visitExpandItem(final ExpandItemContext ctx) { ExpandItemImpl expandItem = null; if (ctx.vS != null) { - expandItem = new ExpandItemImpl().setStar(true); + expandItem = new ExpandItemImpl().setIsStar(true); if (ctx.vR != null) { - //expandItem.setRef(true); - //TODO do creat reference segement + expandItem.setIsRef(true); } else if (ctx.vM != null) { - expandItem.setExpandQueryOption(new LevelOptionImpl().setMax()); + expandItem.setExpandQueryOption(new LevelExpandOptionImpl().setMax().setText(ctx.vM.getText())); } else if (ctx.vL != null) { - expandItem.setExpandQueryOption(new LevelOptionImpl().setValue(ctx.vL.getText())); + expandItem.setExpandQueryOption(new LevelExpandOptionImpl().setText(ctx.vL.getText())); } } else if (ctx.vEP != null) { expandItem = (ExpandItemImpl) ctx.vEP.accept(this); - } else { - // error - } - if (ctx.vEPE != null) { - contextExpandItemPath.push(expandItem); - List list = (List) ctx.vEPE.accept(this); - for (SystemQueryOptionImpl option : list) { - expandItem.setExpandQueryOption(option); + if (ctx.vEPE != null) { + ExpandItemImpl contextExpandItemPathBU = contextExpandItemPath; + contextExpandItemPath = expandItem; + + List list = (List) ctx.vEPE.accept(this); + for (SystemQueryOptionImpl option : list) { + expandItem.setExpandQueryOption(option); + } + contextExpandItemPath = contextExpandItemPathBU; } - contextExpandItemPath.pop(); } return expandItem; @@ -819,134 +890,71 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitExpandPath(ExpandPathContext ctx) { + public Object visitExpandPath(final ExpandPathContext ctx) { ExpandItemImpl expandItem = new ExpandItemImpl(); - contextExpandItemPath.push(expandItem); + UriResourceItImpl pathInfoIT = new UriResourceItImpl(); + + UriResourceImplTyped tmp = (UriResourceImplTyped) contextUriInfo.getLastResourcePart(); + pathInfoIT.setCollection(tmp.isCollection()).setType(getLastType(tmp)); + + // save context + ExpandItemImpl contextExpandItemPathBU = contextExpandItemPath; + UriInfoImpl uriInfoResourceBU = contextUriInfo; + + // set tmp context + contextExpandItemPath = expandItem; + contextUriInfo = new UriInfoImpl().setKind(UriInfoKind.resource); + contextUriInfo.addPathInfo(pathInfoIT); super.visitExpandPath(ctx); + expandItem.setResourcePath(contextUriInfo); - contextExpandItemPath.pop(); + // reset context + contextUriInfo = uriInfoResourceBU; + contextExpandItemPath = contextExpandItemPathBU; return expandItem; } @Override - public Object visitExpandPathSegment(ExpandPathSegmentContext ctx) { - ExpandItemImpl expandItemPrev = contextExpandItemPath.peek(); - - String odi = ctx.vODI.getText(); - if (ctx.vNS == null) { - EdmType targetType = null; - if (expandItemPrev.getLastSegement() == null) { - // used the global type - UriResourceImplTyped lastSegment = (UriResourceImplTyped) this.contextUriInfo.getLastUriPathInfo(); - targetType = this.getLastType(lastSegment); - } else { - ExpandSegment segment = expandItemPrev.getLastSegement(); - if (segment.getTypeFilter() != null) { - targetType = segment.getTypeFilter(); - } else { - targetType = segment.getType(); - } - } - - if (!(targetType instanceof EdmStructuralType)) { - throw wrap(new UriParserSemanticException("Prev Expandsegment has no properties")); - } - - EdmStructuralType structType = (EdmStructuralType) targetType; - EdmElement property = (EdmElement) structType.getProperty(odi); - if (property != null) { - ExpandSegment seg = new ExpandSegment(); - seg.setProperty(property); - expandItemPrev.addSegment(seg); - return null; - } - - throw wrap(new UriParserSemanticException("Prev Expandsegment has no property:" + odi)); - - } else { - EdmType targetType = null; - if (expandItemPrev.getLastSegement() == null) { - UriResourceImplTyped lastSegment = (UriResourceImplTyped) this.contextUriInfo.getLastUriPathInfo(); - targetType = this.getLastType(lastSegment); - - ExpandSegment seg = new ExpandSegmentIt(); - expandItemPrev.addSegment(seg); - - } else { - ExpandSegment segment = expandItemPrev.getLastSegement(); - if (segment.getTypeFilter() != null) { - throw wrap(new UriParserSemanticException("Prev Expandsegment has already a type filter")); - } else { - targetType = segment.getType(); - } - } - - FullQualifiedName fullName = getFullName(ctx.vNS, odi); - - if (targetType instanceof EdmEntityType) { - EdmEntityType et = edm.getEntityType(fullName); - if (et == null) { - throw wrap(new UriParserSemanticException("entity type not found")); - } - if (et.compatibleTo(targetType)) { - expandItemPrev.getLastSegement().setFilter(et); - return null; - } - } - - if (targetType instanceof EdmComplexType) { - EdmComplexType ct = edm.getComplexType(fullName); - if (ct == null) { - throw wrap(new UriParserSemanticException("Complex type not found")); - } - if (ct.compatibleTo(targetType)) { - expandItemPrev.getLastSegement().setFilter(ct); - return null; - } - } - } - return null; - } - - @Override - public Object visitExpandPathExtension(ExpandPathExtensionContext ctx) { - ExpandItemImpl expandItemPrev = contextExpandItemPath.peek(); - - if (contextType == null) { - contextType = new Stack(); - } - + public Object visitExpandPathExtension(final ExpandPathExtensionContext ctx) { List list = new ArrayList(); EdmType targetType = null; - if (expandItemPrev.getLastSegement() == null) { - // used the global type - UriResourceImplTyped lastSegment = (UriResourceImplTyped) this.contextUriInfo.getLastUriPathInfo(); - targetType = this.getLastType(lastSegment); + boolean isColl = false; + if (contextExpandItemPath == null) { + // use the type of the last resource path segement + UriResourceImplTyped lastSegment = (UriResourceImplTyped) contextUriInfo.getLastResourcePart(); + targetType = getLastType(lastSegment); + isColl = lastSegment.isCollection(); } else { - ExpandSegment segment = expandItemPrev.getLastSegement(); - if (segment.getTypeFilter() != null) { - targetType = segment.getTypeFilter(); + if (contextExpandItemPath.getPath() == null) { + // use the type of the last resource path segement + UriResourceImplTyped lastSegment = (UriResourceImplTyped) contextUriInfo.getLastResourcePart(); + targetType = getLastType(lastSegment); + isColl = lastSegment.isCollection(); } else { - targetType = segment.getType(); + // use the type of the last ''expand'' path segement + UriInfoImpl info = (UriInfoImpl) contextExpandItemPath.getPath(); + targetType = getLastType((UriResourceImplTyped) info.getLastResourcePart()); + isColl = ((UriResourceImplTyped) info.getLastResourcePart()).isCollection(); } } - contextType.push(targetType); + contextTypes.push(new LastTypeColl(targetType, isColl)); if (ctx.vC != null) { - ExpandSegment seg = new ExpandSegmentCount(); - expandItemPrev.addSegment(seg); + UriInfoImpl resourcePath = (UriInfoImpl) contextExpandItemPath.getPath(); + resourcePath.addPathInfo(new UriResourceCountImpl()); + for (ExpandCountOptionContext s : ctx.vlEOC) { list.add((SystemQueryOptionImpl) s.accept(this)); } - } else if (ctx.vR != null) { - ExpandSegment seg = new ExpandSegmentRef(); - expandItemPrev.addSegment(seg); + UriInfoImpl resourcePath = (UriInfoImpl) contextExpandItemPath.getPath(); + resourcePath.addPathInfo(new UriResourceRefImpl()); + for (ExpandRefOptionContext s : ctx.vlEOR) { list.add((SystemQueryOptionImpl) s.accept(this)); } @@ -956,37 +964,27 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } } - contextType.pop(); + contextTypes.pop(); return list; } @Override - public Object visitFilter(FilterContext ctx) { + public Object visitFilter(final FilterContext ctx) { - FilterOptionImpl filter = new FilterOptionImpl() - .setExpression((ExpressionImpl) ctx.children.get(2).accept(this)); + FilterOptionImpl filter = new FilterOptionImpl().setExpression((ExpressionImpl) ctx.children.get(2).accept(this)); return filter; } @Override - public Object visitOrderBy(OrderByContext ctx) { - - OrderByOptionImpl orderBy = new OrderByOptionImpl(); - // TODO collect orders - // .setExpression((Expression) ctx.children.get(2).accept(this)); - return orderBy; - } - - @Override - public ExpressionImpl visitFloorMethodCallExpr(FloorMethodCallExprContext ctx) { + public ExpressionImpl visitFloorMethodCallExpr(final FloorMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.FLOOR) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public Object visitFormat(FormatContext ctx) { + public Object visitFormat(final FormatContext ctx) { FormatOptionImpl format = new FormatOptionImpl(); TerminalNodeImpl c2 = (TerminalNodeImpl) ctx.children.get(2); @@ -1003,62 +1001,50 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { format.setValue(c2.getText() + "/" + ctx.children.get(4).getText()); } } + String text = ctx.children.get(2).getText(); + if ( ctx.getChildCount()> 4) { + text += ctx.children.get(3).getText(); + text += ctx.children.get(4).getText(); + } + + format.setText(text); + return format; } @Override - public ExpressionImpl visitFractionalsecondsMethodCallExpr(FractionalsecondsMethodCallExprContext ctx) { + public ExpressionImpl visitFractionalsecondsMethodCallExpr(final FractionalsecondsMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.FRACTIONALSECOND) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public ExpressionImpl visitGeoLengthMethodCallExpr(GeoLengthMethodCallExprContext ctx) { + public ExpressionImpl visitGeoLengthMethodCallExpr(final GeoLengthMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.GEOLENGTH) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public ExpressionImpl visitHourMethodCallExpr(HourMethodCallExprContext ctx) { + public ExpressionImpl visitHourMethodCallExpr(final HourMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.HOUR) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public Object visitId(IdContext ctx) { + public Object visitId(final IdContext ctx) { IdOptionImpl id = new IdOptionImpl(); - /* - * UriInfoImplResource uriInfoImplpath = new UriInfoImplResource(edm); - * - * // store the context uriInfoPath - * UriInfoImplResource backupUriInfoPath = this.contextUriInfoPath; - * - * // set temporary uriInfoPath to collect the path information of the memberExpression - * this.contextUriInfoPath = uriInfoImplpath; - * - * ctx.children.get(2).accept(this); - * - * this.contextUriInfoPath = backupUriInfoPath; - * - * // add the typeFilter which was part of the resource path behind the $entity segment - * UriPathInfoImpl lastPathInfo = uriInfoImplpath.getLastUriPathInfo(); - * EdmStructuralType typeFilter = ((UriInfoImplEntity) this.contextUriInfo).getTypeFilter(); - * if (typeFilter != null) { - * lastPathInfo.addTypeFilter(typeFilter); - * } - */ - - String text = ctx.children.get(2).getText(); - + + String text = ctx.children.get(2).getText(); + return id.setValue(text).setText(text); } @Override - public ExpressionImpl visitIndexOfMethodCallExpr(IndexOfMethodCallExprContext ctx) { + public ExpressionImpl visitIndexOfMethodCallExpr(final IndexOfMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.INDEXOF) .addParameter((ExpressionImpl) ctx.vE1.accept(this)) @@ -1066,7 +1052,16 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public ExpressionImpl visitIntersectsMethodCallExpr(IntersectsMethodCallExprContext ctx) { + public Object visitInlinecount(final InlinecountContext ctx) { + InlineCountOptionImpl inlineCount = new InlineCountOptionImpl(); + + String text = ctx.children.get(2).getText(); + + return inlineCount.setValue(text.equals("true") ? true : false).setText(text); + } + + @Override + public ExpressionImpl visitIntersectsMethodCallExpr(final IntersectsMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.GEOLENGTH) .addParameter((ExpressionImpl) ctx.vE1.accept(this)) @@ -1074,7 +1069,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public ExpressionImpl visitIsofExpr(IsofExprContext ctx) { + public ExpressionImpl visitIsofExpr(final IsofExprContext ctx) { MethodCallImpl method = new MethodCallImpl(); if (ctx.vE1 != null) { ExpressionImpl onExpression = (ExpressionImpl) ctx.vE1.accept(this); @@ -1090,107 +1085,28 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public ExpressionImpl visitLengthMethodCallExpr(LengthMethodCallExprContext ctx) { + public ExpressionImpl visitLengthMethodCallExpr(final LengthMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.LENGTH) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public ExpressionImpl visitMaxDateTimeMethodCallExpr(MaxDateTimeMethodCallExprContext ctx) { + public ExpressionImpl visitMaxDateTimeMethodCallExpr(final MaxDateTimeMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.MINDATETIME); } @Override - public Object visitRootExpr(RootExprContext ctx) { - UriInfoImpl uriInfoImplpath = new UriInfoImpl(edm).setKind(UriInfoKind.resource); + public Object visitMemberExpr(final MemberExprContext ctx) { - UriResourceRootImpl pathInfoRoot = new UriResourceRootImpl(); - - uriInfoImplpath.addPathInfo(pathInfoRoot); - - if (ctx.vPs != null) { - // store the context uriInfoPath - UriInfoImpl backupUriInfoPath = this.contextUriInfo; - - // set temporary uriInfoPath to collect the path information of the memberExpression - this.contextUriInfo = uriInfoImplpath; - - ctx.vPs.accept(this); - - this.contextUriInfo = backupUriInfoPath; - } - return new MemberImpl() - .setPath(uriInfoImplpath); - - } - - @Override - public Object visitInlinecount(InlinecountContext ctx) { - // TODO implement - return super.visitInlinecount(ctx); - } - - @Override - public Object visitAltAny(AltAnyContext ctx) { - UriInfoImpl uriInfoImplpath = new UriInfoImpl(edm).setKind(UriInfoKind.resource); + UriInfoImpl uriInfoImplpath = new UriInfoImpl().setKind(UriInfoKind.resource); UriResourceItImpl pathInfoIT = new UriResourceItImpl(); - pathInfoIT.setType(contextType.peek()); + LastTypeColl lastTypeInfo = this.contextTypes.peek(); + pathInfoIT.setType(lastTypeInfo.type); + pathInfoIT.setCollection(lastTypeInfo.isCollection); - uriInfoImplpath.addPathInfo(pathInfoIT); - uriInfoImplpath.addPathInfo((UriResourcePartImpl) super.visitAltAny(ctx)); - - return new MemberImpl() - .setPath(uriInfoImplpath); - } - - @Override - public Object visitAnyExpr(AnyExprContext ctx) { - UriResourceAnyImpl any = new UriResourceAnyImpl(); - if (ctx.vLV != null) { - any.setLamdaVariable(ctx.vLV.getText()); - lambdaVariables.push(any.getLamdaVariable()); - any.setExpression((ExpressionImpl) ctx.vLE.accept(this)); - lambdaVariables.pop(); - } - return any; - } - - @Override - public Object visitAltAll(AltAllContext ctx) { - UriInfoImpl uriInfoImplpath = new UriInfoImpl(edm).setKind(UriInfoKind.resource); - - UriResourceItImpl pathInfoIT = new UriResourceItImpl(); - pathInfoIT.setType(contextType.peek()); - - uriInfoImplpath.addPathInfo(pathInfoIT); - uriInfoImplpath.addPathInfo((UriResourcePartImpl) super.visitAltAll(ctx)); - - return new MemberImpl() - .setPath(uriInfoImplpath); - } - - @Override - public Object visitAllExpr(AllExprContext ctx) { - UriResourceAllImpl all = new UriResourceAllImpl(); - all.setLamdaVariable(ctx.vLV.getText()); - lambdaVariables.push(all.getLamdaVariable()); - all.setExpression((ExpressionImpl) ctx.vLE.accept(this)); - lambdaVariables.pop(); - return all; - } - - @Override - public Object visitMemberExpr(MemberExprContext ctx) { - - UriInfoImpl uriInfoImplpath = new UriInfoImpl(edm).setKind(UriInfoKind.resource); - - UriResourceItImpl pathInfoIT = new UriResourceItImpl(); - // the start type for members is the final type of the resource path - // check wath happens for expand - pathInfoIT.setType(contextType.peek()); if (ctx.vIt != null || ctx.vIts != null) { pathInfoIT.setIsExplicitIT(true); // a $it prohibits unbound functions as member expression } @@ -1198,22 +1114,17 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { uriInfoImplpath.addPathInfo(pathInfoIT); if (ctx.vPs != null) { - // store the context uriInfoPath - UriInfoImpl backupUriInfoPath = this.contextUriInfo; + // save the context + UriInfoImpl backupUriInfoPath = contextUriInfo; + + // set temporary uriInfoPath + contextUriInfo = uriInfoImplpath; - // set temporary uriInfoPath to collect the path information of the memberExpression - this.contextUriInfo = uriInfoImplpath; - contextDetectedLambda = null; ctx.vPs.accept(this); - this.contextUriInfo = backupUriInfoPath; - if (contextDetectedLambda!= null) { - LambdaRefImpl tmp = contextDetectedLambda; - contextDetectedLambda = null; - return tmp; - } - - } + // reset context + contextUriInfo = backupUriInfoPath; + } if (ctx.vALL != null) { uriInfoImplpath.addPathInfo((UriResourcePartImpl) ctx.vALL.accept(this)); @@ -1221,79 +1132,64 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (ctx.vANY != null) { uriInfoImplpath.addPathInfo((UriResourcePartImpl) ctx.vANY.accept(this)); } - return new MemberImpl() .setPath(uriInfoImplpath); } @Override - public ExpressionImpl visitMinDateTimeMethodCallExpr(MinDateTimeMethodCallExprContext ctx) { + public ExpressionImpl visitMinDateTimeMethodCallExpr(final MinDateTimeMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.MINDATETIME); } @Override - public ExpressionImpl visitMinuteMethodCallExpr(MinuteMethodCallExprContext ctx) { + public ExpressionImpl visitMinuteMethodCallExpr(final MinuteMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.MINUTE) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public ExpressionImpl visitMonthMethodCallExpr(MonthMethodCallExprContext ctx) { + public ExpressionImpl visitMonthMethodCallExpr(final MonthMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.MONTH) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public Object visitNameValueOptList(NameValueOptListContext ctx) { + public Object visitNameValueOptList(final NameValueOptListContext ctx) { // is key predicate if (ctx.vVO != null) { - String text = ctx.vVO.vV.getText(); + String valueText = ctx.vVO.vV.getText(); ExpressionImpl expression = (ExpressionImpl) ctx.vVO.vV.accept(this); - if (!(contextUriInfo.getLastUriPathInfo() instanceof UriResourceImplTyped)) { - throw wrap(new UriParserSyntaxException("Invalid Paramterslist")); + if (!(contextUriInfo.getLastResourcePart() instanceof UriResourceImplTyped)) { + throw wrap(new UriParserSyntaxException("Paramterslist on untyped resource path segement not allowed")); } - EdmEntityType entityType = (EdmEntityType) ((UriResourceImplTyped) contextUriInfo.getLastUriPathInfo()).getType(); + EdmEntityType entityType = + (EdmEntityType) ((UriResourceImplTyped) contextUriInfo.getLastResourcePart()).getType(); List keyPredicates = entityType.getKeyPredicateNames(); if (keyPredicates.size() == 1) { String keyName = keyPredicates.get(0); List list = new ArrayList(); - list.add(new UriParameterImpl().setName(keyName).setText(text).setExpression(expression)); + list.add(new UriParameterImpl().setName(keyName).setText(valueText).setExpression(expression)); return list; } - // if there is only a single key in the URI but there are more than one keys defined in the EDM, then reduce - // the keylist with the keys defined as referential constained. - - if (contextUriInfo.getLastUriPathInfo() instanceof UriResourceNavigationPropertyImpl) { - UriResourceNavigationPropertyImpl nav = (UriResourceNavigationPropertyImpl) contextUriInfo.getLastUriPathInfo(); - EdmNavigationProperty navProp = (EdmNavigationProperty) nav.getNavigationProperty(); - /* - * if ( navProp.getPartner() != null) { - * //copy keylist into tmpKeyList - * - * EdmEntityType entityType = nav.getType()// TODO check typecast, - * EdmNavigationProperty navProp2 = entityType.getProperty(navProp.getPartner()); - * for ( EdmRefConstrain constrain : navProp2 ) { - * //remove constrain.referenceproperty from tmpKeyList - * } - * - * if( tmpKeyList.size==1) - * String keyName = keyPredicates.get(0); - * List list = new ArrayList(); - * list.add(new UriParameterImpl().setName(keyName).setValue(value)); - * return list; - * } - * } - */ - } + // If there is only a single key in the URI but there are more than one keys defined in the EDM, then reduce + // The keylist with the keys defined as referential constrained. + // TODO add support vor using refential constrains + /* + * if (contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl) { + * UriResourceNavigationPropertyImpl nav = + * (UriResourceNavigationPropertyImpl) contextUriInfo.getLastResourcePart(); + * nav.getNavigationProperty(); + * } + */ throw wrap(new UriParserSyntaxException( "for using a value only keyPredicate there must be exact ONE defined keyProperty")); @@ -1311,7 +1207,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public UriParameterImpl visitNameValuePair(NameValuePairContext ctx) { + public UriParameterImpl visitNameValuePair(final NameValuePairContext ctx) { UriParameterImpl uriParameter = new UriParameterImpl(); uriParameter.setName(ctx.vODI.getText()); @@ -1326,32 +1222,38 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public ExpressionImpl visitNowMethodCallExpr(NowMethodCallExprContext ctx) { + public ExpressionImpl visitNowMethodCallExpr(final NowMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.NOW); } @Override - public Object visitOdataRelativeUriEOF(OdataRelativeUriEOFContext ctx) { - // setup context - this.contextUriInfo = null; - // visit children + public Object visitOdataRelativeUriEOF(final OdataRelativeUriEOFContext ctx) { + contextUriInfo = null; super.visitOdataRelativeUriEOF(ctx); - - return this.contextUriInfo; + return contextUriInfo; } @Override - public Object visitPathSegment(PathSegmentContext ctx) { + public Object visitOrderBy(final OrderByContext ctx) { - if (contextUriInfo.getLastUriPathInfo() == null || - contextUriInfo.getLastUriPathInfo() instanceof UriResourceRootImpl) { + OrderByOptionImpl orderBy = new OrderByOptionImpl(); + // TODO collect orders + // .setExpression((Expression) ctx.children.get(2).accept(this)); + return orderBy; + } + + @Override + public Object visitPathSegment(final PathSegmentContext ctx) { + + if (contextUriInfo.getLastResourcePart() == null || + contextUriInfo.getLastResourcePart() instanceof UriResourceRootImpl) { readFirstPathInfoSegment(ctx); } else { readNextPathInfoSegment(ctx); } - UriResourcePartImpl pathInfoSegment = (UriResourcePartImpl) this.contextUriInfo.getLastUriPathInfo(); + UriResourcePartImpl pathInfoSegment = (UriResourcePartImpl) contextUriInfo.getLastResourcePart(); if (ctx.vlNVO.size() > 0) { // check for keyPredicates @@ -1369,7 +1271,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitPathSegments(PathSegmentsContext ctx) { + public Object visitPathSegments(final PathSegmentsContext ctx) { // path segment for (PathSegmentContext it : ctx.vlPS) { it.accept(this); @@ -1383,57 +1285,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitConstSegment(ConstSegmentContext ctx) { - UriInfoImpl uriInfoResource = this.contextUriInfo; - UriResourcePart pathInfo = uriInfoResource.getLastUriPathInfo(); + public Object visitQueryOptions(final QueryOptionsContext ctx) { - if (ctx.vV != null) { - if (pathInfo instanceof UriResourcePartTyped) { - if (!((UriResourcePartTyped) pathInfo).isCollection()) { - this.contextUriInfo.addPathInfo(new UriResourceValueImpl()); - } else { - throw wrap(new UriParserSemanticException("$value only allowed on typed path segments")); - } - return null; - } else { - throw wrap(new UriParserSemanticException("$value only allowed on typed path segments")); - } - - } else if (ctx.vC != null) { - if (pathInfo instanceof UriResourceImplTyped) { - if (((UriResourceImplTyped) pathInfo).isCollection()) { - this.contextUriInfo.addPathInfo(new UriResourceCountImpl()); - } else { - throw wrap(new UriParserSemanticException("$count only allowed on collection properties")); - } - } else { - throw wrap(new UriParserSemanticException("$count only allowed on typed properties")); - } - } else if (ctx.vR != null) { - if (pathInfo instanceof UriResourceImplTyped) { - EdmType type = ((UriResourceImplTyped) pathInfo).getType(); - if (type instanceof EdmEntityType) { - this.contextUriInfo.addPathInfo(new UriResourceRefImpl()); - } else { - throw wrap(new UriParserSemanticException("$ref only allowd on endity types")); - } - } else { - throw wrap(new UriParserSemanticException("$ref only allowed on typed properties")); - } - - } - return null; - } - - @Override - public Object visitQueryOptions(QueryOptionsContext ctx) { - if (contextType == null) { - contextType = new Stack(); - - } - // contextType.push(this.contextUriInfo.getLastUriPathInfo().getType()); - - // QueryOptionsList qpList = new QueryOptionsList(); List qpList = new ArrayList(); for (QueryOptionContext entityOption : ctx.vlQO) { qpList.add((QueryOptionImpl) entityOption.accept(this)); @@ -1443,35 +1296,59 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitResourcePath(ResourcePathContext ctx) { + public Object visitResourcePath(final ResourcePathContext ctx) { if (ctx.vAll != null) { - this.contextUriInfo = new UriInfoImpl(edm).setKind(UriInfoKind.all); + contextUriInfo = new UriInfoImpl().setKind(UriInfoKind.all); } else if (ctx.vCJ != null) { ctx.vCJ.accept(this); } else if (ctx.vlPS != null) { - UriInfoImpl uriInfoPath = new UriInfoImpl(edm).setKind(UriInfoKind.resource); - this.contextUriInfo = uriInfoPath; + UriInfoImpl uriInfoPath = new UriInfoImpl().setKind(UriInfoKind.resource); + contextUriInfo = uriInfoPath; super.visitResourcePath(ctx); // visit all children of ctx } - return this.contextUriInfo; + return contextUriInfo; } @Override - public ExpressionImpl visitRoundMethodCallExpr(RoundMethodCallExprContext ctx) { + public Object visitRootExpr(final RootExprContext ctx) { + UriInfoImpl uriInfoImplpath = new UriInfoImpl().setKind(UriInfoKind.resource); + + UriResourceRootImpl pathInfoRoot = new UriResourceRootImpl(); + + uriInfoImplpath.addPathInfo(pathInfoRoot); + + if (ctx.vPs != null) { + // store the context uriInfoPath + UriInfoImpl backupUriInfoPath = contextUriInfo; + + // set temporary uriInfoPath to collect the path information of the memberExpression + contextUriInfo = uriInfoImplpath; + + ctx.vPs.accept(this); + + contextUriInfo = backupUriInfoPath; + } + return new MemberImpl() + .setPath(uriInfoImplpath); + + } + + @Override + public ExpressionImpl visitRoundMethodCallExpr(final RoundMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.ROUND) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public ExpressionImpl visitSecondMethodCallExpr(SecondMethodCallExprContext ctx) { + public ExpressionImpl visitSecondMethodCallExpr(final SecondMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.SECOND) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public Object visitSelect(SelectContext ctx) { + public Object visitSelect(final SelectContext ctx) { List selectItems = new ArrayList(); for (SelectItemContext si : ctx.vlSI) { @@ -1482,10 +1359,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitSelectItem(SelectItemContext ctx) { + public Object visitSelectItem(final SelectItemContext ctx) { SelectItemOptionImpl selectItem = new SelectItemOptionImpl(); - selectItem.setEdm(edm); - selectItem.setStartType(contextType.peek()); contextSelectItem = selectItem; for (SelectSegmentContext si : ctx.vlSS) { @@ -1497,7 +1372,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitSelectSegment(SelectSegmentContext ctx) { + public Object visitSelectSegment(final SelectSegmentContext ctx) { if (ctx.vS != null) { if (ctx.vNS != null) { @@ -1514,28 +1389,109 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { String odi = ctx.vODI.getText(); if (ctx.vNS == null) { - contextSelectItem.addProperty(odi); + EdmType prevType = contextSelectItem.getType(); + if (prevType == null) { + prevType = this.contextTypes.peek().type; + } + + if (!(prevType instanceof EdmStructuralType)) { + throw wrap(new UriParserSemanticException("Previous select item is not a structural type")); + } + + EdmStructuralType structType = (EdmStructuralType) prevType; + EdmElement property = (EdmElement) structType.getProperty(odi); + if (property == null) { + throw wrap(new UriParserSemanticException("Previous select item has not property: " + odi)); + + } + + // create new segment + SelectSegmentImpl newSegment = new SelectSegmentImpl().setProperty(property); + contextSelectItem.addSegment(newSegment); + + return this; } else { String namespace = ctx.vNS.getText(); namespace = namespace.substring(0, namespace.length() - 1); FullQualifiedName fullName = new FullQualifiedName(namespace, odi); - contextSelectItem.addQualifiedThing(fullName); + // contextSelectItem.addQualifiedThing(fullName); + + EdmType prevType = contextSelectItem.getType(); + if (prevType != null) { // context types required at least one property + if (prevType instanceof EdmComplexType) { + EdmComplexType ct = edm.getComplexType(fullName); + if (ct != null) { + if (((EdmStructuralType) prevType).compatibleTo(ct)) { + SelectSegmentImpl lastSegment = contextSelectItem.getLastSegment(); + lastSegment.setTypeCast(ct); + return this; + } + } + } + } else { + prevType = this.contextTypes.peek().type; + if (prevType instanceof EdmEntityType) { + EdmEntityType et = edm.getEntityType(fullName); + if (((EdmStructuralType) prevType).compatibleTo(et)) { + contextSelectItem.setEntityTypeCast(et); + return this; + } + } + } + + FullQualifiedName finalTypeName = new FullQualifiedName(prevType.getNamespace(), prevType.getName()); + + // check for action + EdmAction action = edm.getAction(fullName, finalTypeName, null); + // TODO verify that null ignores if it is a collection + + if (action != null) { + contextSelectItem.addSegment(new SelectSegmentImpl().setAction(action)); + } + + // check for function + EdmFunction function = edm.getFunction(fullName, finalTypeName, null, null); + // TODO verify that null ignores if it is a collection + + if (function != null) { + contextSelectItem.addSegment(new SelectSegmentImpl().setFunction(function)); + } + } return null; } + @Override - public ExpressionImpl visitStartsWithMethodCallExpr(StartsWithMethodCallExprContext ctx) { + public Object visitSkip(SkipContext ctx) { + SkipOptionImpl skiptoken = new SkipOptionImpl(); + + String text = ctx.children.get(2).getText(); + + return skiptoken.setValue(text).setText(text); + } + + @Override + public Object visitSkiptoken(SkiptokenContext ctx) { + SkiptokenOptionImpl skiptoken = new SkiptokenOptionImpl(); + + String text = ctx.children.get(2).getText(); + + return skiptoken.setValue(text).setText(text); + } + + @Override + public ExpressionImpl visitStartsWithMethodCallExpr(final StartsWithMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.STARTSWITH) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public ExpressionImpl visitSubstringMethodCallExpr(SubstringMethodCallExprContext ctx) { + public ExpressionImpl visitSubstringMethodCallExpr(final SubstringMethodCallExprContext ctx) { MethodCallImpl ret = new MethodCallImpl(); ret.setMethod(SupportedMethodCalls.SUBSTRING); ret.addParameter((ExpressionImpl) ctx.vE1.accept(this)); @@ -1550,69 +1506,72 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public ExpressionImpl visitTimeMethodCallExpr(TimeMethodCallExprContext ctx) { + public ExpressionImpl visitTimeMethodCallExpr(final TimeMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.TIME) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } + @Override - public ExpressionImpl visitToLowerMethodCallExpr(ToLowerMethodCallExprContext ctx) { + public Object visitTop(TopContext ctx) { + TopOptionImpl top = new TopOptionImpl(); + + String text = ctx.children.get(2).getText(); + + return top.setValue(text).setText(text); + } + + @Override + public ExpressionImpl visitToLowerMethodCallExpr(final ToLowerMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.TOLOWER) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public ExpressionImpl visitTotalOffsetMinutesMethodCallExpr(TotalOffsetMinutesMethodCallExprContext ctx) { + public ExpressionImpl visitTotalOffsetMinutesMethodCallExpr(final TotalOffsetMinutesMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.TOTALOFFSETMINUTES) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public ExpressionImpl visitTotalsecondsMethodCallExpr(TotalsecondsMethodCallExprContext ctx) { + public ExpressionImpl visitTotalsecondsMethodCallExpr(final TotalsecondsMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.TOTALSECONDS) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public ExpressionImpl visitToUpperMethodCallExpr(ToUpperMethodCallExprContext ctx) { + public ExpressionImpl visitToUpperMethodCallExpr(final ToUpperMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.TOUPPER) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public ExpressionImpl visitTrimMethodCallExpr(TrimMethodCallExprContext ctx) { + public ExpressionImpl visitTrimMethodCallExpr(final TrimMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.TRIM) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override - public Object visitUnary(UnaryContext ctx) { + public Object visitUnary(final UnaryContext ctx) { // TODO implement return super.visitUnary(ctx); } @Override - public ExpressionImpl visitYearMethodCallExpr(YearMethodCallExprContext ctx) { + public ExpressionImpl visitYearMethodCallExpr(final YearMethodCallExprContext ctx) { return new MethodCallImpl() .setMethod(SupportedMethodCalls.YEAR) .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } - private FullQualifiedName getFullName(NamespaceContext vNS, String odi) { - if (vNS != null) { - String namespace = vNS.getText(); - namespace = namespace.substring(0, namespace.length() - 1); - - return new FullQualifiedName(namespace, odi); - } - return null; - + private ParseCancellationException wrap(final UriParserException uriParserException) { + return new ParseCancellationException(uriParserException); } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParserException.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParserException.java index f4780c3ee..e766d6814 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParserException.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParserException.java @@ -23,16 +23,14 @@ public class UriParserException extends Exception { /** * */ - private static final long serialVersionUID = -1813203179082217112L; + private static final long serialVersionUID = 1L; - public UriParserException(String message, Throwable cause) { + public UriParserException(final String message, final Throwable cause) { super(message, cause); } - public UriParserException(String message) { + public UriParserException(final String message) { super(message, null); } - - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParserSemanticException.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParserSemanticException.java index 530b24fe0..687bb4236 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParserSemanticException.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParserSemanticException.java @@ -24,16 +24,14 @@ public class UriParserSemanticException extends UriParserException { /** * */ - private static final long serialVersionUID = -1813203179082217112L; - - public UriParserSemanticException(String message, Throwable cause) { + private static final long serialVersionUID = 1L; + + public UriParserSemanticException(final String message, final Throwable cause) { super(message, cause); } - public UriParserSemanticException(String message) { + public UriParserSemanticException(final String message) { super(message, null); } - - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParserSyntaxException.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParserSyntaxException.java index d3f9dcf99..16ab8f0fe 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParserSyntaxException.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParserSyntaxException.java @@ -23,13 +23,13 @@ public class UriParserSyntaxException extends UriParserException { /** * */ - private static final long serialVersionUID = -975557346686301719L; + private static final long serialVersionUID = 1L; - public UriParserSyntaxException(String message, Throwable cause) { + public UriParserSyntaxException(final String message, final Throwable cause) { super(message, cause); } - public UriParserSyntaxException(String message) { + public UriParserSyntaxException(final String message) { super(message, null); } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceActionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceActionImpl.java index d714969ec..5b418ef4c 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceActionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceActionImpl.java @@ -38,7 +38,7 @@ public class UriResourceActionImpl extends UriResourceImplTyped implements UriRe return action; } - public UriResourceActionImpl setAction(EdmAction action) { + public UriResourceActionImpl setAction(final EdmAction action) { this.action = action; return this; } @@ -48,20 +48,15 @@ public class UriResourceActionImpl extends UriResourceImplTyped implements UriRe return actionImport; } - public UriResourceActionImpl setActionImport(EdmActionImport actionImport) { + public UriResourceActionImpl setActionImport(final EdmActionImport actionImport) { this.actionImport = actionImport; - this.setAction(actionImport.getAction()); + setAction(actionImport.getAction()); return this; } - @Override - public String toString() { - return action.getName() + super.toString(); - } - @Override public boolean isCollection() { - if ( action != null) { + if (action != null) { return action.getReturnType().isCollection(); } return false; @@ -72,4 +67,13 @@ public class UriResourceActionImpl extends UriResourceImplTyped implements UriRe return action.getReturnType().getType(); } + @Override + public String toString() { + if (actionImport != null) { + return actionImport.getName(); + } else if (action != null) { + return action.getName(); + } + return ""; + } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceAllImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceAllImpl.java index 6bc480dbe..0bd66f726 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceAllImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceAllImpl.java @@ -32,7 +32,7 @@ public class UriResourceAllImpl extends UriResourceImplTyped implements UriResou private ExpressionImpl expression; public UriResourceAllImpl() { - super(UriResourceKind.lamdaAll); + super(UriResourceKind.lambdaAll); } @Override @@ -49,8 +49,8 @@ public class UriResourceAllImpl extends UriResourceImplTyped implements UriResou public String getLamdaVariable() { return lamdaVariable; } - - public UriResourceAllImpl setLamdaVariable(String lamdaVariable) { + + public UriResourceAllImpl setLamdaVariable(final String lamdaVariable) { this.lamdaVariable = lamdaVariable; return this; }; @@ -59,9 +59,14 @@ public class UriResourceAllImpl extends UriResourceImplTyped implements UriResou public Expression getExpression() { return expression; } - - public UriResourceAllImpl setExpression(ExpressionImpl expression) { + + public UriResourceAllImpl setExpression(final ExpressionImpl expression) { this.expression = expression; return this; }; + + @Override + public String toString() { + return "all"; + } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceAnyImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceAnyImpl.java index eb1ce680f..ba4f4f821 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceAnyImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceAnyImpl.java @@ -32,7 +32,7 @@ public class UriResourceAnyImpl extends UriResourceImplTyped implements UriResou private ExpressionImpl expression; public UriResourceAnyImpl() { - super(UriResourceKind.lamdaAny); + super(UriResourceKind.lambdaAny); } @Override @@ -49,8 +49,8 @@ public class UriResourceAnyImpl extends UriResourceImplTyped implements UriResou public String getLamdaVariable() { return lamdaVariable; } - - public UriResourceAnyImpl setLamdaVariable(String lamdaVariable) { + + public UriResourceAnyImpl setLamdaVariable(final String lamdaVariable) { this.lamdaVariable = lamdaVariable; return this; }; @@ -59,9 +59,14 @@ public class UriResourceAnyImpl extends UriResourceImplTyped implements UriResou public Expression getExpression() { return expression; } - - public UriResourceAnyImpl setExpression(ExpressionImpl expression) { + + public UriResourceAnyImpl setExpression(final ExpressionImpl expression) { this.expression = expression; return this; + } + + @Override + public String toString() { + return "any"; }; } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceComplexPropertyImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceComplexPropertyImpl.java index 9ce1afa53..0ef7ce3d2 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceComplexPropertyImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceComplexPropertyImpl.java @@ -37,14 +37,14 @@ public class UriResourceComplexPropertyImpl extends UriResourceImplTyped impleme return property; } - public UriResourceComplexPropertyImpl setProperty(EdmProperty property) { + public UriResourceComplexPropertyImpl setProperty(final EdmProperty property) { this.property = property; return this; } @Override public EdmComplexType getComplexType() { - return (EdmComplexType) this.getType(); + return (EdmComplexType) getType(); } @Override @@ -62,4 +62,9 @@ public class UriResourceComplexPropertyImpl extends UriResourceImplTyped impleme return property.isCollection(); } + @Override + public String toString() { + return property.getName(); + } + } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceCountImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceCountImpl.java index f276d762f..23164abc9 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceCountImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceCountImpl.java @@ -27,4 +27,9 @@ public class UriResourceCountImpl extends UriResourcePartImpl implements UriReso super(UriResourceKind.count); } + @Override + public String toString() { + return "$count"; + } + } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceEntitySetImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceEntitySetImpl.java index e99706354..523901eb3 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceEntitySetImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceEntitySetImpl.java @@ -37,16 +37,11 @@ public class UriResourceEntitySetImpl extends UriResourceImplKeyPred implements return edmEntitySet; } - public UriResourceEntitySetImpl setEntitSet(EdmEntitySet edmES) { - this.edmEntitySet = edmES; + public UriResourceEntitySetImpl setEntitSet(final EdmEntitySet edmES) { + edmEntitySet = edmES; return this; } - @Override - public String toString() { - return edmEntitySet.getName() + super.toString(); - } - @Override public EdmEntityType getEntityType() { return edmEntitySet.getEntityType(); @@ -54,11 +49,7 @@ public class UriResourceEntitySetImpl extends UriResourceImplKeyPred implements @Override public EdmType getType() { - /*if (singleTypeFilter != null) { - return singleTypeFilter; - } else if (collectionTypeFilter != null) { - return collectionTypeFilter; - }*/ + return edmEntitySet.getEntityType(); } @@ -71,4 +62,9 @@ public class UriResourceEntitySetImpl extends UriResourceImplKeyPred implements return false; } + @Override + public String toString() { + return edmEntitySet.getName(); + } + } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceFunctionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceFunctionImpl.java index 0042f9c68..9769a2c8e 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceFunctionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceFunctionImpl.java @@ -50,7 +50,7 @@ public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements U return retList; } - public UriResourceFunctionImpl setParameters(List parameters) { + public UriResourceFunctionImpl setParameters(final List parameters) { this.parameters = parameters; return this; } @@ -60,7 +60,7 @@ public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements U return function; } - public UriResourceFunctionImpl setFunction(EdmFunction function) { + public UriResourceFunctionImpl setFunction(final EdmFunction function) { this.function = function; return this; } @@ -70,8 +70,9 @@ public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements U return functionImport; } - public UriResourceFunctionImpl setFunctionImport(EdmFunctionImport edmFI, List parameters) { - this.functionImport = edmFI; + public UriResourceFunctionImpl setFunctionImport(final EdmFunctionImport edmFI, + final List parameters) { + functionImport = edmFI; this.parameters = parameters; List names = new ArrayList(); @@ -84,27 +85,29 @@ public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements U return this; } - @Override - public String toString() { - return function.getName() + super.toString(); - } - @Override public EdmType getType() { return function.getReturnType().getType(); - + } @Override public boolean isCollection() { - if (keyPredicates != null ) { + if (keyPredicates != null) { return false; } return function.getReturnType().isCollection(); } - + @Override + public String toString() { + if (functionImport != null) { + return functionImport.getName(); + } else if (function != null) { + return function.getName(); + } + return ""; + } - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceImplKeyPred.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceImplKeyPred.java index ab6d7486f..6af51d907 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceImplKeyPred.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceImplKeyPred.java @@ -31,7 +31,7 @@ public abstract class UriResourceImplKeyPred extends UriResourceImplTyped { protected List keyPredicates = null; protected EdmType singleTypeFilter = null; - public UriResourceImplKeyPred(UriResourceKind kind) { + public UriResourceImplKeyPred(final UriResourceKind kind) { super(kind); } @@ -58,18 +58,17 @@ public abstract class UriResourceImplKeyPred extends UriResourceImplTyped { return retList; } - public UriResourceImplKeyPred setKeyPredicates(List list) { + public UriResourceImplKeyPred setKeyPredicates(final List list) { keyPredicates = list; return this; } - public void setSingleTypeFilter(EdmType singleTypeFilter) { + public void setSingleTypeFilter(final EdmType singleTypeFilter) { this.singleTypeFilter = singleTypeFilter; } - public void setCollectionTypeFilter(EdmType collectionTypeFilter) { + public void setCollectionTypeFilter(final EdmType collectionTypeFilter) { this.collectionTypeFilter = collectionTypeFilter; } - } \ No newline at end of file diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceImplTyped.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceImplTyped.java index 0b5aca4d3..4a1e3efcd 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceImplTyped.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceImplTyped.java @@ -26,16 +26,16 @@ import org.apache.olingo.odata4.producer.api.uri.UriResourcePartTyped; public abstract class UriResourceImplTyped extends UriResourcePartImpl implements UriResourcePartTyped { protected EdmType typeFilter = null; - - public UriResourceImplTyped(UriResourceKind kind) { + + public UriResourceImplTyped(final UriResourceKind kind) { super(kind); } - public EdmType getTypeFilter() {//TODO rename to TypeFilter + public EdmType getTypeFilter() { return typeFilter; } - - public UriResourceImplTyped setTypeFilter(EdmStructuralType typeFilter) { + + public UriResourceImplTyped setTypeFilter(final EdmStructuralType typeFilter) { this.typeFilter = typeFilter; return this; } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceItImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceItImpl.java index 329766021..c4de8cc32 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceItImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceItImpl.java @@ -31,21 +31,11 @@ public class UriResourceItImpl extends UriResourceImplKeyPred implements UriReso private EdmType type; private boolean isCollection; - public UriResourceItImpl() { super(UriResourceKind.it); } - @Override - public String toString() { - - if (explicitIT) { - return "$it" + super.toString(); - } - return super.toString(); - } - - public UriResourceItImpl setIsExplicitIT(boolean explicitIT) { + public UriResourceItImpl setIsExplicitIT(final boolean explicitIT) { this.explicitIT = explicitIT; return this; } @@ -62,22 +52,25 @@ public class UriResourceItImpl extends UriResourceImplKeyPred implements UriReso @Override public boolean isCollection() { - if (keyPredicates != null ) { + if (keyPredicates != null) { return false; } return isCollection; } - public UriResourceItImpl setType(EdmType type) { + public UriResourceItImpl setType(final EdmType type) { this.type = type; return this; } - public UriResourceItImpl setCollection(boolean isCollection) { + public UriResourceItImpl setCollection(final boolean isCollection) { this.isCollection = isCollection; return this; } - + @Override + public String toString() { + return "$it"; + } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaRefImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaRefImpl.java new file mode 100644 index 000000000..4b0d4f37d --- /dev/null +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaRefImpl.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * 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.producer.core.uri; + +import org.apache.olingo.odata4.commons.api.edm.EdmType; +import org.apache.olingo.odata4.producer.api.uri.UriResourceIt; +import org.apache.olingo.odata4.producer.api.uri.UriResourceKind; +import org.apache.olingo.odata4.producer.api.uri.UriResourceLambdaRef; + +public class UriResourceLambdaRefImpl extends UriResourceImplTyped implements UriResourceLambdaRef { + + private EdmType type; + private boolean isCollection; + private String variableText; + + public UriResourceLambdaRefImpl() { + super(UriResourceKind.lambdaVariable); + } + + @Override + public String getVariableText() { + return variableText; + } + + public UriResourceLambdaRefImpl setVariableText(String variableText) { + this.variableText = variableText; + return this; + } + + @Override + public EdmType getType() { + return type; + } + + public UriResourceLambdaRefImpl setType(EdmType type) { + this.type = type; + return this; + + } + + @Override + public boolean isCollection() { + return isCollection; + } + + public UriResourceLambdaRefImpl isCollection(boolean isCollection) { + this.isCollection = isCollection; + return this; + } + +} diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceNavigationPropertyImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceNavigationPropertyImpl.java index 9da82c2f8..c55a679d5 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceNavigationPropertyImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceNavigationPropertyImpl.java @@ -31,42 +31,33 @@ public class UriResourceNavigationPropertyImpl extends UriResourceImplKeyPred im super(UriResourceKind.navigationProperty); } - @Override - public String toString() { - return navigationProperty.getName() + super.toString(); - } - @Override public EdmNavigationProperty getNavigationProperty() { return navigationProperty; } - public UriResourceNavigationPropertyImpl addNavigationProperty(EdmNavigationProperty property) { - this.navigationProperty = property; + public UriResourceNavigationPropertyImpl setNavigationProperty(final EdmNavigationProperty property) { + navigationProperty = property; return this; } @Override public EdmType getType() { - /*if (singleTypeFilter != null) { - return singleTypeFilter; - } else if (collectionTypeFilter != null) { - return collectionTypeFilter; - }*/ return navigationProperty.getType(); } @Override public boolean isCollection() { - if (keyPredicates != null ) { + if (keyPredicates != null) { return false; } return navigationProperty.isCollection(); - - } - + @Override + public String toString() { + return navigationProperty.getName(); + } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourcePartImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourcePartImpl.java index 0a2e66f0c..deaba0677 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourcePartImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourcePartImpl.java @@ -24,10 +24,10 @@ import org.apache.olingo.odata4.producer.api.uri.UriResourcePart; /** * Covers Functionimports and BoundFunction in URI */ -public class UriResourcePartImpl implements UriResourcePart { +public abstract class UriResourcePartImpl implements UriResourcePart { protected UriResourceKind kind; - public UriResourcePartImpl(UriResourceKind kind) { + public UriResourcePartImpl(final UriResourceKind kind) { this.kind = kind; } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourcePropertyImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourcePropertyImpl.java index 8ba903749..11bb0ef2b 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourcePropertyImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourcePropertyImpl.java @@ -26,7 +26,7 @@ import org.apache.olingo.odata4.producer.api.uri.UriResourceSimpleProperty; public class UriResourcePropertyImpl extends UriResourceImplTyped implements UriResourceSimpleProperty { protected EdmProperty property; - public UriResourcePropertyImpl(UriResourceKind kind) { + public UriResourcePropertyImpl(final UriResourceKind kind) { super(kind); } @@ -35,7 +35,7 @@ public class UriResourcePropertyImpl extends UriResourceImplTyped implements Uri return property; } - public UriResourcePropertyImpl setProperty(EdmProperty property) { + public UriResourcePropertyImpl setProperty(final EdmProperty property) { this.property = property; return this; } @@ -48,7 +48,11 @@ public class UriResourcePropertyImpl extends UriResourceImplTyped implements Uri @Override public boolean isCollection() { return property.isCollection(); - + } + + @Override + public String toString() { + return property.getName(); } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceRefImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceRefImpl.java index 690034e9c..0ff23e3e3 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceRefImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceRefImpl.java @@ -18,9 +18,9 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri; - import org.apache.olingo.odata4.producer.api.uri.UriResourceKind; import org.apache.olingo.odata4.producer.api.uri.UriResourceRef; + public class UriResourceRefImpl extends UriResourcePartImpl implements UriResourceRef { public UriResourceRefImpl() { @@ -28,7 +28,9 @@ public class UriResourceRefImpl extends UriResourcePartImpl implements UriResour } - - + @Override + public String toString() { + return "$ref"; + } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceRootImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceRootImpl.java index bf2c3fb36..f6c3d79fe 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceRootImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceRootImpl.java @@ -21,12 +21,15 @@ package org.apache.olingo.odata4.producer.core.uri; import org.apache.olingo.odata4.producer.api.uri.UriResourceKind; import org.apache.olingo.odata4.producer.api.uri.UriResourceRoot; -public class UriResourceRootImpl extends UriResourcePartImpl implements UriResourceRoot { +public class UriResourceRootImpl extends UriResourcePartImpl implements UriResourceRoot { public UriResourceRootImpl() { super(UriResourceKind.root); } - + @Override + public String toString() { + return "$root"; + } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceSimplePropertyImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceSimplePropertyImpl.java index e16a73cbc..4a66afca3 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceSimplePropertyImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceSimplePropertyImpl.java @@ -18,7 +18,6 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri; - import org.apache.olingo.odata4.commons.api.edm.EdmProperty; import org.apache.olingo.odata4.commons.api.edm.EdmType; import org.apache.olingo.odata4.producer.api.uri.UriResourceKind; @@ -27,20 +26,18 @@ import org.apache.olingo.odata4.producer.api.uri.UriResourceSimpleProperty; public class UriResourceSimplePropertyImpl extends UriResourceImplTyped implements UriResourceSimpleProperty { EdmProperty property; - + public UriResourceSimplePropertyImpl() { super(UriResourceKind.simpleProperty); } - - @Override public EdmProperty getProperty() { return property; } - - public UriResourceSimplePropertyImpl setProperty( EdmProperty property) { - this.property = property; + + public UriResourceSimplePropertyImpl setProperty(final EdmProperty property) { + this.property = property; return this; } @@ -53,7 +50,10 @@ public class UriResourceSimplePropertyImpl extends UriResourceImplTyped implemen public boolean isCollection() { return property.isCollection(); } - - + + @Override + public String toString() { + return property.getName(); + } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceSingletonImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceSingletonImpl.java index bee3fb004..5bec6fb7a 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceSingletonImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceSingletonImpl.java @@ -31,34 +31,28 @@ public class UriResourceSingletonImpl extends UriResourceImplTyped implements Ur public UriResourceSingletonImpl() { super(UriResourceKind.singleton); } - @Override public EdmSingleton getSingleton() { return singleton; } - - public UriResourceSingletonImpl setSingleton(EdmSingleton singleton) { + + public UriResourceSingletonImpl setSingleton(final EdmSingleton singleton) { this.singleton = singleton; return this; } - + @Override public EdmEntityType getEntityTypeFilter() { return (EdmEntityType) typeFilter; } - @Override - public String toString() { - return singleton.getName() + super.toString(); - } - @Override public EdmType getType() { return singleton.getEntityType(); } - + @Override public EdmEntityType getEntityType() { return singleton.getEntityType(); @@ -69,13 +63,9 @@ public class UriResourceSingletonImpl extends UriResourceImplTyped implements Ur return false; } - - - - - - - - + @Override + public String toString() { + return singleton.toString(); + } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceValueImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceValueImpl.java index ceae82a40..1dd82b6b4 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceValueImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceValueImpl.java @@ -18,10 +18,9 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri; - - import org.apache.olingo.odata4.producer.api.uri.UriResourceKind; import org.apache.olingo.odata4.producer.api.uri.UriResourceValue; + public class UriResourceValueImpl extends UriResourcePartImpl implements UriResourceValue { public UriResourceValueImpl() { @@ -29,7 +28,9 @@ public class UriResourceValueImpl extends UriResourcePartImpl implements UriReso } - - + @Override + public String toString() { + return "$value"; + } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/AliasQueryOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/AliasQueryOptionImpl.java index 2e0a9e107..d5ed1ecae 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/AliasQueryOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/AliasQueryOptionImpl.java @@ -22,7 +22,7 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.AliasQueryOption; import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl; public class AliasQueryOptionImpl extends QueryOptionImpl implements AliasQueryOption { - // TODO change value of alias to a interface which need to be defined + private ExpressionImpl aliasValue; @Override @@ -30,13 +30,9 @@ public class AliasQueryOptionImpl extends QueryOptionImpl implements AliasQueryO return aliasValue; } - - - public AliasQueryOptionImpl setAliasValue(ExpressionImpl aliasValue) { + public AliasQueryOptionImpl setAliasValue(final ExpressionImpl aliasValue) { this.aliasValue = aliasValue; return this; } - - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/CustomQueryOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/CustomQueryOptionImpl.java index 2096d6ff8..b3822a9b0 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/CustomQueryOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/CustomQueryOptionImpl.java @@ -21,6 +21,5 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption; import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption; public class CustomQueryOptionImpl extends QueryOptionImpl implements CustomQueryOption { - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/ExpandItemImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/ExpandItemImpl.java index 22b34d732..896f0627d 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/ExpandItemImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/ExpandItemImpl.java @@ -23,11 +23,10 @@ import java.util.ArrayList; import java.util.List; import org.apache.olingo.odata4.commons.api.edm.Edm; -import org.apache.olingo.odata4.producer.api.uri.UriResourceProperty; +import org.apache.olingo.odata4.producer.api.uri.UriInfoResource; import org.apache.olingo.odata4.producer.api.uri.queryoption.ExceptionVisitExpand; import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandItem; import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandVisitor; import org.apache.olingo.odata4.producer.api.uri.queryoption.FilterOption; import org.apache.olingo.odata4.producer.api.uri.queryoption.InlineCountOption; import org.apache.olingo.odata4.producer.api.uri.queryoption.LevelExpandOption; @@ -35,18 +34,11 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByOption; import org.apache.olingo.odata4.producer.api.uri.queryoption.SearchOption; import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption; import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; import org.apache.olingo.odata4.producer.api.uri.queryoption.TopOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.VisitableExpand; -public class ExpandItemImpl implements ExpandItem, VisitableExpand { - private Edm edm; - private ExpandSegment lastExpandSegment = null; - - private List segments = new ArrayList(); - - private boolean isStar; +public class ExpandItemImpl implements ExpandItem { private LevelExpandOption levelExpandOption; private FilterOption filterOption; private SearchOption searchOption; @@ -57,49 +49,44 @@ public class ExpandItemImpl implements ExpandItem, VisitableExpand { private SelectOption selectOption; private ExpandOption expandOption; - public ExpandItemImpl setEdm(Edm edm) { - this.edm = edm; + private UriInfoResource resourcePath; + + private boolean isStar; + + private boolean isRef; + + public ExpandItemImpl setEdm(final Edm edm) { return this; } - - public ExpandItemImpl setStar(boolean isStar) { - this.isStar = isStar; - return this; - } - - - - public ExpandSegment getLastSegement() { - return lastExpandSegment; - } - - - public ExpandItemImpl setExpandQueryOption(QueryOptionImpl item) { + public ExpandItemImpl setExpandQueryOption(final QueryOptionImpl item) { if (item instanceof SystemQueryOptionImpl) { - SystemQueryOptionImpl sysItem = (SystemQueryOptionImpl) item; + SystemQueryOptionImpl sysItem = (SystemQueryOptionImpl) item; - if (sysItem.getKind() == SystemQueryOptionEnum.EXPAND) { - expandOption = (ExpandOptionImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.FILTER) { - filterOption = (FilterOptionImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.INLINECOUNT) { - inlineCountOption = (InlineCountImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.ORDERBY) { - orderByOption = (OrderByImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.SEARCH) { - searchOption = (SearchOptionImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.SELECT) { - selectOption = (SelectOptionImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.SKIP) { - skipOption = (SkipOptionImpl) sysItem; - } else if (sysItem.getKind() == SystemQueryOptionEnum.TOP) { - topOption = (TopOptionImpl) sysItem; - } + if (sysItem.getKind() == SupportedQueryOptions.EXPAND) { + expandOption = (ExpandOptionImpl) sysItem; + } else if (sysItem.getKind() == SupportedQueryOptions.FILTER) { + filterOption = (FilterOptionImpl) sysItem; + } else if (sysItem.getKind() == SupportedQueryOptions.INLINECOUNT) { + inlineCountOption = (InlineCountOptionImpl) sysItem; + } else if (sysItem.getKind() == SupportedQueryOptions.ORDERBY) { + orderByOption = (OrderByImpl) sysItem; + } else if (sysItem.getKind() == SupportedQueryOptions.SEARCH) { + searchOption = (SearchOptionImpl) sysItem; + } else if (sysItem.getKind() == SupportedQueryOptions.SELECT) { + selectOption = (SelectOptionImpl) sysItem; + } else if (sysItem.getKind() == SupportedQueryOptions.SKIP) { + skipOption = (SkipOptionImpl) sysItem; + } else if (sysItem.getKind() == SupportedQueryOptions.TOP) { + topOption = (TopOptionImpl) sysItem; + } else if (sysItem.getKind() == SupportedQueryOptions.LEVEL) { + levelExpandOption = (LevelExpandOption) sysItem; } + } return this; } - public ExpandItemImpl setExpandQueryOptions(List list) { + + public ExpandItemImpl setExpandQueryOptions(final List list) { for (QueryOptionImpl item : list) { setExpandQueryOption(item); @@ -107,40 +94,8 @@ public class ExpandItemImpl implements ExpandItem, VisitableExpand { return this; } - public ExpandItemImpl addSegment(ExpandSegment segment) { - lastExpandSegment = segment; - segments.add(segment); - return this; - } - - - @Override - public T accept(ExpandVisitor visitor) throws ExceptionVisitExpand { - - List parameters = new ArrayList(); - for (ExpandSegment segment : segments) { - parameters.add(segment.accept(visitor)); - } - - // TODO implement visitor pattern for options - - return null; //visitor.visitExpandItem(parameters, isStar, isRef, finalType); - } - - @Override - public boolean isStar() { - return isStar; - } - - - - @Override - public List getPropertyChainList() { - - return null; - } @Override public LevelExpandOption getLevel() { @@ -188,6 +143,35 @@ public class ExpandItemImpl implements ExpandItem, VisitableExpand { return expandOption; } + public ExpandItemImpl setResourcePath(final UriInfoResource resourcePath) { + this.resourcePath = resourcePath; + return this; + } + @Override + public UriInfoResource getPath() { + + return resourcePath; + } + + @Override + public boolean isStar() { + return isStar; + } + + public ExpandItemImpl setIsStar(final boolean isStar) { + this.isStar = isStar; + return this; + } + + @Override + public boolean isRef() { + return isRef; + } + + public ExpandItemImpl setIsRef(final boolean isRef) { + this.isRef = isRef; + return this; + } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/ExpandOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/ExpandOptionImpl.java index 08161a33c..ad330fc5a 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/ExpandOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/ExpandOptionImpl.java @@ -24,22 +24,21 @@ import java.util.List; import org.apache.olingo.odata4.producer.api.uri.queryoption.ExceptionVisitExpand; import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandItem; import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandVisitor; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; -import org.apache.olingo.odata4.producer.api.uri.queryoption.VisitableExpand; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; -public class ExpandOptionImpl extends SystemQueryOptionImpl implements ExpandOption, VisitableExpand { +public class ExpandOptionImpl extends SystemQueryOptionImpl implements ExpandOption { List expandItems = new ArrayList(); public ExpandOptionImpl() { - setKind(SystemQueryOptionEnum.EXPAND); + setKind(SupportedQueryOptions.EXPAND); } - public void addExpandItem(ExpandItemImpl expandItem) { + public void addExpandItem(final ExpandItemImpl expandItem) { expandItems.add(expandItem); } + @Override public List getExpandItems() { List retList = new ArrayList(); for (ExpandItemImpl item : expandItems) { @@ -48,14 +47,5 @@ public class ExpandOptionImpl extends SystemQueryOptionImpl implements ExpandOpt return retList; } - @Override - public T accept(ExpandVisitor visitor) throws ExceptionVisitExpand { - List parameters = new ArrayList(); - for (ExpandItemImpl expandItem : expandItems) { - parameters.add(expandItem.accept(visitor)); - } - - return visitor.visitExpand(parameters); - } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/FilterOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/FilterOptionImpl.java index bb1d6ec09..f24f17f4a 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/FilterOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/FilterOptionImpl.java @@ -18,9 +18,8 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri.queryoption; - import org.apache.olingo.odata4.producer.api.uri.queryoption.FilterOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl; public class FilterOptionImpl extends SystemQueryOptionImpl implements FilterOption { @@ -28,10 +27,10 @@ public class FilterOptionImpl extends SystemQueryOptionImpl implements FilterOpt private ExpressionImpl expression; public FilterOptionImpl() { - setKind(SystemQueryOptionEnum.FILTER); + setKind(SupportedQueryOptions.FILTER); } - - public FilterOptionImpl setExpression(ExpressionImpl expression) { + + public FilterOptionImpl setExpression(final ExpressionImpl expression) { this.expression = expression; return this; } @@ -41,6 +40,4 @@ public class FilterOptionImpl extends SystemQueryOptionImpl implements FilterOpt return expression; } - - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/FormatOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/FormatOptionImpl.java index ab8e280b9..0104c4e4e 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/FormatOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/FormatOptionImpl.java @@ -19,25 +19,23 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption; import org.apache.olingo.odata4.producer.api.uri.queryoption.FormatOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; - +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; public class FormatOptionImpl extends SystemQueryOptionImpl implements FormatOption { private String value; public FormatOptionImpl() { - setKind(SystemQueryOptionEnum.FORMAT); + setKind(SupportedQueryOptions.FORMAT); } - public FormatOptionImpl setValue(String value) { + public FormatOptionImpl setValue(final String value) { this.value = value; return this; } - + @Override public String getFormat() { return value; } - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/IdOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/IdOptionImpl.java index 6d5722eda..4dfb70816 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/IdOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/IdOptionImpl.java @@ -18,28 +18,20 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri.queryoption; - import org.apache.olingo.odata4.producer.api.uri.queryoption.IdOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; public class IdOptionImpl extends SystemQueryOptionImpl implements IdOption { private String value; - public IdOptionImpl() { - setKind(SystemQueryOptionEnum.ID); + setKind(SupportedQueryOptions.ID); } - - public IdOptionImpl setValue(String value) { + + public IdOptionImpl setValue(final String value) { this.value = value; return this; } - - //TODO remove - public String getValue() { - return value; - } - @Override public String getIdValue() { diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/InlineCountImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/InlineCountOptionImpl.java similarity index 72% rename from odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/InlineCountImpl.java rename to odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/InlineCountOptionImpl.java index 3610d60ee..f70635c71 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/InlineCountImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/InlineCountOptionImpl.java @@ -19,30 +19,28 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption; import org.apache.olingo.odata4.producer.api.uri.queryoption.InlineCountOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; +public class InlineCountOptionImpl extends SystemQueryOptionImpl implements InlineCountOption { -public class InlineCountImpl extends SystemQueryOptionImpl implements InlineCountOption { + private boolean count; - private String count; - - public InlineCountImpl() { - setKind(SystemQueryOptionEnum.INLINECOUNT); + public InlineCountOptionImpl() { + setKind(SupportedQueryOptions.INLINECOUNT); } - public String getCount() { + + @Override + public boolean getvalue() { return count; } - public InlineCountImpl setCount(String count) { + + public InlineCountOptionImpl setValue(boolean count) { this.count = count; return this; } - @Override - public boolean getInlineCountValue() { - // TODO Auto-generated method stub - return false; - } + } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/LevelOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/LevelExpandOptionImpl.java similarity index 69% rename from odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/LevelOptionImpl.java rename to odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/LevelExpandOptionImpl.java index ab0d34f4d..b50b1dc87 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/LevelOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/LevelExpandOptionImpl.java @@ -19,36 +19,40 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri.queryoption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; +import org.apache.olingo.odata4.producer.api.uri.queryoption.LevelExpandOption; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; -public class LevelOptionImpl extends SystemQueryOptionImpl implements LevelOption{ +public class LevelExpandOptionImpl extends SystemQueryOptionImpl implements LevelExpandOption { private boolean isMax; - private String value; + private int value; - public LevelOptionImpl() { - setKind(SystemQueryOptionEnum.LEVEL); + public LevelExpandOptionImpl() { + setKind(SupportedQueryOptions.LEVEL); } - public LevelOptionImpl setValue(String value) { + public LevelExpandOptionImpl setValue(final int value) { this.value = value; return this; } - public String getValue() { + public int getValue() { return value; } - @Override public boolean isMax() { return isMax; } - - public LevelOptionImpl setMax() { + + public LevelExpandOptionImpl setMax() { isMax = true; return this; - + + } + + @Override + public int getLevel() { + return value; } - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/LevelOption.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/LevelOption.java deleted file mode 100644 index 34bdaafb6..000000000 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/LevelOption.java +++ /dev/null @@ -1,23 +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.producer.core.uri.queryoption; - -public interface LevelOption { - boolean isMax(); -} diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/OrderByImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/OrderByImpl.java index a9b20149d..43f1d95db 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/OrderByImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/OrderByImpl.java @@ -18,34 +18,34 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri.queryoption; - import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByItem; import org.apache.olingo.odata4.producer.api.uri.queryoption.OrderByOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; + +public class OrderByImpl extends SystemQueryOptionImpl implements OrderByOption { -public class OrderByImpl extends SystemQueryOptionImpl implements OrderByOption{ - private List orders; public OrderByImpl() { - setKind(SystemQueryOptionEnum.ORDERBY); + setKind(SupportedQueryOptions.ORDERBY); } - - public List getOrders() { + + @Override + public List getOrders() { List retList = new ArrayList(); - for ( OrderByOptionImpl item: orders) { + for (OrderByOptionImpl item : orders) { retList.add(item); } return Collections.unmodifiableList(retList); } - - public OrderByImpl addOrder(OrderByOptionImpl order) { + + public OrderByImpl addOrder(final OrderByOptionImpl order) { orders.add(order); return this; } - + } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/OrderByOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/OrderByOptionImpl.java index 2da85cb60..db0eded58 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/OrderByOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/OrderByOptionImpl.java @@ -31,21 +31,20 @@ public class OrderByOptionImpl extends SystemQueryOptionImpl implements OrderByI public boolean isDescending() { return descending; } - - public OrderByItem setSortOrder( boolean descending) { + + public OrderByItem setSortOrder(final boolean descending) { this.descending = descending; return this; } - + @Override public ExpressionImpl getExpression() { return expression; } - - public OrderByItem setExpression(ExpressionImpl expression) { + + public OrderByItem setExpression(final ExpressionImpl expression) { this.expression = expression; return this; } - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/QueryOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/QueryOptionImpl.java index b6c2bb29e..e5a7a6d6c 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/QueryOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/QueryOptionImpl.java @@ -20,7 +20,7 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption; import org.apache.olingo.odata4.producer.api.uri.queryoption.QueryOption; -public class QueryOptionImpl implements QueryOption { +public abstract class QueryOptionImpl implements QueryOption { private String name; private String text; @@ -29,7 +29,7 @@ public class QueryOptionImpl implements QueryOption { return name; } - public QueryOptionImpl setName(String name) { + public QueryOptionImpl setName(final String name) { this.name = name; return this; } @@ -39,8 +39,8 @@ public class QueryOptionImpl implements QueryOption { return text; } - public QueryOptionImpl setText(String value) { - this.text = value; + public QueryOptionImpl setText(final String value) { + text = value; return this; } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SearchOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SearchOptionImpl.java index c27190707..0bf1a1ace 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SearchOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SearchOptionImpl.java @@ -20,14 +20,14 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption; import org.apache.olingo.odata4.producer.api.uri.queryoption.SearchOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; import org.apache.olingo.odata4.producer.api.uri.queryoption.search.SearchExpression; -/*TODO implement*/ +/* TODO implement */ public class SearchOptionImpl extends SystemQueryOptionImpl implements SearchOption { public SearchOptionImpl() { - setKind(SystemQueryOptionEnum.SEARCH); + setKind(SupportedQueryOptions.SEARCH); } @Override @@ -36,5 +36,4 @@ public class SearchOptionImpl extends SystemQueryOptionImpl implements SearchOpt return null; } - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectItemOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectItemOptionImpl.java index 51992a10f..28a2e9391 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectItemOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectItemOptionImpl.java @@ -25,7 +25,6 @@ import java.util.List; import org.apache.olingo.odata4.commons.api.edm.Edm; import org.apache.olingo.odata4.commons.api.edm.EdmAction; import org.apache.olingo.odata4.commons.api.edm.EdmComplexType; -import org.apache.olingo.odata4.commons.api.edm.EdmElement; import org.apache.olingo.odata4.commons.api.edm.EdmEntityType; import org.apache.olingo.odata4.commons.api.edm.EdmFunction; import org.apache.olingo.odata4.commons.api.edm.EdmStructuralType; @@ -34,155 +33,37 @@ import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName; import org.apache.olingo.odata4.producer.api.uri.UriResourceProperty; import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectItem; -public class SelectItemOptionImpl implements SelectItem{ +public class SelectItemOptionImpl implements SelectItem { - private Edm edm; - private EdmType finalType; - private SelectSegment lastSegment = null; + private SelectSegmentImpl lastSegment = null; // only one of these must me filled - private List segments = new ArrayList(); - private EdmAction action; - private EdmFunction function; - private boolean isStar; - private FullQualifiedName addOperationsInSchema; - - public class SelectSegment { - private EdmElement property; // ia EdmProperty or EdmNavigationProperty - private EdmType initialType; - private EdmType typeCast; - private EdmType finalType; - - - public SelectSegment setProperty(EdmElement property) { - this.property = property; - this.initialType = property.getType(); - this.finalType = initialType; - return this; - } - - public EdmType getType() { - return finalType; - } - - public EdmType getTypeCast() { - return typeCast; - } - - public EdmElement getProperty() { - return property; - } - - public void addCast(EdmStructuralType type) { - this.typeCast = type; - this.finalType = type; - - } - } + private List segments = new ArrayList(); public EdmType getType() { - return finalType; - } - - public SelectItemOptionImpl setEdm(Edm edm) { - this.edm = edm; - return this; - } - - /** - * Sets the start type used for the type validation. For example this may be the type of the - * last resource path segment. - * @param startType - * @return - */ - public SelectItemOptionImpl setStartType(EdmType startType) { - this.finalType = startType; - return this; - } - - public SelectItemOptionImpl addProperty(String propertyName) { - - if (!(finalType instanceof EdmStructuralType)) { - // TODO error - return this; - } - - EdmStructuralType structType = (EdmStructuralType) finalType; - EdmElement property = (EdmElement) structType.getProperty(propertyName); - if (property == null) { - // TODO error - return this; - } - - // create new segment - this.lastSegment = new SelectSegment().setProperty(property); - this.segments.add(this.lastSegment); - - this.finalType = lastSegment.getType(); - return this; - } - - public void addStar() { - // TODO add checks - isStar = true; - } - - public void addAllOperationsInSchema(FullQualifiedName addOperationsInSchema) { - // TODO add checks - this.addOperationsInSchema =addOperationsInSchema; - } - - public SelectItemOptionImpl addQualifiedThing(FullQualifiedName fullName) { - // TODO add checks - if (finalType instanceof EdmEntityType) { - EdmEntityType et = edm.getEntityType(fullName); - if (((EdmStructuralType) finalType).compatibleTo(et)) { - this.lastSegment.addCast(et); - this.finalType = this.lastSegment.getType(); - return this; + if (lastSegment != null) { + EdmType type = lastSegment.getTypeCast(); + if (type != null) { + return type; } + return lastSegment.getType(); } - - if (finalType instanceof EdmComplexType) { - EdmComplexType ct = edm.getComplexType(fullName); - if (ct != null) { - if (((EdmStructuralType) finalType).compatibleTo(ct)) { - this.lastSegment.addCast(ct); - this.finalType = this.lastSegment.getType(); - return this; - } - } - } - - FullQualifiedName finalTypeName = new FullQualifiedName(finalType.getNamespace(), finalType.getName()); - - // check for action - EdmAction action = edm.getAction(fullName, finalTypeName, null); - // TODO verify that null ignores if it is a collection - - if (action != null) { - if (lastSegment != null) { - // TODO throw error action not usable behind property cast - } - this.action = action; - } - - // check for function - EdmFunction function = edm.getFunction(fullName, finalTypeName, null, null); - // TODO verify that null ignores if it is a collection - // TODO verify that the second for parameters null ignores the parameters - - if (function != null) { - if (lastSegment != null) { - // TODO throw error action not usable behind property cast - } - this.function = function; - } - return null; + } + + + public void addSegment(SelectSegmentImpl newSegment) { + segments.add(newSegment); + lastSegment = newSegment; } + public void addStar() {} + + public void addAllOperationsInSchema(final FullQualifiedName addOperationsInSchema) {} + + + @Override public boolean isStar() { // TODO Auto-generated method stub @@ -207,19 +88,22 @@ public class SelectItemOptionImpl implements SelectItem{ return null; } - @Override - public EdmAction getAction() { - return action; - } - - @Override - public EdmFunction getFunction() { - return function; - } @Override public List getPropertyChainList() { // TODO Auto-generated method stub return null; } + + + public SelectSegmentImpl getLastSegment() { + return lastSegment; + } + + + public void setEntityTypeCast(EdmEntityType et) { + // TODO Auto-generated method stub + + } + } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectOptionImpl.java index bfa5fda42..7365c6b6a 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectOptionImpl.java @@ -23,17 +23,17 @@ import java.util.List; import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectItem; import org.apache.olingo.odata4.producer.api.uri.queryoption.SelectOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; public class SelectOptionImpl extends SystemQueryOptionImpl implements SelectOption { private List selectItems; public SelectOptionImpl() { - setKind(SystemQueryOptionEnum.SELECT); + setKind(SupportedQueryOptions.SELECT); } - public SelectOptionImpl setSelectItems(List selectItems) { + public SelectOptionImpl setSelectItems(final List selectItems) { this.selectItems = selectItems; return this; } @@ -41,7 +41,7 @@ public class SelectOptionImpl extends SystemQueryOptionImpl implements SelectOpt @Override public List getSelectItems() { List retList = new ArrayList(); - for ( SelectItemOptionImpl item : selectItems) { + for (SelectItemOptionImpl item : selectItems) { retList.add(item); } return retList; diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/ExpandSegment.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectSegmentImpl.java similarity index 61% rename from odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/ExpandSegment.java rename to odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectSegmentImpl.java index 173cbce37..7fbad91c3 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/ExpandSegment.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectSegmentImpl.java @@ -18,38 +18,61 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri.queryoption; +import org.apache.olingo.odata4.commons.api.edm.EdmAction; import org.apache.olingo.odata4.commons.api.edm.EdmElement; +import org.apache.olingo.odata4.commons.api.edm.EdmFunction; import org.apache.olingo.odata4.commons.api.edm.EdmStructuralType; import org.apache.olingo.odata4.commons.api.edm.EdmType; -import org.apache.olingo.odata4.producer.api.uri.queryoption.ExceptionVisitExpand; -import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandVisitor; -import org.apache.olingo.odata4.producer.api.uri.queryoption.VisitableExpand; -/*TODO fix this*/ -public class ExpandSegment implements VisitableExpand { - private EdmType typeFilter; - private EdmElement property; - public ExpandSegment setProperty(EdmElement property) { +public class SelectSegmentImpl { + + private EdmElement property; + private EdmAction action; + private EdmFunction function; + + private EdmType typeCast; + + public EdmElement getProperty() { + return property; + } + + public SelectSegmentImpl setProperty(final EdmElement property) { this.property = property; + return this; } public EdmType getType() { return property.getType(); } - - public EdmType getTypeFilter() { - return this.typeFilter; + + public EdmType getTypeCast() { + return typeCast; } + + public SelectSegmentImpl setTypeCast(final EdmStructuralType type) { + typeCast = type; + return this; + } + - public void setFilter(EdmStructuralType type) { - this.typeFilter = type; + public EdmAction getAction() { + return action; } - @Override - public T accept(ExpandVisitor visitor) throws ExceptionVisitExpand { - return null;//visitor.visitExpandSegment(property, initialType, finalType); + public SelectSegmentImpl setAction(EdmAction action) { + this.action = action; + return this; } + public EdmFunction getFunction() { + return function; + } + + public SelectSegmentImpl setFunction(EdmFunction function) { + this.function = function; + return this; + } + } \ No newline at end of file diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkipOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkipOptionImpl.java index 80cf37f39..7a43666b3 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkipOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkipOptionImpl.java @@ -20,30 +20,26 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption; import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; -/*TODO implement*/ +/* TODO implement */ public class SkipOptionImpl extends SystemQueryOptionImpl implements SkipOption { - private boolean isMax; private String value; public SkipOptionImpl() { - setKind(SystemQueryOptionEnum.SEARCH); + setKind(SupportedQueryOptions.SKIP); } - + + @Override public String getValue() { return value; } - public SkipOptionImpl setValue(String value) { + + public SkipOptionImpl setValue(final String value) { this.value = value; return this; } - @Override - public String getSkipValue() { - // TODO Auto-generated method stub - return null; - } - + } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkipTokenOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkiptokenOptionImpl.java similarity index 66% rename from odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkipTokenOptionImpl.java rename to odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkiptokenOptionImpl.java index 78f222d79..67ce8a72d 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkipTokenOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkiptokenOptionImpl.java @@ -18,35 +18,27 @@ * under the License. ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri.queryoption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SkipTokenOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; -/*TODO implement*/ -public class SkipTokenOptionImpl extends SystemQueryOptionImpl implements SkipTokenOption{ - private boolean isMax; - private String token; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SkiptokenOption; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; - public SkipTokenOptionImpl() { - setKind(SystemQueryOptionEnum.SEARCH); +/* TODO implement */ +public class SkiptokenOptionImpl extends SystemQueryOptionImpl implements SkiptokenOption { + private String skipTokenValue; + + public SkiptokenOptionImpl() { + setKind(SupportedQueryOptions.SKIPTOKEN); } + - public String getToken() { - return token; + @Override + public String getValue() { + return skipTokenValue; } - - public SkipTokenOptionImpl - setToken( String token) { - this.token = token; + + public SkiptokenOptionImpl setValue(String skipTokenValue) { + this.skipTokenValue = skipTokenValue; return this; } - @Override - public String getSkipTokenValue() { - // TODO Auto-generated method stub - return null; - } - - - - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SystemQueryOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SystemQueryOptionImpl.java index c855d80c8..388b712f3 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SystemQueryOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SystemQueryOptionImpl.java @@ -19,31 +19,24 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption; import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOption; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; +public class SystemQueryOptionImpl extends QueryOptionImpl implements SystemQueryOption { -public class SystemQueryOptionImpl extends QueryOptionImpl implements SystemQueryOption{ + private SupportedQueryOptions kind; - private SystemQueryOptionEnum kind; - @Override - public SystemQueryOptionEnum getKind() { + public SupportedQueryOptions getKind() { return kind; } - - void setKind(SystemQueryOptionEnum kind) { + void setKind(final SupportedQueryOptions kind) { this.kind = kind; } - - @Override public String getName() { return kind.toString(); } - - - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/TopOptionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/TopOptionImpl.java index dff7cec29..9d6f7d60e 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/TopOptionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/TopOptionImpl.java @@ -19,24 +19,22 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri.queryoption; - -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; import org.apache.olingo.odata4.producer.api.uri.queryoption.TopOption; -/*TODO implement*/ +/* TODO implement */ public class TopOptionImpl extends SystemQueryOptionImpl implements TopOption { - private boolean isMax; private String value; public TopOptionImpl() { - setKind(SystemQueryOptionEnum.TOP); + setKind(SupportedQueryOptions.TOP); } public String getValue() { return value; } - - public TopOptionImpl setValue(String value) { + + public TopOptionImpl setValue(final String value) { this.value = value; return this; } @@ -46,5 +44,5 @@ public class TopOptionImpl extends SystemQueryOptionImpl implements TopOption { // TODO Auto-generated method stub return null; } - + } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/AliasImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/AliasImpl.java index 7b4231760..30f7a0822 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/AliasImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/AliasImpl.java @@ -18,16 +18,20 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri.queryoption.expression; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExpressionVisitor; + public class AliasImpl extends ExpressionImpl { private String referenceName; - public void setReference(String referenceName) { + public void setReference(final String referenceName) { this.referenceName = referenceName; } @Override - public T accept(ExpressionVisitor visitor) throws ExceptionVisitExpression { + public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { return visitor.visitAlias(referenceName); } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/BinaryImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/BinaryImpl.java index bf22f39f0..480abcb89 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/BinaryImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/BinaryImpl.java @@ -18,11 +18,14 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri.queryoption.expression; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.BinaryExpression; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedBinaryOperators; -public class BinaryImpl extends ExpressionImpl implements BinaryExpression, VisitableExression { +public class BinaryImpl extends ExpressionImpl implements BinaryExpression { private SupportedBinaryOperators operator; private ExpressionImpl left; @@ -33,7 +36,7 @@ public class BinaryImpl extends ExpressionImpl implements BinaryExpression, Visi return operator; } - public BinaryExpression setOperator(SupportedBinaryOperators operator) { + public BinaryExpression setOperator(final SupportedBinaryOperators operator) { this.operator = operator; return this; } @@ -43,8 +46,8 @@ public class BinaryImpl extends ExpressionImpl implements BinaryExpression, Visi return left; } - public void setLeftOperand(ExpressionImpl operand) { - this.left = operand; + public void setLeftOperand(final ExpressionImpl operand) { + left = operand; } @Override @@ -52,13 +55,13 @@ public class BinaryImpl extends ExpressionImpl implements BinaryExpression, Visi return right; } - public void setRightOperand(ExpressionImpl operand) { - this.right = operand; + public void setRightOperand(final ExpressionImpl operand) { + right = operand; } @Override - public T accept(ExpressionVisitor visitor) throws ExceptionVisitExpression { + public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { T left = this.left.accept(visitor); T right = this.right.accept(visitor); return visitor.visitBinaryOperator(operator, left, right); diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExpressionImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExpressionImpl.java index 0bdb71f82..08546300a 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExpressionImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExpressionImpl.java @@ -20,12 +20,6 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption.expression; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression; -public class ExpressionImpl implements Expression, VisitableExression { - - @Override - public T accept(ExpressionVisitor visitor) throws ExceptionVisitExpression { - // TODO Auto-generated method stub - return null; - } +public abstract class ExpressionImpl implements Expression { } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/LambdaRefImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/LambdaRefImpl.java index 665af5910..dc9063f1b 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/LambdaRefImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/LambdaRefImpl.java @@ -18,27 +18,30 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri.queryoption.expression; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.LambdaRef; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.VisitableExression; public class LambdaRefImpl extends ExpressionImpl implements LambdaRef, VisitableExression { private String variableText; @Override - public String getVariableText() { + public String getVariableName() { return variableText; } - public LambdaRefImpl setVariableText(String text) { - this.variableText = text; + public LambdaRefImpl setVariableText(final String text) { + variableText = text; return this; } @Override - public T accept(ExpressionVisitor visitor) throws ExceptionVisitExpression { - return null; + public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { + + return visitor.visitLambdaReference(variableText); } - - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/LiteralImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/LiteralImpl.java index eade6b794..0057bf0dd 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/LiteralImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/LiteralImpl.java @@ -18,7 +18,11 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri.queryoption.expression; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Literal; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.VisitableExression; public class LiteralImpl extends ExpressionImpl implements Literal, VisitableExression { @@ -29,13 +33,13 @@ public class LiteralImpl extends ExpressionImpl implements Literal, VisitableExr return text; } - public LiteralImpl setText(String text) { + public LiteralImpl setText(final String text) { this.text = text; return this; } @Override - public T accept(ExpressionVisitor visitor) throws ExceptionVisitExpression { + public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { return visitor.visitLiteral(text); } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/MemberImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/MemberImpl.java index 56ff31d44..641ed7ee7 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/MemberImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/MemberImpl.java @@ -18,37 +18,30 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri.queryoption.expression; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; import org.apache.olingo.odata4.producer.api.uri.UriInfoResource; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Member; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.VisitableExression; public class MemberImpl extends ExpressionImpl implements Member, VisitableExression { - private boolean isIT; // means $it as defined in the ABNF private UriInfoResource path; - @Override - public boolean isIT() { - return isIT; - } - - public Member setIT(boolean isIT) { - this.isIT = isIT; - return this; - } - @Override public UriInfoResource getPath() { return path; } - public Member setPath(UriInfoResource pathSegments) { - this.path = pathSegments; + public Member setPath(final UriInfoResource pathSegments) { + path = pathSegments; return this; } @Override - public T accept(ExpressionVisitor visitor) throws ExceptionVisitExpression { - return visitor.visitMember(this); + public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { + return visitor.visitMember(path); } } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/MethodCallImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/MethodCallImpl.java index f8c666d79..a9d4022a2 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/MethodCallImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/MethodCallImpl.java @@ -21,43 +21,47 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption.expression; import java.util.ArrayList; import java.util.List; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.MethodCall; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedMethodCalls; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.VisitableExression; -public class MethodCallImpl extends ExpressionImpl implements MethodCall, VisitableExression{ +public class MethodCallImpl extends ExpressionImpl implements MethodCall, VisitableExression { private SupportedMethodCalls method; private List parameters = new ArrayList(); - + @Override public SupportedMethodCalls getMethod() { return method; } - public MethodCallImpl setMethod(SupportedMethodCalls methodCalls) { - this.method = methodCalls; + public MethodCallImpl setMethod(final SupportedMethodCalls methodCalls) { + method = methodCalls; return this; } - + @Override public List getParameters() { List list = new ArrayList(); - for ( ExpressionImpl item : parameters) { + for (ExpressionImpl item : parameters) { list.add(item); } return list; } - public MethodCallImpl addParameter(ExpressionImpl readCommonExpression) { + public MethodCallImpl addParameter(final ExpressionImpl readCommonExpression) { parameters.add(readCommonExpression); return this; } @Override - public T accept(ExpressionVisitor visitor) throws ExceptionVisitExpression { + public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { List userParameters = new ArrayList(); - for (ExpressionImpl parameter : parameters ) { + for (ExpressionImpl parameter : parameters) { userParameters.add(parameter.accept(visitor)); } return visitor.visitMethodCall(method, userParameters); diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/TypeLiteralImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/TypeLiteralImpl.java index e74ff7682..e0a43cee4 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/TypeLiteralImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/TypeLiteralImpl.java @@ -19,7 +19,11 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption.expression; import org.apache.olingo.odata4.commons.api.edm.EdmType; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.TypeLiteral; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.VisitableExression; public class TypeLiteralImpl extends ExpressionImpl implements TypeLiteral, VisitableExression { @@ -29,17 +33,15 @@ public class TypeLiteralImpl extends ExpressionImpl implements TypeLiteral, Visi public EdmType getType() { return type; } - - public TypeLiteralImpl setType(EdmType type) { + + public TypeLiteralImpl setType(final EdmType type) { this.type = type; return this; } @Override - public T accept(ExpressionVisitor visitor) throws ExceptionVisitExpression { - return null; + public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { + return visitor.visitTypeLiteral(type); } - - } diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/UnaryOperatorImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/UnaryOperatorImpl.java index 98da4ba9e..8ec6ecb4b 100644 --- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/UnaryOperatorImpl.java +++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/UnaryOperatorImpl.java @@ -18,9 +18,13 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.uri.queryoption.expression; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedUnaryOperators; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.UnaryOperator; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.VisitableExression; public class UnaryOperatorImpl extends ExpressionImpl implements UnaryOperator, VisitableExression { @@ -32,7 +36,7 @@ public class UnaryOperatorImpl extends ExpressionImpl implements UnaryOperator, return operator; } - public void setOperator(SupportedUnaryOperators operator) { + public void setOperator(final SupportedUnaryOperators operator) { this.operator = operator; } @@ -41,12 +45,12 @@ public class UnaryOperatorImpl extends ExpressionImpl implements UnaryOperator, return expression; } - public void setOperand(ExpressionImpl expression) { + public void setOperand(final ExpressionImpl expression) { this.expression = expression; } @Override - public T accept(ExpressionVisitor visitor) throws ExceptionVisitExpression { + public T accept(final ExpressionVisitor visitor) throws ExceptionVisitExpression, ODataApplicationException { T operand = expression.accept(visitor); return visitor.visitUnaryOperator(operator, operand); } diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/EdmTechProvider.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/EdmTechProvider.java index 38adef07f..1bcd35193 100644 --- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/EdmTechProvider.java +++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/EdmTechProvider.java @@ -674,7 +674,7 @@ public class EdmTechProvider extends EdmProvider { propertyDecimal, propertySingle, propertyDouble, propertyDuration, propertyGuid, propertyInt16, propertyInt32, propertyInt64, propertySByte, - propertyTimeOfDay/* ,TODO propertyStream */)); + propertyTimeOfDay/* TODO add steam property */)); } else if (complexTypeName.equals(nameCTCollAllPrim)) { return new ComplexType() @@ -688,7 +688,7 @@ public class EdmTechProvider extends EdmProvider { collPropertyDecimal, collPropertyBinary, collPropertyDate, collPropertyDateTimeOffset, collPropertyDuration, collPropertyGuid, - collPropertyTimeOfDay /* ,TODO collectionPropertyStream */)); + collPropertyTimeOfDay /* TODO add collectionPropertyStream */)); } else if (complexTypeName.equals(nameCTTwoPrim)) { return new ComplexType() @@ -1089,7 +1089,7 @@ public class EdmTechProvider extends EdmProvider { propertySingle, propertyDouble, propertyDecimal, propertyBinary, propertyDate, propertyDateTimeOffset, - propertyDuration, propertyGuid, propertyTimeOfDay /* TODO add stream */, + propertyDuration, propertyGuid, propertyTimeOfDay /* TODO add stream property */, collPropertyString, collPropertyBoolean, collPropertyByte, collPropertySByte, collPropertyInt16, @@ -1097,7 +1097,7 @@ public class EdmTechProvider extends EdmProvider { collPropertySingle, collPropertyDouble, collPropertyDecimal, collPropertyBinary, collPropertyDate, collPropertyDateTimeOffset, - collPropertyDuration, collPropertyGuid, collPropertyTimeOfDay /* TODO add stream, */)); + collPropertyDuration, collPropertyGuid, collPropertyTimeOfDay /* TODO add stream property */)); } else if (entityTypeName.equals(nameETKeyNav)) { return new EntityType() @@ -1370,6 +1370,15 @@ public class EdmTechProvider extends EdmProvider { } else if (functionName.equals(nameUFCRTStringTwoParam)) { return Arrays.asList( + new Function() + .setName("UFCRTStringTwoParam") + .setParameters(Arrays.asList( + new Parameter() + .setName("ParameterInt16") + .setType(nameInt16))) + .setComposable(true) + .setReturnType( + new ReturnType().setType(nameString)), new Function() .setName("UFCRTStringTwoParam") .setParameters(Arrays.asList( @@ -1382,6 +1391,7 @@ public class EdmTechProvider extends EdmProvider { .setComposable(true) .setReturnType( new ReturnType().setType(nameString)) + ); } else if (functionName.equals(nameUFCRTESTwoKeyNavParam)) { diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ExpandToText.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ExpandToText.java deleted file mode 100644 index d9926ce67..000000000 --- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ExpandToText.java +++ /dev/null @@ -1,68 +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.producer.core.testutil; - -import java.util.List; - -import org.apache.olingo.odata4.commons.api.edm.EdmElement; -import org.apache.olingo.odata4.commons.api.edm.EdmType; -import org.apache.olingo.odata4.producer.api.uri.queryoption.ExceptionVisitExpand; -import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandVisitor; -import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandOptionImpl; - - -public class ExpandToText implements ExpandVisitor { - - public static String Serialize(ExpandOptionImpl expand) throws ExceptionVisitExpand { - return expand.accept(new ExpandToText()); - } - - @Override - public String visitExpandSegment(EdmElement property, EdmType initialType, EdmType finalType) { - - return "<" + property.getName() + "(" + finalType.getNamespace() + "/" + finalType.getName() + ">"; - } - - @Override - public String visitExpandItem(List expandSegments, boolean isStar, boolean isRef, EdmType finalType) { - String tmp = ""; - for (String expandItem : expandSegments) { - if (tmp.length() != 0) { - tmp += ","; - } - tmp += expandItem; - } - return "<(" + tmp + ")>"; - } - - @Override - public String visitExpand(List expandItems) { - String tmp = ""; - - for (String expandItem : expandItems) { - if (tmp.length() != 0) { - tmp += ","; - } - tmp += expandItem; - } - return "<(" + tmp + ")>"; - } - -} diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ExpandValidator.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ExpandValidator.java new file mode 100644 index 000000000..324fd6fc8 --- /dev/null +++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ExpandValidator.java @@ -0,0 +1,180 @@ +/******************************************************************************* + * + * 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.producer.core.testutil; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import org.apache.olingo.odata4.commons.api.edm.Edm; +import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; +import org.apache.olingo.odata4.producer.api.uri.UriInfoKind; +import org.apache.olingo.odata4.producer.api.uri.UriResourcePart; +import org.apache.olingo.odata4.producer.api.uri.UriResourceRef; +import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandItem; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl; +import org.apache.olingo.odata4.producer.core.uri.UriResourceNavigationPropertyImpl; +import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandOptionImpl; +import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl; +import org.apache.olingo.odata4.producer.core.uri.queryoption.LevelExpandOptionImpl; + +public class ExpandValidator implements Validator{ + private Edm edm; + private Validator invokedByValidator; + private int expandItemIndex; + private ExpandOptionImpl expandOption; + private ExpandItem expandItem; + + // --- Setup --- + + public ExpandValidator setUpValidator(Validator parentValidator) { + this.invokedByValidator = parentValidator; + return this; + } + + + public ExpandValidator setExpand(ExpandOptionImpl expand) { + this.expandOption = expand; + first(); + return this; + } + + public ExpandValidator setEdm(final Edm edm) { + this.edm = edm; + return this; + } + + // --- Navigation --- + + public UriResourceValidator goPath() { + UriInfoImpl uriInfo = (UriInfoImpl) expandItem.getPath(); + + + if (uriInfo.getKind() != UriInfoKind.resource) { + fail("goPath can only be used on resourcePaths"); + } + + return new UriResourceValidator() + .setUpValidator(this) + .setEdm(edm) + .setUriInfoImplPath(uriInfo); + + } + + public ExpandValidator goExpand() { + ExpandValidator val = new ExpandValidator(); + val.setExpand( (ExpandOptionImpl)expandItem.getExpand()); + val.setUpValidator(this); + return val; + } + + public ExpandValidator goUpExpandValidator() { + return (ExpandValidator) invokedByValidator; + } + + public UriResourceValidator goUpUriResValidator() { + return (UriResourceValidator) invokedByValidator; + } + + public ExpandValidator first() { + expandItemIndex = 0; + expandItem = expandOption.getExpandItems().get(expandItemIndex); + return this; + } + + public ExpandValidator n() { + expandItemIndex++; + + try { + expandItem = expandOption.getExpandItems().get(expandItemIndex); + } catch (IndexOutOfBoundsException ex) { + fail("not enought segemnts"); + } + return this; + + } + + public ExpandValidator isSegStar(int index) { + assertEquals(true, expandItem.isStar()); + return this; + } + + public ExpandValidator isSegRef(int index) { + assertEquals(true, expandItem.isRef()); + return this; + } + + + + + public ExpandValidator isLevels(String text) { + LevelExpandOptionImpl obj = (LevelExpandOptionImpl) expandItem.getLevel(); + assertEquals(text, obj.getText()); + return this; + } + + public ExpandValidator isSkipText(String string) { + // TODO Auto-generated method stub + return this; + } + + public ExpandValidator isTopText(String string) { + // TODO Auto-generated method stub + return this; + } + + public ExpandValidator isCountText(String string) { + // TODO Auto-generated method stub + return this; + } + + public ExpandValidator isSegCount(int i) { + // TODO Auto-generated method stub + return this; + } + + public ExpandValidator isSelectText(String string) { + // TODO Auto-generated method stub + return this; + } + + public ExpandValidator isLevelsText(String string) { + + return this; + } + + public ExpandValidator isFilterSerialized(String serialized) { + FilterOptionImpl filter = (FilterOptionImpl) expandItem.getFilter(); + + try { + String tmp = FilterTreeToText.Serialize(filter); + assertEquals(serialized, tmp); + } catch (ExceptionVisitExpression e) { + fail(e.getMessage()); + } catch (ODataApplicationException e) { + fail(e.getMessage()); + } + + return this; + } + + +} diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterTreeToText.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterTreeToText.java index d3f933cb8..1d8749e94 100644 --- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterTreeToText.java +++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterTreeToText.java @@ -18,22 +18,43 @@ ******************************************************************************/ package org.apache.olingo.odata4.producer.core.testutil; +import static org.junit.Assert.fail; + import java.util.List; +import org.apache.olingo.odata4.commons.api.edm.EdmType; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; +import org.apache.olingo.odata4.producer.api.uri.UriInfoResource; +import org.apache.olingo.odata4.producer.api.uri.UriResourcePart; +import org.apache.olingo.odata4.producer.api.uri.UriResourceIt; +import org.apache.olingo.odata4.producer.api.uri.UriResourceCount; +import org.apache.olingo.odata4.producer.api.uri.UriResourceAction; +import org.apache.olingo.odata4.producer.api.uri.UriResourceAll; +import org.apache.olingo.odata4.producer.api.uri.UriResourceAny; +import org.apache.olingo.odata4.producer.api.uri.UriResourceEntitySet; +import org.apache.olingo.odata4.producer.api.uri.UriResourceFunction; +import org.apache.olingo.odata4.producer.api.uri.UriResourceNavigation; +import org.apache.olingo.odata4.producer.api.uri.UriResourceProperty; +import org.apache.olingo.odata4.producer.api.uri.UriResourceSingleton; +import org.apache.olingo.odata4.producer.api.uri.UriResourceRef; +import org.apache.olingo.odata4.producer.api.uri.UriResourceRoot; +import org.apache.olingo.odata4.producer.api.uri.UriResourceValue; + +import org.apache.olingo.odata4.producer.api.uri.queryoption.FilterOption; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExpressionVisitor; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedBinaryOperators; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedMethodCalls; import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedUnaryOperators; -import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExceptionVisitExpression; -import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionVisitor; -import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.MemberImpl; - +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.VisitableExression; +import org.apache.olingo.odata4.producer.core.uri.UriResourceActionImpl; public class FilterTreeToText implements ExpressionVisitor { - - public static String Serialize(FilterOptionImpl filter) throws ExceptionVisitExpression { - return filter.getExpression().accept(new FilterTreeToText()); + + public static String Serialize(FilterOption filter) throws ExceptionVisitExpression, ODataApplicationException { + Expression expression = filter.getExpression(); + return expression.accept(new FilterTreeToText()); } @Override @@ -68,15 +89,34 @@ public class FilterTreeToText implements ExpressionVisitor { } @Override - public String visitMember(MemberImpl member) throws ExceptionVisitExpression { + public String visitMember(UriInfoResource resource) throws ExceptionVisitExpression, ODataApplicationException { String ret = ""; - if (member.isIT()) { - ret += "$it"; - } - UriInfoImpl path = (UriInfoImpl) member.getPath(); - if (path != null) { - ret += path.toString(); + UriInfoResource path = resource; + + for (UriResourcePart item : path.getUriResourceParts()) { + String tmp = ""; + if (item instanceof UriResourceIt) { + if (((UriResourceIt) item).isExplicitIt()) { + tmp = "$it"; + } + } else if ( item instanceof UriResourceAll) { + UriResourceAll all = (UriResourceAll) item; + tmp = visitLambdaExpression(all.getLamdaVariable(), all.getExpression()); + } else if ( item instanceof UriResourceAny) { + UriResourceAny any = (UriResourceAny) item; + tmp = visitLambdaExpression(any.getLamdaVariable(), any.getExpression()); + } else { + tmp = item.toString(); + } + + + + if (ret.length() != 0) { + ret += "/"; + } + ret += tmp; + } return ret; } @@ -86,4 +126,21 @@ public class FilterTreeToText implements ExpressionVisitor { return "<" + referenceName + ">"; } + @Override + public String visitLambdaExpression(String variableText, Expression expression) + throws ExceptionVisitExpression, ODataApplicationException { + return "<" + variableText + ";" + expression.accept(this) + ">"; + } + + @Override + public String visitTypeLiteral(EdmType type) { + return type.toString(); + } + + @Override + public String visitLambdaReference(String variableText) { + // TODO Auto-generated method stub + return null; + } + } diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterValidator.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterValidator.java index e3673e639..47d1e0033 100644 --- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterValidator.java +++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterValidator.java @@ -22,13 +22,14 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import org.apache.olingo.odata4.commons.api.edm.Edm; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; import org.apache.olingo.odata4.producer.api.uri.UriInfoKind; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression; import org.apache.olingo.odata4.producer.core.uri.ParserAdapter; import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl; import org.apache.olingo.odata4.producer.core.uri.UriParserException; import org.apache.olingo.odata4.producer.core.uri.UriParseTreeVisitor; import org.apache.olingo.odata4.producer.core.uri.queryoption.FilterOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExceptionVisitExpression; public class FilterValidator implements Validator { private Edm edm; @@ -167,6 +168,9 @@ public class FilterValidator implements Validator { } catch (ExceptionVisitExpression e) { fail("Exception occured while converting the filterTree into text" + "\n" + " Exception: " + e.getMessage()); + } catch (ODataApplicationException e) { + fail("Exception occured while converting the filterTree into text" + "\n" + + " Exception: " + e.getMessage()); } return this; diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourceValidator.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourceValidator.java index ee25df43a..411e433c0 100644 --- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourceValidator.java +++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourceValidator.java @@ -28,12 +28,14 @@ import org.apache.olingo.odata4.commons.api.edm.Edm; import org.apache.olingo.odata4.commons.api.edm.EdmElement; import org.apache.olingo.odata4.commons.api.edm.EdmType; import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName; +import org.apache.olingo.odata4.commons.api.exception.ODataApplicationException; import org.apache.olingo.odata4.producer.api.uri.UriInfo; import org.apache.olingo.odata4.producer.api.uri.UriInfoKind; import org.apache.olingo.odata4.producer.api.uri.UriInfoResource; import org.apache.olingo.odata4.producer.api.uri.UriParameter; import org.apache.olingo.odata4.producer.api.uri.UriResourceKind; import org.apache.olingo.odata4.producer.api.uri.queryoption.CustomQueryOption; +import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.ExceptionVisitExpression; import org.apache.olingo.odata4.producer.core.uri.ParserAdapter; import org.apache.olingo.odata4.producer.core.uri.UriInfoImpl; import org.apache.olingo.odata4.producer.core.uri.UriParserException; @@ -50,7 +52,7 @@ import org.apache.olingo.odata4.producer.core.uri.UriResourcePropertyImpl; import org.apache.olingo.odata4.producer.core.uri.UriResourceSimplePropertyImpl; import org.apache.olingo.odata4.producer.core.uri.UriResourceSingletonImpl; import org.apache.olingo.odata4.producer.core.uri.queryoption.CustomQueryOptionImpl; -import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExceptionVisitExpression; +import org.apache.olingo.odata4.producer.core.uri.queryoption.ExpandOptionImpl; import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl; public class UriResourceValidator implements Validator { @@ -63,7 +65,7 @@ public class UriResourceValidator implements Validator { // --- Setup --- - public UriResourceValidator setUriValidator(UriValidator uriValidator) { + public UriResourceValidator setUpValidator(Validator uriValidator) { invokedBy = uriValidator; return this; } @@ -106,23 +108,24 @@ public class UriResourceValidator implements Validator { return (UriValidator) invokedBy; } - public UriResourceValidator at(int index) { - uriResourceIndex = index; - try { - uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(index); - } catch (IndexOutOfBoundsException ex) { - fail("not enought segemnts"); + public ExpandValidator goUpExpandValidator() { + return (ExpandValidator) invokedBy; + } + + public ExpandValidator goExpand() { + + ExpandOptionImpl expand = (ExpandOptionImpl) uriInfo.getExpandOption(); + if (expand == null) { + fail("goExpand can only be used if there is an expand option"); } - return this; + + return new ExpandValidator().setUpValidator(this).setExpand(expand); } public UriResourceValidator first() { uriResourceIndex = 0; - try { - uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(0); - } catch (IndexOutOfBoundsException ex) { - fail("not enought segemnts"); - } + uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(0); + return this; } @@ -150,6 +153,16 @@ public class UriResourceValidator implements Validator { return this; } + public UriResourceValidator at(int index) { + uriResourceIndex = index; + try { + uriPathInfo = (UriResourcePartImpl) uriInfo.getUriResourceParts().get(index); + } catch (IndexOutOfBoundsException ex) { + fail("not enought segemnts"); + } + return this; + } + // --- Validation --- public UriResourceValidator isTypeFilter(FullQualifiedName expectedType) { @@ -275,6 +288,8 @@ public class UriResourceValidator implements Validator { assertEquals(expectedFilterTreeAsString, filterTreeAsString); } catch (ExceptionVisitExpression e) { fail("isFilterString: Exception " + e.getMessage() + " occured"); + } catch (ODataApplicationException e) { + fail("isFilterString: Exception " + e.getMessage() + " occured"); } return this; @@ -293,7 +308,7 @@ public class UriResourceValidator implements Validator { return this; } - + public UriResourceValidator isParameter(int index, String name, String text) { if (!(uriPathInfo instanceof UriResourceFunctionImpl)) { // TODO add and "or" for FunctionImports @@ -360,7 +375,7 @@ public class UriResourceValidator implements Validator { assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunction().getName()); return this; } - + public UriResourceValidator isFunctionImport(String name) { assertEquals(UriResourceKind.function, uriPathInfo.getKind()); assertEquals(name, ((UriResourceFunctionImpl) uriPathInfo).getFunctionImport().getName()); @@ -415,8 +430,36 @@ public class UriResourceValidator implements Validator { public UriResourceValidator isNav(String name) { assertEquals(UriResourceKind.navigationProperty, uriPathInfo.getKind()); assertEquals(name, ((UriResourceNavigationPropertyImpl) uriPathInfo).getNavigationProperty().getName()); - // assertEquals(type, new FullQualifiedName(property.getType().getNamespace(), property.getType().getName())); return this; } + public UriResourceValidator isIt() { + assertEquals(UriResourceKind.it, uriPathInfo.getKind()); + return this; + } + + public UriResourceValidator isTopText(String topText) { + assertEquals(topText,uriInfo.getTopOption().getText()); + return this; + } + + public UriResourceValidator isFormatText(String formatText) { + assertEquals(formatText,uriInfo.getFormatOption().getText()); + return this; + } + + public UriResourceValidator isInlineCountText(String inlineCountText) { + assertEquals(inlineCountText,uriInfo.getInlineCountOption().getText()); + return this; + } + + public UriResourceValidator isSkipText(String skipText) { + assertEquals(skipText,uriInfo.getSkipOption().getText()); + return this; + } + + public UriResourceValidator isSkipTokenText(String skipTokenText) { + assertEquals(skipTokenText,uriInfo.getSkipTokenOption().getText()); + return this; + } } diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriValidator.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriValidator.java index 80540857a..c308ac6a3 100644 --- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriValidator.java +++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriValidator.java @@ -67,7 +67,7 @@ public class UriValidator implements Validator { } return new UriResourceValidator() - .setUriValidator(this) + .setUpValidator(this) .setEdm(edm) .setUriInfoImplPath(uriInfo); } diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/uri/antlr/TestByAbapResourcePath.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/uri/antlr/TestByAbapResourcePath.java index 35016b4c1..34bef458c 100644 --- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/uri/antlr/TestByAbapResourcePath.java +++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/uri/antlr/TestByAbapResourcePath.java @@ -20,8 +20,10 @@ package org.apache.olingo.odata4.producer.core.uri.antlr; // sync 20.1.2014 import java.util.Arrays; +import java.util.Stack; import org.apache.olingo.odata4.commons.api.edm.Edm; +import org.apache.olingo.odata4.commons.api.edm.EdmType; import org.apache.olingo.odata4.commons.core.edm.provider.EdmProviderImpl; import org.apache.olingo.odata4.producer.api.uri.UriInfoKind; import org.apache.olingo.odata4.producer.api.uri.UriResourceKind; @@ -43,7 +45,6 @@ public class TestByAbapResourcePath { testUri = new UriValidator().setEdm(edm); testRes = new UriResourceValidator().setEdm(edm); testFilter = new FilterValidator().setEdm(edm); - } @Test @@ -1940,7 +1941,6 @@ public class TestByAbapResourcePath { .isSimple("CollPropertyString") .isType(EdmTechProvider.nameString, true); testUri.run("SINav/CollPropertyString/$count") - .isKind(UriInfoKind.resource).goPath() .first() .isSingleton("SINav") @@ -1951,137 +1951,766 @@ public class TestByAbapResourcePath { .isCount(); } - // TODO make rest @Test public void runExpand() { - testUri.run("ESKeyNav(1)?$expand=*"); - testUri.run("ESKeyNav(1)?$expand=*/$ref"); - testUri.run("ESKeyNav(1)?$expand=*/$ref,NavPropertyETKeyNavMany"); - testUri.run("ESKeyNav(1)?$expand=*($levels=3)"); - testUri.run("ESKeyNav(1)?$expand=*($levels=max)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$ref"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($filter=PropertyInt16 eq 1)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($orderby=PropertyInt16)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($skip=1)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($top=2)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($count=true)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($skip=1;$top=3)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($skip=1%3b$top=3)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$count"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$count"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$count($filter=PropertyInt16 gt 1)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($filter=PropertyInt16 eq 1)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($orderby=PropertyInt16)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($skip=1)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($top=2)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($count=true)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($select=PropertyString)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($expand=NavPropertyETTwoKeyNavOne)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($expand=NavPropertyETKeyNavMany)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne($levels=5)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($select=PropertyString)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne($levels=max)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($skip=1;$top=2)"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($skip=1%3b$top=2)"); - testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='Hugo')?$expand=NavPropertyETKeyNavMany"); - testUri - .run("ESTwoKeyNav(PropertyInt16=1,PropertyString='Hugo')?$expand=com.sap.odata.test1.ETBaseTwoKeyNav" - + "/NavPropertyETKeyNavMany"); - testUri - .run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?$expand=com.sap.odata.test1.ETBaseTwoKeyNav" - + "/NavPropertyETTwoKeyNavMany"); - testUri - .run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?$expand=com.sap.odata.test1.ETBaseTwoKeyNav" - + "/NavPropertyETTwoKeyNavMany/com.sap.odata.test1.ETTwoBaseTwoKeyNav"); - testUri.run("ESTwoKeyNav?$expand=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyComplexNav/NavPropertyETTwoKeyNavOne"); - testUri - .run("ESTwoKeyNav?$expand=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyComplexNav" - + "/com.sap.odata.test1.CTTwoBasePrimCompNav/NavPropertyETTwoKeyNavOne"); - testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref,NavPropertyETTwoKeyNavMany($skip=2;$top=1)"); - testUri - .run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?$expand=com.sap.odata.test1.ETBaseTwoKeyNav" - + "/NavPropertyETTwoKeyNavMany/com.sap.odata.test1.ETTwoBaseTwoKeyNav($select=PropertyString)"); - testUri - .run("ESKeyNav?$expand=NavPropertyETKeyNavOne($expand=NavPropertyETKeyNavMany(" - + "$expand=NavPropertyETKeyNavOne))"); - testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($select=PropertyInt16)"); - testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($select=PropertyComplex/PropertyInt16)"); + testUri.run("ESKeyNav(1)?$expand=*") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .isSegStar(0); + + testUri.run("ESKeyNav(1)?$expand=*/$ref") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .isSegStar(0) + .isSegRef(1); + + testUri.run("ESKeyNav(1)?$expand=*/$ref,NavPropertyETKeyNavMany") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .isSegStar(0).isSegRef(1) + .n() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany"); + + testUri.run("ESKeyNav(1)?$expand=*($levels=3)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .isSegStar(0) + .isLevels("3"); + + testUri.run("ESKeyNav(1)?$expand=*($levels=max)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .isSegStar(0) + .isLevels("max"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .n().isRef(); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$ref") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavOne") + .isType(EdmTechProvider.nameETKeyNav, false) + .n().isRef(); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($filter=PropertyInt16 eq 1)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .n().isRef() + .goUpExpandValidator().isFilterSerialized(""); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($orderby=PropertyInt16)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .n().isRef() + .goUpExpandValidator();// .isFilterSerialized(""); TODO check order BY + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($skip=1)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .n().isRef() + .goUpExpandValidator() + .isSkipText("1"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($top=2)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .n().isRef() + .goUpExpandValidator() + .isTopText("1"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($count=true)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .n().isRef() + .goUpExpandValidator() + .isCountText("1"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($skip=1;$top=3)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .n().isRef() + .goUpExpandValidator() + .isSkipText("1") + .isTopText("3"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref($skip=1%3b$top=3)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + + .isType(EdmTechProvider.nameETKeyNav, true) + .n().isRef() + .goUpExpandValidator() + .isSkipText("1") + .isTopText("3"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$count") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .n().isCount(); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne/$count") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavOne") + .isType(EdmTechProvider.nameETKeyNav, false) + .n().isCount(); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$count($filter=PropertyInt16 gt 1)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .n().isCount() + .goUpExpandValidator() + .isFilterSerialized(""); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($filter=PropertyInt16 eq 1)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .goUpExpandValidator() + .isFilterSerialized(""); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($orderby=PropertyInt16)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .goUpExpandValidator();// TODO check orderby + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($skip=1)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .goUpExpandValidator() + .isSkipText("1"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($top=2)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .goUpExpandValidator() + .isTopText("1"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($count=true)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .goUpExpandValidator() + .isCountText("1"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($select=PropertyString)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .goUpExpandValidator() + .isSelectText("PropertyString"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($expand=NavPropertyETTwoKeyNavOne)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .goUpExpandValidator() + .goExpand() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETTwoKeyNavOne"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($expand=NavPropertyETKeyNavMany)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .goUpExpandValidator() + .goExpand() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne($levels=5)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavOne") + .isType(EdmTechProvider.nameETKeyNav, false) + .goUpExpandValidator() + .isLevelsText("5"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($select=PropertyString)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .goUpExpandValidator() + .isSelectText("PropertyString"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavOne($levels=max)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavOne") + .isType(EdmTechProvider.nameETKeyNav, false) + .goUpExpandValidator() + .isLevelsText("max"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($skip=1;$top=2)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .goUpExpandValidator() + .isSkipText("1") + .isTopText("2"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany($skip=1%3b$top=2)") + .isKind(UriInfoKind.resource).goPath().goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true) + .goUpExpandValidator() + .isSkipText("max") + .isTopText("2"); + + testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='Hugo')?$expand=NavPropertyETKeyNavMany") + .isKind(UriInfoKind.resource).goPath() + .first() + .isKeyPredicate(0, "PropertyInt16", "1") + .isKeyPredicate(1, "PropertyString", "'Hugo'") + .goExpand() + .first() + .goPath().first() + .isIt().n() + .isNav("NavPropertyETKeyNavMany") + .isType(EdmTechProvider.nameETKeyNav, true); + + testUri.run("ESTwoKeyNav?" + + "$expand=com.sap.odata.test1.ETBaseTwoKeyNav/NavPropertyETKeyNavMany") + .isKind(UriInfoKind.resource).goPath().first() + .goExpand().first() + .goPath().first() + .isUriPathInfoKind(UriResourceKind.it) + .isType(EdmTechProvider.nameETTwoKeyNav) + .isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav) + .n() + .isNav("NavPropertyETKeyNavMany"); + + testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='Hugo')?" + + "$expand=com.sap.odata.test1.ETBaseTwoKeyNav/NavPropertyETKeyNavMany") + .isKind(UriInfoKind.resource).goPath().first() + .isKeyPredicate(0, "PropertyInt16", "1") + .isKeyPredicate(1, "PropertyString", "'Hugo'") + .goExpand().first() + .goPath().first() + .isUriPathInfoKind(UriResourceKind.it) + .isType(EdmTechProvider.nameETTwoKeyNav) + .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) + .n() + .isNav("NavPropertyETKeyNavMany"); + + testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?" + + "$expand=com.sap.odata.test1.ETBaseTwoKeyNav/NavPropertyETTwoKeyNavMany") + .isKind(UriInfoKind.resource).goPath().first() + .isKeyPredicate(0, "PropertyInt16", "1") + .isKeyPredicate(1, "PropertyString", "'2'") + .goExpand().first() + .goPath().first() + .isUriPathInfoKind(UriResourceKind.it) + .isType(EdmTechProvider.nameETTwoKeyNav) + .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) + .n() + .isNav("NavPropertyETTwoKeyNavMany"); + + testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?$expand=com.sap.odata.test1.ETBaseTwoKeyNav" + + "/NavPropertyETTwoKeyNavMany/com.sap.odata.test1.ETTwoBaseTwoKeyNav") + .isKind(UriInfoKind.resource).goPath().first() + .isKeyPredicate(0, "PropertyInt16", "1") + .isKeyPredicate(1, "PropertyString", "'2'") + .goExpand().first() + .goPath().first() + .isUriPathInfoKind(UriResourceKind.it) + .isType(EdmTechProvider.nameETTwoKeyNav) + .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) + .n() + .isNav("NavPropertyETTwoKeyNavMany") + .isType(EdmTechProvider.nameETTwoKeyNav) + .isTypeFilterOnCollection(EdmTechProvider.nameETTwoBaseTwoKeyNav); + + testUri.run("ESTwoKeyNav?$expand=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyComplexNav/NavPropertyETTwoKeyNavOne") + .isKind(UriInfoKind.resource).goPath().first() + .goExpand().first() + .goPath().first() + .isUriPathInfoKind(UriResourceKind.it) + .isType(EdmTechProvider.nameETTwoKeyNav) + .isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav) + .n() + .isComplex("PropertyComplexNav") + .isType(EdmTechProvider.nameCTBasePrimCompNav) + .n() + .isNav("NavPropertyETTwoKeyNavOne"); + + testUri.run("ESTwoKeyNav?$expand=com.sap.odata.test1.ETBaseTwoKeyNav/PropertyComplexNav" + + "/com.sap.odata.test1.CTTwoBasePrimCompNav/NavPropertyETTwoKeyNavOne") + .isKind(UriInfoKind.resource).goPath().first() + .goExpand().first() + .goPath().first() + .isUriPathInfoKind(UriResourceKind.it) + .isType(EdmTechProvider.nameETTwoKeyNav) + .isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav) + .n() + .isComplex("PropertyComplexNav") + .isType(EdmTechProvider.nameCTBasePrimCompNav) + .n() + .isNav("NavPropertyETTwoKeyNavOne"); + + testUri.run("ESKeyNav(1)?$expand=NavPropertyETKeyNavMany/$ref,NavPropertyETTwoKeyNavMany($skip=2;$top=1)") + .isKind(UriInfoKind.resource).goPath().first() + .goExpand().first() + .goPath() + .first().isUriPathInfoKind(UriResourceKind.it) + .n().isNav("NavPropertyETKeyNavMany") + .n().isRef() + .goUpExpandValidator() + .n() + .goPath() + .first().isUriPathInfoKind(UriResourceKind.it) + .n().isNav("NavPropertyETTwoKeyNavMany") + .goUpExpandValidator() + .isSkipText("2") + .isTopText("1"); + + testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')?$expand=com.sap.odata.test1.ETBaseTwoKeyNav" + + "/NavPropertyETTwoKeyNavMany/com.sap.odata.test1.ETTwoBaseTwoKeyNav($select=PropertyString)") + .isKind(UriInfoKind.resource).goPath() + .first() + .isKeyPredicate(0, "PropertyInt16", "1") + .isKeyPredicate(1, "PropertyString", "'2'") + .goExpand().first() + .goPath().first() + .isUriPathInfoKind(UriResourceKind.it) + .isType(EdmTechProvider.nameETTwoKeyNav) + .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) + .n().isNav("NavPropertyETTwoKeyNavMany") + .isType(EdmTechProvider.nameETTwoKeyNav) + .isTypeFilterOnCollection(EdmTechProvider.nameETTwoBaseTwoKeyNav) + .goUpExpandValidator(); // TODO check select + + testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($expand=NavPropertyETKeyNavMany(" + + "$expand=NavPropertyETKeyNavOne))") + .isKind(UriInfoKind.resource) + .goPath().first() + .goExpand().first() + .goPath().first() + .isUriPathInfoKind(UriResourceKind.it) + .isType(EdmTechProvider.nameETKeyNav) + .n().isNav("NavPropertyETKeyNavOne") + .goUpExpandValidator() + .goExpand().first() + .goPath().first() + .isUriPathInfoKind(UriResourceKind.it) + .isType(EdmTechProvider.nameETKeyNav) + .n().isNav("NavPropertyETKeyNavMany") + .goUpExpandValidator() + .goExpand().first() + .goPath().first() + .isUriPathInfoKind(UriResourceKind.it) + .isType(EdmTechProvider.nameETKeyNav) + .n().isNav("NavPropertyETKeyNavOne"); + + testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($select=PropertyInt16)") + .isKind(UriInfoKind.resource) + .goPath().first() + .goExpand().first() + .goPath().first() + .isUriPathInfoKind(UriResourceKind.it) + .isType(EdmTechProvider.nameETKeyNav) + .n().isNav("NavPropertyETKeyNavOne") + .goUpExpandValidator(); + // .isSelectText("PropertyInt16") //TODO check select + + testUri.run("ESKeyNav?$expand=NavPropertyETKeyNavOne($select=PropertyComplex/PropertyInt16)") + .isKind(UriInfoKind.resource) + .goPath().first() + .goExpand().first() + .goPath().first() + .isUriPathInfoKind(UriResourceKind.it) + .isType(EdmTechProvider.nameETKeyNav) + .n().isNav("NavPropertyETKeyNavOne") + .goUpExpandValidator(); + // .isSelectText("PropertyInt16")//TODO check select + } + + private void isSkipText(String string) { + // TODO Auto-generated method stub + } @Test public void runTop() { // top - testUri.run("ESKeyNav?$top=1"); - testUri.run("ESKeyNav?$top=0"); - testUri.run("ESKeyNav?$top=-3"); + testUri.run("ESKeyNav?$top=1") + .isKind(UriInfoKind.resource).goPath() + .isEntitySet("ESKeyNav") + .isTopText("1"); + + testUri.run("ESKeyNav?$top=0") + .isKind(UriInfoKind.resource).goPath() + .isEntitySet("ESKeyNav") + .isTopText("0"); + + testUri.run("ESKeyNav?$top=-3") + .isKind(UriInfoKind.resource).goPath() + .isEntitySet("ESKeyNav") + .isTopText("-3"); } @Test public void runFormat() { // format - testUri.run("ESKeyNav(1)?$format=atom"); - testUri.run("ESKeyNav(1)?$format=json"); - testUri.run("ESKeyNav(1)?$format=xml"); - testUri.run("ESKeyNav(1)?$format=IANA_content_type/must_contain_a_slash"); - testUri.run("ESKeyNav(1)?$format=Test_all_valid_signsSpecified_for_format_signs%26-._~$@%27/Aa123%26-._~$@%27"); + testUri.run("ESKeyNav(1)?$format=atom") + .isKind(UriInfoKind.resource).goPath() + .isFormatText("atom"); + testUri.run("ESKeyNav(1)?$format=json") + .isKind(UriInfoKind.resource).goPath() + .isFormatText("json"); + testUri.run("ESKeyNav(1)?$format=xml") + .isKind(UriInfoKind.resource).goPath() + .isFormatText("xml"); + testUri.run("ESKeyNav(1)?$format=IANA_content_type/must_contain_a_slash") + .isKind(UriInfoKind.resource).goPath() + .isFormatText("IANA_content_type/must_contain_a_slash"); + testUri.run("ESKeyNav(1)?$format=Test_all_valid_signsSpecified_for_format_signs%26-._~$@%27/Aa123%26-._~$@%27") + .isKind(UriInfoKind.resource).goPath() + .isFormatText("Test_all_valid_signsSpecified_for_format_signs%26-._~$@%27/Aa123%26-._~$@%27"); } @Test public void runCount() { // count - testUri.run("ESAllPrim?$count=true"); - testUri.run("ESAllPrim?$count=false"); + testUri.run("ESAllPrim?$count=true") + .isKind(UriInfoKind.resource).goPath() + .isInlineCountText("true"); + testUri.run("ESAllPrim?$count=false") + .isKind(UriInfoKind.resource).goPath() + .isInlineCountText("false"); // testUri.run("ESAllPrim?$count=foo"); } @Test - public void rest() { + public void skip() { // skip - testUri.run("ESAllPrim?$skip=3"); - testUri.run("ESAllPrim?$skip=0"); - testUri.run("ESAllPrim?$skip=-3"); - testUri.run("ESAllPrim?$skiptoken=foo"); + testUri.run("ESAllPrim?$skip=3") + .isKind(UriInfoKind.resource).goPath() + .isSkipText("3"); + testUri.run("ESAllPrim?$skip=0") + .isKind(UriInfoKind.resource).goPath() + .isSkipText("0"); + testUri.run("ESAllPrim?$skip=-3") + .isKind(UriInfoKind.resource).goPath() + .isSkipText("-3"); + } + + @Test + public void skiptoken() { + + testUri.run("ESAllPrim?$skiptoken=foo") + .isKind(UriInfoKind.resource).goPath() + .isSkipTokenText("foo"); + } + + @Test + public void misc() { + testUri.run(""); - testUri.run("$all"); - testUri.run("$metadata"); - testUri.run("$batch"); - testUri.run("$crossjoin(ESKeyNav)"); - testUri.run("ESKeyNav"); - testUri.run("ESKeyNav(1)"); - testUri.run("SINav"); - testUri.run("FICRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')"); - testUri.run("FICRTETKeyNav()"); - testUri.run("FICRTCollCTTwoPrim()"); - testUri.run("FICRTCTAllPrimTwoParam(ParameterInt16=1,ParameterString='2')"); - testUri.run("FICRTCollStringTwoParam(ParameterInt16=1,ParameterString='2')"); - testUri.run("FICRTStringTwoParam(ParameterInt16=1)"); - testUri.run("FICRTStringTwoParam(ParameterInt16=1,ParameterString='2')"); - testUri.run("AIRTETParam"); - testUri.run("AIRTPrimParam"); - testUri.run("ESKeyNav/$count"); - testUri.run("ESKeyNav/$ref"); - testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()"); - testUri.run("ESAllPrim/com.sap.odata.test1.BAESAllPrimRTETAllPrim"); - testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()"); - testUri.run("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav"); - testUri.run("ESTwoKeyNav/$count"); - testUri.run("ESTwoKeyNav/$ref"); - testUri.run("ESKeyNav(1)"); - testUri.run("ESKeyNav(1)/$ref"); - testUri.run("ESMedia(1)/$value"); - testUri.run("ESAllPrim/com.sap.odata.test1.BAESAllPrimRTETAllPrim"); - testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()"); - testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav"); - testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav/$ref"); - testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav/$value"); + testUri.run("$all") + .isKind(UriInfoKind.all); + + testUri.run("$metadata") + .isKind(UriInfoKind.metadata); + + testUri.run("$batch") + .isKind(UriInfoKind.batch); + + testUri.run("$crossjoin(ESKeyNav)") + .isKind(UriInfoKind.crossjoin) + .isCrossJoinEntityList(Arrays.asList("ESKeyNav")); + + testUri.run("ESKeyNav") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESKeyNav"); + testUri.run("ESKeyNav(1)") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESKeyNav") + .isKeyPredicate(0, "PropertyInt16", "1"); + + testUri.run("SINav") + .isKind(UriInfoKind.resource) + .goPath().first() + .isSingleton("SINav"); + + testUri.run("FICRTESMixPrimCollCompTwoParam(ParameterInt16=1,ParameterString='2')") + .isKind(UriInfoKind.resource) + .goPath() + .isFunctionImport("FICRTESMixPrimCollCompTwoParam") + .isType(EdmTechProvider.nameETMixPrimCollComp) + .isParameter(0, "ParameterInt16", "1") + .isParameter(1, "ParameterString", "'2'"); + + testUri.run("FICRTETKeyNav()") + .isKind(UriInfoKind.resource) + .goPath().first() + .isFunctionImport("FICRTETKeyNav") + .isType(EdmTechProvider.nameETKeyNav); + + testUri.run("FICRTCollCTTwoPrim()") + .isKind(UriInfoKind.resource) + .goPath().first() + .isFunctionImport("FICRTCollCTTwoPrim") + .isType(EdmTechProvider.nameCTTwoPrim); + + testUri.run("FICRTCTAllPrimTwoParam(ParameterInt16=1,ParameterString='2')") + .isKind(UriInfoKind.resource) + .goPath().first() + .isFunctionImport("FICRTCTAllPrimTwoParam") + .isType(EdmTechProvider.nameCTAllPrim) + .isParameter(0, "ParameterInt16", "1") + .isParameter(1, "ParameterString", "'2'"); + + testUri.run("FICRTCollStringTwoParam(ParameterInt16=1,ParameterString='2')") + .isKind(UriInfoKind.resource) + .goPath().first() + .isFunctionImport("FICRTCollStringTwoParam") + .isType(EdmTechProvider.nameString) + .isParameter(0, "ParameterInt16", "1") + .isParameter(1, "ParameterString", "'2'"); + + testUri.run("FICRTStringTwoParam(ParameterInt16=1)") + .isKind(UriInfoKind.resource) + .goPath().first() + .isFunctionImport("FICRTStringTwoParam") + .isFunction("UFCRTStringTwoParam") + .isType(EdmTechProvider.nameString) + .isParameter(0, "ParameterInt16", "1"); + + testUri.run("FICRTStringTwoParam(ParameterInt16=1,ParameterString='2')") + .isKind(UriInfoKind.resource) + .goPath().first() + .isFunctionImport("FICRTStringTwoParam") + .isFunction("UFCRTStringTwoParam") + .isType(EdmTechProvider.nameString) + .isParameter(0, "ParameterInt16", "1"); + + testUri.run("AIRTETParam") + .isKind(UriInfoKind.resource) + .goPath().first() + .isActionImport("AIRTETParam"); + + testUri.run("AIRTPrimParam") + .isKind(UriInfoKind.resource) + .goPath().first() + .isActionImport("AIRTPrimParam"); + + testUri.run("ESKeyNav/$count") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESKeyNav") + .n().isCount(); + + testUri.run("ESKeyNav/$ref") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESKeyNav") + .n().isRef(); + + testUri.run("ESKeyNav/$count") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESKeyNav") + .n().isCount(); + + testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESTwoKeyNav") + .n().isFunction("BFCESTwoKeyNavRTESTwoKeyNav"); + + testUri.run("ESAllPrim/com.sap.odata.test1.BAESAllPrimRTETAllPrim") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESAllPrim") + .n().isAction("BAESAllPrimRTETAllPrim"); + + testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESTwoKeyNav") + .n().isFunction("BFCESTwoKeyNavRTESTwoKeyNav"); + + testUri.run("ESTwoKeyNav/com.sap.odata.test1.ETBaseTwoKeyNav") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESTwoKeyNav") + .isTypeFilterOnCollection(EdmTechProvider.nameETBaseTwoKeyNav); + + testUri.run("ESTwoKeyNav/$count") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESTwoKeyNav") + .n() + .isCount(); + + testUri.run("ESTwoKeyNav/$ref") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESTwoKeyNav") + .n() + .isRef(); + + testUri.run("ESKeyNav(1)") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESKeyNav") + .isKeyPredicate(0, "PropertyInt16", "1"); + + testUri.run("ESKeyNav(1)/$ref") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESKeyNav") + .isKeyPredicate(0, "PropertyInt16", "1") + .n() + .isRef(); + + testUri.run("ESMedia(1)/$value") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESMedia") + .n() + .isValue(); + + testUri.run("ESAllPrim/com.sap.odata.test1.BAESAllPrimRTETAllPrim") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESAllPrim") + .n().isAction("BAESAllPrimRTETAllPrim"); + + testUri.run("ESTwoKeyNav/com.sap.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav()") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESTwoKeyNav") + .n().isFunction("BFCESTwoKeyNavRTESTwoKeyNav"); + + testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESTwoKeyNav") + .isKeyPredicate(0, "PropertyInt16", "1") + .isKeyPredicate(1, "PropertyString", "'2'") + .isType(EdmTechProvider.nameETTwoKeyNav) + .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav); + + testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav/$ref") + .isKind(UriInfoKind.resource) + .goPath().first() + .isEntitySet("ESTwoKeyNav") + .isKeyPredicate(0, "PropertyInt16", "1") + .isKeyPredicate(1, "PropertyString", "'2'") + .isType(EdmTechProvider.nameETTwoKeyNav) + .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) + .n().isRef(); + + testUri.run("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/com.sap.odata.test1.ETBaseTwoKeyNav/$value") + .goPath().first() + .isEntitySet("ESTwoKeyNav") + .isKeyPredicate(0, "PropertyInt16", "1") + .isKeyPredicate(1, "PropertyString", "'2'") + .isType(EdmTechProvider.nameETTwoKeyNav) + .isTypeFilterOnEntry(EdmTechProvider.nameETBaseTwoKeyNav) + .n().isValue(); + } @Test public void testSpecial() { - testFilter.runOnETKeyNav("any()"); + // testFilter.runOnETKeyNav("any()"); } @@ -2327,7 +2956,7 @@ public class TestByAbapResourcePath { testFilter.runOnETKeyNav("cast(NavPropertyETKeyNavOne,com.sap.odata.test1.ETKeyPrimNav)"); // testFilter.runOnETKeyNav("Xcast(NavPropertyETKeyPrimNavOne,com.sap.odata.test1.ETKeyNav)"); - testFilter.runOnETKeyNav("any()"); + // testFilter.runOnETKeyNav("any()"); testFilter.runOnETKeyNav("any(d:d/PropertyInt16 eq 1)"); testFilter.runOnETKeyNav("NavPropertyETTwoKeyNavMany/any(d:d/PropertyString eq 'SomeString')"); diff --git a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/uri/antlr/TestUriParserImpl.java b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/uri/antlr/TestUriParserImpl.java index a0e895fa4..44917c69a 100644 --- a/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/uri/antlr/TestUriParserImpl.java +++ b/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/uri/antlr/TestUriParserImpl.java @@ -27,7 +27,7 @@ import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName; import org.apache.olingo.odata4.commons.core.edm.provider.EdmProviderImpl; import org.apache.olingo.odata4.producer.api.uri.UriInfoKind; import org.apache.olingo.odata4.producer.api.uri.UriResourceKind; -import org.apache.olingo.odata4.producer.api.uri.queryoption.SystemQueryOptionEnum; +import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions; import org.apache.olingo.odata4.producer.core.testutil.EdmTechProvider; import org.apache.olingo.odata4.producer.core.testutil.EdmTechTestProvider; import org.apache.olingo.odata4.producer.core.testutil.FilterValidator;