You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ko...@apache.org on 2014/02/07 15:54:14 UTC
[4/4] git commit: [OLINGO-63] Uri Parser: add Tests for package
org.apache.olingo.odata4.producer.core.uri
[OLINGO-63] Uri Parser: add Tests for package org.apache.olingo.odata4.producer.core.uri
Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/commit/b14e278a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/tree/b14e278a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/diff/b14e278a
Branch: refs/heads/master
Commit: b14e278ab4268c594ebac3c83d9a3c4e74e1d745
Parents: 224967b
Author: Sven Kobler <sv...@sap.com>
Authored: Fri Feb 7 15:32:39 2014 +0100
Committer: Sven Kobler <sv...@sap.com>
Committed: Fri Feb 7 15:38:21 2014 +0100
----------------------------------------------------------------------
.../producer/api/uri/UriResourceKind.java | 2 +-
.../producer/api/uri/UriResourceLambdaAll.java | 2 +-
.../producer/api/uri/UriResourceLambdaAny.java | 2 +-
.../api/uri/UriResourcePrimitiveProperty.java | 23 +
.../api/uri/UriResourceSimpleProperty.java | 23 -
.../api/uri/UriResourceStartingTypeFilter.java | 3 -
.../api/uri/queryoption/ExpandItem.java | 20 +-
.../api/uri/queryoption/SelectItem.java | 5 +-
.../odata4/producer/core/uri/antlr/UriLexer.g4 | 2 +-
.../olingo/odata4/producer/core/uri/Parser.java | 109 ++++
.../odata4/producer/core/uri/ParserAdapter.java | 107 ----
.../odata4/producer/core/uri/UriInfoImpl.java | 85 ++--
.../producer/core/uri/UriParameterImpl.java | 3 +-
.../producer/core/uri/UriParseTreeVisitor.java | 103 ++--
.../core/uri/UriResourceActionImpl.java | 5 +-
.../producer/core/uri/UriResourceAllImpl.java | 73 ---
.../producer/core/uri/UriResourceAnyImpl.java | 72 ---
.../core/uri/UriResourceEntitySetImpl.java | 3 -
.../core/uri/UriResourceFunctionImpl.java | 3 +-
.../core/uri/UriResourceImplKeyPred.java | 1 -
.../producer/core/uri/UriResourceImplTyped.java | 8 +-
.../producer/core/uri/UriResourceItImpl.java | 10 +-
.../core/uri/UriResourceLambdaAllImpl.java | 73 +++
.../core/uri/UriResourceLambdaAnyImpl.java | 72 +++
.../core/uri/UriResourceLambdaVarImpl.java | 2 +-
.../uri/UriResourcePrimitivePropertyImpl.java | 59 +++
.../producer/core/uri/UriResourceRootImpl.java | 7 +-
.../core/uri/UriResourceSimplePropertyImpl.java | 59 ---
.../core/uri/UriResourceSingletonImpl.java | 2 +-
.../uri/UriResourceStartingTypeFilterImpl.java | 10 +-
.../core/uri/queryoption/ExpandItemImpl.java | 29 +-
.../core/uri/queryoption/OrderByOptionImpl.java | 1 -
.../core/uri/queryoption/QueryOptionImpl.java | 2 +-
.../core/uri/queryoption/SearchOptionImpl.java | 2 +
.../core/uri/queryoption/SelectItemImpl.java | 15 +-
.../uri/queryoption/expression/AliasImpl.java | 1 -
.../producer/core/testutil/ExpandValidator.java | 18 +-
.../core/testutil/FilterTreeToText.java | 4 +-
.../producer/core/testutil/FilterValidator.java | 14 +-
.../core/testutil/UriResourceValidator.java | 31 +-
.../producer/core/testutil/UriValidator.java | 4 +-
.../producer/core/uri/UriInfoImplTest.java | 178 +++++++
.../producer/core/uri/UriParameterImplTest.java | 508 +++++++++++++++++++
.../core/uri/antlr/TestFullResourcePath.java | 223 ++++----
.../producer/core/uri/antlr/TestParser.java | 18 +-
.../core/uri/antlr/TestUriParserImpl.java | 35 +-
.../core/uri/queryoption/QueryOptionTest.java | 363 +++++++++++++
.../core/uri/queryoption/QueryOptiontest.java | 370 --------------
.../queryoption/expression/ExpressionTest.java | 16 +-
49 files changed, 1710 insertions(+), 1070 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceKind.java
----------------------------------------------------------------------
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 19d239a..7621133 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
@@ -21,5 +21,5 @@ package org.apache.olingo.odata4.producer.api.uri;
public enum UriResourceKind {
action, complexProperty, count, entitySet, function, it, lambdaAll, lambdaAny,
- lambdaVariable, navigationProperty, ref, root, simpleProperty, singleton, startingTypeFilter, value,
+ lambdaVariable, navigationProperty, ref, root, primitiveProperty, singleton, startingTypeFilter, value,
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceLambdaAll.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceLambdaAll.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceLambdaAll.java
index f77649e..68a9b0b 100644
--- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceLambdaAll.java
+++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceLambdaAll.java
@@ -22,7 +22,7 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expressi
public interface UriResourceLambdaAll extends UriResourcePartTyped {
- public String getVariable();
+ public String getLamdaVariable();
public Expression getExpression();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceLambdaAny.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceLambdaAny.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceLambdaAny.java
index 871dd65..4912ff2 100644
--- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceLambdaAny.java
+++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceLambdaAny.java
@@ -22,7 +22,7 @@ import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expressi
public interface UriResourceLambdaAny extends UriResourcePartTyped {
- public String getVariable();
+ public String getLamdaVariable();
public Expression getExpression();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourcePrimitiveProperty.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourcePrimitiveProperty.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourcePrimitiveProperty.java
new file mode 100644
index 0000000..9383a78
--- /dev/null
+++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourcePrimitiveProperty.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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;
+
+public interface UriResourcePrimitiveProperty extends UriResourceProperty {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceSimpleProperty.java
----------------------------------------------------------------------
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
deleted file mode 100644
index bfb3868..0000000
--- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceSimpleProperty.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.api.uri;
-
-public interface UriResourceSimpleProperty extends UriResourceProperty {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceStartingTypeFilter.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceStartingTypeFilter.java b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceStartingTypeFilter.java
index e37a83b..9f3bef0 100644
--- a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceStartingTypeFilter.java
+++ b/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/UriResourceStartingTypeFilter.java
@@ -18,9 +18,6 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri;
-import java.util.List;
-
-import org.apache.olingo.odata4.commons.api.edm.EdmNavigationProperty;
import org.apache.olingo.odata4.commons.api.edm.EdmType;
public interface UriResourceStartingTypeFilter extends UriResourcePartTyped {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/ExpandItem.java
----------------------------------------------------------------------
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 6f67680..10693b4 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
@@ -22,25 +22,25 @@ import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
public interface ExpandItem {
- LevelsExpandOption getLevels();
+ LevelsExpandOption getLevelsOption();
- FilterOption getFilter();
+ FilterOption getFilterOption();
- SearchOption getSearch();
+ SearchOption getSearchOption();
- OrderByOption getOrderBy();
+ OrderByOption getOrderByOption();
- SkipOption getSkip();
+ SkipOption getSkipOption();
- TopOption getTop();
+ TopOption getTopOption();
- InlineCountOption getInlineCount();
+ InlineCountOption getInlineCountOption();
- SelectOption getSelect();
+ SelectOption getSelectOption();
- ExpandOption getExpand();
+ ExpandOption getExpandOption();
- UriInfoResource getResourcePath();
+ UriInfoResource getResourceInfo();
boolean isStar();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-api/src/main/java/org/apache/olingo/odata4/producer/api/uri/queryoption/SelectItem.java
----------------------------------------------------------------------
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 4a82a5d..14640b6 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
@@ -18,12 +18,9 @@
******************************************************************************/
package org.apache.olingo.odata4.producer.api.uri.queryoption;
-import java.util.List;
-
import org.apache.olingo.odata4.commons.api.edm.EdmEntityType;
import org.apache.olingo.odata4.commons.api.edm.provider.FullQualifiedName;
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
-import org.apache.olingo.odata4.producer.api.uri.UriResourcePart;
public interface SelectItem {
@@ -36,6 +33,6 @@ public interface SelectItem {
EdmEntityType getEntityTypeCast();
- UriInfoResource getPath();
+ UriInfoResource getResourceInfo();
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriLexer.g4
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriLexer.g4 b/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriLexer.g4
index 6bdc824..26d4350 100644
--- a/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriLexer.g4
+++ b/odata4-lib/odata4-producer-core/src/main/antlr4/org/apache/olingo/odata4/producer/core/uri/antlr/UriLexer.g4
@@ -306,7 +306,7 @@ mode MODE_FRAGMENT;
// character.
//;==============================================================================
-REST_F : .* -> type(REST);
+REST_F : ~('\r'|'\n')* -> type(REST), popMode;
//;==============================================================================
mode MODE_SYSTEM_QUERY_REST;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/Parser.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/Parser.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/Parser.java
new file mode 100644
index 0000000..e170869
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/Parser.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * 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.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.BailErrorStrategy;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.DefaultErrorStrategy;
+import org.antlr.v4.runtime.atn.PredictionMode;
+import org.antlr.v4.runtime.misc.ParseCancellationException;
+import org.apache.olingo.odata4.producer.api.uri.UriInfo;
+import org.apache.olingo.odata4.producer.core.uri.antlr.UriLexer;
+import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser;
+import org.apache.olingo.odata4.producer.core.uri.antlr.UriParserParser.OdataRelativeUriEOFContext;
+
+public class Parser {
+ static public UriInfo parseUri(final String input, final UriParseTreeVisitor uriParseTreeVisitor)
+ throws UriParserException {
+
+ try {
+ OdataRelativeUriEOFContext parseTree = parseInput(input, true);
+ //reset visitor
+ uriParseTreeVisitor.init();
+ parseTree.accept(uriParseTreeVisitor);
+ UriInfoImpl uriInput = uriParseTreeVisitor.getUriInfo();
+ return uriInput;
+ } catch (ParseCancellationException e) {
+ Throwable cause = e.getCause();
+ if (cause instanceof UriParserException) {
+ throw (UriParserException) cause;
+ }
+ }
+ return null;
+ }
+
+
+ static private OdataRelativeUriEOFContext parseInput(final String input, boolean onResource)
+ throws UriParserSyntaxException {
+ UriParserParser parser = null;
+ UriLexer lexer = null;
+ OdataRelativeUriEOFContext ret = null;
+
+ // Use 2 stage approach to improve performance
+ // see https://github.com/antlr/antlr4/issues/192
+
+ // stage = 1
+ try {
+ // 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());
+
+ // user the faster LL parsing
+ parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
+
+ // parse
+ ret = parser.odataRelativeUriEOF();
+
+ } catch (ParseCancellationException hardException) {
+ // stage = 2
+ try {
+
+ // create parser
+ lexer = new UriLexer(new ANTLRInputStream(input));
+ parser = new UriParserParser(new CommonTokenStream(lexer));
+
+ // Used default error strategy
+ parser.setErrorHandler(new DefaultErrorStrategy());
+
+ // Use the slower SLL parsing
+ parser.getInterpreter().setPredictionMode(PredictionMode.LL);
+
+ // parse
+ ret = parser.odataRelativeUriEOF();
+
+ } catch (Exception weakException) {
+ throw new UriParserSyntaxException("Error in syntax", weakException);
+
+ // exceptionOnStage = 2;
+ }
+ } catch (Exception hardException) {
+ throw new UriParserSyntaxException("Error in syntax", hardException);
+ }
+
+ return ret;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ParserAdapter.java
----------------------------------------------------------------------
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
deleted file mode 100644
index d93e41e..0000000
--- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/ParserAdapter.java
+++ /dev/null
@@ -1,107 +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.antlr.v4.runtime.ANTLRInputStream;
-import org.antlr.v4.runtime.BailErrorStrategy;
-import org.antlr.v4.runtime.CommonTokenStream;
-import org.antlr.v4.runtime.DefaultErrorStrategy;
-import org.antlr.v4.runtime.atn.PredictionMode;
-import org.antlr.v4.runtime.misc.ParseCancellationException;
-import org.apache.olingo.odata4.producer.core.uri.antlr.UriLexer;
-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, final UriParseTreeVisitor uriParseTreeVisitor)
- throws UriParserException {
-
- try {
- OdataRelativeUriEOFContext parseTree = parseInput(input, true);
- //reset visitor
- uriParseTreeVisitor.init();
- parseTree.accept(uriParseTreeVisitor);
- UriInfoImpl uriInput = uriParseTreeVisitor.getUriInfo();
- return uriInput;
- } catch (ParseCancellationException e) {
- Throwable cause = e.getCause();
- if (cause instanceof UriParserException) {
- throw (UriParserException) cause;
- }
- }
- return null;
- }
-
-
- static private OdataRelativeUriEOFContext parseInput(final String input, boolean onResource)
- throws UriParserSyntaxException {
- UriParserParser parser = null;
- UriLexer lexer = null;
- OdataRelativeUriEOFContext ret = null;
-
- // Use 2 stage approach to improve performance
- // see https://github.com/antlr/antlr4/issues/192
-
- // stage= 1
- try {
- // 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());
-
- // user the faster LL parsing
- parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
-
- // parse
- ret = parser.odataRelativeUriEOF();
-
- } catch (ParseCancellationException hardException) {
-
- try {
- // create parser
- lexer = new UriLexer(new ANTLRInputStream(input));
- parser = new UriParserParser(new CommonTokenStream(lexer));
-
- // Used default error strategy
- parser.setErrorHandler(new DefaultErrorStrategy());
-
- // User the slower SLL parsing
- parser.getInterpreter().setPredictionMode(PredictionMode.LL);
-
- // parse
- ret = parser.odataRelativeUriEOF();
-
- } catch (Exception weakException) {
- throw new UriParserSyntaxException("Error in syntax", weakException);
-
- // exceptionOnStage = 2;
- }
- } catch (Exception hardException) {
- throw new UriParserSyntaxException("Error in syntax", hardException);
- }
-
- return ret;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriInfoImpl.java
----------------------------------------------------------------------
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 a7184cc..60f1eb5 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
@@ -135,7 +135,7 @@ public class UriInfoImpl implements UriInfo {
return Collections.unmodifiableList(returnList);
}
- public UriInfoImpl addPathInfo(final UriResourcePartImpl uriPathInfo) {
+ public UriInfoImpl addResourcePart(final UriResourcePartImpl uriPathInfo) {
pathParts.add(uriPathInfo);
lastResourcePart = uriPathInfo;
return this;
@@ -154,6 +154,11 @@ public class UriInfoImpl implements UriInfo {
public EdmEntityType getEntityTypeCast() {
return entityTypeCast;
}
+
+ public UriInfoImpl setEntityTypeCast(final EdmEntityType type) {
+ entityTypeCast = type;
+ return this;
+ }
@Override
public ExpandOption getExpandOption() {
@@ -184,6 +189,11 @@ public class UriInfoImpl implements UriInfo {
public UriInfoKind getKind() {
return kind;
}
+
+ public UriInfoImpl setKind(final UriInfoKind kind) {
+ this.kind = kind;
+ return this;
+ }
public UriResourcePart getLastResourcePart() {
return lastResourcePart;
@@ -220,50 +230,12 @@ public class UriInfoImpl implements UriInfo {
return topOption;
}
- public UriInfoImpl setEntityTypeCast(final EdmEntityType type) {
- entityTypeCast = type;
- return this;
- }
-
- public UriInfoImpl setFormat(final FormatOptionImpl formatOption) {
- this.formatOption = formatOption;
- return this;
- }
-
- public UriInfoImpl setKind(final UriInfoKind kind) {
- this.kind = kind;
- return this;
- }
-
+
public UriInfoImpl setQueryOptions(final List<QueryOptionImpl> list) {
for (QueryOptionImpl item : list) {
if (item instanceof SystemQueryOptionImpl) {
- SystemQueryOptionImpl sysItem = (SystemQueryOptionImpl) item;
-
- if (sysItem.getKind() == SupportedQueryOptions.EXPAND) {
- expandOption = (ExpandOptionImpl) sysItem;
- } else if (sysItem.getKind() == SupportedQueryOptions.FILTER) {
- filterOption = (FilterOptionImpl) sysItem;
- } else if (sysItem.getKind() == SupportedQueryOptions.FORMAT) {
- formatOption = (FormatOptionImpl) sysItem;
- } else if (sysItem.getKind() == SupportedQueryOptions.ID) {
- idOption = (IdOptionImpl) sysItem;
- } else if (sysItem.getKind() == SupportedQueryOptions.INLINECOUNT) {
- inlineCountOption = (InlineCountOptionImpl) sysItem;
- } else if (sysItem.getKind() == SupportedQueryOptions.ORDERBY) {
- orderByOption = (OrderByOptionImpl) 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.SKIPTOKEN) {
- skipTokenOption = (SkipTokenOptionImpl) sysItem;
- } else if (sysItem.getKind() == SupportedQueryOptions.TOP) {
- topOption = (TopOptionImpl) sysItem;
- }
+ setSystemQueryOption((SystemQueryOptionImpl)item);
} else if (item instanceof CustomQueryOptionImpl) {
customQueryOptions.add((CustomQueryOptionImpl) item);
}
@@ -271,14 +243,39 @@ public class UriInfoImpl implements UriInfo {
return this;
}
+ public UriInfoImpl setSystemQueryOption(SystemQueryOptionImpl systemOption) {
+
+ if (systemOption.getKind() == SupportedQueryOptions.EXPAND) {
+ expandOption = (ExpandOptionImpl) systemOption;
+ } else if (systemOption.getKind() == SupportedQueryOptions.FILTER) {
+ filterOption = (FilterOptionImpl) systemOption;
+ } else if (systemOption.getKind() == SupportedQueryOptions.FORMAT) {
+ formatOption = (FormatOptionImpl) systemOption;
+ } else if (systemOption.getKind() == SupportedQueryOptions.ID) {
+ idOption = (IdOptionImpl) systemOption;
+ } else if (systemOption.getKind() == SupportedQueryOptions.INLINECOUNT) {
+ inlineCountOption = (InlineCountOptionImpl) systemOption;
+ } else if (systemOption.getKind() == SupportedQueryOptions.ORDERBY) {
+ orderByOption = (OrderByOptionImpl) systemOption;
+ } else if (systemOption.getKind() == SupportedQueryOptions.SEARCH) {
+ searchOption = (SearchOptionImpl) systemOption;
+ } else if (systemOption.getKind() == SupportedQueryOptions.SELECT) {
+ selectOption = (SelectOptionImpl) systemOption;
+ } else if (systemOption.getKind() == SupportedQueryOptions.SKIP) {
+ skipOption = (SkipOptionImpl) systemOption;
+ } else if (systemOption.getKind() == SupportedQueryOptions.SKIPTOKEN) {
+ skipTokenOption = (SkipTokenOptionImpl) systemOption;
+ } else if (systemOption.getKind() == SupportedQueryOptions.TOP) {
+ topOption = (TopOptionImpl) systemOption;
+ }
+ return this;
+ }
+
@Override
public UriInfoService asUriInfoService() {
return this;
}
- public void clearPathInfo() {
- pathParts.clear();
- }
public String getFragment() {
return fragment;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParameterImpl.java
----------------------------------------------------------------------
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 8f5e10f..54950bc 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
@@ -21,6 +21,7 @@ package org.apache.olingo.odata4.producer.core.uri;
import org.apache.olingo.odata4.producer.api.uri.UriParameter;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
public class UriParameterImpl implements UriParameter {
private String name;
@@ -64,7 +65,7 @@ public class UriParameterImpl implements UriParameter {
return expression;
}
- public UriParameterImpl setExpression(final Expression expression) {
+ public UriParameterImpl setExpression(final ExpressionImpl expression) {
this.expression = expression;
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriParseTreeVisitor.java
----------------------------------------------------------------------
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 b6a778c..4256be6 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,7 +46,6 @@ 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.core.edm.primitivetype.EdmPrimitiveTypeKind;
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.UriResourcePart;
import org.apache.olingo.odata4.producer.api.uri.UriResourcePartTyped;
import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.SupportedBinaryOperators;
@@ -279,14 +278,10 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
}
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;
-
}
private LambdaVariables getLambdaVar(final String odi) {
@@ -331,7 +326,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (edmEntitySet != null) {
UriResourceEntitySetImpl uriResource = new UriResourceEntitySetImpl();
uriResource.setEntitSet(edmEntitySet);
- contextUriInfo.addPathInfo(uriResource);
+ contextUriInfo.addResourcePart(uriResource);
return null;
}
@@ -340,7 +335,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (edmSingleton != null) {
UriResourceSingletonImpl uriResource = new UriResourceSingletonImpl();
uriResource.setSingleton(edmSingleton);
- contextUriInfo.addPathInfo(uriResource);
+ contextUriInfo.addResourcePart(uriResource);
return null;
}
@@ -349,7 +344,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (edmActionImport != null) {
UriResourceActionImpl uriResource = new UriResourceActionImpl();
uriResource.setActionImport(edmActionImport);
- contextUriInfo.addPathInfo(uriResource);
+ contextUriInfo.addResourcePart(uriResource);
return null;
}
@@ -363,7 +358,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
UriResourceFunctionImpl uriResource = new UriResourceFunctionImpl();
uriResource.setFunctionImport(edmFunctionImport, parameters);
- contextUriInfo.addPathInfo(uriResource);
+ contextUriInfo.addResourcePart(uriResource);
return null;
}
}
@@ -391,8 +386,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
UriResourceLambdaVarImpl lambdaResource = new UriResourceLambdaVarImpl();
lambdaResource.setVariableText(lVar.name);
lambdaResource.setType(lVar.type);
- lambdaResource.isCollection(lVar.isCollection);
- contextUriInfo.addPathInfo(lambdaResource);
+ lambdaResource.setCollection(lVar.isCollection);
+ contextUriInfo.addResourcePart(lambdaResource);
return null;
}
@@ -411,22 +406,22 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (property instanceof EdmProperty) {
if (((EdmProperty) property).isPrimitive() == true) {
// create simple property
- UriResourceSimplePropertyImpl simpleResource = new UriResourceSimplePropertyImpl();
+ UriResourcePrimitivePropertyImpl simpleResource = new UriResourcePrimitivePropertyImpl();
simpleResource.setProperty((EdmProperty) property);
- contextUriInfo.addPathInfo(simpleResource);
+ contextUriInfo.addResourcePart(simpleResource);
return null;
} else {
// create complex property
UriResourceComplexPropertyImpl complexResource = new UriResourceComplexPropertyImpl();
complexResource.setProperty((EdmProperty) property);
- contextUriInfo.addPathInfo(complexResource);
+ contextUriInfo.addResourcePart(complexResource);
return null;
}
} else if (property instanceof EdmNavigationProperty) {
// create navigation property
UriResourceNavigationPropertyImpl navigationResource = new UriResourceNavigationPropertyImpl();
navigationResource.setNavigationProperty((EdmNavigationProperty) property);
- contextUriInfo.addPathInfo(navigationResource);
+ contextUriInfo.addResourcePart(navigationResource);
return null;
} else {
throw wrap(new UriParserSemanticException("Unkown property type"));
@@ -453,13 +448,13 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
// this may be the case if a member expression within a filter starts with a typeCast
UriResourceStartingTypeFilterImpl uriResource = new UriResourceStartingTypeFilterImpl();
uriResource.setType(source.type);
- uriResource.setIsCollection(source.isCollection);
+ uriResource.setCollection(source.isCollection);
if (source.isCollection) {
uriResource.setCollectionTypeFilter(filterEntityType);
} else {
uriResource.setEntryTypeFilter(filterEntityType);
}
- contextUriInfo.addPathInfo(uriResource);
+ contextUriInfo.addResourcePart(uriResource);
return null;
} else {
@@ -511,13 +506,13 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
// this may be the case if a member expression within a filter starts with a typeCast
UriResourceStartingTypeFilterImpl uriResource = new UriResourceStartingTypeFilterImpl();
uriResource.setType(source.type);
- uriResource.setIsCollection(source.isCollection);
+ uriResource.setCollection(source.isCollection);
if (source.isCollection) {
uriResource.setCollectionTypeFilter(filterComplexType);
} else {
uriResource.setEntryTypeFilter(filterComplexType);
}
- contextUriInfo.addPathInfo(uriResource);
+ contextUriInfo.addResourcePart(uriResource);
return null;
} else {
if (lastResource1 instanceof UriResourceImplKeyPred) {
@@ -560,7 +555,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (action != null) {
UriResourceActionImpl pathInfoAction = new UriResourceActionImpl();
pathInfoAction.setAction(action);
- contextUriInfo.addPathInfo(pathInfoAction);
+ contextUriInfo.addResourcePart(pathInfoAction);
return null;
}
@@ -584,7 +579,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
UriResourceFunctionImpl pathInfoFunction = new UriResourceFunctionImpl();
pathInfoFunction.setFunction(function);
pathInfoFunction.setParameters(parameters);
- contextUriInfo.addPathInfo(pathInfoFunction);
+ contextUriInfo.addResourcePart(pathInfoFunction);
ctx.vlNVO.remove(0);// parameters are consumed
return null;
}
@@ -596,7 +591,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
UriResourceFunctionImpl pathInfoFunction = new UriResourceFunctionImpl();
pathInfoFunction.setFunction(function);
pathInfoFunction.setParameters(parameters);
- contextUriInfo.addPathInfo(pathInfoFunction);
+ contextUriInfo.addResourcePart(pathInfoFunction);
ctx.vlNVO.remove(0);// parameters are consumed
return null;
}
@@ -627,7 +622,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public Object visitAllExpr(final AllExprContext ctx) {
- UriResourceAllImpl all = new UriResourceAllImpl();
+ UriResourceLambdaAllImpl all = new UriResourceLambdaAllImpl();
// TODO
UriResourcePart obj = contextUriInfo.getLastResourcePart();
@@ -674,7 +669,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
// pathInfoIT.setCollection(lastTypeInfo.isCollection);
// uriInfoImplpath.addPathInfo(pathInfoIT);
- uriInfoImplpath.addPathInfo((UriResourcePartImpl) super.visitAltAll(ctx));
+ uriInfoImplpath.addResourcePart((UriResourcePartImpl) super.visitAltAll(ctx));
return new MemberImpl()
.setPath(uriInfoImplpath);
@@ -699,7 +694,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
// pathInfoIT.setCollection(contextTypes.peek().isCollection);
// uriInfoImplpath.addPathInfo(pathInfoIT);
- uriInfoImplpath.addPathInfo((UriResourcePartImpl) super.visitAltAny(ctx));
+ uriInfoImplpath.addResourcePart((UriResourcePartImpl) super.visitAltAny(ctx));
return new MemberImpl()
.setPath(uriInfoImplpath);
@@ -799,7 +794,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (ctx.vF != null) {
FormatOptionImpl format = (FormatOptionImpl) ctx.vF.accept(this);
- uriInfo.setFormat(format);
+ uriInfo.setSystemQueryOption(format);
}
if (ctx.vCF != null) {
@@ -858,7 +853,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public Object visitAnyExpr(final AnyExprContext ctx) {
- UriResourceAnyImpl any = new UriResourceAnyImpl();
+ UriResourceLambdaAnyImpl any = new UriResourceLambdaAnyImpl();
if (ctx.vLV != null) {
// TODO
UriResourcePart obj = contextUriInfo.getLastResourcePart();
@@ -964,7 +959,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (ctx.vV != null) {
if (pathInfo instanceof UriResourcePartTyped) {
if (!((UriResourcePartTyped) pathInfo).isCollection()) {
- contextUriInfo.addPathInfo(new UriResourceValueImpl());
+ contextUriInfo.addResourcePart(new UriResourceValueImpl());
} else {
throw wrap(new UriParserSemanticException("$value only allowed on typed path segments"));
}
@@ -976,7 +971,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
} else if (ctx.vC != null) {
if (pathInfo instanceof UriResourceImplTyped) {
if (((UriResourceImplTyped) pathInfo).isCollection()) {
- contextUriInfo.addPathInfo(new UriResourceCountImpl());
+ contextUriInfo.addResourcePart(new UriResourceCountImpl());
} else {
throw wrap(new UriParserSemanticException("$count only allowed on collection properties"));
}
@@ -987,7 +982,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (pathInfo instanceof UriResourceImplTyped) {
EdmType type = ((UriResourceImplTyped) pathInfo).getType();
if (type instanceof EdmEntityType) {
- contextUriInfo.addPathInfo(new UriResourceRefImpl());
+ contextUriInfo.addResourcePart(new UriResourceRefImpl());
} else {
throw wrap(new UriParserSemanticException("$ref only allowd on endity types"));
}
@@ -996,9 +991,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
}
} else if (ctx.vAll != null) {
- contextUriInfo.addPathInfo((UriResourceAllImpl) ctx.vAll.accept(this));
+ contextUriInfo.addResourcePart((UriResourceLambdaAllImpl) ctx.vAll.accept(this));
} else if (ctx.vAny != null) {
- contextUriInfo.addPathInfo((UriResourceAnyImpl) ctx.vAny.accept(this));
+ contextUriInfo.addResourcePart((UriResourceLambdaAnyImpl) ctx.vAny.accept(this));
}
return null;
}
@@ -1187,7 +1182,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
// contextUriInfo.addPathInfo(pathInfoIT);
super.visitExpandPath(ctx);
- expandItem.setResourcePath(contextUriInfo);
+ expandItem.setResourceInfo(contextUriInfo);
// reset context
contextUriInfo = uriInfoResourceBU;
@@ -1208,14 +1203,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
targetType = getLastType(lastSegment);
isColl = lastSegment.isCollection();
} else {
- if (contextExpandItemPath.getResourcePath() == null) {
+ if (contextExpandItemPath.getResourceInfo() == null) {
// use the type of the last resource path segement
UriResourceImplTyped lastSegment = (UriResourceImplTyped) contextUriInfo.getLastResourcePart();
targetType = getLastType(lastSegment);
isColl = lastSegment.isCollection();
} else {
// use the type of the last ''expand'' path segement
- UriInfoImpl info = (UriInfoImpl) contextExpandItemPath.getResourcePath();
+ UriInfoImpl info = (UriInfoImpl) contextExpandItemPath.getResourceInfo();
targetType = getLastType((UriResourceImplTyped) info.getLastResourcePart());
isColl = ((UriResourceImplTyped) info.getLastResourcePart()).isCollection();
}
@@ -1224,15 +1219,15 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
contextTypes.push(new LastTypeColl(targetType, isColl));
if (ctx.vC != null) {
- UriInfoImpl resourcePath = (UriInfoImpl) contextExpandItemPath.getResourcePath();
- resourcePath.addPathInfo(new UriResourceCountImpl());
+ UriInfoImpl resourcePath = (UriInfoImpl) contextExpandItemPath.getResourceInfo();
+ resourcePath.addResourcePart(new UriResourceCountImpl());
for (ExpandCountOptionContext s : ctx.vlEOC) {
list.add((SystemQueryOptionImpl) s.accept(this));
}
} else if (ctx.vR != null) {
- UriInfoImpl resourcePath = (UriInfoImpl) contextExpandItemPath.getResourcePath();
- resourcePath.addPathInfo(new UriResourceRefImpl());
+ UriInfoImpl resourcePath = (UriInfoImpl) contextExpandItemPath.getResourceInfo();
+ resourcePath.addResourcePart(new UriResourceRefImpl());
for (ExpandRefOptionContext s : ctx.vlEOR) {
list.add((SystemQueryOptionImpl) s.accept(this));
@@ -1407,7 +1402,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
UriResourceItImpl pathInfoIT = new UriResourceItImpl();
pathInfoIT.setType(lastTypeInfo.type);
pathInfoIT.setCollection(lastTypeInfo.isCollection);
- uriInfoImplpath.addPathInfo(pathInfoIT);
+ uriInfoImplpath.addResourcePart(pathInfoIT);
}
if (ctx.vPs != null) {
@@ -1424,10 +1419,10 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
}
if (ctx.vALL != null) {
- uriInfoImplpath.addPathInfo((UriResourcePartImpl) ctx.vALL.accept(this));
+ uriInfoImplpath.addResourcePart((UriResourcePartImpl) ctx.vALL.accept(this));
}
if (ctx.vANY != null) {
- uriInfoImplpath.addPathInfo((UriResourcePartImpl) ctx.vANY.accept(this));
+ uriInfoImplpath.addResourcePart((UriResourcePartImpl) ctx.vANY.accept(this));
}
return new MemberImpl()
@@ -1651,11 +1646,11 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
UriResourceImplTyped lastType = (UriResourceImplTyped) lastResource;
UriResourceRootImpl pathInfoRoot = new UriResourceRootImpl();
- pathInfoRoot.setIsCollection(lastType.isCollection());
+ pathInfoRoot.setCollection(lastType.isCollection());
pathInfoRoot.setType(getLastType(lastType));
UriInfoImpl uriInfoImplpath = new UriInfoImpl().setKind(UriInfoKind.resource);
- uriInfoImplpath.addPathInfo(pathInfoRoot);
+ uriInfoImplpath.addResourcePart(pathInfoRoot);
if (ctx.vPs != null) {
// store the context uriInfoPath
@@ -1755,17 +1750,17 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
if (element instanceof EdmProperty) {
EdmProperty property = (EdmProperty) element;
if (property.isPrimitive()) {
- UriResourceSimplePropertyImpl simple = new UriResourceSimplePropertyImpl();
+ UriResourcePrimitivePropertyImpl simple = new UriResourcePrimitivePropertyImpl();
simple.setProperty(property);
- UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getPath();
- resourcePath.addPathInfo(simple);
+ UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getResourceInfo();
+ resourcePath.addResourcePart(simple);
} else {
UriResourceComplexPropertyImpl complex = new UriResourceComplexPropertyImpl();
complex.setProperty(property);
- UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getPath();
- resourcePath.addPathInfo(complex);
+ UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getResourceInfo();
+ resourcePath.addResourcePart(complex);
}
} else {
throw wrap(new UriParserSemanticException("Only Simple and Complex properties within select allowed"));
@@ -1785,7 +1780,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
EdmComplexType ct = edm.getComplexType(fullName);
if (ct != null) {
if (((EdmStructuralType) prevType).compatibleTo(ct)) {
- UriResourcePart lastSegment = ((UriInfoImpl)contextSelectItem.getPath()).getLastResourcePart();
+ UriResourcePart lastSegment = ((UriInfoImpl)contextSelectItem.getResourceInfo()).getLastResourcePart();
if (lastSegment instanceof UriResourceImplKeyPred) {
UriResourceImplKeyPred lastKeyPred = (UriResourceImplKeyPred) lastSegment;
lastKeyPred.setCollectionTypeFilter(ct);
@@ -1820,8 +1815,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
UriResourceActionImpl uriAction = new UriResourceActionImpl();
uriAction.setAction(action);
- UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getPath();
- resourcePath.addPathInfo(uriAction);
+ UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getResourceInfo();
+ resourcePath.addResourcePart(uriAction);
}
// check for function
@@ -1832,8 +1827,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
UriResourceFunctionImpl uriFunction = new UriResourceFunctionImpl();
uriFunction.setFunction(function);
- UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getPath();
- resourcePath.addPathInfo(uriFunction);
+ UriInfoImpl resourcePath = (UriInfoImpl) contextSelectItem.getResourceInfo();
+ resourcePath.addResourcePart(uriFunction);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceActionImpl.java
----------------------------------------------------------------------
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 f9bcd6a..42aba94 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
@@ -56,10 +56,7 @@ public class UriResourceActionImpl extends UriResourceImplTyped implements UriRe
@Override
public boolean isCollection() {
- if (action != null) {
- return action.getReturnType().isCollection();
- }
- return false;
+ return action.getReturnType().isCollection();
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceAllImpl.java
----------------------------------------------------------------------
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
deleted file mode 100644
index 3037188..0000000
--- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceAllImpl.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-package org.apache.olingo.odata4.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.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
-import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
-import org.apache.olingo.odata4.producer.api.uri.UriResourceLambdaAll;
-import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
-import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
-
-public class UriResourceAllImpl extends UriResourceImplTyped implements UriResourceLambdaAll {
- protected EdmProperty property;
- private String lamdaVariable;
- private ExpressionImpl expression;
-
- public UriResourceAllImpl() {
- super(UriResourceKind.lambdaAll);
- }
-
- @Override
- public EdmType getType() {
- return EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance();
- }
-
- @Override
- public boolean isCollection() {
- return false;
- }
-
- @Override
- public String getVariable() {
- return lamdaVariable;
- }
-
- public UriResourceAllImpl setLamdaVariable(final String lamdaVariable) {
- this.lamdaVariable = lamdaVariable;
- return this;
- };
-
- @Override
- public Expression getExpression() {
- return expression;
- }
-
- public UriResourceAllImpl setExpression(final ExpressionImpl expression) {
- this.expression = expression;
- return this;
- };
-
- @Override
- public String toString() {
- return "all";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceAnyImpl.java
----------------------------------------------------------------------
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
deleted file mode 100644
index 19597a9..0000000
--- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceAnyImpl.java
+++ /dev/null
@@ -1,72 +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.commons.api.edm.EdmProperty;
-import org.apache.olingo.odata4.commons.api.edm.EdmType;
-import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
-import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
-import org.apache.olingo.odata4.producer.api.uri.UriResourceLambdaAny;
-import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
-import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
-
-public class UriResourceAnyImpl extends UriResourceImplTyped implements UriResourceLambdaAny {
- protected EdmProperty property;
- private String lamdaVariable;
- private ExpressionImpl expression;
-
- public UriResourceAnyImpl() {
- super(UriResourceKind.lambdaAny);
- }
-
- @Override
- public EdmType getType() {
- return EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance();
- }
-
- @Override
- public boolean isCollection() {
- return false;
- }
-
- @Override
- public String getVariable() {
- return lamdaVariable;
- }
-
- public UriResourceAnyImpl setLamdaVariable(final String lamdaVariable) {
- this.lamdaVariable = lamdaVariable;
- return this;
- };
-
- @Override
- public Expression getExpression() {
- return expression;
- }
-
- public UriResourceAnyImpl setExpression(final ExpressionImpl expression) {
- this.expression = expression;
- return this;
- }
-
- @Override
- public String toString() {
- return "any";
- };
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceEntitySetImpl.java
----------------------------------------------------------------------
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 523901e..2491622 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
@@ -49,9 +49,7 @@ public class UriResourceEntitySetImpl extends UriResourceImplKeyPred implements
@Override
public EdmType getType() {
-
return edmEntitySet.getEntityType();
-
}
@Override
@@ -66,5 +64,4 @@ public class UriResourceEntitySetImpl extends UriResourceImplKeyPred implements
public String toString() {
return edmEntitySet.getName();
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceFunctionImpl.java
----------------------------------------------------------------------
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 9769a2c..605bb1e 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
@@ -81,15 +81,14 @@ public class UriResourceFunctionImpl extends UriResourceImplKeyPred implements U
}
setFunction(edmFI.getFunction(names));
+ setParameters(parameters);
return this;
}
@Override
public EdmType getType() {
-
return function.getReturnType().getType();
-
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceImplKeyPred.java
----------------------------------------------------------------------
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 b83523e..aa85f48 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
@@ -75,7 +75,6 @@ public abstract class UriResourceImplKeyPred extends UriResourceImplTyped {
return this;
}
- @Override
public String toString(final boolean includeFilters) {
if (includeFilters == true) {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceImplTyped.java
----------------------------------------------------------------------
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 48f9613..d7bc932 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
@@ -43,8 +43,12 @@ public abstract class UriResourceImplTyped extends UriResourcePartImpl implement
@Override
public String toString(final boolean includeFilters) {
- if (typeFilter != null) {
- return toString() + "/" + getFQN(typeFilter).toString();
+ if (includeFilters) {
+ if (typeFilter != null) {
+ return toString() + "/" + getFQN(typeFilter).toString();
+ } else {
+ return toString();
+ }
}
return toString();
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceItImpl.java
----------------------------------------------------------------------
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 07c8b96..d8b29f0 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
@@ -38,6 +38,11 @@ public class UriResourceItImpl extends UriResourceImplKeyPred implements UriReso
public EdmType getType() {
return type;
}
+
+ public UriResourceItImpl setType(final EdmType type) {
+ this.type = type;
+ return this;
+ }
@Override
public boolean isCollection() {
@@ -47,11 +52,6 @@ public class UriResourceItImpl extends UriResourceImplKeyPred implements UriReso
return isCollection;
}
- public UriResourceItImpl setType(final EdmType type) {
- this.type = type;
- return this;
- }
-
public UriResourceItImpl setCollection(final boolean isCollection) {
this.isCollection = isCollection;
return this;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaAllImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaAllImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaAllImpl.java
new file mode 100644
index 0000000..846d759
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaAllImpl.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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.EdmProperty;
+import org.apache.olingo.odata4.commons.api.edm.EdmType;
+import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
+import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
+import org.apache.olingo.odata4.producer.api.uri.UriResourceLambdaAll;
+import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
+
+public class UriResourceLambdaAllImpl extends UriResourceImplTyped implements UriResourceLambdaAll {
+ protected EdmProperty property;
+ private String lamdaVariable;
+ private ExpressionImpl expression;
+
+ public UriResourceLambdaAllImpl() {
+ super(UriResourceKind.lambdaAll);
+ }
+
+ @Override
+ public EdmType getType() {
+ return EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance();
+ }
+
+ @Override
+ public boolean isCollection() {
+ return false;
+ }
+
+ @Override
+ public String getLamdaVariable() {
+ return lamdaVariable;
+ }
+
+ public UriResourceLambdaAllImpl setLamdaVariable(final String lamdaVariable) {
+ this.lamdaVariable = lamdaVariable;
+ return this;
+ };
+
+ @Override
+ public Expression getExpression() {
+ return expression;
+ }
+
+ public UriResourceLambdaAllImpl setExpression(final ExpressionImpl expression) {
+ this.expression = expression;
+ return this;
+ };
+
+ @Override
+ public String toString() {
+ return "all";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaAnyImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaAnyImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaAnyImpl.java
new file mode 100644
index 0000000..59189d9
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaAnyImpl.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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.EdmProperty;
+import org.apache.olingo.odata4.commons.api.edm.EdmType;
+import org.apache.olingo.odata4.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
+import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
+import org.apache.olingo.odata4.producer.api.uri.UriResourceLambdaAny;
+import org.apache.olingo.odata4.producer.api.uri.queryoption.expression.Expression;
+import org.apache.olingo.odata4.producer.core.uri.queryoption.expression.ExpressionImpl;
+
+public class UriResourceLambdaAnyImpl extends UriResourceImplTyped implements UriResourceLambdaAny {
+ protected EdmProperty property;
+ private String lamdaVariable;
+ private ExpressionImpl expression;
+
+ public UriResourceLambdaAnyImpl() {
+ super(UriResourceKind.lambdaAny);
+ }
+
+ @Override
+ public EdmType getType() {
+ return EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance();
+ }
+
+ @Override
+ public boolean isCollection() {
+ return false;
+ }
+
+ @Override
+ public String getLamdaVariable() {
+ return lamdaVariable;
+ }
+
+ public UriResourceLambdaAnyImpl setLamdaVariable(final String lamdaVariable) {
+ this.lamdaVariable = lamdaVariable;
+ return this;
+ };
+
+ @Override
+ public Expression getExpression() {
+ return expression;
+ }
+
+ public UriResourceLambdaAnyImpl setExpression(final ExpressionImpl expression) {
+ this.expression = expression;
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return "any";
+ };
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaVarImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaVarImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaVarImpl.java
index b98a925..6f637b4 100644
--- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaVarImpl.java
+++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceLambdaVarImpl.java
@@ -58,7 +58,7 @@ public class UriResourceLambdaVarImpl extends UriResourceImplTyped implements Ur
return isCollection;
}
- public UriResourceLambdaVarImpl isCollection(final boolean isCollection) {
+ public UriResourceLambdaVarImpl setCollection(final boolean isCollection) {
this.isCollection = isCollection;
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourcePrimitivePropertyImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourcePrimitivePropertyImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourcePrimitivePropertyImpl.java
new file mode 100644
index 0000000..1ee75c7
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourcePrimitivePropertyImpl.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.EdmProperty;
+import org.apache.olingo.odata4.commons.api.edm.EdmType;
+import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
+import org.apache.olingo.odata4.producer.api.uri.UriResourcePrimitiveProperty;
+
+public class UriResourcePrimitivePropertyImpl extends UriResourceImplTyped implements UriResourcePrimitiveProperty {
+
+ EdmProperty property;
+
+ public UriResourcePrimitivePropertyImpl() {
+ super(UriResourceKind.primitiveProperty);
+ }
+
+ @Override
+ public EdmProperty getProperty() {
+ return property;
+ }
+
+ public UriResourcePrimitivePropertyImpl setProperty(final EdmProperty property) {
+ this.property = property;
+ return this;
+ }
+
+ @Override
+ public EdmType getType() {
+ return property.getType();
+ }
+
+ @Override
+ public boolean isCollection() {
+ return property.isCollection();
+ }
+
+ @Override
+ public String toString() {
+ return property.getName();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceRootImpl.java
----------------------------------------------------------------------
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 67fb2a6..a226bac 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
@@ -22,7 +22,7 @@ import org.apache.olingo.odata4.commons.api.edm.EdmType;
import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
import org.apache.olingo.odata4.producer.api.uri.UriResourceRoot;
-public class UriResourceRootImpl extends UriResourceImplTyped implements UriResourceRoot {
+public class UriResourceRootImpl extends UriResourceImplKeyPred implements UriResourceRoot {
private EdmType type;
private boolean isCollection;
@@ -43,10 +43,13 @@ public class UriResourceRootImpl extends UriResourceImplTyped implements UriReso
@Override
public boolean isCollection() {
+ if (keyPredicates != null) {
+ return false;
+ }
return isCollection;
}
- public UriResourceRootImpl setIsCollection(final boolean isCollection) {
+ public UriResourceRootImpl setCollection(final boolean isCollection) {
this.isCollection = isCollection;
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceSimplePropertyImpl.java
----------------------------------------------------------------------
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
deleted file mode 100644
index 4a66afc..0000000
--- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceSimplePropertyImpl.java
+++ /dev/null
@@ -1,59 +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.commons.api.edm.EdmProperty;
-import org.apache.olingo.odata4.commons.api.edm.EdmType;
-import org.apache.olingo.odata4.producer.api.uri.UriResourceKind;
-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(final EdmProperty property) {
- this.property = property;
- return this;
- }
-
- @Override
- public EdmType getType() {
- return property.getType();
- }
-
- @Override
- public boolean isCollection() {
- return property.isCollection();
- }
-
- @Override
- public String toString() {
- return property.getName();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceSingletonImpl.java
----------------------------------------------------------------------
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 5bec6fb..5b42392 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
@@ -65,7 +65,7 @@ public class UriResourceSingletonImpl extends UriResourceImplTyped implements Ur
@Override
public String toString() {
- return singleton.toString();
+ return singleton.getName();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceStartingTypeFilterImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceStartingTypeFilterImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceStartingTypeFilterImpl.java
index d5e3ef0..52c76cf 100644
--- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceStartingTypeFilterImpl.java
+++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/UriResourceStartingTypeFilterImpl.java
@@ -48,12 +48,20 @@ public class UriResourceStartingTypeFilterImpl extends UriResourceImplKeyPred im
@Override
public boolean isCollection() {
+ if (keyPredicates != null) {
+ return false;
+ }
return isCollection;
}
- public UriResourceStartingTypeFilterImpl setIsCollection(final boolean isCollection) {
+ public UriResourceStartingTypeFilterImpl setCollection(final boolean isCollection) {
this.isCollection = isCollection;
return this;
}
+
+ @Override
+ public String toString() {
+ return type.getNamespace() + "." +type.getName();
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/ExpandItemImpl.java
----------------------------------------------------------------------
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 f8731ef..0f397a4 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
@@ -21,7 +21,6 @@ package org.apache.olingo.odata4.producer.core.uri.queryoption;
import java.util.List;
-import org.apache.olingo.odata4.commons.api.edm.Edm;
import org.apache.olingo.odata4.producer.api.uri.UriInfoResource;
import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandItem;
import org.apache.olingo.odata4.producer.api.uri.queryoption.ExpandOption;
@@ -46,7 +45,7 @@ public class ExpandItemImpl implements ExpandItem {
private SelectOption selectOption;
private ExpandOption expandOption;
- private UriInfoResource resourcePath;
+ private UriInfoResource resourceInfo;
private boolean isStar;
@@ -85,60 +84,60 @@ public class ExpandItemImpl implements ExpandItem {
}
@Override
- public LevelsExpandOption getLevels() {
+ public LevelsExpandOption getLevelsOption() {
return levelsExpandOption;
}
@Override
- public FilterOption getFilter() {
+ public FilterOption getFilterOption() {
return filterOption;
}
@Override
- public SearchOption getSearch() {
+ public SearchOption getSearchOption() {
return searchOption;
}
@Override
- public OrderByOption getOrderBy() {
+ public OrderByOption getOrderByOption() {
return orderByOption;
}
@Override
- public SkipOption getSkip() {
+ public SkipOption getSkipOption() {
return skipOption;
}
@Override
- public TopOption getTop() {
+ public TopOption getTopOption() {
return topOption;
}
@Override
- public InlineCountOption getInlineCount() {
+ public InlineCountOption getInlineCountOption() {
return inlineCountOption;
}
@Override
- public SelectOption getSelect() {
+ public SelectOption getSelectOption() {
return selectOption;
}
@Override
- public ExpandOption getExpand() {
+ public ExpandOption getExpandOption() {
return expandOption;
}
- public ExpandItemImpl setResourcePath(final UriInfoResource resourcePath) {
- this.resourcePath = resourcePath;
+ public ExpandItemImpl setResourceInfo(final UriInfoResource resourceInfo) {
+ this.resourceInfo = resourceInfo;
return this;
}
@Override
- public UriInfoResource getResourcePath() {
+ public UriInfoResource getResourceInfo() {
- return resourcePath;
+ return resourceInfo;
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/OrderByOptionImpl.java
----------------------------------------------------------------------
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 9924231..6710925 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
@@ -19,7 +19,6 @@
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;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/b14e278a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/QueryOptionImpl.java
----------------------------------------------------------------------
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 e5a7a6d..b9b4b0d 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 abstract class QueryOptionImpl implements QueryOption {
+public class QueryOptionImpl implements QueryOption {
private String name;
private String text;