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/01/29 13:45:34 UTC
[2/6] [OLINGO-63] Uri Parser: Add test cases for key predicates,
select, expand and code cleanup
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectSegmentImpl.java
----------------------------------------------------------------------
diff --git a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectSegmentImpl.java b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectSegmentImpl.java
new file mode 100644
index 0000000..7fbad91
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SelectSegmentImpl.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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;
+
+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;
+
+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 getTypeCast() {
+ return typeCast;
+ }
+
+ public SelectSegmentImpl setTypeCast(final EdmStructuralType type) {
+ typeCast = type;
+ return this;
+ }
+
+
+
+ public EdmAction getAction() {
+ return action;
+ }
+
+ 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
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkipOptionImpl.java
----------------------------------------------------------------------
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 80cf37f..7a43666 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;
- }
-
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkipTokenOptionImpl.java
----------------------------------------------------------------------
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
deleted file mode 100644
index 78f222d..0000000
--- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkipTokenOptionImpl.java
+++ /dev/null
@@ -1,52 +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;
-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;
-
- public SkipTokenOptionImpl() {
- setKind(SystemQueryOptionEnum.SEARCH);
- }
-
- public String getToken() {
- return token;
- }
-
- public SkipTokenOptionImpl
- setToken( String token) {
- this.token = token;
- return this;
- }
-
- @Override
- public String getSkipTokenValue() {
- // TODO Auto-generated method stub
- return null;
- }
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkiptokenOptionImpl.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..67ce8a7
--- /dev/null
+++ b/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SkiptokenOptionImpl.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ *
+ * 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;
+
+import org.apache.olingo.odata4.producer.api.uri.queryoption.SkiptokenOption;
+import org.apache.olingo.odata4.producer.api.uri.queryoption.SupportedQueryOptions;
+
+/* TODO implement */
+public class SkiptokenOptionImpl extends SystemQueryOptionImpl implements SkiptokenOption {
+ private String skipTokenValue;
+
+ public SkiptokenOptionImpl() {
+ setKind(SupportedQueryOptions.SKIPTOKEN);
+ }
+
+
+ @Override
+ public String getValue() {
+ return skipTokenValue;
+ }
+
+ public SkiptokenOptionImpl setValue(String skipTokenValue) {
+ this.skipTokenValue = skipTokenValue;
+ return this;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/SystemQueryOptionImpl.java
----------------------------------------------------------------------
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 c855d80..388b712 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();
}
-
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/TopOptionImpl.java
----------------------------------------------------------------------
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 dff7cec..9d6f7d6 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;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/AliasImpl.java
----------------------------------------------------------------------
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 7b42317..30f7a08 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> T accept(ExpressionVisitor<T> visitor) throws ExceptionVisitExpression {
+ public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
return visitor.visitAlias(referenceName);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/BinaryImpl.java
----------------------------------------------------------------------
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 bf22f39..480abcb 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> T accept(ExpressionVisitor<T> visitor) throws ExceptionVisitExpression {
+ public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
T left = this.left.accept(visitor);
T right = this.right.accept(visitor);
return visitor.visitBinaryOperator(operator, left, right);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExceptionVisitExpression.java
----------------------------------------------------------------------
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-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExceptionVisitExpression.java
deleted file mode 100644
index c0ff338..0000000
--- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExceptionVisitExpression.java
+++ /dev/null
@@ -1,28 +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.expression;
-
-public class ExceptionVisitExpression extends Exception {
-
- /**
- *
- */
- private static final long serialVersionUID = 822365726050299076L;
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExpressionImpl.java
----------------------------------------------------------------------
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 0bdb71f..0854630 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> T accept(ExpressionVisitor<T> visitor) throws ExceptionVisitExpression {
- // TODO Auto-generated method stub
- return null;
- }
+public abstract class ExpressionImpl implements Expression {
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExpressionVisitor.java
----------------------------------------------------------------------
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-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExpressionVisitor.java
deleted file mode 100644
index 6283865..0000000
--- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/ExpressionVisitor.java
+++ /dev/null
@@ -1,40 +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.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;
-
-public interface ExpressionVisitor<T> {
-
- T visitBinaryOperator(SupportedBinaryOperators operator, T left, T right) throws ExceptionVisitExpression;
-
- T visitUnaryOperator(SupportedUnaryOperators operator, T operand) throws ExceptionVisitExpression;
-
- T visitMethodCall(SupportedMethodCalls methodCall, List<T> parameters) throws ExceptionVisitExpression;
-
- T visitLiteral(String literal) throws ExceptionVisitExpression;
-
- T visitMember(MemberImpl member) throws ExceptionVisitExpression;
-
- T visitAlias(String referenceName) throws ExceptionVisitExpression;
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/LambdaRefImpl.java
----------------------------------------------------------------------
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 665af59..dc9063f 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> T accept(ExpressionVisitor<T> visitor) throws ExceptionVisitExpression {
- return null;
- }
+ public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
-
+ return visitor.visitLambdaReference(variableText);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/LiteralImpl.java
----------------------------------------------------------------------
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 eade6b7..0057bf0 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> T accept(ExpressionVisitor<T> visitor) throws ExceptionVisitExpression {
+ public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
return visitor.visitLiteral(text);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/MemberImpl.java
----------------------------------------------------------------------
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 56ff31d..641ed7e 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> T accept(ExpressionVisitor<T> visitor) throws ExceptionVisitExpression {
- return visitor.visitMember(this);
+ public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
+ return visitor.visitMember(path);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/MethodCallImpl.java
----------------------------------------------------------------------
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 f8c666d..a9d4022 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<ExpressionImpl> parameters = new ArrayList<ExpressionImpl>();
-
+
@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<Expression> getParameters() {
List<Expression> list = new ArrayList<Expression>();
- 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> T accept(ExpressionVisitor<T> visitor) throws ExceptionVisitExpression {
+ public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
List<T> userParameters = new ArrayList<T>();
- for (ExpressionImpl parameter : parameters ) {
+ for (ExpressionImpl parameter : parameters) {
userParameters.add(parameter.accept(visitor));
}
return visitor.visitMethodCall(method, userParameters);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/TypeLiteralImpl.java
----------------------------------------------------------------------
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 e74ff76..e0a43ce 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> T accept(ExpressionVisitor<T> visitor) throws ExceptionVisitExpression {
- return null;
+ public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
+ return visitor.visitTypeLiteral(type);
}
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/UnaryOperatorImpl.java
----------------------------------------------------------------------
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 98da4ba..8ec6ecb 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> T accept(ExpressionVisitor<T> visitor) throws ExceptionVisitExpression {
+ public <T> T accept(final ExpressionVisitor<T> visitor) throws ExceptionVisitExpression, ODataApplicationException {
T operand = expression.accept(visitor);
return visitor.visitUnaryOperator(operator, operand);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/VisitableExression.java
----------------------------------------------------------------------
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-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/VisitableExression.java
deleted file mode 100644
index e4a2235..0000000
--- a/odata4-lib/odata4-producer-core/src/main/java/org/apache/olingo/odata4/producer/core/uri/queryoption/expression/VisitableExression.java
+++ /dev/null
@@ -1,54 +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.expression;
-
-
-
-
-
-
-
-
-/* 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
- * behave as follows:
- * <li>Call accept on all sub nodes and store the returned Objects
- * <li>Call the appropriate method on the {@link ExpressionVisitor} instance and provide the stored objects to that
- * instance
- * <li>Return the object which should be passed to the processing algorithm of the parent expression node
- * <br>
- * <br>
- * @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> T accept(ExpressionVisitor<T> visitor) throws ExceptionVisitExpression;
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/EdmTechProvider.java
----------------------------------------------------------------------
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 38adef0..1bcd351 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()
@@ -1374,6 +1374,15 @@ public class EdmTechProvider extends EdmProvider {
.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(
+ new Parameter()
.setName("ParameterString")
.setType(nameString),
new Parameter()
@@ -1382,6 +1391,7 @@ public class EdmTechProvider extends EdmProvider {
.setComposable(true)
.setReturnType(
new ReturnType().setType(nameString))
+
);
} else if (functionName.equals(nameUFCRTESTwoKeyNavParam)) {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/ExpandToText.java
----------------------------------------------------------------------
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 d9926ce..0000000
--- 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<String> {
-
- 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<String> 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<String> expandItems) {
- String tmp = "";
-
- for (String expandItem : expandItems) {
- if (tmp.length() != 0) {
- tmp += ",";
- }
- tmp += expandItem;
- }
- return "<(" + tmp + ")>";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/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/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 0000000..324fd6f
--- /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;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterTreeToText.java
----------------------------------------------------------------------
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 d3f933c..1d8749e 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<String> {
-
- 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<String> {
}
@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<String> {
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;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/FilterValidator.java
----------------------------------------------------------------------
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 e3673e6..47d1e00 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;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriResourceValidator.java
----------------------------------------------------------------------
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 ee25df4..411e433 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;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/1ef03f92/odata4-lib/odata4-producer-core/src/test/java/org/apache/olingo/odata4/producer/core/testutil/UriValidator.java
----------------------------------------------------------------------
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 8054085..c308ac6 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);
}