You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/10/19 15:12:36 UTC
[3/4] olingo-odata4 git commit: [OLINGO786] FIx edm annotation classes
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmDynamicAnnotationExpression.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmDynamicAnnotationExpression.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmDynamicAnnotationExpression.java
deleted file mode 100644
index 3115491..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmDynamicAnnotationExpression.java
+++ /dev/null
@@ -1,291 +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.commons.core.edm.annotation;
-
-import org.apache.olingo.commons.api.edm.annotation.EdmAnd;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationPath;
-import org.apache.olingo.commons.api.edm.annotation.EdmApply;
-import org.apache.olingo.commons.api.edm.annotation.EdmCast;
-import org.apache.olingo.commons.api.edm.annotation.EdmCollection;
-import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression;
-import org.apache.olingo.commons.api.edm.annotation.EdmEq;
-import org.apache.olingo.commons.api.edm.annotation.EdmGe;
-import org.apache.olingo.commons.api.edm.annotation.EdmGt;
-import org.apache.olingo.commons.api.edm.annotation.EdmIf;
-import org.apache.olingo.commons.api.edm.annotation.EdmIsOf;
-import org.apache.olingo.commons.api.edm.annotation.EdmLabeledElement;
-import org.apache.olingo.commons.api.edm.annotation.EdmLabeledElementReference;
-import org.apache.olingo.commons.api.edm.annotation.EdmLe;
-import org.apache.olingo.commons.api.edm.annotation.EdmLt;
-import org.apache.olingo.commons.api.edm.annotation.EdmNavigationPropertyPath;
-import org.apache.olingo.commons.api.edm.annotation.EdmNe;
-import org.apache.olingo.commons.api.edm.annotation.EdmNot;
-import org.apache.olingo.commons.api.edm.annotation.EdmNull;
-import org.apache.olingo.commons.api.edm.annotation.EdmOr;
-import org.apache.olingo.commons.api.edm.annotation.EdmPath;
-import org.apache.olingo.commons.api.edm.annotation.EdmPropertyPath;
-import org.apache.olingo.commons.api.edm.annotation.EdmPropertyValue;
-import org.apache.olingo.commons.api.edm.annotation.EdmRecord;
-import org.apache.olingo.commons.api.edm.annotation.EdmUrlRef;
-
-public abstract class AbstractEdmDynamicAnnotationExpression
-extends AbstractEdmAnnotationExpression implements EdmDynamicAnnotationExpression {
-
- @Override
- public boolean isNot() {
- return this instanceof EdmNot;
- }
-
- @Override
- public EdmNot asNot() {
- return isNot() ? (EdmNot) this : null;
-
- }
-
- @Override
- public boolean isAnd() {
- return this instanceof EdmAnd;
- }
-
- @Override
- public EdmAnd asAnd() {
- return isAnd() ? (EdmAnd) this : null;
- }
-
- @Override
- public boolean isOr() {
- return this instanceof EdmOr;
- }
-
- @Override
- public EdmOr asOr() {
- return isOr() ? (EdmOr) this : null;
- }
-
- @Override
- public boolean isEq() {
- return this instanceof EdmEq;
- }
-
- @Override
- public EdmEq asEq() {
- return isEq() ? (EdmEq) this : null;
- }
-
- @Override
- public boolean isNe() {
- return this instanceof EdmNe;
- }
-
- @Override
- public EdmNe asNe() {
- return isNe() ? (EdmNe) this : null;
- }
-
- @Override
- public boolean isGt() {
- return this instanceof EdmGt;
- }
-
- @Override
- public EdmGt asGt() {
- return isGt() ? (EdmGt) this : null;
- }
-
- @Override
- public boolean isGe() {
- return this instanceof EdmGe;
- }
-
- @Override
- public EdmGe asGe() {
- return isGe() ? (EdmGe) this : null;
- }
-
- @Override
- public boolean isLt() {
- return this instanceof EdmLt;
- }
-
- @Override
- public EdmLt asLt() {
- return isLt() ? (EdmLt) this : null;
- }
-
- @Override
- public boolean isLe() {
- return this instanceof EdmLe;
- }
-
- @Override
- public EdmLe asLe() {
- return isLe() ? (EdmLe) this : null;
- }
-
- @Override
- public boolean isAnnotationPath() {
- return this instanceof EdmAnnotationPath;
- }
-
- @Override
- public EdmAnnotationPath asAnnotationPath() {
- return isAnnotationPath() ? (EdmAnnotationPath) this : null;
- }
-
- @Override
- public boolean isApply() {
- return this instanceof EdmApply;
- }
-
- @Override
- public EdmApply asApply() {
- return isApply() ? (EdmApply) this : null;
- }
-
- @Override
- public boolean isCast() {
- return this instanceof EdmCast;
- }
-
- @Override
- public EdmCast asCast() {
- return isCast() ? (EdmCast) this : null;
- }
-
- @Override
- public boolean isCollection() {
- return this instanceof EdmCollection;
- }
-
- @Override
- public EdmCollection asCollection() {
- return isCollection() ? (EdmCollection) this : null;
- }
-
- @Override
- public boolean isIf() {
- return this instanceof EdmIf;
- }
-
- @Override
- public EdmIf asIf() {
- return isIf() ? (EdmIf) this : null;
- }
-
- @Override
- public boolean isIsOf() {
- return this instanceof EdmIsOf;
- }
-
- @Override
- public EdmIsOf asIsOf() {
- return isIsOf() ? (EdmIsOf) this : null;
- }
-
- @Override
- public boolean isLabeledElement() {
- return this instanceof EdmLabeledElement;
- }
-
- @Override
- public EdmLabeledElement asLabeledElement() {
- return isLabeledElement() ? (EdmLabeledElement) this : null;
- }
-
- @Override
- public boolean isLabeledElementReference() {
- return this instanceof EdmLabeledElementReference;
- }
-
- @Override
- public EdmLabeledElementReference asLabeledElementReference() {
- return isLabeledElementReference() ? (EdmLabeledElementReference) this : null;
- }
-
- @Override
- public boolean isNull() {
- return this instanceof EdmNull;
- }
-
- @Override
- public EdmNull asNull() {
- return isNull() ? (EdmNull) this : null;
- }
-
- @Override
- public boolean isNavigationPropertyPath() {
- return this instanceof EdmNavigationPropertyPath;
- }
-
- @Override
- public EdmNavigationPropertyPath asNavigationPropertyPath() {
- return isNavigationPropertyPath() ? (EdmNavigationPropertyPath) this : null;
- }
-
- @Override
- public boolean isPath() {
- return this instanceof EdmPath;
- }
-
- @Override
- public EdmPath asPath() {
- return isPath() ? (EdmPath) this : null;
- }
-
- @Override
- public boolean isPropertyPath() {
- return this instanceof EdmPropertyPath;
- }
-
- @Override
- public EdmPropertyPath asPropertyPath() {
- return isPropertyPath() ? (EdmPropertyPath) this : null;
- }
-
- @Override
- public boolean isPropertyValue() {
- return this instanceof EdmPropertyValue;
- }
-
- @Override
- public EdmPropertyValue asPropertyValue() {
- return isPropertyValue() ? (EdmPropertyValue) this : null;
- }
-
- @Override
- public boolean isRecord() {
- return this instanceof EdmRecord;
- }
-
- @Override
- public EdmRecord asRecord() {
- return isRecord() ? (EdmRecord) this : null;
- }
-
- @Override
- public boolean isUrlRef() {
- return this instanceof EdmUrlRef;
- }
-
- @Override
- public EdmUrlRef asUrlRef() {
- return isUrlRef() ? (EdmUrlRef) this : null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmDynamicExpression.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmDynamicExpression.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmDynamicExpression.java
new file mode 100644
index 0000000..72f79b5
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmDynamicExpression.java
@@ -0,0 +1,295 @@
+/*
+ * 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.commons.core.edm.annotation;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.annotation.EdmAnd;
+import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationPath;
+import org.apache.olingo.commons.api.edm.annotation.EdmApply;
+import org.apache.olingo.commons.api.edm.annotation.EdmCast;
+import org.apache.olingo.commons.api.edm.annotation.EdmCollection;
+import org.apache.olingo.commons.api.edm.annotation.EdmDynamicExpression;
+import org.apache.olingo.commons.api.edm.annotation.EdmEq;
+import org.apache.olingo.commons.api.edm.annotation.EdmGe;
+import org.apache.olingo.commons.api.edm.annotation.EdmGt;
+import org.apache.olingo.commons.api.edm.annotation.EdmIf;
+import org.apache.olingo.commons.api.edm.annotation.EdmIsOf;
+import org.apache.olingo.commons.api.edm.annotation.EdmLabeledElement;
+import org.apache.olingo.commons.api.edm.annotation.EdmLabeledElementReference;
+import org.apache.olingo.commons.api.edm.annotation.EdmLe;
+import org.apache.olingo.commons.api.edm.annotation.EdmLt;
+import org.apache.olingo.commons.api.edm.annotation.EdmNavigationPropertyPath;
+import org.apache.olingo.commons.api.edm.annotation.EdmNe;
+import org.apache.olingo.commons.api.edm.annotation.EdmNot;
+import org.apache.olingo.commons.api.edm.annotation.EdmNull;
+import org.apache.olingo.commons.api.edm.annotation.EdmOr;
+import org.apache.olingo.commons.api.edm.annotation.EdmPath;
+import org.apache.olingo.commons.api.edm.annotation.EdmPropertyPath;
+import org.apache.olingo.commons.api.edm.annotation.EdmPropertyValue;
+import org.apache.olingo.commons.api.edm.annotation.EdmRecord;
+import org.apache.olingo.commons.api.edm.annotation.EdmUrlRef;
+
+public abstract class AbstractEdmDynamicExpression extends AbstractEdmExpression implements EdmDynamicExpression {
+
+ public AbstractEdmDynamicExpression(Edm edm, String name) {
+ super(edm, name);
+ }
+
+ @Override
+ public boolean isNot() {
+ return this instanceof EdmNot;
+ }
+
+ @Override
+ public EdmNot asNot() {
+ return isNot() ? (EdmNot) this : null;
+
+ }
+
+ @Override
+ public boolean isAnd() {
+ return this instanceof EdmAnd;
+ }
+
+ @Override
+ public EdmAnd asAnd() {
+ return isAnd() ? (EdmAnd) this : null;
+ }
+
+ @Override
+ public boolean isOr() {
+ return this instanceof EdmOr;
+ }
+
+ @Override
+ public EdmOr asOr() {
+ return isOr() ? (EdmOr) this : null;
+ }
+
+ @Override
+ public boolean isEq() {
+ return this instanceof EdmEq;
+ }
+
+ @Override
+ public EdmEq asEq() {
+ return isEq() ? (EdmEq) this : null;
+ }
+
+ @Override
+ public boolean isNe() {
+ return this instanceof EdmNe;
+ }
+
+ @Override
+ public EdmNe asNe() {
+ return isNe() ? (EdmNe) this : null;
+ }
+
+ @Override
+ public boolean isGt() {
+ return this instanceof EdmGt;
+ }
+
+ @Override
+ public EdmGt asGt() {
+ return isGt() ? (EdmGt) this : null;
+ }
+
+ @Override
+ public boolean isGe() {
+ return this instanceof EdmGe;
+ }
+
+ @Override
+ public EdmGe asGe() {
+ return isGe() ? (EdmGe) this : null;
+ }
+
+ @Override
+ public boolean isLt() {
+ return this instanceof EdmLt;
+ }
+
+ @Override
+ public EdmLt asLt() {
+ return isLt() ? (EdmLt) this : null;
+ }
+
+ @Override
+ public boolean isLe() {
+ return this instanceof EdmLe;
+ }
+
+ @Override
+ public EdmLe asLe() {
+ return isLe() ? (EdmLe) this : null;
+ }
+
+ @Override
+ public boolean isAnnotationPath() {
+ return this instanceof EdmAnnotationPath;
+ }
+
+ @Override
+ public EdmAnnotationPath asAnnotationPath() {
+ return isAnnotationPath() ? (EdmAnnotationPath) this : null;
+ }
+
+ @Override
+ public boolean isApply() {
+ return this instanceof EdmApply;
+ }
+
+ @Override
+ public EdmApply asApply() {
+ return isApply() ? (EdmApply) this : null;
+ }
+
+ @Override
+ public boolean isCast() {
+ return this instanceof EdmCast;
+ }
+
+ @Override
+ public EdmCast asCast() {
+ return isCast() ? (EdmCast) this : null;
+ }
+
+ @Override
+ public boolean isCollection() {
+ return this instanceof EdmCollection;
+ }
+
+ @Override
+ public EdmCollection asCollection() {
+ return isCollection() ? (EdmCollection) this : null;
+ }
+
+ @Override
+ public boolean isIf() {
+ return this instanceof EdmIf;
+ }
+
+ @Override
+ public EdmIf asIf() {
+ return isIf() ? (EdmIf) this : null;
+ }
+
+ @Override
+ public boolean isIsOf() {
+ return this instanceof EdmIsOf;
+ }
+
+ @Override
+ public EdmIsOf asIsOf() {
+ return isIsOf() ? (EdmIsOf) this : null;
+ }
+
+ @Override
+ public boolean isLabeledElement() {
+ return this instanceof EdmLabeledElement;
+ }
+
+ @Override
+ public EdmLabeledElement asLabeledElement() {
+ return isLabeledElement() ? (EdmLabeledElement) this : null;
+ }
+
+ @Override
+ public boolean isLabeledElementReference() {
+ return this instanceof EdmLabeledElementReference;
+ }
+
+ @Override
+ public EdmLabeledElementReference asLabeledElementReference() {
+ return isLabeledElementReference() ? (EdmLabeledElementReference) this : null;
+ }
+
+ @Override
+ public boolean isNull() {
+ return this instanceof EdmNull;
+ }
+
+ @Override
+ public EdmNull asNull() {
+ return isNull() ? (EdmNull) this : null;
+ }
+
+ @Override
+ public boolean isNavigationPropertyPath() {
+ return this instanceof EdmNavigationPropertyPath;
+ }
+
+ @Override
+ public EdmNavigationPropertyPath asNavigationPropertyPath() {
+ return isNavigationPropertyPath() ? (EdmNavigationPropertyPath) this : null;
+ }
+
+ @Override
+ public boolean isPath() {
+ return this instanceof EdmPath;
+ }
+
+ @Override
+ public EdmPath asPath() {
+ return isPath() ? (EdmPath) this : null;
+ }
+
+ @Override
+ public boolean isPropertyPath() {
+ return this instanceof EdmPropertyPath;
+ }
+
+ @Override
+ public EdmPropertyPath asPropertyPath() {
+ return isPropertyPath() ? (EdmPropertyPath) this : null;
+ }
+
+ @Override
+ public boolean isPropertyValue() {
+ return this instanceof EdmPropertyValue;
+ }
+
+ @Override
+ public EdmPropertyValue asPropertyValue() {
+ return isPropertyValue() ? (EdmPropertyValue) this : null;
+ }
+
+ @Override
+ public boolean isRecord() {
+ return this instanceof EdmRecord;
+ }
+
+ @Override
+ public EdmRecord asRecord() {
+ return isRecord() ? (EdmRecord) this : null;
+ }
+
+ @Override
+ public boolean isUrlRef() {
+ return this instanceof EdmUrlRef;
+ }
+
+ @Override
+ public EdmUrlRef asUrlRef() {
+ return isUrlRef() ? (EdmUrlRef) this : null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmElementOrAttributeNotation.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmElementOrAttributeNotation.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmElementOrAttributeNotation.java
deleted file mode 100644
index aafe681..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmElementOrAttributeNotation.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.edm.annotation;
-
-/**
- * Groups dynamic expressions that may be provided using element notation or attribute notation.
- */
-public abstract class AbstractEdmElementOrAttributeNotation extends AbstractEdmDynamicAnnotationExpression {
-
- private final String value;
-
- public AbstractEdmElementOrAttributeNotation(final String value) {
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmExpression.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmExpression.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmExpression.java
new file mode 100644
index 0000000..89469df
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmExpression.java
@@ -0,0 +1,154 @@
+/*
+ * 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.commons.core.edm.annotation;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.annotation.EdmConstantExpression;
+import org.apache.olingo.commons.api.edm.annotation.EdmDynamicExpression;
+import org.apache.olingo.commons.api.edm.annotation.EdmExpression;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlDynamicExpression;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlExpression;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression;
+
+public abstract class AbstractEdmExpression implements EdmExpression {
+
+ private final String name;
+ protected final Edm edm;
+
+ public AbstractEdmExpression(Edm edm, String name) {
+ this.edm = edm;
+ this.name = name;
+ }
+
+ @Override
+ public String getExpressionName() {
+ return name;
+ };
+
+ @Override
+ public boolean isConstant() {
+ return this instanceof EdmConstantExpression;
+ }
+
+ @Override
+ public EdmConstantExpression asConstant() {
+ return isConstant() ? (EdmConstantExpression) this : null;
+ }
+
+ @Override
+ public boolean isDynamic() {
+ return this instanceof EdmDynamicExpression;
+ }
+
+ @Override
+ public EdmDynamicExpression asDynamic() {
+ return isDynamic() ? (EdmDynamicExpression) this : null;
+ }
+
+ public static EdmExpression getExpression(Edm edm, final CsdlExpression exp) {
+ EdmExpression _expression = null;
+
+ if (exp.isConstant()) {
+ _expression = new EdmConstantExpressionImpl(edm, exp.asConstant());
+ } else if (exp.isDynamic()) {
+ _expression = getDynamicExpression(edm, exp.asDynamic());
+ }
+
+ return _expression;
+ }
+
+ private static EdmDynamicExpression getDynamicExpression(Edm edm, final CsdlDynamicExpression exp) {
+
+ EdmDynamicExpression _expression = null;
+
+ if (exp.isLogicalOrComparison()) {
+ CsdlLogicalOrComparisonExpression expLocal = exp.asLogicalOrComparison();
+ switch (exp.asLogicalOrComparison().getType()) {
+ case Not:
+ _expression = new EdmNotImpl(edm, expLocal);
+ break;
+ case And:
+ _expression = new EdmAndImpl(edm, expLocal);
+ break;
+
+ case Or:
+ _expression = new EdmOrImpl(edm, expLocal);
+ break;
+
+ case Eq:
+ _expression = new EdmEqImpl(edm, expLocal);
+ break;
+
+ case Ne:
+ _expression = new EdmNeImpl(edm, expLocal);
+ break;
+
+ case Ge:
+ _expression = new EdmGeImpl(edm, expLocal);
+ break;
+
+ case Gt:
+ _expression = new EdmGtImpl(edm, expLocal);
+ break;
+
+ case Le:
+ _expression = new EdmLeImpl(edm, expLocal);
+ break;
+
+ case Lt:
+ _expression = new EdmLtImpl(edm, expLocal);
+ break;
+
+ default:
+ }
+ } else if (exp.isAnnotationPath()) {
+ _expression = new EdmAnnotationPathImpl(edm, exp.asAnnotationPath());
+ } else if (exp.isApply()) {
+ _expression = new EdmApplyImpl(edm, exp.asApply());
+ } else if (exp.isCast()) {
+ _expression = new EdmCastImpl(edm, exp.asCast());
+ } else if (exp.isCollection()) {
+ _expression = new EdmCollectionImpl(edm, exp.asCollection());
+ } else if (exp.isIf()) {
+ _expression = new EdmIfImpl(edm, exp.asIf());
+ } else if (exp.isIsOf()) {
+ _expression = new EdmIsOfImpl(edm, exp.asIsOf());
+ } else if (exp.isLabeledElement()) {
+ _expression = new EdmLabeledElementImpl(edm, exp.asLabeledElement());
+ } else if (exp.isLabeledElementReference()) {
+ _expression = new EdmLabeledElementReferenceImpl(edm, exp.asLabeledElementReference());
+ } else if (exp.isNull()) {
+ _expression = new EdmNullImpl(edm, exp.asNull());
+ } else if (exp.isNavigationPropertyPath()) {
+ _expression = new EdmNavigationPropertyPathImpl(edm, exp.asNavigationPropertyPath());
+ } else if (exp.isPath()) {
+ _expression = new EdmPathImpl(edm, exp.asPath());
+ } else if (exp.isPropertyPath()) {
+ _expression = new EdmPropertyPathImpl(edm, exp.asPropertyPath());
+ } else if (exp.isPropertyValue()) {
+ _expression = new EdmPropertyValueImpl(edm, exp.asPropertyValue());
+ } else if (exp.isRecord()) {
+ _expression = new EdmRecordImpl(edm, exp.asRecord());
+ } else if (exp.isUrlRef()) {
+ _expression = new EdmUrlRefImpl(edm, exp.asUrlRef());
+ }
+
+ return _expression;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmLogicalOrComparisonExpression.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmLogicalOrComparisonExpression.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmLogicalOrComparisonExpression.java
new file mode 100644
index 0000000..9aa8b00
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmLogicalOrComparisonExpression.java
@@ -0,0 +1,70 @@
+/*
+ * 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.commons.core.edm.annotation;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmException;
+import org.apache.olingo.commons.api.edm.annotation.EdmExpression;
+import org.apache.olingo.commons.api.edm.annotation.EdmLogicalOrComparisonExpression;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression;
+//CHECKSTYLE:OFF
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression.LogicalOrComparisonExpressionType;
+
+//CHECKSTYLE:ON
+
+public abstract class AbstractEdmLogicalOrComparisonExpression
+ extends AbstractEdmAnnotatableDynamicExpression implements EdmLogicalOrComparisonExpression {
+
+ private EdmExpression left;
+ private EdmExpression right;
+ private CsdlLogicalOrComparisonExpression csdlExp;
+
+ public AbstractEdmLogicalOrComparisonExpression(Edm edm, CsdlLogicalOrComparisonExpression csdlExp) {
+ super(edm, csdlExp.getType().toString(), csdlExp);
+ this.csdlExp = csdlExp;
+ }
+
+ @Override
+ public EdmExpression getLeftExpression() {
+ if (left == null) {
+ if (csdlExp.getLeft() == null) {
+ throw new EdmException("Comparison Or Logical expression MUST have a left and right expression.");
+ }
+ left = AbstractEdmExpression.getExpression(edm, csdlExp.getLeft());
+ if (csdlExp.getType() == LogicalOrComparisonExpressionType.Not) {
+ right = left;
+ }
+ }
+ return left;
+ }
+
+ @Override
+ public EdmExpression getRightExpression() {
+ if (right == null) {
+ if (csdlExp.getRight() == null) {
+ throw new EdmException("Comparison Or Logical expression MUST have a left and right expression.");
+ }
+ right = AbstractEdmExpression.getExpression(edm, csdlExp.getRight());
+ if (csdlExp.getType() == LogicalOrComparisonExpressionType.Not) {
+ left = right;
+ }
+ }
+ return right;
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmTwoParamsOpDynamicAnnotationExpression.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmTwoParamsOpDynamicAnnotationExpression.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmTwoParamsOpDynamicAnnotationExpression.java
deleted file mode 100644
index 2c5a289..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmTwoParamsOpDynamicAnnotationExpression.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.edm.annotation;
-
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
-import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression;
-import org.apache.olingo.commons.api.edm.annotation.EdmTwoParamsOpDynamicAnnotationExpression;
-
-public abstract class AbstractEdmTwoParamsOpDynamicAnnotationExpression
-extends AbstractEdmDynamicAnnotationExpression implements EdmTwoParamsOpDynamicAnnotationExpression {
-
- private final EdmAnnotationExpression left;
-
- private final EdmAnnotationExpression right;
-
- public AbstractEdmTwoParamsOpDynamicAnnotationExpression(
- final EdmAnnotationExpression left, final EdmAnnotationExpression right) {
-
- this.left = left;
- this.right = right;
- }
-
- @Override
- public EdmAnnotationExpression getLeftExpression() {
- return left;
- }
-
- @Override
- public EdmAnnotationExpression getRightExpression() {
- return right;
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmAndImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmAndImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmAndImpl.java
index 0b75297..181172b 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmAndImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmAndImpl.java
@@ -6,9 +6,9 @@
* 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
@@ -18,14 +18,13 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmAnd;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
-import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression;
-public class EdmAndImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmAnd {
+public class EdmAndImpl extends AbstractEdmLogicalOrComparisonExpression implements EdmAnd {
- public EdmAndImpl(final EdmAnnotationExpression left, final EdmAnnotationExpression right) {
- super(left, right);
+ public EdmAndImpl(Edm edm, CsdlLogicalOrComparisonExpression csdlExp) {
+ super(edm, csdlExp);
}
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmAnnotationPathImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmAnnotationPathImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmAnnotationPathImpl.java
index 38d70fa..2c6cf50 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmAnnotationPathImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmAnnotationPathImpl.java
@@ -6,9 +6,9 @@
* 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
@@ -18,12 +18,21 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationPath;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlAnnotationPath;
-public class EdmAnnotationPathImpl extends AbstractEdmElementOrAttributeNotation implements EdmAnnotationPath {
+public class EdmAnnotationPathImpl extends AbstractEdmDynamicExpression implements EdmAnnotationPath {
- public EdmAnnotationPathImpl(final String value) {
- super(value);
+ private final CsdlAnnotationPath csdlExp;
+
+ public EdmAnnotationPathImpl(Edm edm, CsdlAnnotationPath csdlExp) {
+ super(edm, "AnnotationPath");
+ this.csdlExp = csdlExp;
}
+ @Override
+ public String getValue() {
+ return csdlExp.getValue();
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmApplyImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmApplyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmApplyImpl.java
index bc0a7af..a185a55 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmApplyImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmApplyImpl.java
@@ -6,9 +6,9 @@
* 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
@@ -18,30 +18,51 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.annotation.EdmApply;
+import org.apache.olingo.commons.api.edm.annotation.EdmExpression;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlApply;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlExpression;
-public class EdmApplyImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmApply {
+public class EdmApplyImpl extends AbstractEdmAnnotatableDynamicExpression implements EdmApply {
- private final String function;
+ private CsdlApply csdlExp;
- private final List<EdmAnnotationExpression> parameters;
+ private String function;
+ private List<EdmExpression> parameters;
- public EdmApplyImpl(final String function, final List<EdmAnnotationExpression> parameters) {
- this.function = function;
- this.parameters = parameters;
+ public EdmApplyImpl(Edm edm, CsdlApply csdlExp) {
+ super(edm, "Apply", csdlExp);
+ this.csdlExp = csdlExp;
}
@Override
public String getFunction() {
+ if (function == null) {
+ if (csdlExp.getFunction() == null) {
+ throw new EdmException("An Apply expression must specify a function.");
+ }
+ function = csdlExp.getFunction();
+ }
return function;
}
@Override
- public List<EdmAnnotationExpression> getParameters() {
+ public List<EdmExpression> getParameters() {
+ if (parameters == null) {
+ List<EdmExpression> localParameters = new ArrayList<EdmExpression>();
+ if (csdlExp.getParameters() != null) {
+ for (CsdlExpression param : csdlExp.getParameters()) {
+ localParameters.add(getExpression(edm, param));
+ }
+ }
+ parameters = Collections.unmodifiableList(localParameters);
+ }
return parameters;
}
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCastImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCastImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCastImpl.java
index 8989200..ce793cf 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCastImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCastImpl.java
@@ -19,27 +19,23 @@
package org.apache.olingo.commons.core.edm.annotation;
import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmType;
import org.apache.olingo.commons.api.edm.annotation.EdmCast;
-import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression;
+import org.apache.olingo.commons.api.edm.annotation.EdmExpression;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlCast;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-public class EdmCastImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmCast {
-
- private final Edm edm;
+public class EdmCastImpl extends AbstractEdmAnnotatableDynamicExpression implements EdmCast {
private final CsdlCast cast;
-
- private final EdmDynamicAnnotationExpression value;
-
+ private EdmExpression value;
private EdmType type;
- public EdmCastImpl(final Edm edm, final CsdlCast cast, final EdmDynamicAnnotationExpression value) {
- this.edm = edm;
- this.cast = cast;
- this.value = value;
+ public EdmCastImpl(final Edm edm, final CsdlCast csdlExp) {
+ super(edm, "Cast", csdlExp);
+ this.cast = csdlExp;
}
@Override
@@ -65,6 +61,9 @@ public class EdmCastImpl extends AbstractEdmAnnotatableDynamicAnnotationExpressi
@Override
public EdmType getType() {
if (type == null) {
+ if (cast.getType() == null) {
+ throw new EdmException("Must specify a type for a Cast expression.");
+ }
final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(cast.getType()).build();
type = typeInfo.getType();
}
@@ -72,7 +71,13 @@ public class EdmCastImpl extends AbstractEdmAnnotatableDynamicAnnotationExpressi
}
@Override
- public EdmDynamicAnnotationExpression getValue() {
+ public EdmExpression getValue() {
+ if (value == null) {
+ if (cast.getValue() == null) {
+ throw new EdmException("Cast expressions require an expression value.");
+ }
+ value = getExpression(edm, cast.getValue());
+ }
return value;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCollectionImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCollectionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCollectionImpl.java
index 41472d0..e8d5fca 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCollectionImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCollectionImpl.java
@@ -6,9 +6,9 @@
* 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
@@ -18,22 +18,37 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmCollection;
+import org.apache.olingo.commons.api.edm.annotation.EdmExpression;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlCollection;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlExpression;
-public class EdmCollectionImpl extends AbstractEdmDynamicAnnotationExpression implements EdmCollection {
+public class EdmCollectionImpl extends AbstractEdmDynamicExpression implements EdmCollection {
- private final List<EdmAnnotationExpression> items;
+ private List<EdmExpression> items;
+ private CsdlCollection csdlCollection;
- public EdmCollectionImpl(final List<EdmAnnotationExpression> items) {
- this.items = items;
+ public EdmCollectionImpl(Edm edm, CsdlCollection csdlExp) {
+ super(edm, "Collection");
+ this.csdlCollection = csdlExp;
}
@Override
- public List<EdmAnnotationExpression> getItems() {
+ public List<EdmExpression> getItems() {
+ if (items == null) {
+ List<EdmExpression> localItems = new ArrayList<EdmExpression>();
+ if (csdlCollection.getItems() != null) {
+ for (CsdlExpression item : csdlCollection.getItems()) {
+ localItems.add(getExpression(edm, item));
+ }
+ }
+ items = Collections.unmodifiableList(localItems);
+ }
return items;
}
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java
deleted file mode 100644
index bbe0dbc..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java
+++ /dev/null
@@ -1,153 +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.commons.core.edm.annotation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Property;
-import org.apache.olingo.commons.api.data.Valuable;
-import org.apache.olingo.commons.api.data.ValueType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
-import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
-import org.apache.olingo.commons.api.edm.annotation.EdmConstantAnnotationExpression;
-import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression;
-import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
-
-public class EdmConstantAnnotationExpressionImpl implements EdmConstantAnnotationExpression {
-
- private final Valuable value;
- private final EdmPrimitiveType type;
-
- public EdmConstantAnnotationExpressionImpl(final CsdlConstantExpression constExprConstruct) {
- if (constExprConstruct.getType() == CsdlConstantExpression.ConstantExpressionType.EnumMember) {
- final List<Property> enumValues = new ArrayList<Property>();
- String enumTypeName = null;
- for (String split : StringUtils.split(constExprConstruct.getValue(), ' ')) {
- final String[] enumSplit = StringUtils.split(split, '/');
- enumTypeName = enumSplit[0];
- enumValues.add(new Property(enumSplit[0], enumSplit[1]));
- }
- if (enumValues.size() == 1) {
- value = enumValues.get(0);
- } else {
- final List<Property> collValue = new ArrayList<Property>();
- for (Property enumValue : enumValues) {
- collValue.add(enumValue);
- }
- value = new Property(enumTypeName, null, ValueType.COLLECTION_ENUM, collValue);
- }
- type = null;
- } else {
- EdmPrimitiveTypeKind kind;
- switch (constExprConstruct.getType()) {
- case Binary:
- kind = EdmPrimitiveTypeKind.Binary;
- break;
- case Bool:
- kind = EdmPrimitiveTypeKind.Boolean;
- break;
- case Date:
- kind = EdmPrimitiveTypeKind.Date;
- break;
- case DateTimeOffset:
- kind = EdmPrimitiveTypeKind.DateTimeOffset;
- break;
- case Decimal:
- kind = EdmPrimitiveTypeKind.Decimal;
- break;
- case Duration:
- kind = EdmPrimitiveTypeKind.Duration;
- break;
- case Float:
- kind = EdmPrimitiveTypeKind.Single;
- break;
- case Guid:
- kind = EdmPrimitiveTypeKind.Guid;
- break;
- case Int:
- kind = EdmPrimitiveTypeKind.Int32;
- break;
- case TimeOfDay:
- kind = EdmPrimitiveTypeKind.TimeOfDay;
- break;
- case String:
- default:
- kind = EdmPrimitiveTypeKind.String;
- }
- type = EdmPrimitiveTypeFactory.getInstance(kind);
- try {
- final Object valueOfString = type.valueOfString(constExprConstruct.getValue(),
- null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null,
- type.getDefaultType());
- value = new Property(kind.getFullQualifiedName().getName(), null, ValueType.PRIMITIVE, valueOfString);
- } catch (EdmPrimitiveTypeException e) {
- throw new IllegalArgumentException(e);
- }
- }
- }
-
- @Override
- public boolean isConstant() {
- return true;
- }
-
- @Override
- public EdmConstantAnnotationExpression asConstant() {
- return this;
- }
-
- @Override
- public boolean isDynamic() {
- return false;
- }
-
- @Override
- public EdmDynamicAnnotationExpression asDynamic() {
- return null;
- }
-
- @Override
- public Valuable getValue() {
- return value;
- }
-
- @Override
- public String getValueAsString() {
- if (value == null) {
- return "";
- } else if (value.isEnum()) {
- return value.toString();
- } else if (value.isGeospatial()) {
- return value.toString();
- } else {
- // TODO: check after copied from ClientPrimitiveValueImpl
- try {
- return type.valueToString(value.getValue(), null, null,
- Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
- } catch (EdmPrimitiveTypeException e) {
- throw new IllegalArgumentException(e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmConstantExpressionImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmConstantExpressionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmConstantExpressionImpl.java
new file mode 100644
index 0000000..8e199ec
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmConstantExpressionImpl.java
@@ -0,0 +1,148 @@
+/*
+ * 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.commons.core.edm.annotation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.data.Property;
+import org.apache.olingo.commons.api.data.Valuable;
+import org.apache.olingo.commons.api.data.ValueType;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.annotation.EdmConstantExpression;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlConstantExpression;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
+
+public class EdmConstantExpressionImpl extends AbstractEdmExpression implements EdmConstantExpression {
+
+ private Valuable value;
+ private EdmPrimitiveType type;
+ private final CsdlConstantExpression constExprConstruct;
+
+ public EdmConstantExpressionImpl(Edm edm, final CsdlConstantExpression constExprConstruct) {
+ super(edm, constExprConstruct.getType().toString());
+ this.constExprConstruct = constExprConstruct;
+ }
+
+ @Override
+ public Valuable getValue() {
+ if(value == null){
+ build();
+ }
+ return value;
+ }
+
+ @Override
+ public String getValueAsString() {
+ return constExprConstruct.getValue();
+
+// if (value == null) {
+// build();
+// }
+// if (value == null) {
+// return "";
+// } else if (value.isEnum()) {
+// return value.getValue().toString();
+// } else if (value.isGeospatial()) {
+// return value.toString();
+// } else {
+// // TODO: check after copied from ClientPrimitiveValueImpl
+// try {
+// return type.valueToString(value.getValue(), null, null,
+// Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
+// } catch (EdmPrimitiveTypeException e) {
+// throw new IllegalArgumentException(e);
+// }
+// }
+ }
+
+ private void build() {
+ if (constExprConstruct.getType() == CsdlConstantExpression.ConstantExpressionType.EnumMember) {
+ // TODO: Delete ProeprtyValue here
+ final List<Property> enumValues = new ArrayList<Property>();
+ String enumTypeName = null;
+ for (String split : StringUtils.split(constExprConstruct.getValue(), ' ')) {
+ final String[] enumSplit = StringUtils.split(split, '/');
+ enumTypeName = enumSplit[0];
+ enumValues.add(new Property(enumSplit[0], null, ValueType.ENUM, enumSplit[1]));
+ }
+ if (enumValues.size() == 1) {
+ value = enumValues.get(0);
+ } else {
+ final List<Property> collValue = new ArrayList<Property>();
+ for (Property enumValue : enumValues) {
+ collValue.add(enumValue);
+ }
+ value = new Property(enumTypeName, null, ValueType.COLLECTION_ENUM, collValue);
+ }
+ type = null;
+ } else {
+ EdmPrimitiveTypeKind kind;
+ switch (constExprConstruct.getType()) {
+ case Binary:
+ kind = EdmPrimitiveTypeKind.Binary;
+ break;
+ case Bool:
+ kind = EdmPrimitiveTypeKind.Boolean;
+ break;
+ case Date:
+ kind = EdmPrimitiveTypeKind.Date;
+ break;
+ case DateTimeOffset:
+ kind = EdmPrimitiveTypeKind.DateTimeOffset;
+ break;
+ case Decimal:
+ kind = EdmPrimitiveTypeKind.Decimal;
+ break;
+ case Duration:
+ kind = EdmPrimitiveTypeKind.Duration;
+ break;
+ case Float:
+ kind = EdmPrimitiveTypeKind.Single;
+ break;
+ case Guid:
+ kind = EdmPrimitiveTypeKind.Guid;
+ break;
+ case Int:
+ kind = EdmPrimitiveTypeKind.Int32;
+ break;
+ case TimeOfDay:
+ kind = EdmPrimitiveTypeKind.TimeOfDay;
+ break;
+ case String:
+ default:
+ kind = EdmPrimitiveTypeKind.String;
+ }
+ type = EdmPrimitiveTypeFactory.getInstance(kind);
+ try {
+ final Object valueOfString = type.valueOfString(constExprConstruct.getValue(),
+ null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null,
+ type.getDefaultType());
+ value = new Property(kind.getFullQualifiedName().getName(), null, ValueType.PRIMITIVE, valueOfString);
+ } catch (EdmPrimitiveTypeException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmEqImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmEqImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmEqImpl.java
index bd88887..bf530c1 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmEqImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmEqImpl.java
@@ -18,13 +18,13 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmEq;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression;
-public class EdmEqImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmEq {
+public class EdmEqImpl extends AbstractEdmLogicalOrComparisonExpression implements EdmEq {
- public EdmEqImpl(final EdmAnnotationExpression left, final EdmAnnotationExpression right) {
- super(left, right);
+ public EdmEqImpl(Edm edm, CsdlLogicalOrComparisonExpression csdlExp) {
+ super(edm, csdlExp);
}
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmGeImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmGeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmGeImpl.java
index ace7a33..3119631 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmGeImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmGeImpl.java
@@ -6,9 +6,9 @@
* 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
@@ -18,13 +18,13 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmGe;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression;
-public class EdmGeImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmGe {
+public class EdmGeImpl extends AbstractEdmLogicalOrComparisonExpression implements EdmGe {
- public EdmGeImpl(final EdmAnnotationExpression left, final EdmAnnotationExpression right) {
- super(left, right);
+ public EdmGeImpl(Edm edm, CsdlLogicalOrComparisonExpression csdlExp) {
+ super(edm, csdlExp);
}
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmGtImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmGtImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmGtImpl.java
index feed77c..08434e6 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmGtImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmGtImpl.java
@@ -18,13 +18,13 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmGt;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression;
-public class EdmGtImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmGt {
+public class EdmGtImpl extends AbstractEdmLogicalOrComparisonExpression implements EdmGt {
- public EdmGtImpl(final EdmAnnotationExpression left, final EdmAnnotationExpression right) {
- super(left, right);
+ public EdmGtImpl(Edm edm, CsdlLogicalOrComparisonExpression csdlExp) {
+ super(edm, csdlExp);
}
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIfImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIfImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIfImpl.java
index e868e34..e33bd11 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIfImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIfImpl.java
@@ -6,9 +6,9 @@
* 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
@@ -18,37 +18,52 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmException;
+import org.apache.olingo.commons.api.edm.annotation.EdmExpression;
import org.apache.olingo.commons.api.edm.annotation.EdmIf;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlIf;
-public class EdmIfImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmIf {
+public class EdmIfImpl extends AbstractEdmAnnotatableDynamicExpression implements EdmIf {
- private final EdmAnnotationExpression guard;
+ private EdmExpression guard;
+ private EdmExpression _then;
+ private EdmExpression _else;
+ private CsdlIf csdlExp;
- private final EdmAnnotationExpression _then;
-
- private final EdmAnnotationExpression _else;
-
- public EdmIfImpl(final EdmAnnotationExpression guard,
- final EdmAnnotationExpression _then, final EdmAnnotationExpression _else) {
-
- this.guard = guard;
- this._then = _then;
- this._else = _else;
+ public EdmIfImpl(Edm edm, CsdlIf csdlExp) {
+ super(edm, "If", csdlExp);
+ this.csdlExp = csdlExp;
}
@Override
- public EdmAnnotationExpression getGuard() {
+ public EdmExpression getGuard() {
+ if (guard == null) {
+ if (csdlExp.getGuard() == null) {
+ throw new EdmException("Guard clause of an if expression must not be null");
+ }
+ guard = getExpression(edm, csdlExp.getGuard());
+ }
return guard;
}
@Override
- public EdmAnnotationExpression getThen() {
+ public EdmExpression getThen() {
+ if (_then == null) {
+ if (csdlExp.getThen() == null) {
+ throw new EdmException("Then clause of an if expression must not be null");
+ }
+ _then = getExpression(edm, csdlExp.getThen());
+ }
return _then;
}
@Override
- public EdmAnnotationExpression getElse() {
+ public EdmExpression getElse() {
+ // The else clause might be null in certain conditions so we can`t evaluate this here.
+ if (_else == null && csdlExp.getElse() != null) {
+ _else = getExpression(edm, csdlExp.getElse());
+ }
return _else;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIsOfImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIsOfImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIsOfImpl.java
index 9732a0a..aa4ed16 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIsOfImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIsOfImpl.java
@@ -19,27 +19,25 @@
package org.apache.olingo.commons.core.edm.annotation;
import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmException;
import org.apache.olingo.commons.api.edm.EdmType;
-import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression;
+import org.apache.olingo.commons.api.edm.annotation.EdmExpression;
import org.apache.olingo.commons.api.edm.annotation.EdmIsOf;
import org.apache.olingo.commons.api.edm.geo.SRID;
import org.apache.olingo.commons.api.edm.provider.annotation.CsdlIsOf;
import org.apache.olingo.commons.core.edm.EdmTypeInfo;
-public class EdmIsOfImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmIsOf {
+public class EdmIsOfImpl extends AbstractEdmAnnotatableDynamicExpression implements EdmIsOf {
private final Edm edm;
-
private final CsdlIsOf isOf;
-
- private final EdmDynamicAnnotationExpression value;
-
+ private EdmExpression value;
private EdmType type;
- public EdmIsOfImpl(final Edm edm, final CsdlIsOf isOf, final EdmDynamicAnnotationExpression value) {
+ public EdmIsOfImpl(final Edm edm, final CsdlIsOf isOf) {
+ super(edm, "IsOf", isOf);
this.edm = edm;
this.isOf = isOf;
- this.value = value;
}
@Override
@@ -65,6 +63,9 @@ public class EdmIsOfImpl extends AbstractEdmAnnotatableDynamicAnnotationExpressi
@Override
public EdmType getType() {
if (type == null) {
+ if(isOf.getType() == null){
+ throw new EdmException("Must specify a type for an IsOf expression.");
+ }
final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(isOf.getType()).build();
type = typeInfo.getType();
}
@@ -72,7 +73,13 @@ public class EdmIsOfImpl extends AbstractEdmAnnotatableDynamicAnnotationExpressi
}
@Override
- public EdmDynamicAnnotationExpression getValue() {
+ public EdmExpression getValue() {
+ if(value == null){
+ if(isOf.getValue() == null){
+ throw new EdmException("IsOf expressions require an expression value.");
+ }
+ value = getExpression(edm, isOf.getValue());
+ }
return value;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLabeledElementImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLabeledElementImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLabeledElementImpl.java
index d921017..babe388 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLabeledElementImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLabeledElementImpl.java
@@ -6,9 +6,9 @@
* 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
@@ -18,28 +18,39 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
-import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmException;
+import org.apache.olingo.commons.api.edm.annotation.EdmExpression;
import org.apache.olingo.commons.api.edm.annotation.EdmLabeledElement;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLabeledElement;
public class EdmLabeledElementImpl
-extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmLabeledElement {
+ extends AbstractEdmAnnotatableDynamicExpression implements EdmLabeledElement {
- private final String name;
+ private EdmExpression value;
+ private CsdlLabeledElement csdlLableledElement;
- private final EdmDynamicAnnotationExpression value;
-
- public EdmLabeledElementImpl(final String name, final EdmDynamicAnnotationExpression value) {
- this.name = name;
- this.value = value;
+ public EdmLabeledElementImpl(Edm edm, CsdlLabeledElement csdlExp) {
+ super(edm, "LabeledElement", csdlExp);
+ this.csdlLableledElement = csdlExp;
}
@Override
public String getName() {
- return name;
+ if (csdlLableledElement.getName() == null) {
+ throw new EdmException("The LabeledElement expression must have a name attribute.");
+ }
+ return csdlLableledElement.getName();
}
@Override
- public EdmDynamicAnnotationExpression getValue() {
+ public EdmExpression getValue() {
+ if (value == null) {
+ if (csdlLableledElement.getValue() == null) {
+ throw new EdmException("The LabeledElement expression must have a child expression");
+ }
+ value = getExpression(edm, csdlLableledElement.getValue());
+ }
return value;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLabeledElementReferenceImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLabeledElementReferenceImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLabeledElementReferenceImpl.java
index 4eab4cb..5c1887c 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLabeledElementReferenceImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLabeledElementReferenceImpl.java
@@ -6,9 +6,9 @@
* 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
@@ -18,13 +18,21 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmLabeledElementReference;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLabeledElementReference;
-public class EdmLabeledElementReferenceImpl
-extends AbstractEdmElementOrAttributeNotation implements EdmLabeledElementReference {
+public class EdmLabeledElementReferenceImpl extends AbstractEdmDynamicExpression implements EdmLabeledElementReference {
- public EdmLabeledElementReferenceImpl(final String value) {
- super(value);
+ private final CsdlLabeledElementReference csdlExp;
+
+ public EdmLabeledElementReferenceImpl(Edm edm, CsdlLabeledElementReference csdlExp) {
+ super(edm, "LabeledElementReference");
+ this.csdlExp = csdlExp;
}
+ @Override
+ public String getValue() {
+ return csdlExp.getValue();
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLeImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLeImpl.java
index 9a1f51d..84be8f3 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLeImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLeImpl.java
@@ -18,14 +18,13 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
-import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmLe;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression;
-public class EdmLeImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmLe {
+public class EdmLeImpl extends AbstractEdmLogicalOrComparisonExpression implements EdmLe {
- public EdmLeImpl(final EdmAnnotationExpression left, final EdmAnnotationExpression right) {
- super(left, right);
+ public EdmLeImpl(Edm edm, CsdlLogicalOrComparisonExpression csdlExp) {
+ super(edm, csdlExp);
}
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLtImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLtImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLtImpl.java
index c59b877..0adea0a 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLtImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLtImpl.java
@@ -18,13 +18,13 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmLt;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression;
-public class EdmLtImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmLt {
+public class EdmLtImpl extends AbstractEdmLogicalOrComparisonExpression implements EdmLt {
- public EdmLtImpl(final EdmAnnotationExpression left, final EdmAnnotationExpression right) {
- super(left, right);
+ public EdmLtImpl(Edm edm, CsdlLogicalOrComparisonExpression csdlExp) {
+ super(edm, csdlExp);
}
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNavigationPropertyPathImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNavigationPropertyPathImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNavigationPropertyPathImpl.java
index a1a7785..7d09276 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNavigationPropertyPathImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNavigationPropertyPathImpl.java
@@ -6,9 +6,9 @@
* 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
@@ -18,13 +18,21 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmNavigationPropertyPath;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlNavigationPropertyPath;
-public class EdmNavigationPropertyPathImpl
-extends AbstractEdmElementOrAttributeNotation implements EdmNavigationPropertyPath {
+public class EdmNavigationPropertyPathImpl extends AbstractEdmDynamicExpression implements EdmNavigationPropertyPath {
- public EdmNavigationPropertyPathImpl(final String value) {
- super(value);
+ private final CsdlNavigationPropertyPath csdlExp;
+
+ public EdmNavigationPropertyPathImpl(Edm edm, CsdlNavigationPropertyPath csdlExp) {
+ super(edm, "NavigationPropertyPath");
+ this.csdlExp = csdlExp;
}
+ @Override
+ public String getValue() {
+ return csdlExp.getValue();
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNeImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNeImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNeImpl.java
index aebadf2..c55e01a 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNeImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNeImpl.java
@@ -18,13 +18,13 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmNe;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression;
-public class EdmNeImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmNe {
+public class EdmNeImpl extends AbstractEdmLogicalOrComparisonExpression implements EdmNe {
- public EdmNeImpl(final EdmAnnotationExpression left, final EdmAnnotationExpression right) {
- super(left, right);
+ public EdmNeImpl(Edm edm, CsdlLogicalOrComparisonExpression csdlExp) {
+ super(edm, csdlExp);
}
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNotImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNotImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNotImpl.java
index b34c255..ca1235d 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNotImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNotImpl.java
@@ -18,21 +18,13 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
-import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmNot;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression;
-public class EdmNotImpl extends AbstractEdmDynamicAnnotationExpression implements EdmNot {
+public class EdmNotImpl extends AbstractEdmLogicalOrComparisonExpression implements EdmNot {
- private final EdmAnnotationExpression expression;
-
- public EdmNotImpl(final EdmAnnotationExpression expression) {
- this.expression = expression;
- }
-
- @Override
- public EdmAnnotationExpression getExpression() {
- return expression;
+ public EdmNotImpl(Edm edm, CsdlLogicalOrComparisonExpression csdlExp) {
+ super(edm, csdlExp);
}
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNullImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNullImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNullImpl.java
index f8b127e..b1151fc 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNullImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNullImpl.java
@@ -18,8 +18,13 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmNull;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlNull;
-public class EdmNullImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmNull {
- // No additional methods needed for now.
+public class EdmNullImpl extends AbstractEdmAnnotatableDynamicExpression implements EdmNull {
+
+ public EdmNullImpl(Edm edm, CsdlNull csdlExp) {
+ super(edm, "Null", csdlExp);
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmOrImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmOrImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmOrImpl.java
index 30cc51d..a06da92 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmOrImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmOrImpl.java
@@ -18,13 +18,13 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmOr;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlLogicalOrComparisonExpression;
-public class EdmOrImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmOr {
+public class EdmOrImpl extends AbstractEdmLogicalOrComparisonExpression implements EdmOr {
- public EdmOrImpl(final EdmAnnotationExpression left, final EdmAnnotationExpression right) {
- super(left, right);
+ public EdmOrImpl(Edm edm, CsdlLogicalOrComparisonExpression csdlExp) {
+ super(edm, csdlExp);
}
-
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPathImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPathImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPathImpl.java
index 669609c..35c7d30 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPathImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPathImpl.java
@@ -6,9 +6,9 @@
* 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
@@ -18,12 +18,21 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmPath;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlPath;
-public class EdmPathImpl extends AbstractEdmElementOrAttributeNotation implements EdmPath {
+public class EdmPathImpl extends AbstractEdmDynamicExpression implements EdmPath {
- public EdmPathImpl(final String value) {
- super(value);
+ private final CsdlPath csdlExp;
+
+ public EdmPathImpl(Edm edm, CsdlPath csdlExp) {
+ super(edm, "Path");
+ this.csdlExp = csdlExp;
}
+ @Override
+ public String getValue() {
+ return csdlExp.getValue();
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPropertyPathImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPropertyPathImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPropertyPathImpl.java
index 7809b34..1f18616 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPropertyPathImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPropertyPathImpl.java
@@ -18,12 +18,21 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
+import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.annotation.EdmPropertyPath;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlPropertyPath;
-public class EdmPropertyPathImpl extends AbstractEdmElementOrAttributeNotation implements EdmPropertyPath {
+public class EdmPropertyPathImpl extends AbstractEdmDynamicExpression implements EdmPropertyPath {
- public EdmPropertyPathImpl(final String value) {
- super(value);
+ private final CsdlPropertyPath csdlExp;
+
+ public EdmPropertyPathImpl(Edm edm, CsdlPropertyPath csdlExp) {
+ super(edm, "PropertyPath");
+ this.csdlExp = csdlExp;
}
+ @Override
+ public String getValue() {
+ return csdlExp.getValue();
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/41210245/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPropertyValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPropertyValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPropertyValueImpl.java
index 08307ea..97406d4 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPropertyValueImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPropertyValueImpl.java
@@ -6,9 +6,9 @@
* 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
@@ -18,28 +18,39 @@
*/
package org.apache.olingo.commons.core.edm.annotation;
-import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression;
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.edm.EdmException;
+import org.apache.olingo.commons.api.edm.annotation.EdmExpression;
import org.apache.olingo.commons.api.edm.annotation.EdmPropertyValue;
+import org.apache.olingo.commons.api.edm.provider.annotation.CsdlPropertyValue;
public class EdmPropertyValueImpl
-extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmPropertyValue {
+ extends AbstractEdmAnnotatableDynamicExpression implements EdmPropertyValue {
- private final String property;
+ private EdmExpression value;
+ private CsdlPropertyValue csdlExp;
- private final EdmAnnotationExpression value;
-
- public EdmPropertyValueImpl(final String property, final EdmAnnotationExpression value) {
- this.property = property;
- this.value = value;
+ public EdmPropertyValueImpl(Edm edm, CsdlPropertyValue csdlExp) {
+ super(edm, "PropertyValue", csdlExp);
+ this.csdlExp = csdlExp;
}
@Override
public String getProperty() {
- return property;
+ if (csdlExp.getProperty() == null) {
+ throw new EdmException("PropertyValue expressions require a referenced property value.");
+ }
+ return csdlExp.getProperty();
}
@Override
- public EdmAnnotationExpression getValue() {
+ public EdmExpression getValue() {
+ if (value == null) {
+ if (csdlExp.getValue() == null) {
+ throw new EdmException("PropertyValue expressions require an expression value.");
+ }
+ value = getExpression(edm, csdlExp.getValue());
+ }
return value;
}