diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java index fccaa54e0..759636d31 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonODataClient.java @@ -23,7 +23,7 @@ import org.apache.olingo.client.api.communication.header.ODataPreferences; import org.apache.olingo.client.api.communication.request.batch.CommonBatchRequestFactory; import org.apache.olingo.client.api.communication.request.cud.CommonCUDRequestFactory; import org.apache.olingo.client.api.communication.request.cud.CommonUpdateType; -import org.apache.olingo.client.api.communication.request.invoke.CommonInvokeRequestFactory; +import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory; import org.apache.olingo.client.api.communication.request.retrieve.CommonRetrieveRequestFactory; import org.apache.olingo.client.api.communication.request.streamed.CommonStreamedRequestFactory; import org.apache.olingo.client.api.op.ClientODataDeserializer; @@ -73,7 +73,7 @@ public interface CommonODataClient { CommonStreamedRequestFactory getStreamedRequestFactory(); - CommonInvokeRequestFactory getInvokeRequestFactory(); + InvokeRequestFactory getInvokeRequestFactory(); CommonBatchRequestFactory getBatchRequestFactory(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/CommonInvokeRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/InvokeRequestFactory.java similarity index 96% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/CommonInvokeRequestFactory.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/InvokeRequestFactory.java index f6839b439..e25a168cd 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/CommonInvokeRequestFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/InvokeRequestFactory.java @@ -28,7 +28,7 @@ import org.apache.olingo.commons.api.edm.EdmOperation; /** * OData request factory class. */ -public interface CommonInvokeRequestFactory extends Serializable { +public interface InvokeRequestFactory extends Serializable { /** * Gets an invoke request instance. diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/CommonProperty.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/CommonProperty.java index b11de1046..156631cfd 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/CommonProperty.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/CommonProperty.java @@ -18,6 +18,8 @@ */ package org.apache.olingo.client.api.edm.xml; +import org.apache.olingo.commons.api.edm.geo.SRID; + public interface CommonProperty extends Named { String getType(); @@ -34,6 +36,6 @@ public interface CommonProperty extends Named { boolean isUnicode(); - String getSrid(); + SRID getSrid(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/Schema.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/Schema.java index cee0c9ace..07a1b13a0 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/Schema.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/Schema.java @@ -32,9 +32,9 @@ public interface Schema { EnumType getEnumType(String name); - List getAnnotationsList(); + List getAnnotationGroups(); - CommonAnnotations getAnnotationsList(String target); + CommonAnnotations getAnnotationGroup(String target); List getComplexTypes(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v3/Parameter.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v3/Parameter.java index a5f5c88a5..1d89b58bf 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v3/Parameter.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v3/Parameter.java @@ -18,7 +18,9 @@ */ package org.apache.olingo.client.api.edm.xml.v3; -public interface Parameter extends org.apache.olingo.client.api.edm.xml.CommonParameter { +import org.apache.olingo.client.api.edm.xml.CommonParameter; + +public interface Parameter extends CommonParameter { ParameterMode getMode(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Action.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Action.java index 1591c5fd0..996cac887 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Action.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Action.java @@ -22,7 +22,7 @@ import java.util.List; import org.apache.olingo.client.api.edm.xml.Named; -public interface Action extends Named { +public interface Action extends Named, Annotatable { boolean isBound(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/AnnotatedEdmItem.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Annotatable.java similarity index 90% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/AnnotatedEdmItem.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Annotatable.java index e48862931..4f5e35709 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/AnnotatedEdmItem.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Annotatable.java @@ -18,7 +18,9 @@ */ package org.apache.olingo.client.api.edm.xml.v4; -public interface AnnotatedEdmItem { +import java.util.List; - Annotation getAnnotation(); +public interface Annotatable { + + List getAnnotations(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Annotation.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Annotation.java index b70e729de..69c437ebc 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Annotation.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Annotation.java @@ -18,16 +18,13 @@ */ package org.apache.olingo.client.api.edm.xml.v4; -import org.apache.olingo.client.api.edm.xml.v4.annotation.ConstExprConstruct; -import org.apache.olingo.client.api.edm.xml.v4.annotation.DynExprConstruct; +import org.apache.olingo.client.api.edm.xml.v4.annotation.AnnotationExpression; -public interface Annotation { +public interface Annotation extends Annotatable { String getTerm(); String getQualifier(); - ConstExprConstruct getConstExpr(); - - DynExprConstruct getDynExpr(); + AnnotationExpression getExpression(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/BindingTarget.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/BindingTarget.java index f4d8491cf..171c41665 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/BindingTarget.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/BindingTarget.java @@ -22,7 +22,7 @@ import java.util.List; import org.apache.olingo.client.api.edm.xml.Named; -public interface BindingTarget extends Named, AnnotatedEdmItem { +public interface BindingTarget extends Named, Annotatable { List getNavigationPropertyBindings(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/ComplexType.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/ComplexType.java index bc939114f..a72a32934 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/ComplexType.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/ComplexType.java @@ -20,7 +20,7 @@ package org.apache.olingo.client.api.edm.xml.v4; import java.util.List; -public interface ComplexType extends org.apache.olingo.client.api.edm.xml.ComplexType, AnnotatedEdmItem { +public interface ComplexType extends org.apache.olingo.client.api.edm.xml.ComplexType, Annotatable { boolean isAbstractEntityType(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/EntityContainer.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/EntityContainer.java index cb164ccf9..02c51b104 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/EntityContainer.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/EntityContainer.java @@ -20,7 +20,7 @@ package org.apache.olingo.client.api.edm.xml.v4; import java.util.List; -public interface EntityContainer extends org.apache.olingo.client.api.edm.xml.EntityContainer { +public interface EntityContainer extends org.apache.olingo.client.api.edm.xml.EntityContainer, Annotatable { @Override EntitySet getEntitySet(String name); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/IncludeAnnotations.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/IncludeAnnotations.java index b200ee963..2b822a4c4 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/IncludeAnnotations.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/IncludeAnnotations.java @@ -22,7 +22,7 @@ public interface IncludeAnnotations { String getQualifier(); - String getTargeyNamespace(); + String getTargetNamespace(); String getTermNamespace(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/NavigationProperty.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/NavigationProperty.java index b6e2fcc16..0eaaba728 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/NavigationProperty.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/NavigationProperty.java @@ -23,7 +23,7 @@ import org.apache.olingo.client.api.edm.xml.OnDelete; import java.util.List; import org.apache.olingo.client.api.edm.xml.CommonNavigationProperty; -public interface NavigationProperty extends CommonNavigationProperty, AnnotatedEdmItem { +public interface NavigationProperty extends CommonNavigationProperty, Annotatable { String getType(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/OperationImport.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/OperationImport.java index 292df861b..a86d5cc06 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/OperationImport.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/OperationImport.java @@ -20,7 +20,7 @@ package org.apache.olingo.client.api.edm.xml.v4; import org.apache.olingo.client.api.edm.xml.Named; -public interface OperationImport extends Named, AnnotatedEdmItem { +public interface OperationImport extends Named, Annotatable { String getEntitySet(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Parameter.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Parameter.java index 0b8b975de..127fa7c6a 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Parameter.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Parameter.java @@ -18,7 +18,10 @@ */ package org.apache.olingo.client.api.edm.xml.v4; -public interface Parameter extends org.apache.olingo.client.api.edm.xml.CommonParameter { +import org.apache.olingo.client.api.edm.xml.CommonParameter; +import org.apache.olingo.commons.api.edm.geo.SRID; - String getSrid(); +public interface Parameter extends CommonParameter, Annotatable { + + SRID getSrid(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Property.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Property.java index 20d909a38..74400cdcf 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Property.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Property.java @@ -20,6 +20,6 @@ package org.apache.olingo.client.api.edm.xml.v4; import org.apache.olingo.client.api.edm.xml.CommonProperty; -public interface Property extends CommonProperty, AnnotatedEdmItem { +public interface Property extends CommonProperty, Annotatable { } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/ReferentialConstraint.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/ReferentialConstraint.java index 98c64c576..5e2993265 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/ReferentialConstraint.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/ReferentialConstraint.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.client.api.edm.xml.v4; -public interface ReferentialConstraint { +public interface ReferentialConstraint extends Annotatable { String getProperty(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/ReturnType.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/ReturnType.java index 6ace4fe1b..50ffc75bd 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/ReturnType.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/ReturnType.java @@ -18,6 +18,8 @@ */ package org.apache.olingo.client.api.edm.xml.v4; +import org.apache.olingo.commons.api.edm.geo.SRID; + public interface ReturnType { Integer getMaxLength(); @@ -26,7 +28,7 @@ public interface ReturnType { Integer getScale(); - String getSrid(); + SRID getSrid(); String getType(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Schema.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Schema.java index 961b27e1f..1d9063511 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Schema.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Schema.java @@ -19,8 +19,9 @@ package org.apache.olingo.client.api.edm.xml.v4; import java.util.List; +import java.util.Map; -public interface Schema extends org.apache.olingo.client.api.edm.xml.Schema, AnnotatedEdmItem { +public interface Schema extends org.apache.olingo.client.api.edm.xml.Schema, Annotatable { @Override List getEntityContainers(); @@ -43,12 +44,16 @@ public interface Schema extends org.apache.olingo.client.api.edm.xml.Schema, Ann List getActions(String name); - List getAnnotations(); + Annotation getAnnotation(String term); + + Map getAnnotatables(); List getFunctions(); List getFunctions(String name); + Term getTerm(String name); + List getTerms(); TypeDefinition getTypeDefinition(String name); @@ -56,9 +61,9 @@ public interface Schema extends org.apache.olingo.client.api.edm.xml.Schema, Ann List getTypeDefinitions(); @Override - List getAnnotationsList(); + List getAnnotationGroups(); @Override - Annotations getAnnotationsList(String target); + Annotations getAnnotationGroup(String target); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Term.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Term.java index 59cdd2930..6ed5b9fc5 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Term.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/Term.java @@ -19,12 +19,12 @@ package org.apache.olingo.client.api.edm.xml.v4; import java.util.List; - import org.apache.olingo.client.api.edm.xml.Named; +import org.apache.olingo.commons.api.edm.geo.SRID; -public interface Term extends Named { +public interface Term extends Named, Annotatable { - List getAppliesTo(); + List getAppliesTo(); String getBaseTerm(); @@ -36,7 +36,7 @@ public interface Term extends Named { Integer getScale(); - String getSrid(); + SRID getSrid(); String getType(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/TypeDefinition.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/TypeDefinition.java index 568c7376d..20234c24d 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/TypeDefinition.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/TypeDefinition.java @@ -21,8 +21,9 @@ package org.apache.olingo.client.api.edm.xml.v4; import java.util.List; import org.apache.olingo.client.api.edm.xml.Named; +import org.apache.olingo.commons.api.edm.geo.SRID; -public interface TypeDefinition extends Named { +public interface TypeDefinition extends Named, Annotatable { List getAnnotations(); @@ -32,7 +33,7 @@ public interface TypeDefinition extends Named { Integer getScale(); - String getSrid(); + SRID getSrid(); String getUnderlyingType(); diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/v4/InvokeRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/AnnotationExpression.java similarity index 77% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/v4/InvokeRequestFactory.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/AnnotationExpression.java index c9278f426..fb96d9da9 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/v4/InvokeRequestFactory.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/AnnotationExpression.java @@ -16,9 +16,15 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.communication.request.invoke.v4; +package org.apache.olingo.client.api.edm.xml.v4.annotation; -import org.apache.olingo.client.api.communication.request.invoke.CommonInvokeRequestFactory; +public interface AnnotationExpression { -public interface InvokeRequestFactory extends CommonInvokeRequestFactory { + boolean isConstant(); + + ConstantAnnotationExpression asConstant(); + + boolean isDynamic(); + + DynamicAnnotationExpression asDynamic(); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AnnotationPath.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/AnnotationPath.java similarity index 80% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AnnotationPath.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/AnnotationPath.java index 50274b511..225ea8f88 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AnnotationPath.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/AnnotationPath.java @@ -16,10 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.core.edm.xml.v4.annotation; +package org.apache.olingo.client.api.edm.xml.v4.annotation; -public class AnnotationPath extends AbstractElOrAttrConstruct { +public interface AnnotationPath extends DynamicAnnotationExpression { - private static final long serialVersionUID = 6198019768659098819L; + String getValue(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Apply.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Apply.java new file mode 100644 index 000000000..7315ad947 --- /dev/null +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Apply.java @@ -0,0 +1,29 @@ +/* + * 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.client.api.edm.xml.v4.annotation; + +import java.util.List; +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; + +public interface Apply extends DynamicAnnotationExpression, Annotatable { + + String getFunction(); + + List getParameters(); +} diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Cast.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Cast.java new file mode 100644 index 000000000..c580de0fa --- /dev/null +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Cast.java @@ -0,0 +1,38 @@ +/* + * 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.client.api.edm.xml.v4.annotation; + +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; +import org.apache.olingo.commons.api.edm.geo.SRID; + +public interface Cast extends DynamicAnnotationExpression, Annotatable { + + Integer getMaxLength(); + + Integer getPrecision(); + + Integer getScale(); + + SRID getSrid(); + + String getType(); + + DynamicAnnotationExpression getValue(); + +} diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Collection.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Collection.java new file mode 100644 index 000000000..4a6f61d77 --- /dev/null +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Collection.java @@ -0,0 +1,27 @@ +/* + * 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.client.api.edm.xml.v4.annotation; + +import java.util.List; + +public interface Collection extends DynamicAnnotationExpression { + + List getItems(); + +} diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/ConstExprConstruct.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/ConstantAnnotationExpression.java similarity index 94% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/ConstExprConstruct.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/ConstantAnnotationExpression.java index e51b9e36c..2011febf0 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/ConstExprConstruct.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/ConstantAnnotationExpression.java @@ -18,7 +18,7 @@ */ package org.apache.olingo.client.api.edm.xml.v4.annotation; -public interface ConstExprConstruct extends ExprConstruct { +public interface ConstantAnnotationExpression extends AnnotationExpression { public enum Type { diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/DynamicAnnotationExpression.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/DynamicAnnotationExpression.java new file mode 100644 index 000000000..b45c20bb4 --- /dev/null +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/DynamicAnnotationExpression.java @@ -0,0 +1,91 @@ +/* + * 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.client.api.edm.xml.v4.annotation; + +public interface DynamicAnnotationExpression extends AnnotationExpression { + + boolean isNot(); + + Not asNot(); + + boolean isTwoParamsOp(); + + TwoParamsOpDynamicAnnotationExpression asTwoParamsOp(); + + boolean isAnnotationPath(); + + AnnotationPath asAnnotationPath(); + + boolean isApply(); + + Apply asApply(); + + boolean isCast(); + + Cast asCast(); + + boolean isCollection(); + + Collection asCollection(); + + boolean isIf(); + + If asIf(); + + boolean isIsOf(); + + IsOf asIsOf(); + + boolean isLabeledElement(); + + LabeledElement asLabeledElement(); + + boolean isLabeledElementReference(); + + LabeledElementReference asLabeledElementReference(); + + boolean isNull(); + + Null asNull(); + + boolean isNavigationPropertyPath(); + + NavigationPropertyPath asNavigationPropertyPath(); + + boolean isPath(); + + Path asPath(); + + boolean isPropertyPath(); + + PropertyPath asPropertyPath(); + + boolean isPropertyValue(); + + PropertyValue asPropertyValue(); + + boolean isRecord(); + + Record asRecord(); + + boolean isUrlRef(); + + UrlRef asUrlRef(); + +} diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/If.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/If.java new file mode 100644 index 000000000..48cb76a5c --- /dev/null +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/If.java @@ -0,0 +1,31 @@ +/* + * 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.client.api.edm.xml.v4.annotation; + +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; + +public interface If extends DynamicAnnotationExpression, Annotatable { + + AnnotationExpression getGuard(); + + AnnotationExpression getThen(); + + AnnotationExpression getElse(); + +} diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/IsOf.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/IsOf.java new file mode 100644 index 000000000..ad6ae2f92 --- /dev/null +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/IsOf.java @@ -0,0 +1,38 @@ +/* + * 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.client.api.edm.xml.v4.annotation; + +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; +import org.apache.olingo.commons.api.edm.geo.SRID; + +public interface IsOf extends DynamicAnnotationExpression, Annotatable { + + Integer getMaxLength(); + + Integer getPrecision(); + + Integer getScale(); + + SRID getSrid(); + + String getType(); + + DynamicAnnotationExpression getValue(); + +} diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/LabeledElement.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/LabeledElement.java new file mode 100644 index 000000000..1e89a9952 --- /dev/null +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/LabeledElement.java @@ -0,0 +1,29 @@ +/* + * 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.client.api.edm.xml.v4.annotation; + +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; + +public interface LabeledElement extends DynamicAnnotationExpression, Annotatable { + + String getName(); + + DynamicAnnotationExpression getValue(); + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/LabeledElementReference.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/LabeledElementReference.java similarity index 80% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/LabeledElementReference.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/LabeledElementReference.java index d33c95532..f34a42ca7 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/LabeledElementReference.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/LabeledElementReference.java @@ -16,10 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.core.edm.xml.v4.annotation; +package org.apache.olingo.client.api.edm.xml.v4.annotation; -public class LabeledElementReference extends AbstractElOrAttrConstruct { +public interface LabeledElementReference extends DynamicAnnotationExpression { - private static final long serialVersionUID = 3649068436729494270L; + String getValue(); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/NavigationPropertyPath.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/NavigationPropertyPath.java similarity index 80% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/NavigationPropertyPath.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/NavigationPropertyPath.java index f6b21d106..bcbf334be 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/NavigationPropertyPath.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/NavigationPropertyPath.java @@ -16,10 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.core.edm.xml.v4.annotation; +package org.apache.olingo.client.api.edm.xml.v4.annotation; -public class NavigationPropertyPath extends AbstractElOrAttrConstruct { +public interface NavigationPropertyPath extends DynamicAnnotationExpression { - private static final long serialVersionUID = -8066400142504963043L; + String getValue(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/ExprConstruct.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Not.java similarity index 89% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/ExprConstruct.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Not.java index 4de83a7ce..6e3fbfed0 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/ExprConstruct.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Not.java @@ -18,6 +18,7 @@ */ package org.apache.olingo.client.api.edm.xml.v4.annotation; -public interface ExprConstruct { +public interface Not extends DynamicAnnotationExpression { + DynamicAnnotationExpression getExpression(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Null.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Null.java new file mode 100644 index 000000000..2e832413a --- /dev/null +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Null.java @@ -0,0 +1,25 @@ +/* + * 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.client.api.edm.xml.v4.annotation; + +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; + +public interface Null extends DynamicAnnotationExpression, Annotatable { + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Path.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Path.java similarity index 81% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Path.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Path.java index b9c4136a1..9500207c1 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Path.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Path.java @@ -16,10 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.core.edm.xml.v4.annotation; +package org.apache.olingo.client.api.edm.xml.v4.annotation; -public class Path extends AbstractElOrAttrConstruct { +public interface Path extends DynamicAnnotationExpression { - private static final long serialVersionUID = -2551058493469292082L; + String getValue(); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyPath.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/PropertyPath.java similarity index 80% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyPath.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/PropertyPath.java index ca47253e8..3ecb01986 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyPath.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/PropertyPath.java @@ -16,10 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.core.edm.xml.v4.annotation; +package org.apache.olingo.client.api.edm.xml.v4.annotation; -public class PropertyPath extends AbstractElOrAttrConstruct { +public interface PropertyPath extends DynamicAnnotationExpression { - private static final long serialVersionUID = 2328584735437885159L; + String getValue(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/CSDLElement.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/PropertyValue.java similarity index 75% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/CSDLElement.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/PropertyValue.java index 18489e7a3..74b77217a 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/CSDLElement.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/PropertyValue.java @@ -16,22 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.edm.xml.v4; +package org.apache.olingo.client.api.edm.xml.v4.annotation; -public enum CSDLElement { +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; - ActionImport, - ComplexType, - EntityContainer, - EntitySet, - EntityType, - EnumType, - FunctionImport, - Member, - NavigationProperty, - Property, - Singleton, - Term, - TypeDefinition +public interface PropertyValue extends DynamicAnnotationExpression, Annotatable { + + String getProperty(); + + AnnotationExpression getValue(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Record.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Record.java new file mode 100644 index 000000000..fe2cd8d74 --- /dev/null +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/Record.java @@ -0,0 +1,30 @@ +/* + * 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.client.api.edm.xml.v4.annotation; + +import java.util.List; +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; + +public interface Record extends DynamicAnnotationExpression, Annotatable { + + List getPropertyValues(); + + String getType(); + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/DynExprSingleParamOp.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/TwoParamsOpDynamicAnnotationExpression.java similarity index 63% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/DynExprSingleParamOp.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/TwoParamsOpDynamicAnnotationExpression.java index 06797e945..15f56a12e 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/DynExprSingleParamOp.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/TwoParamsOpDynamicAnnotationExpression.java @@ -16,17 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.core.edm.xml.v4.annotation; +package org.apache.olingo.client.api.edm.xml.v4.annotation; -import org.apache.olingo.client.api.edm.xml.v4.annotation.DynExprConstruct; - -public class DynExprSingleParamOp extends DynExprConstructImpl { - - private static final long serialVersionUID = -7974475975925167731L; +public interface TwoParamsOpDynamicAnnotationExpression extends DynamicAnnotationExpression { public static enum Type { - Not, + And, + Or, Eq, Ne, Gt, @@ -43,27 +40,11 @@ public class DynExprSingleParamOp extends DynExprConstructImpl { } return result; } - } - private Type type; - - private DynExprConstruct expression; - - public Type getType() { - return type; - } - - public void setType(final Type type) { - this.type = type; - } - - public DynExprConstruct getExpression() { - return expression; - } - - public void setExpression(final DynExprConstruct expression) { - this.expression = expression; - } + Type getType(); + + DynamicAnnotationExpression getLeftExpression(); + DynamicAnnotationExpression getRightExpression(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/DynExprConstruct.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/UrlRef.java similarity index 89% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/DynExprConstruct.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/UrlRef.java index 5baffa6f0..9e67cfbed 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/DynExprConstruct.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/edm/xml/v4/annotation/UrlRef.java @@ -18,6 +18,8 @@ */ package org.apache.olingo.client.api.edm.xml.v4.annotation; -public interface DynExprConstruct extends ExprConstruct { +public interface UrlRef extends DynamicAnnotationExpression { + + AnnotationExpression getValue(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java index db9b8c8a4..576d64803 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v3/ODataClient.java @@ -22,7 +22,6 @@ import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory; import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory; import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType; -import org.apache.olingo.client.api.communication.request.invoke.v3.InvokeRequestFactory; import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRequestFactory; import org.apache.olingo.client.api.communication.request.streamed.v3.StreamedRequestFactory; import org.apache.olingo.client.api.op.v3.ODataBinder; @@ -64,9 +63,6 @@ public interface ODataClient extends CommonODataClient { @Override StreamedRequestFactory getStreamedRequestFactory(); - @Override - InvokeRequestFactory getInvokeRequestFactory(); - @Override BatchRequestFactory getBatchRequestFactory(); } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java index 7ee53bf09..171f51f2c 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java +++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/v4/ODataClient.java @@ -22,7 +22,6 @@ import org.apache.olingo.client.api.CommonODataClient; import org.apache.olingo.client.api.communication.request.batch.v4.BatchRequestFactory; import org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFactory; import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType; -import org.apache.olingo.client.api.communication.request.invoke.v4.InvokeRequestFactory; import org.apache.olingo.client.api.communication.request.retrieve.v4.RetrieveRequestFactory; import org.apache.olingo.client.api.communication.request.streamed.v4.StreamedRequestFactory; import org.apache.olingo.client.api.communication.request.v4.AsyncRequestFactory; @@ -67,9 +66,6 @@ public interface ODataClient extends CommonODataClient { @Override StreamedRequestFactory getStreamedRequestFactory(); - @Override - InvokeRequestFactory getInvokeRequestFactory(); - @Override BatchRequestFactory getBatchRequestFactory(); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractInvokeRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractInvokeRequestFactory.java index a1a1b8c48..08fc6f296 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractInvokeRequestFactory.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/AbstractInvokeRequestFactory.java @@ -19,22 +19,15 @@ package org.apache.olingo.client.core.communication.request.invoke; import java.net.URI; -import org.apache.olingo.client.api.CommonODataClient; -import org.apache.olingo.client.api.communication.request.invoke.CommonInvokeRequestFactory; +import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory; import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; import org.apache.olingo.commons.api.domain.ODataInvokeResult; import org.apache.olingo.commons.api.edm.EdmOperation; -public abstract class AbstractInvokeRequestFactory implements CommonInvokeRequestFactory { +public abstract class AbstractInvokeRequestFactory implements InvokeRequestFactory { private static final long serialVersionUID = -906760270085197249L; - protected final CommonODataClient client; - - protected AbstractInvokeRequestFactory(final CommonODataClient client) { - this.client = client; - } - @Override public ODataInvokeRequest getInvokeRequest( final URI uri, final EdmOperation operation) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java index 662f9db40..0d71a4a9e 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v3/InvokeRequestFactoryImpl.java @@ -23,7 +23,6 @@ import java.util.Map; import org.apache.olingo.client.api.v3.ODataClient; import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent; -import org.apache.olingo.client.api.communication.request.invoke.v3.InvokeRequestFactory; import org.apache.olingo.commons.api.domain.ODataInvokeResult; import org.apache.olingo.commons.api.domain.ODataValue; import org.apache.olingo.client.api.http.HttpMethod; @@ -36,12 +35,14 @@ import org.apache.olingo.commons.api.edm.EdmOperation; import org.apache.olingo.commons.api.edm.EdmReturnType; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; -public class InvokeRequestFactoryImpl extends AbstractInvokeRequestFactory implements InvokeRequestFactory { +public class InvokeRequestFactoryImpl extends AbstractInvokeRequestFactory { private static final long serialVersionUID = -659256862901915496L; + private final ODataClient client; + public InvokeRequestFactoryImpl(final ODataClient client) { - super(client); + this.client = client; } @Override diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/InvokeRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/InvokeRequestFactoryImpl.java index 4d5a4b1f8..ded99922d 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/InvokeRequestFactoryImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/invoke/v4/InvokeRequestFactoryImpl.java @@ -23,7 +23,6 @@ import java.util.Map; import org.apache.olingo.client.api.v4.ODataClient; import org.apache.olingo.client.api.communication.request.invoke.ODataInvokeRequest; import org.apache.olingo.client.api.communication.request.invoke.ODataNoContent; -import org.apache.olingo.client.api.communication.request.invoke.v4.InvokeRequestFactory; import org.apache.olingo.client.api.http.HttpMethod; import org.apache.olingo.commons.api.domain.ODataInvokeResult; import org.apache.olingo.commons.api.domain.ODataValue; @@ -36,12 +35,14 @@ import org.apache.olingo.commons.api.edm.EdmOperation; import org.apache.olingo.commons.api.edm.EdmReturnType; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; -public class InvokeRequestFactoryImpl extends AbstractInvokeRequestFactory implements InvokeRequestFactory { +public class InvokeRequestFactoryImpl extends AbstractInvokeRequestFactory { private static final long serialVersionUID = 8452737360003104372L; + private final ODataClient client; + public InvokeRequestFactoryImpl(final ODataClient client) { - super(client); + this.client = client; } @SuppressWarnings("unchecked") diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java index 15a9604c1..f95746e04 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmActionImportImpl.java @@ -18,18 +18,23 @@ */ package org.apache.olingo.client.core.edm; +import java.util.List; import org.apache.olingo.client.api.edm.xml.v4.ActionImport; import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; import org.apache.olingo.commons.api.edm.EdmActionImport; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmActionImport { private final ActionImport actionImport; + private final EdmAnnotationHelper helper; + private FullQualifiedName actionFQN; public EdmActionImportImpl(final Edm edm, final EdmEntityContainer container, final String name, @@ -37,6 +42,7 @@ public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmAc super(edm, container, name, actionImport.getEntitySet()); this.actionImport = actionImport; + this.helper = new EdmAnnotationHelperImpl(edm, actionImport); } public FullQualifiedName getActionFQN() { @@ -52,4 +58,13 @@ public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmAc return edm.getUnboundAction(getActionFQN()); } + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.ActionImport; + } + + @Override + public List getAnnotations() { + return helper.getAnnotations(); + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationHelperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationHelperImpl.java new file mode 100644 index 000000000..6333bca70 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationHelperImpl.java @@ -0,0 +1,53 @@ +/* + * 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.client.core.edm; + +import java.util.ArrayList; +import java.util.List; +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; +import org.apache.olingo.client.api.edm.xml.v4.Annotation; +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; + +public class EdmAnnotationHelperImpl implements EdmAnnotationHelper { + + private final Edm edm; + + private final Annotatable annotatable; + + private List annotations; + + public EdmAnnotationHelperImpl(final Edm edm, final Annotatable annotatable) { + this.edm = edm; + this.annotatable = annotatable; + } + + @Override + public List getAnnotations() { + if (annotations == null) { + annotations = new ArrayList(); + for (Annotation annotation : annotatable.getAnnotations()) { + annotations.add(new EdmAnnotationImpl(edm, annotation)); + } + } + return annotations; + } + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java new file mode 100644 index 000000000..b219eb2e0 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationImpl.java @@ -0,0 +1,238 @@ +/* + * 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.client.core.edm; + +import java.util.ArrayList; +import java.util.List; +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; +import org.apache.olingo.client.api.edm.xml.v4.Annotation; +import org.apache.olingo.client.api.edm.xml.v4.annotation.AnnotationExpression; +import org.apache.olingo.client.api.edm.xml.v4.annotation.DynamicAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.v4.annotation.PropertyValue; +import org.apache.olingo.client.core.edm.v4.annotation.EdmCastImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmAnnotationPathImpl; +import org.apache.olingo.client.core.edm.v4.annotation.EdmConstantAnnotationExpressionImpl; +import org.apache.olingo.client.core.edm.v4.annotation.EdmIsOfImpl; +import org.apache.olingo.client.core.edm.v4.annotation.EdmRecordImpl; +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotatable; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmTerm; +import org.apache.olingo.commons.api.edm.FullQualifiedName; +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.EdmPropertyValue; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; +import org.apache.olingo.commons.core.edm.annotation.EdmAndImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmApplyImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmCollectionImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmEqImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmGeImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmGtImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmIfImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmLabeledElementImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmLabeledElementReferenceImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmLeImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmLtImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmNavigationPropertyPathImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmNeImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmNotImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmNullImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmOrImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmPathImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmPropertyPathImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmPropertyValueImpl; +import org.apache.olingo.commons.core.edm.annotation.EdmUrlRefImpl; + +public class EdmAnnotationImpl implements EdmAnnotation { + + private final Edm edm; + + private final Annotation annotation; + + private final EdmAnnotationHelper helper; + + private EdmTerm term; + + private EdmAnnotationExpression expression; + + public EdmAnnotationImpl(final Edm edm, final Annotation annotation) { + this.edm = edm; + this.annotation = annotation; + this.helper = new EdmAnnotationHelperImpl(edm, annotation); + } + + @Override + public EdmTerm getTerm() { + if (term == null) { + term = edm.getTerm(new FullQualifiedName(annotation.getTerm())); + } + return term; + } + + @Override + public String getQualifier() { + return annotation.getQualifier(); + } + + private EdmAnnotationExpression getExpression(final AnnotationExpression exp) { + EdmAnnotationExpression _expression = null; + + if (exp.isConstant()) { + _expression = new EdmConstantAnnotationExpressionImpl(edm, exp.asConstant()); + } else if (annotation.getExpression().isDynamic()) { + _expression = getDynamicExpression(exp.asDynamic()); + } + + return _expression; + } + + private EdmDynamicAnnotationExpression getDynamicExpression(final DynamicAnnotationExpression exp) { + EdmDynamicAnnotationExpression _expression = null; + + if (exp.isNot()) { + _expression = new EdmNotImpl(getDynamicExpression(exp.asNot().getExpression())); + } else if (exp.isTwoParamsOp()) { + switch (exp.asTwoParamsOp().getType()) { + case And: + _expression = new EdmAndImpl( + getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), + getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); + break; + + case Or: + _expression = new EdmOrImpl( + getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), + getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); + break; + + case Eq: + _expression = new EdmEqImpl( + getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), + getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); + break; + + case Ne: + _expression = new EdmNeImpl( + getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), + getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); + break; + + case Ge: + _expression = new EdmGeImpl( + getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), + getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); + break; + + case Gt: + _expression = new EdmGtImpl( + getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), + getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); + break; + + case Le: + _expression = new EdmLeImpl( + getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), + getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); + break; + + case Lt: + _expression = new EdmLtImpl( + getDynamicExpression(exp.asTwoParamsOp().getLeftExpression()), + getDynamicExpression(exp.asTwoParamsOp().getRightExpression())); + break; + + default: + } + } else if (exp.isAnnotationPath()) { + _expression = new EdmAnnotationPathImpl(exp.asAnnotationPath().getValue()); + } else if (exp.isApply()) { + final List parameters = + new ArrayList(exp.asApply().getParameters().size()); + for (AnnotationExpression param : exp.asApply().getParameters()) { + parameters.add(getExpression(param)); + } + _expression = new EdmApplyImpl(exp.asApply().getFunction(), parameters); + } else if (exp.isCast()) { + _expression = new EdmCastImpl(edm, exp.asCast(), getDynamicExpression(exp.asCast().getValue())); + } else if (exp.isCollection()) { + final List items = + new ArrayList(exp.asCollection().getItems().size()); + for (AnnotationExpression param : exp.asCollection().getItems()) { + items.add(getExpression(param)); + } + _expression = new EdmCollectionImpl(items); + } else if (exp.isIf()) { + _expression = new EdmIfImpl( + getExpression(exp.asIf().getGuard()), + getExpression(exp.asIf().getThen()), + getExpression(exp.asIf().getElse())); + } else if (exp.isIsOf()) { + _expression = new EdmIsOfImpl(edm, exp.asIsOf(), getDynamicExpression(exp.asIsOf().getValue())); + } else if (exp.isLabeledElement()) { + _expression = new EdmLabeledElementImpl( + exp.asLabeledElement().getName(), getDynamicExpression(exp.asLabeledElement().getValue())); + } else if (exp.isLabeledElementReference()) { + _expression = new EdmLabeledElementReferenceImpl(exp.asLabeledElementReference().getValue()); + } else if (exp.isNull()) { + _expression = new EdmNullImpl(); + } else if (exp.isNavigationPropertyPath()) { + _expression = new EdmNavigationPropertyPathImpl(exp.asNavigationPropertyPath().getValue()); + } else if (exp.isPath()) { + _expression = new EdmPathImpl(exp.asPath().getValue()); + } else if (exp.isPropertyPath()) { + _expression = new EdmPropertyPathImpl(exp.asPropertyPath().getValue()); + } else if (exp.isPropertyValue()) { + _expression = new EdmPropertyValueImpl( + exp.asPropertyValue().getProperty(), getExpression(exp.asPropertyValue().getValue())); + } else if (exp.isRecord()) { + final List propertyValues = + new ArrayList(exp.asRecord().getPropertyValues().size()); + for (PropertyValue propertyValue : exp.asRecord().getPropertyValues()) { + propertyValues.add(new EdmPropertyValueImpl( + propertyValue.getProperty(), getExpression(propertyValue.getValue()))); + } + _expression = new EdmRecordImpl(edm, exp.asRecord().getType(), propertyValues); + } else if (exp.isUrlRef()) { + _expression = new EdmUrlRefImpl(getExpression(exp.asUrlRef().getValue())); + } + + if (_expression instanceof EdmAnnotatable && exp instanceof Annotatable) { + for (Annotation _annotation : ((Annotatable) exp).getAnnotations()) { + ((EdmAnnotatable) _expression).getAnnotations().add(new EdmAnnotationImpl(edm, _annotation)); + } + } + + return _expression; + } + + @Override + public EdmAnnotationExpression getExpression() { + if (expression == null) { + expression = getExpression(annotation.getExpression()); + } + return expression; + } + + @Override + public List getAnnotations() { + return helper.getAnnotations(); + } + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationsImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationsImpl.java new file mode 100644 index 000000000..b4888b669 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmAnnotationsImpl.java @@ -0,0 +1,146 @@ +/* + * 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.client.core.edm; + +import java.util.ArrayList; +import java.util.List; +import org.apache.commons.lang3.StringUtils; +import org.apache.olingo.client.api.edm.xml.v4.Annotation; +import org.apache.olingo.client.api.edm.xml.v4.Annotations; +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmAnnotations; +import org.apache.olingo.commons.api.edm.EdmAnnotationsTarget; +import org.apache.olingo.commons.api.edm.EdmEntityContainer; +import org.apache.olingo.commons.api.edm.EdmEnumType; +import org.apache.olingo.commons.api.edm.EdmSchema; +import org.apache.olingo.commons.api.edm.EdmStructuredType; +import org.apache.olingo.commons.api.edm.EdmTerm; +import org.apache.olingo.commons.api.edm.FullQualifiedName; + +public class EdmAnnotationsImpl implements EdmAnnotations { + + private final Edm edm; + + private final EdmSchema schema; + + private final Annotations annotationGroup; + + private EdmAnnotationsTarget target; + + private List annotations; + + public EdmAnnotationsImpl(final Edm edm, final EdmSchema schema, final Annotations annotationGroup) { + this.edm = edm; + this.schema = schema; + this.annotationGroup = annotationGroup; + } + + private EdmAnnotationsTarget getTarget(final EdmStructuredType structured, final String path) { + EdmAnnotationsTarget _target = null; + if (structured != null) { + _target = path == null + ? structured + : structured.getStructuralProperty(path); + if (_target == null) { + _target = structured.getNavigationProperty(path); + } + } + return _target; + } + + private EdmAnnotationsTarget getTarget(final EdmEnumType enumType, final String path) { + EdmAnnotationsTarget _target = null; + if (enumType != null) { + _target = path == null + ? enumType + : enumType.getMember(path); + } + return _target; + } + + @Override + public EdmAnnotationsTarget getTarget() { + if (target == null) { + final String[] splitted = StringUtils.split(annotationGroup.getTarget(), '/'); + final FullQualifiedName base = new FullQualifiedName(splitted[0]); + final String path = splitted.length > 1 ? splitted[1] : null; + + final EdmEntityContainer baseEntityContainer = schema.getEntityContainer(base); + + target = baseEntityContainer == null? null: baseEntityContainer.getActionImport(path); + if (target == null) { + target = getTarget(edm.getComplexType(base), path); + if (target == null) { + target = baseEntityContainer; + if (target == null) { + target = baseEntityContainer == null? null: baseEntityContainer.getEntitySet(path); + if (target == null) { + target = getTarget(edm.getEntityType(base), path); + if (target == null) { + target = getTarget(edm.getEnumType(base), path); + if (target == null) { + target = baseEntityContainer == null? null: baseEntityContainer.getFunctionImport(path); + if (target == null) { + target = baseEntityContainer == null? null: baseEntityContainer.getSingleton(path); + if (target == null) { + target = edm.getTerm(base); + if (target == null) { + target = edm.getTypeDefinition(base); + } + } + } + } + } + } + } + } + } + } + return target; + } + + @Override + public String getQualifier() { + return annotationGroup.getQualifier(); + } + + @Override + public EdmAnnotation getAnnotation(final EdmTerm term) { + EdmAnnotation result = null; + for (EdmAnnotation annotation : getAnnotations()) { + if (term.getFullQualifiedName().equals(annotation.getTerm().getFullQualifiedName())) { + result = annotation; + } + } + return result; + } + + @Override + public List getAnnotations() { + if (annotations == null) { + annotations = new ArrayList(); + for (Annotation annotation : annotationGroup.getAnnotations()) { + annotations.add(new EdmAnnotationImpl(edm, annotation)); + } + } + return annotations; + } + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmBindingTargetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmBindingTargetImpl.java index 452c880f7..9aa3485db 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmBindingTargetImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmBindingTargetImpl.java @@ -25,6 +25,7 @@ import java.util.List; import org.apache.olingo.client.api.edm.xml.v4.BindingTarget; import org.apache.olingo.client.api.edm.xml.v4.NavigationPropertyBinding; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmBindingTarget; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmException; @@ -32,18 +33,23 @@ import org.apache.olingo.commons.api.edm.EdmNavigationPropertyBinding; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.Target; import org.apache.olingo.commons.core.edm.AbstractEdmBindingTarget; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; import org.apache.olingo.commons.core.edm.EdmNavigationPropertyBindingImpl; public abstract class EdmBindingTargetImpl extends AbstractEdmBindingTarget { private final BindingTarget target; + + private final EdmAnnotationHelper helper; + private List navigationPropertyBindings; public EdmBindingTargetImpl(final Edm edm, final EdmEntityContainer container, - final String name, final FullQualifiedName type, final BindingTarget target) { + final String name, final FullQualifiedName type, final BindingTarget target) { super(edm, container, name, type); this.target = target; + this.helper = new EdmAnnotationHelperImpl(edm, target); } @Override @@ -53,8 +59,8 @@ public abstract class EdmBindingTargetImpl extends AbstractEdmBindingTarget { final List navigationPropertyBindings = target.getNavigationPropertyBindings(); boolean found = false; for (final Iterator itor = navigationPropertyBindings.iterator(); itor - .hasNext() - && !found;) { + .hasNext() + && !found;) { final NavigationPropertyBinding binding = itor.next(); if (binding.getPath().equals(path)) { @@ -95,4 +101,9 @@ public abstract class EdmBindingTargetImpl extends AbstractEdmBindingTarget { return navigationPropertyBindings; } + @Override + public List getAnnotations() { + return helper.getAnnotations(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java index ae6c37755..0b40f67e1 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java @@ -18,21 +18,19 @@ */ package org.apache.olingo.client.core.edm; -import org.apache.olingo.commons.core.edm.EdmTypeInfo; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; - import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import org.apache.olingo.client.api.v3.UnsupportedInV3Exception; import org.apache.olingo.client.api.edm.xml.CommonParameter; import org.apache.olingo.client.api.edm.xml.ComplexType; import org.apache.olingo.client.api.edm.xml.EntityContainer; @@ -41,12 +39,18 @@ import org.apache.olingo.client.api.edm.xml.EnumType; import org.apache.olingo.client.api.edm.xml.Schema; import org.apache.olingo.client.api.edm.xml.v3.FunctionImport; import org.apache.olingo.client.api.edm.xml.v4.Action; +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; +import org.apache.olingo.client.api.edm.xml.v4.Annotation; +import org.apache.olingo.client.api.edm.xml.v4.Annotations; import org.apache.olingo.client.api.edm.xml.v4.Function; +import org.apache.olingo.client.api.edm.xml.v4.Term; import org.apache.olingo.client.api.edm.xml.v4.TypeDefinition; import org.apache.olingo.client.core.edm.v3.EdmActionProxy; import org.apache.olingo.client.core.edm.v3.EdmFunctionProxy; import org.apache.olingo.client.core.edm.v3.FunctionImportUtils; import org.apache.olingo.commons.api.edm.EdmAction; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmAnnotations; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntityType; @@ -54,10 +58,12 @@ import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmSchema; import org.apache.olingo.commons.api.edm.EdmServiceMetadata; +import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; import org.apache.olingo.commons.core.edm.AbstractEdm; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; public class EdmClientImpl extends AbstractEdm { @@ -101,6 +107,15 @@ public class EdmClientImpl extends AbstractEdm { return aliasToNamespace; } + @Override + protected Map createSchemas() { + final Map _schemas = new LinkedHashMap(xmlSchemas.size()); + for (Schema schema : xmlSchemas) { + _schemas.put(schema.getNamespace(), new EdmSchemaImpl(version, this, xmlSchemas, schema)); + } + return _schemas; + } + @Override protected EdmEntityContainer createEntityContainer(final FullQualifiedName containerName) { EdmEntityContainer result = null; @@ -142,8 +157,6 @@ public class EdmClientImpl extends AbstractEdm { if (xmlTypeDefinition != null) { result = new EdmTypeDefinitionImpl(version, this, typeDefinitionName, xmlTypeDefinition); } - } else { - throw new UnsupportedInV3Exception(); } return result; @@ -407,6 +420,57 @@ public class EdmClientImpl extends AbstractEdm { return result; } + @Override + protected EdmTerm createTerm(final FullQualifiedName termName) { + EdmTerm result = null; + + final Schema schema = xmlSchemaByNamespace.get(termName.getNamespace()); + if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { + final Term term = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getTerm(termName.getName()); + if (term != null) { + result = new EdmTermImpl(this, term); + } + } + + return result; + } + + @Override + protected EdmAnnotations createAnnotationGroup(final FullQualifiedName targetName) { + EdmAnnotationsImpl result = null; + + final Schema schema = xmlSchemaByNamespace.get(targetName.getNamespace()); + if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { + final Annotations annotationGroup = + ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getAnnotationGroup(targetName.getName()); + if (annotationGroup != null) { + result = new EdmAnnotationsImpl(this, schemas.get(schema.getNamespace()), annotationGroup); + } + } + + return result; + } + + @Override + protected List createAnnotations(final FullQualifiedName annotatedName) { + List result = null; + + final Schema schema = xmlSchemaByNamespace.get(annotatedName.getNamespace()); + if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { + final Annotatable annotatable = + ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getAnnotatables().get(annotatedName.getName()); + if (annotatable != null && annotatable.getAnnotations() != null) { + result = new ArrayList(); + for (Annotation annotation : annotatable.getAnnotations()) { + final EdmTerm term = getTerm(new FullQualifiedName(annotation.getTerm())); + result.add(new EdmAnnotationImpl(this, annotation)); + } + } + } + + return result; + } + @Override public boolean equals(final Object obj) { return EqualsBuilder.reflectionEquals(this, obj); @@ -421,13 +485,4 @@ public class EdmClientImpl extends AbstractEdm { public String toString() { return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE); } - - @Override - protected List createSchemas() { - final List schemas = new ArrayList(); - for (Schema schema : xmlSchemas) { - schemas.add(new EdmSchemaImpl(version, this, xmlSchemas, schema)); - } - return schemas; - } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java index 1ccc8d54f..f770e5616 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmComplexTypeImpl.java @@ -24,15 +24,19 @@ import java.util.Map; import org.apache.olingo.client.api.edm.xml.ComplexType; import org.apache.olingo.client.api.edm.xml.Schema; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmNavigationProperty; import org.apache.olingo.commons.api.edm.EdmProperty; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.AbstractEdmComplexType; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper; public class EdmComplexTypeImpl extends AbstractEdmComplexType { - private final EdmStructuredTypeHelper helper; + private final EdmStructuredTypeHelper typeHelper; + + private EdmAnnotationHelper annotationHelper; public static EdmComplexTypeImpl getInstance(final Edm edm, final FullQualifiedName fqn, final List xmlSchemas, final ComplexType complexType) { @@ -53,26 +57,36 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType { final List xmlSchemas, final ComplexType complexType) { super(edm, fqn, baseTypeName); - this.helper = new EdmStructuredTypeHelperImpl(edm, xmlSchemas, complexType); + this.typeHelper = new EdmStructuredTypeHelperImpl(edm, getFullQualifiedName(), xmlSchemas, complexType); + if (complexType instanceof org.apache.olingo.client.api.edm.xml.v4.ComplexType) { + this.annotationHelper = new EdmAnnotationHelperImpl(edm, + (org.apache.olingo.client.api.edm.xml.v4.ComplexType) complexType); + } } @Override protected Map getProperties() { - return helper.getProperties(); + return typeHelper.getProperties(); } @Override protected Map getNavigationProperties() { - return helper.getNavigationProperties(); + return typeHelper.getNavigationProperties(); } @Override public boolean isOpenType() { - return helper.isOpenType(); + return typeHelper.isOpenType(); } @Override public boolean isAbstract() { - return helper.isAbstract(); + return typeHelper.isAbstract(); } + + @Override + public List getAnnotations() { + return annotationHelper == null ? null : annotationHelper.getAnnotations(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java index cf846f7e8..ff0938bb7 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityContainerImpl.java @@ -18,6 +18,7 @@ */ package org.apache.olingo.client.core.edm; +import java.util.Collections; import org.apache.olingo.commons.core.edm.EdmTypeInfo; import java.util.List; @@ -34,12 +35,13 @@ import org.apache.olingo.client.core.edm.v3.EdmEntitySetProxy; import org.apache.olingo.client.core.edm.v3.EdmFunctionImportProxy; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmActionImport; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntitySet; -import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.EdmSingleton; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.AbstractEdmEntityContainer; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { @@ -47,6 +49,8 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { private final List xmlSchemas; + private EdmAnnotationHelper helper; + public EdmEntityContainerImpl(final Edm edm, final FullQualifiedName entityContainerName, final EntityContainer xmlEntityContainer, final List xmlSchemas) { @@ -55,6 +59,10 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { this.xmlEntityContainer = xmlEntityContainer; this.xmlSchemas = xmlSchemas; + if (xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer) { + this.helper = new EdmAnnotationHelperImpl(edm, + (org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer); + } } @Override @@ -72,63 +80,69 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { final Singleton singleton = ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer). getSingleton(singletonName); - if (singleton == null) { - throw new EdmException("Singleton named '" + singletonName + "' not found in " + entityContainerName); - } - return new EdmSingletonImpl(edm, this, singletonName, new EdmTypeInfo.Builder(). - setTypeExpression(singleton.getEntityType()).setDefaultNamespace(entityContainerName.getNamespace()). - build().getFullQualifiedName(), singleton); + return singleton == null + ? null + : new EdmSingletonImpl(edm, this, singletonName, new EdmTypeInfo.Builder(). + setTypeExpression(singleton.getEntityType()). + setDefaultNamespace(entityContainerName.getNamespace()). + build().getFullQualifiedName(), singleton); } @Override protected EdmEntitySet createEntitySet(final String entitySetName) { + EdmEntitySet result = null; + final EntitySet entitySet = xmlEntityContainer.getEntitySet(entitySetName); - if (entitySet == null) { - throw new EdmException("EntitySet named '" + entitySetName + "' not found in " + entityContainerName); + if (entitySet != null) { + final FullQualifiedName entityType = new EdmTypeInfo.Builder().setTypeExpression(entitySet.getEntityType()). + setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName(); + if (entitySet instanceof org.apache.olingo.client.api.edm.xml.v4.EntitySet) { + result = new EdmEntitySetImpl(edm, this, entitySetName, entityType, + (org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet); + } else { + result = new EdmEntitySetProxy(edm, this, entitySetName, entityType, xmlSchemas); + } } - final FullQualifiedName entityType = new EdmTypeInfo.Builder().setTypeExpression(entitySet.getEntityType()). - setDefaultNamespace(entityContainerName.getNamespace()).build().getFullQualifiedName(); - if (entitySet instanceof org.apache.olingo.client.api.edm.xml.v4.EntitySet) { - return new EdmEntitySetImpl(edm, this, entitySetName, entityType, - (org.apache.olingo.client.api.edm.xml.v4.EntitySet) entitySet); - } else { - return new EdmEntitySetProxy(edm, this, entitySetName, entityType, xmlSchemas); - } + return result; } @Override protected EdmActionImport createActionImport(final String actionImportName) { + EdmActionImport result = null; + if (xmlEntityContainer instanceof org.apache.olingo.client.api.edm.xml.v4.EntityContainer) { final ActionImport actionImport = ((org.apache.olingo.client.api.edm.xml.v4.EntityContainer) xmlEntityContainer). getActionImport(actionImportName); - if (actionImport == null) { - throw new EdmException("ActionImport named '" + actionImportName + "' not found in " + entityContainerName); + if (actionImport != null) { + result = new EdmActionImportImpl(edm, this, actionImportName, actionImport); } - return new EdmActionImportImpl(edm, this, actionImportName, actionImport); } else { final FunctionImport functionImport = (FunctionImport) xmlEntityContainer.getFunctionImport(actionImportName); - if (functionImport == null) { - throw new EdmException("FunctionImport named '" + actionImportName + "' not found in " + entityContainerName); + if (functionImport != null) { + result = new EdmActionImportProxy(edm, this, actionImportName, functionImport); } - return new EdmActionImportProxy(edm, this, actionImportName, functionImport); } + + return result; } @Override protected EdmFunctionImport createFunctionImport(final String functionImportName) { + EdmFunctionImport result = null; + final CommonFunctionImport functionImport = xmlEntityContainer.getFunctionImport(functionImportName); - if (functionImport == null) { - throw new EdmException("FunctionImport named '" + functionImportName + "' not found in " + entityContainerName); + if (functionImport != null) { + if (functionImport instanceof org.apache.olingo.client.api.edm.xml.v4.FunctionImport) { + result = new EdmFunctionImportImpl(edm, this, functionImportName, + (org.apache.olingo.client.api.edm.xml.v4.FunctionImport) functionImport); + } else { + result = new EdmFunctionImportProxy(edm, this, functionImportName, + (org.apache.olingo.client.api.edm.xml.v3.FunctionImport) functionImport); + } } - if (functionImport instanceof org.apache.olingo.client.api.edm.xml.v4.FunctionImport) { - return new EdmFunctionImportImpl(edm, this, functionImportName, - (org.apache.olingo.client.api.edm.xml.v4.FunctionImport) functionImport); - } else { - return new EdmFunctionImportProxy(edm, this, functionImportName, - (org.apache.olingo.client.api.edm.xml.v3.FunctionImport) functionImport); - } + return result; } @Override @@ -209,4 +223,15 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { } } } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.EntityContainer; + } + + @Override + public List getAnnotations() { + return helper == null ? Collections.emptyList() : helper.getAnnotations(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java index ec9af77b6..2c80ad11b 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntitySetImpl.java @@ -26,12 +26,13 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName; public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntitySet { - private EntitySet entitySet; + private final EntitySet entitySet; public EdmEntitySetImpl(final Edm edm, final EdmEntityContainer container, final String name, final FullQualifiedName type, final EntitySet entitySet) { super(edm, container, name, type, entitySet); + this.entitySet = entitySet; } @@ -39,4 +40,9 @@ public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntityS public boolean isIncludeInServiceDocument() { return entitySet.isIncludeInServiceDocument(); } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.EntitySet; + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java index c7dc7fdae..3cd09cb93 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEntityTypeImpl.java @@ -27,21 +27,25 @@ import org.apache.olingo.client.api.edm.xml.EntityType; import org.apache.olingo.client.api.edm.xml.PropertyRef; import org.apache.olingo.client.api.edm.xml.Schema; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; import org.apache.olingo.commons.api.edm.EdmNavigationProperty; import org.apache.olingo.commons.api.edm.EdmProperty; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.AbstractEdmEntityType; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper; public class EdmEntityTypeImpl extends AbstractEdmEntityType { - private final EdmStructuredTypeHelper helper; + private final EdmStructuredTypeHelper typeHelper; - public static EdmEntityTypeImpl getInstance(final Edm edm, final FullQualifiedName fqn, + private EdmAnnotationHelper annotationHelper; + + public static EdmEntityTypeImpl getInstance(final Edm edm, final FullQualifiedName fqn, final List xmlSchemas, final EntityType entityType) { - + final FullQualifiedName baseTypeName = entityType.getBaseType() == null ? null : new EdmTypeInfo.Builder().setTypeExpression(entityType.getBaseType()).build().getFullQualifiedName(); @@ -68,26 +72,36 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType { final List xmlSchemas, final EntityType entityType) { super(edm, fqn, baseTypeName, entityType.isHasStream()); - this.helper = new EdmStructuredTypeHelperImpl(edm, xmlSchemas, entityType); + this.typeHelper = new EdmStructuredTypeHelperImpl(edm, getFullQualifiedName(), xmlSchemas, entityType); + if (entityType instanceof org.apache.olingo.client.api.edm.xml.v4.EntityType) { + this.annotationHelper = new EdmAnnotationHelperImpl(edm, + (org.apache.olingo.client.api.edm.xml.v4.EntityType) entityType); + } } @Override protected Map getProperties() { - return helper.getProperties(); + return typeHelper.getProperties(); } @Override protected Map getNavigationProperties() { - return helper.getNavigationProperties(); + return typeHelper.getNavigationProperties(); } @Override public boolean isOpenType() { - return helper.isOpenType(); + return typeHelper.isOpenType(); } @Override public boolean isAbstract() { - return helper.isAbstract(); + return typeHelper.isAbstract(); } + + @Override + public List getAnnotations() { + return annotationHelper.getAnnotations(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java index bba016b1e..4a769532d 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java @@ -18,6 +18,12 @@ */ package org.apache.olingo.client.core.edm; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import org.apache.olingo.client.api.edm.xml.EnumType; import org.apache.olingo.client.api.edm.xml.Member; import org.apache.olingo.commons.api.edm.Edm; @@ -26,14 +32,6 @@ import org.apache.olingo.commons.api.edm.EdmMember; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.AbstractEdmEnumType; -import org.apache.olingo.commons.core.edm.EdmMemberImpl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; import org.apache.commons.lang3.ArrayUtils; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; @@ -76,7 +74,7 @@ public class EdmEnumTypeImpl extends AbstractEdmEnumType implements EdmEnumType final Map _members = new LinkedHashMap(xmlMembers.size()); for (Member xmlMember : xmlMembers) { _memberNames.add(xmlMember.getName()); - _members.put(xmlMember.getName(), new EdmMemberImpl(edm, xmlMember.getName(), xmlMember.getValue())); + _members.put(xmlMember.getName(), new EdmMemberImpl(edm, fqn, xmlMember)); } this.memberNames = Collections.unmodifiableList(_memberNames); this.members = Collections.unmodifiableMap(_members); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java index 5c2575e43..4a68b9b46 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmFunctionImportImpl.java @@ -23,15 +23,19 @@ import java.util.List; import org.apache.olingo.client.api.edm.xml.v4.FunctionImport; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; public class EdmFunctionImportImpl extends EdmOperationImportImpl implements EdmFunctionImport { private final FunctionImport functionImport; + private final EdmAnnotationHelper helper; + private FullQualifiedName functionFQN; public EdmFunctionImportImpl(final Edm edm, final EdmEntityContainer container, final String name, @@ -39,6 +43,12 @@ public class EdmFunctionImportImpl extends EdmOperationImportImpl implements Edm super(edm, container, name, functionImport.getEntitySet()); this.functionImport = functionImport; + this.helper = new EdmAnnotationHelperImpl(edm, functionImport); + } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.FunctionImport; } @Override @@ -65,4 +75,9 @@ public class EdmFunctionImportImpl extends EdmOperationImportImpl implements Edm return functionImport.isIncludeInServiceDocument(); } + @Override + public List getAnnotations() { + return helper.getAnnotations(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmMemberImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmMemberImpl.java new file mode 100644 index 000000000..39806a46e --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmMemberImpl.java @@ -0,0 +1,47 @@ +/* + * 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.client.core.edm; + +import java.util.Collections; +import java.util.List; +import org.apache.olingo.client.api.edm.xml.Member; +import org.apache.olingo.client.core.edm.xml.v4.MemberImpl; +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.core.edm.AbstractEdmMember; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; + +public class EdmMemberImpl extends AbstractEdmMember { + + private EdmAnnotationHelper helper; + + public EdmMemberImpl(final Edm edm, final FullQualifiedName enumFQN, final Member member) { + super(edm, enumFQN, member.getName(), member.getValue()); + this.helper = member instanceof MemberImpl + ? new EdmAnnotationHelperImpl(edm, (MemberImpl) member) + : null; + } + + @Override + public List getAnnotations() { + return helper == null ? Collections.emptyList() : helper.getAnnotations(); + } + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java index 08abd9ca2..9939364ab 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmNavigationPropertyImpl.java @@ -24,24 +24,34 @@ import java.util.List; import org.apache.olingo.client.api.edm.xml.v4.NavigationProperty; import org.apache.olingo.client.api.edm.xml.v4.ReferentialConstraint; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmReferentialConstraint; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.AbstractEdmNavigationProperty; -import org.apache.olingo.commons.core.edm.EdmReferentialConstraintImpl; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; import org.apache.olingo.commons.core.edm.EdmTypeInfo; public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty { + private final FullQualifiedName structuredTypeName; + private final NavigationProperty navigationProperty; private final EdmTypeInfo edmTypeInfo; + private final EdmAnnotationHelper helper; + private List referentialConstraints; - public EdmNavigationPropertyImpl(final Edm edm, final NavigationProperty navigationProperty) { + public EdmNavigationPropertyImpl( + final Edm edm, final FullQualifiedName structuredTypeName, final NavigationProperty navigationProperty) { + super(edm, navigationProperty.getName()); + + this.structuredTypeName = structuredTypeName; this.navigationProperty = navigationProperty; this.edmTypeInfo = new EdmTypeInfo.Builder().setTypeExpression(navigationProperty.getType()).build(); + this.helper = new EdmAnnotationHelperImpl(edm, navigationProperty); } @Override @@ -71,11 +81,9 @@ public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty { @Override public String getReferencingPropertyName(final String referencedPropertyName) { - final List _referentialConstraints = - navigationProperty.getReferentialConstraints(); - for (ReferentialConstraint constraint : _referentialConstraints) { - if (constraint.getReferencedProperty().equals(referencedPropertyName)) { - return constraint.getProperty(); + for (EdmReferentialConstraint constraint : getReferentialConstraints()) { + if (constraint.getReferencedPropertyName().equals(referencedPropertyName)) { + return constraint.getPropertyName(); } } @@ -89,12 +97,21 @@ public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty { referentialConstraints = new ArrayList(); if (providerConstraints != null) { for (ReferentialConstraint constraint : providerConstraints) { - referentialConstraints.add( - new EdmReferentialConstraintImpl(constraint.getProperty(), constraint.getReferencedProperty())); + referentialConstraints.add(new EdmReferentialConstraintImpl(edm, constraint)); } } } return referentialConstraints; } + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return structuredTypeName; + } + + @Override + public List getAnnotations() { + return helper.getAnnotations(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java index da29a681b..c0d34712d 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImpl.java @@ -24,20 +24,24 @@ import java.util.List; import org.apache.olingo.client.api.edm.xml.CommonParameter; import org.apache.olingo.client.api.edm.xml.v4.Action; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmParameter; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; import org.apache.olingo.commons.core.edm.AbstractEdmOperation; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; public abstract class EdmOperationImpl extends AbstractEdmOperation { protected final Action operation; + protected final EdmAnnotationHelper helper; + protected static T getInstance(final T instance) { final List parameters = instance.operation.getParameters(); final List _parameters = new ArrayList(parameters.size()); for (CommonParameter parameter : parameters) { - _parameters.add(EdmParameterImpl.getInstance(instance.edm, parameter)); + _parameters.add(new EdmParameterImpl(instance.edm, parameter)); } instance.setParameters(_parameters); @@ -57,6 +61,7 @@ public abstract class EdmOperationImpl extends AbstractEdmOperation { super(edm, name, kind); this.operation = operation; + this.helper = new EdmAnnotationHelperImpl(edm, operation); } private EdmParameter getBindingParameter() { @@ -87,4 +92,10 @@ public abstract class EdmOperationImpl extends AbstractEdmOperation { } return result; } + + @Override + public List getAnnotations() { + return helper.getAnnotations(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImportImpl.java index 9f7aadf08..f41524644 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImportImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmOperationImportImpl.java @@ -18,7 +18,10 @@ */ package org.apache.olingo.client.core.edm; +import java.util.Collections; +import java.util.List; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.Target; import org.apache.olingo.commons.core.edm.AbstractEdmOperationImport; @@ -31,4 +34,8 @@ public abstract class EdmOperationImportImpl extends AbstractEdmOperationImport super(edm, container, name, entitySet == null ? null : new Target.Builder(entitySet, container).build()); } + @Override + public List getAnnotations() { + return Collections.emptyList(); + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java index 6c717093e..68388b33a 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmParameterImpl.java @@ -18,32 +18,39 @@ */ package org.apache.olingo.client.core.edm; -import org.apache.olingo.commons.core.edm.EdmTypeInfo; +import java.util.Collections; +import java.util.List; import org.apache.olingo.client.api.edm.xml.CommonParameter; +import org.apache.olingo.client.api.edm.xml.v4.Parameter; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmMapping; +import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.core.edm.AbstractEdmParameter; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; public class EdmParameterImpl extends AbstractEdmParameter { private final CommonParameter parameter; - private final EdmTypeInfo parameterInfo; + private final EdmTypeInfo typeInfo; - public static EdmParameterImpl getInstance(final Edm edm, final CommonParameter parameter) { - final EdmTypeInfo paramTypeInfo = new EdmTypeInfo.Builder().setTypeExpression(parameter.getType()).build(); - return new EdmParameterImpl(edm, parameter, paramTypeInfo); - } + private EdmAnnotationHelper helper; - private EdmParameterImpl(final Edm edm, final CommonParameter parameter, final EdmTypeInfo parameterInfo) { - super(edm, parameter.getName(), parameterInfo.getFullQualifiedName()); + public EdmParameterImpl(final Edm edm, final CommonParameter parameter) { + super(edm, parameter.getName(), new FullQualifiedName(parameter.getType())); this.parameter = parameter; - this.parameterInfo = parameterInfo; + this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(parameter.getType()).build(); + if (parameter instanceof Parameter) { + this.helper = new EdmAnnotationHelperImpl(edm, (Parameter) parameter); + } } @Override public boolean isCollection() { - return parameterInfo.isCollection(); + return typeInfo.isCollection(); } @Override @@ -71,4 +78,16 @@ public class EdmParameterImpl extends AbstractEdmParameter { return parameter.getScale(); } + @Override + public SRID getSrid() { + return (parameter instanceof Parameter) + ? ((Parameter) parameter).getSrid() + : null; + } + + @Override + public List getAnnotations() { + return helper == null ? Collections.emptyList() : helper.getAnnotations(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java index 9c9b4f63b..3928c64eb 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmPropertyImpl.java @@ -18,34 +18,44 @@ */ package org.apache.olingo.client.core.edm; -import org.apache.olingo.commons.core.edm.EdmTypeInfo; +import java.util.Collections; +import java.util.List; import org.apache.olingo.client.api.edm.xml.CommonProperty; +import org.apache.olingo.client.api.edm.xml.v4.Property; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmMapping; import org.apache.olingo.commons.api.edm.EdmProperty; import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.core.edm.AbstractEdmProperty; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; public class EdmPropertyImpl extends AbstractEdmProperty implements EdmProperty { + private final FullQualifiedName structuredTypeName; + private final CommonProperty property; - private final EdmTypeInfo edmTypeInfo; + private final EdmTypeInfo typeInfo; - public EdmPropertyImpl(final Edm edm, final CommonProperty property) { + private EdmAnnotationHelper helper; + + public EdmPropertyImpl(final Edm edm, final FullQualifiedName structuredTypeName, final CommonProperty property) { super(edm, property.getName()); + + this.structuredTypeName = structuredTypeName; this.property = property; - this.edmTypeInfo = new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build(); + this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(property.getType()).build(); + if (property instanceof Property) { + this.helper = new EdmAnnotationHelperImpl(edm, (Property) property); + } } @Override - protected FullQualifiedName getTypeFQN() { - return edmTypeInfo.getFullQualifiedName(); - } - - @Override - public boolean isCollection() { - return edmTypeInfo.isCollection(); + protected EdmTypeInfo getTypeInfo() { + return typeInfo; } @Override @@ -88,4 +98,21 @@ public class EdmPropertyImpl extends AbstractEdmProperty implements EdmProperty return property.getDefaultValue(); } + @Override + public SRID getSrid() { + return (property instanceof Property) + ? ((Property) property).getSrid() + : null; + } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return structuredTypeName; + } + + @Override + public List getAnnotations() { + return helper == null ? Collections.emptyList() : helper.getAnnotations(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReferentialConstraintImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReferentialConstraintImpl.java new file mode 100644 index 000000000..723785433 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReferentialConstraintImpl.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm; + +import java.util.List; +import org.apache.olingo.client.api.edm.xml.v4.ReferentialConstraint; +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.core.edm.AbstractEdmReferentialConstraint; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; + +public class EdmReferentialConstraintImpl extends AbstractEdmReferentialConstraint { + + private final EdmAnnotationHelper helper; + + public EdmReferentialConstraintImpl(final Edm edm, final ReferentialConstraint constraint) { + super(constraint.getProperty(), constraint.getReferencedProperty()); + this.helper = new EdmAnnotationHelperImpl(edm, constraint); + } + + @Override + public List getAnnotations() { + return helper.getAnnotations(); + } + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java index 71a10099c..851b299b4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmReturnTypeImpl.java @@ -18,16 +18,17 @@ */ package org.apache.olingo.client.core.edm; -import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.apache.olingo.client.api.edm.xml.v4.ReturnType; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.core.edm.AbstractEdmReturnType; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; public class EdmReturnTypeImpl extends AbstractEdmReturnType { private final ReturnType returnType; - private final EdmTypeInfo returnTypeInfo; + private final boolean isCollection; public static EdmReturnTypeImpl getInstance(final Edm edm, final ReturnType returnType) { final EdmTypeInfo returnTypeInfo = new EdmTypeInfo.Builder().setTypeExpression(returnType.getType()).build(); @@ -37,7 +38,12 @@ public class EdmReturnTypeImpl extends AbstractEdmReturnType { private EdmReturnTypeImpl(final Edm edm, final ReturnType returnType, final EdmTypeInfo returnTypeInfo) { super(edm, returnTypeInfo.getFullQualifiedName()); this.returnType = returnType; - this.returnTypeInfo = returnTypeInfo; + this.isCollection = returnTypeInfo.isCollection(); + } + + @Override + public boolean isCollection() { + return isCollection; } @Override @@ -61,8 +67,10 @@ public class EdmReturnTypeImpl extends AbstractEdmReturnType { } @Override - public boolean isCollection() { - return returnTypeInfo.isCollection(); + public SRID getSrid() { + return (returnType instanceof ReturnType) + ? ((ReturnType) returnType).getSrid() + : null; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java index 8e0f9d66b..17d682488 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java @@ -22,7 +22,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - import org.apache.olingo.client.api.edm.xml.ComplexType; import org.apache.olingo.client.api.edm.xml.EntityContainer; import org.apache.olingo.client.api.edm.xml.EntityType; @@ -30,16 +29,22 @@ import org.apache.olingo.client.api.edm.xml.EnumType; import org.apache.olingo.client.api.edm.xml.Schema; import org.apache.olingo.client.api.edm.xml.v3.FunctionImport; import org.apache.olingo.client.api.edm.xml.v4.Action; +import org.apache.olingo.client.api.edm.xml.v4.Annotation; +import org.apache.olingo.client.api.edm.xml.v4.Annotations; import org.apache.olingo.client.api.edm.xml.v4.Function; +import org.apache.olingo.client.api.edm.xml.v4.Term; import org.apache.olingo.client.api.edm.xml.v4.TypeDefinition; import org.apache.olingo.client.core.edm.v3.EdmFunctionProxy; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmAnnotations; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmFunction; +import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; @@ -92,6 +97,7 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override public EdmEntityContainer getEntityContainer(final FullQualifiedName name) { + getEntityContainers(); return entityContainerByName.get(name); } @@ -210,4 +216,48 @@ public class EdmSchemaImpl extends AbstractEdmSchema { } return functions; } + + @Override + protected List createTerms() { + final List terms = new ArrayList(); + if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { + final List providerTerms = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getTerms(); + if (providerTerms != null) { + for (Term term : providerTerms) { + terms.add(new EdmTermImpl(edm, term)); + } + } + } + return terms; + } + + @Override + protected List createAnnotationGroups() { + final List annotationGroups = new ArrayList(); + if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { + final List providerAnnotations = + ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getAnnotationGroups(); + if (providerAnnotations != null) { + for (Annotations annotationGroup : providerAnnotations) { + annotationGroups.add(new EdmAnnotationsImpl(edm, this, annotationGroup)); + } + } + } + return annotationGroups; + } + + @Override + protected List createAnnotations() { + final List annotations = new ArrayList(); + if (schema instanceof org.apache.olingo.client.api.edm.xml.v4.Schema) { + final List providerAnnotations = + ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getAnnotations(); + if (providerAnnotations != null) { + for (Annotation annotation : providerAnnotations) { + annotations.add(new EdmAnnotationImpl(edm, annotation)); + } + } + } + return annotations; + } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java index b91340ecf..403c28f80 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSingletonImpl.java @@ -32,4 +32,9 @@ public class EdmSingletonImpl extends EdmBindingTargetImpl implements EdmSinglet super(edm, container, name, type, singleton); } + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.Singleton; + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java index 77d92df5c..c0b0cabb0 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmStructuredTypeHelperImpl.java @@ -31,12 +31,15 @@ import org.apache.olingo.client.core.edm.v3.EdmNavigationPropertyProxy; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmNavigationProperty; import org.apache.olingo.commons.api.edm.EdmProperty; +import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper; public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper { private final Edm edm; + private final FullQualifiedName structuredTypeName; + private final ComplexType complexType; private final List xmlSchemas; @@ -45,10 +48,11 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper { private Map navigationProperties; - public EdmStructuredTypeHelperImpl( - final Edm edm, final List xmlSchemas, final ComplexType complexType) { + public EdmStructuredTypeHelperImpl(final Edm edm, final FullQualifiedName structuredTypeName, + final List xmlSchemas, final ComplexType complexType) { this.edm = edm; + this.structuredTypeName = structuredTypeName; this.complexType = complexType; this.xmlSchemas = xmlSchemas; } @@ -58,7 +62,7 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper { if (properties == null) { properties = new LinkedHashMap(); for (CommonProperty property : complexType.getProperties()) { - properties.put(property.getName(), new EdmPropertyImpl(edm, property)); + properties.put(property.getName(), new EdmPropertyImpl(edm, structuredTypeName, property)); } } return properties; @@ -71,10 +75,12 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper { for (CommonNavigationProperty navigationProperty : complexType.getNavigationProperties()) { if (navigationProperty instanceof org.apache.olingo.client.api.edm.xml.v4.NavigationProperty) { navigationProperties.put(navigationProperty.getName(), new EdmNavigationPropertyImpl( - edm, (org.apache.olingo.client.api.edm.xml.v4.NavigationProperty) navigationProperty)); + edm, structuredTypeName, + (org.apache.olingo.client.api.edm.xml.v4.NavigationProperty) navigationProperty)); } else if (navigationProperty instanceof org.apache.olingo.client.api.edm.xml.v3.NavigationProperty) { navigationProperties.put(navigationProperty.getName(), new EdmNavigationPropertyProxy( - edm, xmlSchemas, (org.apache.olingo.client.api.edm.xml.v3.NavigationProperty) navigationProperty)); + edm, xmlSchemas, + (org.apache.olingo.client.api.edm.xml.v3.NavigationProperty) navigationProperty)); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTermImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTermImpl.java new file mode 100644 index 000000000..a7793696b --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTermImpl.java @@ -0,0 +1,161 @@ +/* + * 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.client.core.edm; + +import java.util.ArrayList; +import java.util.List; +import org.apache.commons.lang3.ClassUtils; +import org.apache.olingo.client.api.edm.xml.v4.Term; +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmException; +import org.apache.olingo.commons.api.edm.EdmTerm; +import org.apache.olingo.commons.api.edm.EdmType; +import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.geo.SRID; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; +import org.apache.olingo.commons.core.edm.EdmNamedImpl; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class EdmTermImpl extends EdmNamedImpl implements EdmTerm { + + private static final Logger LOG = LoggerFactory.getLogger(EdmTermImpl.class); + + private final Term term; + + private final EdmTypeInfo typeInfo; + + private final EdmAnnotationHelper helper; + + private EdmType termType; + + private EdmTerm baseTerm; + + private List> appliesTo; + + public EdmTermImpl(final Edm edm, final Term term) { + super(edm, term.getName()); + + this.term = term; + this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(term.getType()).build(); + this.helper = new EdmAnnotationHelperImpl(edm, term); + } + + @Override + public FullQualifiedName getFullQualifiedName() { + return typeInfo.getFullQualifiedName(); + } + + @Override + public EdmType getType() { + if (termType == null) { + termType = typeInfo.isPrimitiveType() + ? EdmPrimitiveTypeFactory.getInstance(typeInfo.getPrimitiveTypeKind()) + : typeInfo.isTypeDefinition() + ? typeInfo.getTypeDefinition() + : typeInfo.isEnumType() + ? typeInfo.getEnumType() + : typeInfo.isComplexType() + ? typeInfo.getComplexType() + : null; + if (termType == null) { + throw new EdmException("Cannot find type with name: " + typeInfo.getFullQualifiedName()); + } + } + + return termType; + } + + @Override + public EdmTerm getBaseTerm() { + if (baseTerm == null && term.getBaseTerm() != null) { + baseTerm = edm.getTerm(new FullQualifiedName(term.getBaseTerm())); + } + return baseTerm; + } + + @Override + public List> getAppliesTo() { + if (appliesTo == null) { + appliesTo = new ArrayList>(); + for (String element : term.getAppliesTo()) { + try { + appliesTo.add(ClassUtils.getClass(EdmTerm.class.getPackage().getName() + ".Edm" + element)); + } catch (ClassNotFoundException e) { + LOG.error("Could not load Edm class for {}", element, e); + } + } + } + return appliesTo; + } + + @Override + public Boolean isNullable() { + return term.isNullable(); + } + + @Override + public Integer getMaxLength() { + return term.getMaxLength(); + } + + @Override + public Integer getPrecision() { + return term.getPrecision(); + } + + @Override + public Integer getScale() { + return term.getScale(); + } + + @Override + public SRID getSrid() { + return term.getSrid(); + } + + @Override + public String getDefaultValue() { + return term.getDefaultValue(); + } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.Term; + } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return typeInfo.getFullQualifiedName(); + } + + @Override + public String getAnnotationsTargetPath() { + return null; + } + + @Override + public List getAnnotations() { + return helper.getAnnotations(); + } + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java index 3c146ecbf..1292151dc 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java @@ -18,22 +18,28 @@ */ package org.apache.olingo.client.core.edm; +import java.util.List; import org.apache.olingo.client.api.edm.xml.v4.TypeDefinition; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.core.edm.AbstractEdmTypeDefinition; +import org.apache.olingo.commons.core.edm.EdmAnnotationHelper; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements EdmTypeDefinition { - private TypeDefinition typeDefinition; + private final TypeDefinition typeDefinition; - private EdmPrimitiveType edmPrimitiveTypeInstance; + private final EdmPrimitiveType edmPrimitiveTypeInstance; + + private final EdmAnnotationHelper helper; public EdmTypeDefinitionImpl(final ODataServiceVersion version, final Edm edm, final FullQualifiedName typeDefinitionName, final TypeDefinition typeDefinition) { @@ -46,6 +52,7 @@ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements } catch (IllegalArgumentException e) { throw new EdmException("Invalid underlying type: " + typeDefinition.getUnderlyingType(), e); } + this.helper = new EdmAnnotationHelperImpl(edm, typeDefinition); } @Override @@ -68,8 +75,19 @@ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements return typeDefinition.getScale(); } + @Override + public SRID getSrid() { + return typeDefinition.getSrid(); + } + @Override public Boolean isUnicode() { return typeDefinition.isUnicode(); } + + @Override + public List getAnnotations() { + return helper.getAnnotations(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmActionImportProxy.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmActionImportProxy.java index cb9ae27ad..cb22d1162 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmActionImportProxy.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmActionImportProxy.java @@ -53,4 +53,9 @@ public class EdmActionImportProxy extends EdmOperationImportImpl implements EdmA return edm.getUnboundAction(getActionFQN()); } + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.ActionImport; + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmEntitySetProxy.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmEntitySetProxy.java index 1af488918..079828fd0 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmEntitySetProxy.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmEntitySetProxy.java @@ -29,6 +29,7 @@ import org.apache.olingo.client.api.edm.xml.v3.AssociationSet; import org.apache.olingo.client.core.edm.xml.v3.EntityContainerImpl; import org.apache.olingo.client.core.edm.xml.v3.SchemaImpl; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmBindingTarget; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntitySet; @@ -113,4 +114,14 @@ public class EdmEntitySetProxy extends AbstractEdmBindingTarget implements EdmEn return Collections.emptyList(); } + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.EntitySet; + } + + @Override + public List getAnnotations() { + return Collections.emptyList(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionImportProxy.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionImportProxy.java index b64c9bbbb..da6605d53 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionImportProxy.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionImportProxy.java @@ -65,4 +65,9 @@ public class EdmFunctionImportProxy extends EdmOperationImportImpl implements Ed return true; } + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.FunctionImport; + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionProxy.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionProxy.java index d883f1def..1d184a046 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionProxy.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmFunctionProxy.java @@ -40,4 +40,5 @@ public class EdmFunctionProxy extends EdmOperationProxy implements EdmFunction { public boolean isComposable() { return functionImport.isComposable(); } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmNavigationPropertyProxy.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmNavigationPropertyProxy.java index cadb3ae0a..77e2f5903 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmNavigationPropertyProxy.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmNavigationPropertyProxy.java @@ -19,20 +19,23 @@ package org.apache.olingo.client.core.edm.v3; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.apache.olingo.client.api.edm.xml.Schema; import org.apache.olingo.client.api.edm.xml.v3.Association; import org.apache.olingo.client.api.edm.xml.v3.AssociationEnd; import org.apache.olingo.client.api.edm.xml.v3.NavigationProperty; import org.apache.olingo.client.api.edm.xml.v3.ReferentialConstraint; +import org.apache.olingo.client.core.edm.EdmReferentialConstraintImpl; import org.apache.olingo.client.core.edm.xml.v3.SchemaImpl; +import org.apache.olingo.client.core.edm.xml.v4.ReferentialConstraintImpl; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmNavigationProperty; import org.apache.olingo.commons.api.edm.EdmReferentialConstraint; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.AbstractEdmNavigationProperty; -import org.apache.olingo.commons.core.edm.EdmReferentialConstraintImpl; public class EdmNavigationPropertyProxy extends AbstractEdmNavigationProperty { @@ -120,7 +123,7 @@ public class EdmNavigationPropertyProxy extends AbstractEdmNavigationProperty { @Override public EdmNavigationProperty getPartner() { - return partner == null ? this: partner; + return partner == null ? this : partner; } @Override @@ -156,13 +159,24 @@ public class EdmNavigationPropertyProxy extends AbstractEdmNavigationProperty { referentialConstraints = new ArrayList(); if (constraint != null) { for (int i = 0; i < constraint.getPrincipal().getPropertyRefs().size(); i++) { - referentialConstraints.add(new EdmReferentialConstraintImpl( - constraint.getPrincipal().getPropertyRefs().get(i).getName(), - constraint.getDependent().getPropertyRefs().get(i).getName())); + final ReferentialConstraintImpl referentialConstraint = new ReferentialConstraintImpl(); + referentialConstraint.setProperty(constraint.getPrincipal().getPropertyRefs().get(i).getName()); + referentialConstraint.setReferencedProperty(constraint.getDependent().getPropertyRefs().get(i).getName()); + referentialConstraints.add(new EdmReferentialConstraintImpl(edm, referentialConstraint)); } } } return referentialConstraints; } + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return null; + } + + @Override + public List getAnnotations() { + return Collections.emptyList(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmOperationProxy.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmOperationProxy.java index 353e9165a..b2dfa4ba2 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmOperationProxy.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmOperationProxy.java @@ -18,7 +18,9 @@ */ package org.apache.olingo.client.core.edm.v3; +import org.apache.olingo.client.core.edm.xml.v3.ReturnTypeProxy; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.apache.olingo.client.api.edm.xml.CommonParameter; @@ -27,6 +29,7 @@ import org.apache.olingo.client.api.edm.xml.v3.Parameter; import org.apache.olingo.client.core.edm.EdmParameterImpl; import org.apache.olingo.client.core.edm.EdmReturnTypeImpl; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmParameter; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; @@ -40,7 +43,7 @@ public class EdmOperationProxy extends AbstractEdmOperation { final List parameters = instance.functionImport.getParameters(); final List _parameters = new ArrayList(parameters.size()); for (CommonParameter parameter : parameters) { - _parameters.add(EdmParameterImpl.getInstance(instance.edm, parameter)); + _parameters.add(new EdmParameterImpl(instance.edm, parameter)); } instance.setParameters(_parameters); @@ -74,4 +77,9 @@ public class EdmOperationProxy extends AbstractEdmOperation { return null; } + @Override + public List getAnnotations() { + return Collections.emptyList(); + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmServiceMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmServiceMetadataImpl.java index 9b7157b37..01b4a8790 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmServiceMetadataImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/EdmServiceMetadataImpl.java @@ -43,8 +43,8 @@ public class EdmServiceMetadataImpl extends AbstractEdmServiceMetadataImpl { } @Override - public String getDataServiceVersion() { - return SERVICE_VERSION.toString(); + public ODataServiceVersion getDataServiceVersion() { + return SERVICE_VERSION; } @Override diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmServiceMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmServiceMetadataImpl.java index 25236bea9..d01b99108 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmServiceMetadataImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/EdmServiceMetadataImpl.java @@ -48,8 +48,8 @@ public class EdmServiceMetadataImpl extends AbstractEdmServiceMetadataImpl { } @Override - public String getDataServiceVersion() { - return SERVICE_VERSION.toString(); + public ODataServiceVersion getDataServiceVersion() { + return SERVICE_VERSION; } @Override diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmCastImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmCastImpl.java new file mode 100644 index 000000000..0c0515544 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmCastImpl.java @@ -0,0 +1,80 @@ +/* + * 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.client.core.edm.v4.annotation; + +import org.apache.olingo.client.api.edm.xml.v4.annotation.Cast; +import org.apache.olingo.commons.api.edm.Edm; +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.geo.SRID; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.annotation.AbstractEdmAnnotatableDynamicAnnotationExpression; + +public class EdmCastImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmCast { + + private final Edm edm; + + private final Cast cast; + + private final EdmDynamicAnnotationExpression value; + + private EdmType type; + + public EdmCastImpl(final Edm edm, final Cast cast, final EdmDynamicAnnotationExpression value) { + this.edm = edm; + this.cast = cast; + this.value = value; + } + + @Override + public Integer getMaxLength() { + return cast.getMaxLength(); + } + + @Override + public Integer getPrecision() { + return cast.getPrecision(); + } + + @Override + public Integer getScale() { + return cast.getScale(); + } + + @Override + public SRID getSrid() { + return cast.getSrid(); + } + + @Override + public EdmType getType() { + if (type == null) { + final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(cast.getType()).build(); + type = typeInfo.getType(); + } + return type; + } + + @Override + public EdmDynamicAnnotationExpression getValue() { + return value; + } + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmConstantAnnotationExpressionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmConstantAnnotationExpressionImpl.java new file mode 100644 index 000000000..c53d0e859 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmConstantAnnotationExpressionImpl.java @@ -0,0 +1,137 @@ +/* + * 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.client.core.edm.v4.annotation; + +import java.util.ArrayList; +import java.util.List; +import org.apache.commons.lang3.StringUtils; +import org.apache.olingo.client.api.edm.xml.v4.annotation.ConstantAnnotationExpression; +import org.apache.olingo.commons.api.domain.v4.ODataEnumValue; +import org.apache.olingo.commons.api.domain.v4.ODataValue; +import org.apache.olingo.commons.api.edm.Edm; +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.core.domain.v4.ODataCollectionValueImpl; +import org.apache.olingo.commons.core.domain.v4.ODataEnumValueImpl; +import org.apache.olingo.commons.core.domain.v4.ODataPrimitiveValueImpl; + +public class EdmConstantAnnotationExpressionImpl implements EdmConstantAnnotationExpression { + + private final ODataValue value; + + public EdmConstantAnnotationExpressionImpl(final Edm edm, final ConstantAnnotationExpression constExprConstruct) { + if (constExprConstruct.getType() == ConstantAnnotationExpression.Type.EnumMember) { + final List enumValues = new ArrayList(); + String enumTypeName = null; + for (String split : StringUtils.split(constExprConstruct.getValue(), ' ')) { + final String[] enumSplit = StringUtils.split(split, '/'); + enumTypeName = enumSplit[0]; + enumValues.add(new ODataEnumValueImpl(enumSplit[0], enumSplit[1])); + } + if (enumValues.size() == 1) { + value = enumValues.get(0); + } else { + final ODataCollectionValueImpl collValue = new ODataCollectionValueImpl(enumTypeName); + for (ODataValue enumValue : enumValues) { + collValue.add(enumValue); + } + value = collValue; + } + } else { + final ODataPrimitiveValueImpl.BuilderImpl primitiveValueBuilder = + new ODataPrimitiveValueImpl.BuilderImpl(edm.getServiceMetadata().getDataServiceVersion()); + primitiveValueBuilder.setText(constExprConstruct.getValue()); + + switch (constExprConstruct.getType()) { + case Binary: + primitiveValueBuilder.setType(EdmPrimitiveTypeKind.Binary); + break; + + case Bool: + primitiveValueBuilder.setType(EdmPrimitiveTypeKind.Boolean); + break; + + case Date: + primitiveValueBuilder.setType(EdmPrimitiveTypeKind.Date); + break; + + case DateTimeOffset: + primitiveValueBuilder.setType(EdmPrimitiveTypeKind.DateTimeOffset); + break; + + case Decimal: + primitiveValueBuilder.setType(EdmPrimitiveTypeKind.Decimal); + break; + + case Duration: + primitiveValueBuilder.setType(EdmPrimitiveTypeKind.Duration); + break; + + case Float: + primitiveValueBuilder.setType(EdmPrimitiveTypeKind.Single); + break; + + case Guid: + primitiveValueBuilder.setType(EdmPrimitiveTypeKind.Guid); + break; + + case Int: + primitiveValueBuilder.setType(EdmPrimitiveTypeKind.Int32); + break; + + case TimeOfDay: + primitiveValueBuilder.setType(EdmPrimitiveTypeKind.TimeOfDay); + break; + + case String: + default: + primitiveValueBuilder.setType(EdmPrimitiveTypeKind.String); + } + + value = primitiveValueBuilder.build(); + } + } + + @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 ODataValue getValue() { + return value; + } + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmIsOfImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmIsOfImpl.java new file mode 100644 index 000000000..2d00e797e --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmIsOfImpl.java @@ -0,0 +1,80 @@ +/* + * 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.client.core.edm.v4.annotation; + +import org.apache.olingo.client.api.edm.xml.v4.annotation.IsOf; +import org.apache.olingo.commons.api.edm.Edm; +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.EdmIsOf; +import org.apache.olingo.commons.api.edm.geo.SRID; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.annotation.AbstractEdmAnnotatableDynamicAnnotationExpression; + +public class EdmIsOfImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmIsOf { + + private final Edm edm; + + private final IsOf isOf; + + private final EdmDynamicAnnotationExpression value; + + private EdmType type; + + public EdmIsOfImpl(final Edm edm, final IsOf isOf, final EdmDynamicAnnotationExpression value) { + this.edm = edm; + this.isOf = isOf; + this.value = value; + } + + @Override + public Integer getMaxLength() { + return isOf.getMaxLength(); + } + + @Override + public Integer getPrecision() { + return isOf.getPrecision(); + } + + @Override + public Integer getScale() { + return isOf.getScale(); + } + + @Override + public SRID getSrid() { + return isOf.getSrid(); + } + + @Override + public EdmType getType() { + if (type == null) { + final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(isOf.getType()).build(); + type = typeInfo.getType(); + } + return type; + } + + @Override + public EdmDynamicAnnotationExpression getValue() { + return value; + } + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmRecordImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmRecordImpl.java new file mode 100644 index 000000000..270cf87e5 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v4/annotation/EdmRecordImpl.java @@ -0,0 +1,55 @@ +/* + * 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.client.core.edm.v4.annotation; + +import java.util.List; +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmStructuredType; +import org.apache.olingo.commons.api.edm.annotation.EdmPropertyValue; +import org.apache.olingo.commons.api.edm.annotation.EdmRecord; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; +import org.apache.olingo.commons.core.edm.annotation.AbstractEdmAnnotatableDynamicAnnotationExpression; + +public class EdmRecordImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmRecord { + + private final Edm edm; + + private final List propertyValues; + + private final EdmStructuredType type; + + public EdmRecordImpl(final Edm edm, final String type, final List propertyValues) { + this.edm = edm; + this.propertyValues = propertyValues; + + final EdmTypeInfo typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(type).build(); + this.type = typeInfo.getEntityType() == null ? typeInfo.getComplexType() : typeInfo.getEntityType(); + } + + @Override + public List getPropertyValues() { + return propertyValues; + } + + @Override + public EdmStructuredType getType() { + return type; + } + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java index e21436f75..edfda03b9 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractEdmDeserializer.java @@ -27,7 +27,7 @@ import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser; import java.io.IOException; import org.apache.olingo.client.core.edm.xml.v4.ReturnTypeImpl; -import org.apache.olingo.client.core.edm.xml.v4.annotation.ConstExprConstructImpl; +import org.apache.olingo.client.core.edm.xml.v4.annotation.ConstantAnnotationExpressionImpl; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; public abstract class AbstractEdmDeserializer extends JsonDeserializer { @@ -35,12 +35,12 @@ public abstract class AbstractEdmDeserializer extends JsonDeserializer { protected ODataServiceVersion version; protected boolean isAnnotationConstExprConstruct(final JsonParser jp) throws IOException { - return ConstExprConstructImpl.Type.fromString(jp.getCurrentName()) != null; + return ConstantAnnotationExpressionImpl.Type.fromString(jp.getCurrentName()) != null; } - protected ConstExprConstructImpl parseAnnotationConstExprConstruct(final JsonParser jp) throws IOException { - final ConstExprConstructImpl constExpr = new ConstExprConstructImpl(); - constExpr.setType(ConstExprConstructImpl.Type.fromString(jp.getCurrentName())); + protected ConstantAnnotationExpressionImpl parseAnnotationConstExprConstruct(final JsonParser jp) throws IOException { + final ConstantAnnotationExpressionImpl constExpr = new ConstantAnnotationExpressionImpl(); + constExpr.setType(ConstantAnnotationExpressionImpl.Type.fromString(jp.getCurrentName())); constExpr.setValue(jp.nextTextValue()); return constExpr; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractProperty.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractProperty.java index 8d4da8071..b4e88ebdd 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractProperty.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/AbstractProperty.java @@ -21,6 +21,7 @@ package org.apache.olingo.client.core.edm.xml; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import org.apache.olingo.client.api.edm.xml.CommonProperty; +import org.apache.olingo.commons.api.edm.geo.SRID; @JsonDeserialize(using = PropertyDeserializer.class) public abstract class AbstractProperty extends AbstractEdmItem implements CommonProperty { @@ -43,7 +44,7 @@ public abstract class AbstractProperty extends AbstractEdmItem implements Common private boolean unicode = true; - private String srid; + private SRID srid; @Override public String getName() { @@ -118,11 +119,11 @@ public abstract class AbstractProperty extends AbstractEdmItem implements Common } @Override - public String getSrid() { + public SRID getSrid() { return srid; } - public void setSrid(final String srid) { + public void setSrid(final SRID srid) { this.srid = srid; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeDeserializer.java index ea62ba468..97d7d0b59 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/ComplexTypeDeserializer.java @@ -71,8 +71,8 @@ public class ComplexTypeDeserializer extends AbstractEdmDeserializer { @@ -60,7 +62,14 @@ public class ParameterDeserializer extends AbstractEdmDeserializer { @@ -74,7 +75,10 @@ public class PropertyDeserializer extends AbstractEdmDeserializer org.apache.olingo.client.core.edm.xml.v3.EntityContainerImpl.class)); } else { org.apache.olingo.client.core.edm.xml.v4.EntityContainerImpl entityContainer = - jp.readValueAs( + jp.readValueAs( org.apache.olingo.client.core.edm.xml.v4.EntityContainerImpl.class); entityContainer.setDefaultEntityContainer(true); ((org.apache.olingo.client.core.edm.xml.v4.SchemaImpl) schema). @@ -115,13 +115,11 @@ public class SchemaDeserializer extends AbstractEdmDeserializer } else if ("Annotations".equals(jp.getCurrentName())) { jp.nextToken(); if (schema instanceof org.apache.olingo.client.core.edm.xml.v3.SchemaImpl) { - ((org.apache.olingo.client.core.edm.xml.v3.SchemaImpl) schema).getAnnotationsList(). - add(jp.readValueAs( - org.apache.olingo.client.core.edm.xml.v3.AnnotationsImpl.class)); + ((org.apache.olingo.client.core.edm.xml.v3.SchemaImpl) schema).getAnnotationGroups(). + add(jp.readValueAs(org.apache.olingo.client.core.edm.xml.v3.AnnotationsImpl.class)); } else { - ((org.apache.olingo.client.core.edm.xml.v4.SchemaImpl) schema).getAnnotationsList(). - add(jp.readValueAs( - org.apache.olingo.client.core.edm.xml.v4.AnnotationsImpl.class)); + ((org.apache.olingo.client.core.edm.xml.v4.SchemaImpl) schema).getAnnotationGroups(). + add(jp.readValueAs(org.apache.olingo.client.core.edm.xml.v4.AnnotationsImpl.class)); } } else if ("Action".equals(jp.getCurrentName())) { jp.nextToken(); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/ReturnTypeProxy.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v3/ReturnTypeProxy.java similarity index 92% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/ReturnTypeProxy.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v3/ReturnTypeProxy.java index 79baae30e..c10abb1d6 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/v3/ReturnTypeProxy.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v3/ReturnTypeProxy.java @@ -16,10 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.core.edm.v3; +package org.apache.olingo.client.core.edm.xml.v3; import org.apache.olingo.client.api.edm.xml.v3.FunctionImport; import org.apache.olingo.client.api.edm.xml.v4.ReturnType; +import org.apache.olingo.commons.api.edm.geo.SRID; public class ReturnTypeProxy implements ReturnType { @@ -45,7 +46,7 @@ public class ReturnTypeProxy implements ReturnType { } @Override - public String getSrid() { + public SRID getSrid() { return null; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v3/SchemaImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v3/SchemaImpl.java index 9f6bba485..e8a5650b1 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v3/SchemaImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v3/SchemaImpl.java @@ -57,14 +57,14 @@ public class SchemaImpl extends AbstractSchema implements Schema { } @Override - public List getAnnotationsList() { + public List getAnnotationGroups() { return annotationList; } @Override - public Annotations getAnnotationsList(final String target) { + public Annotations getAnnotationGroup(final String target) { Annotations result = null; - for (Annotations annots : getAnnotationsList()) { + for (Annotations annots : getAnnotationGroups()) { if (target.equals(annots.getTarget())) { result = annots; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AbstractAnnotatedEdmItem.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AbstractAnnotatable.java similarity index 66% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AbstractAnnotatedEdmItem.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AbstractAnnotatable.java index 18b01bebe..ea6d83715 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AbstractAnnotatedEdmItem.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AbstractAnnotatable.java @@ -18,28 +18,22 @@ */ package org.apache.olingo.client.core.edm.xml.v4; -import org.apache.olingo.client.api.edm.xml.v4.AnnotatedEdmItem; +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; import org.apache.olingo.client.api.edm.xml.v4.Annotation; import org.apache.olingo.client.core.edm.xml.AbstractEdmItem; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.List; -public abstract class AbstractAnnotatedEdmItem extends AbstractEdmItem implements AnnotatedEdmItem { +public abstract class AbstractAnnotatable extends AbstractEdmItem implements Annotatable { private static final long serialVersionUID = -8859729466090997718L; - @JsonProperty("Annotation") - private AnnotationImpl annotation; + private final List annotations = new ArrayList(); @Override - public AnnotationImpl getAnnotation() { - return annotation; - } - - @JsonIgnore - public void setAnnotation(final Annotation annotation) { - this.annotation = (AnnotationImpl) annotation; + public List getAnnotations() { + return annotations; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionDeserializer.java index fd0c21410..41399a9d4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionDeserializer.java @@ -52,7 +52,7 @@ public class ActionDeserializer extends AbstractEdmDeserializer { action.setReturnType(parseReturnType(jp, "Action")); } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); - action.setAnnotation(jp.readValueAs(AnnotationImpl.class)); + action.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImpl.java index 9ad13c83d..a09eea679 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImpl.java @@ -28,7 +28,7 @@ import org.apache.olingo.client.api.edm.xml.v4.Parameter; import org.apache.olingo.client.api.edm.xml.v4.ReturnType; @JsonDeserialize(using = ActionDeserializer.class) -public class ActionImpl extends AbstractAnnotatedEdmItem implements Action { +public class ActionImpl extends AbstractAnnotatable implements Action { private static final long serialVersionUID = -99977447455438193L; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImportImpl.java index d54399856..5a06389c1 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImportImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ActionImportImpl.java @@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.olingo.client.api.edm.xml.v4.ActionImport; -public class ActionImportImpl extends AbstractAnnotatedEdmItem implements ActionImport { +public class ActionImportImpl extends AbstractAnnotatable implements ActionImport { private static final long serialVersionUID = -866422101558426421L; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AnnotationDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AnnotationDeserializer.java index 129926d83..d9d9e0c5c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AnnotationDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/AnnotationDeserializer.java @@ -25,7 +25,7 @@ import com.fasterxml.jackson.databind.DeserializationContext; import java.io.IOException; -import org.apache.olingo.client.core.edm.xml.v4.annotation.DynExprConstructImpl; +import org.apache.olingo.client.core.edm.xml.v4.annotation.AbstractDynamicAnnotationExpression; import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; public class AnnotationDeserializer extends AbstractEdmDeserializer { @@ -43,12 +43,15 @@ public class AnnotationDeserializer extends AbstractEdmDeserializer navigationProperties = new ArrayList(); - private Annotation annotation; + private final List annotations = new ArrayList(); @Override public boolean isAbstractEntityType() { @@ -91,12 +91,8 @@ public class ComplexTypeImpl extends AbstractComplexType implements ComplexType } @Override - public Annotation getAnnotation() { - return annotation; - } - - public void setAnnotation(final Annotation annotation) { - this.annotation = annotation; + public List getAnnotations() { + return annotations; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EntityContainerImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EntityContainerImpl.java index c67e17d6f..41640eb0d 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EntityContainerImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EntityContainerImpl.java @@ -19,7 +19,7 @@ package org.apache.olingo.client.core.edm.xml.v4; import org.apache.olingo.client.api.edm.xml.v4.ActionImport; -import org.apache.olingo.client.api.edm.xml.v4.AnnotatedEdmItem; +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; import org.apache.olingo.client.api.edm.xml.v4.Annotation; import org.apache.olingo.client.api.edm.xml.v4.EntityContainer; import org.apache.olingo.client.api.edm.xml.v4.EntitySet; @@ -30,7 +30,7 @@ import org.apache.olingo.client.core.edm.xml.AbstractEntityContainer; import java.util.ArrayList; import java.util.List; -public class EntityContainerImpl extends AbstractEntityContainer implements AnnotatedEdmItem, EntityContainer { +public class EntityContainerImpl extends AbstractEntityContainer implements Annotatable, EntityContainer { private static final long serialVersionUID = 2526002525927260320L; @@ -42,7 +42,7 @@ public class EntityContainerImpl extends AbstractEntityContainer implements Anno private final List functionImports = new ArrayList(); - private Annotation annotation; + private final List annotations = new ArrayList(); @Override public void setDefaultEntityContainer(final boolean defaultEntityContainer) { @@ -118,12 +118,8 @@ public class EntityContainerImpl extends AbstractEntityContainer implements Anno } @Override - public Annotation getAnnotation() { - return annotation; - } - - public void setAnnotation(final Annotation annotation) { - this.annotation = annotation; + public List getAnnotations() { + return annotations; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EntitySetImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EntitySetImpl.java index 9ef33c7c3..b79e0eb52 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EntitySetImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EntitySetImpl.java @@ -32,7 +32,7 @@ public class EntitySetImpl extends AbstractEntitySet implements EntitySet { private boolean includeInServiceDocument = true; - private Annotation annotation; + private final List annotations = new ArrayList(); private final List navigationPropertyBindings = new ArrayList(); @@ -51,12 +51,8 @@ public class EntitySetImpl extends AbstractEntitySet implements EntitySet { } @Override - public Annotation getAnnotation() { - return annotation; - } - - public void setAnnotation(final Annotation annotation) { - this.annotation = annotation; + public List getAnnotations() { + return annotations; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EntityTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EntityTypeImpl.java index 4de91016e..cbe2eea21 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EntityTypeImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EntityTypeImpl.java @@ -35,7 +35,7 @@ public class EntityTypeImpl extends AbstractEntityType implements EntityType { private final List navigationProperties = new ArrayList(); - private Annotation annotation; + private final List annotations = new ArrayList(); @Override public Property getProperty(final String name) { @@ -58,12 +58,8 @@ public class EntityTypeImpl extends AbstractEntityType implements EntityType { } @Override - public Annotation getAnnotation() { - return annotation; - } - - public void setAnnotation(final Annotation annotation) { - this.annotation = annotation; + public List getAnnotations() { + return annotations; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EnumTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EnumTypeImpl.java index 9c9b84d9b..44a3b895e 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EnumTypeImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/EnumTypeImpl.java @@ -18,23 +18,21 @@ */ package org.apache.olingo.client.core.edm.xml.v4; -import org.apache.olingo.client.api.edm.xml.v4.AnnotatedEdmItem; +import java.util.ArrayList; +import java.util.List; +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; import org.apache.olingo.client.api.edm.xml.v4.Annotation; import org.apache.olingo.client.core.edm.xml.AbstractEnumType; -public class EnumTypeImpl extends AbstractEnumType implements AnnotatedEdmItem { +public class EnumTypeImpl extends AbstractEnumType implements Annotatable { private static final long serialVersionUID = -3329664331877556957L; - private Annotation annotation; + private final List annotations = new ArrayList(); @Override - public Annotation getAnnotation() { - return annotation; - } - - public void setAnnotation(final Annotation annotation) { - this.annotation = annotation; + public List getAnnotations() { + return annotations; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/FunctionDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/FunctionDeserializer.java index e1e0707c4..200060f5a 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/FunctionDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/FunctionDeserializer.java @@ -54,7 +54,7 @@ public class FunctionDeserializer extends AbstractEdmDeserializer functionImpl.setReturnType(parseReturnType(jp, "Function")); } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); - functionImpl.setAnnotation(jp.readValueAs(AnnotationImpl.class)); + functionImpl.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/FunctionImportDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/FunctionImportDeserializer.java new file mode 100644 index 000000000..0c4fc0eb8 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/FunctionImportDeserializer.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.client.core.edm.xml.v4; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; + +import java.io.IOException; + +import org.apache.commons.lang3.BooleanUtils; +import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; + +public class FunctionImportDeserializer extends AbstractEdmDeserializer { + + @Override + protected FunctionImportImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + final FunctionImportImpl functImpImpl = new FunctionImportImpl(); + + for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { + final JsonToken token = jp.getCurrentToken(); + if (token == JsonToken.FIELD_NAME) { + if ("Name".equals(jp.getCurrentName())) { + functImpImpl.setName(jp.nextTextValue()); + } else if ("Function".equals(jp.getCurrentName())) { + functImpImpl.setFunction(jp.nextTextValue()); + } else if ("EntitySet".equals(jp.getCurrentName())) { + functImpImpl.setEntitySet(jp.nextTextValue()); + } else if ("IncludeInServiceDocument".equals(jp.getCurrentName())) { + functImpImpl.setIncludeInServiceDocument(BooleanUtils.toBoolean(jp.nextTextValue())); + } else if ("Annotation".equals(jp.getCurrentName())) { + jp.nextToken(); + functImpImpl.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); + } + } + } + + return functImpImpl; + } +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/FunctionImportImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/FunctionImportImpl.java index 5391d93b7..33e806751 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/FunctionImportImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/FunctionImportImpl.java @@ -18,30 +18,27 @@ */ package org.apache.olingo.client.core.edm.xml.v4; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.ArrayList; +import java.util.List; import org.apache.olingo.client.api.edm.xml.v4.Annotation; import org.apache.olingo.client.api.edm.xml.v4.FunctionImport; +@JsonDeserialize(using = FunctionImportDeserializer.class) public class FunctionImportImpl implements FunctionImport { private static final long serialVersionUID = 3023813358471000019L; - @JsonProperty(value = "Name", required = true) private String name; - @JsonProperty(value = "Function", required = true) private String function; - @JsonProperty(value = "EntitySet") private String entitySet; - @JsonProperty(value = "IncludeInServiceDocument") private boolean includeInServiceDocument = false; - @JsonProperty(value = "Annotation") - private Annotation annotation; + private final List annotations = new ArrayList(); @Override public String getName() { @@ -81,13 +78,8 @@ public class FunctionImportImpl implements FunctionImport { } @Override - public Annotation getAnnotation() { - return annotation; - } - - @JsonIgnore - public void setAnnotation(final Annotation annotation) { - this.annotation = annotation; + public List getAnnotations() { + return annotations; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/IncludeAnnotationsImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/IncludeAnnotationsImpl.java index a38345df4..23d311a30 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/IncludeAnnotationsImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/IncludeAnnotationsImpl.java @@ -34,7 +34,7 @@ public class IncludeAnnotationsImpl extends AbstractEdmItem implements IncludeAn private String qualifier; @JsonProperty(value = "TargetNamespace") - private String targeyNamespace; + private String targetNamespace; @Override public String getTermNamespace() { @@ -55,12 +55,12 @@ public class IncludeAnnotationsImpl extends AbstractEdmItem implements IncludeAn } @Override - public String getTargeyNamespace() { - return targeyNamespace; + public String getTargetNamespace() { + return targetNamespace; } public void setTargeyNamespace(final String targeyNamespace) { - this.targeyNamespace = targeyNamespace; + this.targetNamespace = targeyNamespace; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/MemberImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/MemberImpl.java index 152a59f0c..b5b7d2a73 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/MemberImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/MemberImpl.java @@ -18,28 +18,22 @@ */ package org.apache.olingo.client.core.edm.xml.v4; -import org.apache.olingo.client.api.edm.xml.v4.AnnotatedEdmItem; +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; import org.apache.olingo.client.api.edm.xml.v4.Annotation; import org.apache.olingo.client.core.edm.xml.AbstractMember; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.ArrayList; +import java.util.List; -public class MemberImpl extends AbstractMember implements AnnotatedEdmItem { +public class MemberImpl extends AbstractMember implements Annotatable { private static final long serialVersionUID = -344920557183058824L; - @JsonProperty("Annotation") - private Annotation annotation; + private final List annotations = new ArrayList(); @Override - public Annotation getAnnotation() { - return annotation; - } - - @JsonIgnore - public void setAnnotation(final Annotation annotation) { - this.annotation = annotation; + public List getAnnotations() { + return annotations; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/NavigationPropertyDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/NavigationPropertyDeserializer.java index 8ed96691f..8d1e2e262 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/NavigationPropertyDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/NavigationPropertyDeserializer.java @@ -59,7 +59,7 @@ public class NavigationPropertyDeserializer extends AbstractEdmDeserializer annotations = new ArrayList(); @Override public String getType() { @@ -88,12 +88,8 @@ public class NavigationPropertyImpl extends AbstractNavigationProperty implement } @Override - public Annotation getAnnotation() { - return annotation; - } - - public void setAnnotation(final Annotation annotation) { - this.annotation = annotation; + public List getAnnotations() { + return annotations; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ParameterImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ParameterImpl.java index 990cef027..0c117cddb 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ParameterImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ParameterImpl.java @@ -18,22 +18,33 @@ */ package org.apache.olingo.client.core.edm.xml.v4; +import java.util.ArrayList; +import java.util.List; +import org.apache.olingo.client.api.edm.xml.v4.Annotation; import org.apache.olingo.client.api.edm.xml.v4.Parameter; import org.apache.olingo.client.core.edm.xml.AbstractParameter; +import org.apache.olingo.commons.api.edm.geo.SRID; public class ParameterImpl extends AbstractParameter implements Parameter { private static final long serialVersionUID = -1067642515116697747L; - private String srid; + private SRID srid; + + private final List annotations = new ArrayList(); @Override - public String getSrid() { + public SRID getSrid() { return srid; } - public void setSrid(final String srid) { + public void setSrid(final SRID srid) { this.srid = srid; } + @Override + public List getAnnotations() { + return annotations; + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/PropertyImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/PropertyImpl.java index 9b1f67de3..e8d68edef 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/PropertyImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/PropertyImpl.java @@ -18,7 +18,8 @@ */ package org.apache.olingo.client.core.edm.xml.v4; -import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.ArrayList; +import java.util.List; import org.apache.olingo.client.api.edm.xml.v4.Annotation; import org.apache.olingo.client.api.edm.xml.v4.Property; @@ -28,15 +29,10 @@ public class PropertyImpl extends AbstractProperty implements Property { private static final long serialVersionUID = -5541908235094985412L; - private Annotation annotation; + private final List annotations = new ArrayList(); @Override - public Annotation getAnnotation() { - return annotation; - } - - @JsonIgnore - public void setAnnotation(final Annotation annotation) { - this.annotation = annotation; + public List getAnnotations() { + return annotations; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ReferentialConstraintImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ReferentialConstraintImpl.java index d18e87e73..7b1fa7d57 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ReferentialConstraintImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ReferentialConstraintImpl.java @@ -22,7 +22,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.olingo.client.api.edm.xml.v4.ReferentialConstraint; -public class ReferentialConstraintImpl extends AbstractAnnotatedEdmItem implements ReferentialConstraint { +public class ReferentialConstraintImpl extends AbstractAnnotatable implements ReferentialConstraint { private static final long serialVersionUID = -9182114558289778632L; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ReturnTypeDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ReturnTypeDeserializer.java index 85ecc6cf9..f11605bab 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ReturnTypeDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/ReturnTypeDeserializer.java @@ -27,6 +27,7 @@ import java.io.IOException; import org.apache.commons.lang3.BooleanUtils; import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; +import org.apache.olingo.commons.api.edm.geo.SRID; public class ReturnTypeDeserializer extends AbstractEdmDeserializer { @@ -52,7 +53,10 @@ public class ReturnTypeDeserializer extends AbstractEdmDeserializer actions = new ArrayList(); - private final List annotationsList = new ArrayList(); + private final List annotationGroups = new ArrayList(); private final List annotations = new ArrayList(); @@ -59,7 +62,7 @@ public class SchemaImpl extends AbstractSchema implements Schema { private final List typeDefinitions = new ArrayList(); - private Annotation annotation; + private Map annotatables; @Override public List getActions() { @@ -72,14 +75,14 @@ public class SchemaImpl extends AbstractSchema implements Schema { } @Override - public List getAnnotationsList() { - return annotationsList; + public List getAnnotationGroups() { + return annotationGroups; } @Override - public Annotations getAnnotationsList(final String target) { + public Annotations getAnnotationGroup(final String target) { Annotations result = null; - for (Annotations annots : getAnnotationsList()) { + for (Annotations annots : getAnnotationGroups()) { if (target.equals(annots.getTarget())) { result = annots; } @@ -87,6 +90,17 @@ public class SchemaImpl extends AbstractSchema implements Schema { return result; } + @Override + public Annotation getAnnotation(final String term) { + Annotation result = null; + for (Annotation annot : getAnnotations()) { + if (term.equals(annot.getTerm())) { + result = annot; + } + } + return result; + } + @Override public List getAnnotations() { return annotations; @@ -102,6 +116,11 @@ public class SchemaImpl extends AbstractSchema implements Schema { return getAllByName(name, getFunctions()); } + @Override + public Term getTerm(final String name) { + return getOneByName(name, getTerms()); + } + @Override public List getTerms() { return terms; @@ -145,15 +164,6 @@ public class SchemaImpl extends AbstractSchema implements Schema { return null; } - @Override - public Annotation getAnnotation() { - return annotation; - } - - public void setAnnotation(final Annotation annotation) { - this.annotation = annotation; - } - @Override public List getEnumTypes() { return enumTypes; @@ -178,4 +188,38 @@ public class SchemaImpl extends AbstractSchema implements Schema { public List getEntityTypes() { return entityTypes; } + + @Override + public Map getAnnotatables() { + if (annotatables == null) { + annotatables = new HashMap(); + for (Action action : getActions()) { + annotatables.put(action.getName(), action); + } + for (Annotation annotation : getAnnotations()) { + annotatables.put(annotation.getTerm(), annotation); + } + for (ComplexType complexType : getComplexTypes()) { + annotatables.put(complexType.getName(), complexType); + } + annotatables.put(entityContainer.getName(), entityContainer); + for (EntityType entityType : getEntityTypes()) { + annotatables.put(entityType.getName(), entityType); + } + for (EnumType enumType : getEnumTypes()) { + annotatables.put(enumType.getName(), (EnumTypeImpl) enumType); + } + for (Function function : getFunctions()) { + annotatables.put(function.getName(), function); + } + for (Term term : getTerms()) { + annotatables.put(term.getName(), term); + } + for (TypeDefinition typedef : getTypeDefinitions()) { + annotatables.put(typedef.getName(), typedef); + } + } + return annotatables; + } + } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/SingletonDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/SingletonDeserializer.java index d79bd22a4..758f07d04 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/SingletonDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/SingletonDeserializer.java @@ -48,7 +48,7 @@ public class SingletonDeserializer extends AbstractEdmDeserializer { @@ -60,14 +61,15 @@ public class TermDeserializer extends AbstractEdmDeserializer { final String scale = jp.nextTextValue(); term.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); } else if ("SRID".equals(jp.getCurrentName())) { - term.setSrid(jp.nextTextValue()); - } else if ("AppliesTo".equals(jp.getCurrentName())) { - for (String split : StringUtils.split(jp.nextTextValue())) { - term.getAppliesTo().add(CSDLElement.valueOf(split)); + final String srid = jp.nextTextValue(); + if (srid != null) { + term.setSrid(SRID.valueOf(srid)); } + } else if ("AppliesTo".equals(jp.getCurrentName())) { + term.getAppliesTo().addAll(Arrays.asList(StringUtils.split(jp.nextTextValue()))); } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); - term.setAnnotation(jp.readValueAs(AnnotationImpl.class)); + term.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/TermImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/TermImpl.java index d210ddc99..9d7871086 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/TermImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/TermImpl.java @@ -23,11 +23,11 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.ArrayList; import java.util.List; -import org.apache.olingo.client.api.edm.xml.v4.CSDLElement; import org.apache.olingo.client.api.edm.xml.v4.Term; +import org.apache.olingo.commons.api.edm.geo.SRID; @JsonDeserialize(using = TermDeserializer.class) -public class TermImpl extends AbstractAnnotatedEdmItem implements Term { +public class TermImpl extends AbstractAnnotatable implements Term { private static final long serialVersionUID = -5888231162358116515L; @@ -47,9 +47,9 @@ public class TermImpl extends AbstractAnnotatedEdmItem implements Term { private Integer scale; - private String srid; + private SRID srid; - private final List appliesTo = new ArrayList(); + private final List appliesTo = new ArrayList(); @Override public String getName() { @@ -124,16 +124,16 @@ public class TermImpl extends AbstractAnnotatedEdmItem implements Term { } @Override - public String getSrid() { + public SRID getSrid() { return srid; } - public void setSrid(final String srid) { + public void setSrid(final SRID srid) { this.srid = srid; } @Override - public List getAppliesTo() { + public List getAppliesTo() { return appliesTo; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/TypeDefinitionDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/TypeDefinitionDeserializer.java index 8fe90259f..34e33d8c8 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/TypeDefinitionDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/TypeDefinitionDeserializer.java @@ -27,6 +27,7 @@ import java.io.IOException; import org.apache.commons.lang3.BooleanUtils; import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; +import org.apache.olingo.commons.api.edm.geo.SRID; public class TypeDefinitionDeserializer extends AbstractEdmDeserializer { @@ -53,7 +54,10 @@ public class TypeDefinitionDeserializer extends AbstractEdmDeserializer annotations = new ArrayList(); @@ -103,11 +104,11 @@ public class TypeDefinitionImpl extends AbstractEdmItem implements TypeDefinitio } @Override - public String getSrid() { + public SRID getSrid() { return srid; } - public void setSrid(final String srid) { + public void setSrid(final SRID srid) { this.srid = srid; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AnnotatedDynExprConstruct.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractAnnotatableDynamicAnnotationExpression.java similarity index 72% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AnnotatedDynExprConstruct.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractAnnotatableDynamicAnnotationExpression.java index c3eca1171..bb0843e3d 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AnnotatedDynExprConstruct.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractAnnotatableDynamicAnnotationExpression.java @@ -18,21 +18,20 @@ */ package org.apache.olingo.client.core.edm.xml.v4.annotation; -import org.apache.olingo.client.api.edm.xml.v4.AnnotatedEdmItem; +import java.util.ArrayList; +import java.util.List; +import org.apache.olingo.client.api.edm.xml.v4.Annotatable; import org.apache.olingo.client.api.edm.xml.v4.Annotation; -abstract class AnnotatedDynExprConstruct extends DynExprConstructImpl implements AnnotatedEdmItem { +abstract class AbstractAnnotatableDynamicAnnotationExpression + extends AbstractDynamicAnnotationExpression implements Annotatable { private static final long serialVersionUID = -8117155475397749038L; - private Annotation annotation; + private final List annotations = new ArrayList(); @Override - public Annotation getAnnotation() { - return annotation; - } - - public void setAnnotation(final Annotation annotation) { - this.annotation = annotation; + public List getAnnotations() { + return annotations; } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractAnnotationExpression.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractAnnotationExpression.java new file mode 100644 index 000000000..a1cca5079 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractAnnotationExpression.java @@ -0,0 +1,49 @@ +/* + * 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.client.core.edm.xml.v4.annotation; + +import org.apache.olingo.client.api.edm.xml.v4.annotation.AnnotationExpression; +import org.apache.olingo.client.api.edm.xml.v4.annotation.ConstantAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.v4.annotation.DynamicAnnotationExpression; +import org.apache.olingo.client.core.edm.xml.AbstractEdmItem; + +public abstract class AbstractAnnotationExpression extends AbstractEdmItem implements AnnotationExpression { + + private static final long serialVersionUID = 7108626008005050492L; + + @Override + public boolean isConstant() { + return this instanceof ConstantAnnotationExpression; + } + + @Override + public ConstantAnnotationExpression asConstant() { + return isConstant() ? (ConstantAnnotationExpression) this : null; + } + + @Override + public boolean isDynamic() { + return this instanceof DynamicAnnotationExpression; + } + + @Override + public DynamicAnnotationExpression asDynamic() { + return isDynamic() ? (DynamicAnnotationExpression) this : null; + } +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractDynamicAnnotationExpression.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractDynamicAnnotationExpression.java new file mode 100644 index 000000000..429671c20 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractDynamicAnnotationExpression.java @@ -0,0 +1,217 @@ +/* + * 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.client.core.edm.xml.v4.annotation; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.apache.olingo.client.api.edm.xml.v4.annotation.AnnotationPath; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Apply; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Cast; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Collection; +import org.apache.olingo.client.api.edm.xml.v4.annotation.DynamicAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.v4.annotation.If; +import org.apache.olingo.client.api.edm.xml.v4.annotation.IsOf; +import org.apache.olingo.client.api.edm.xml.v4.annotation.LabeledElement; +import org.apache.olingo.client.api.edm.xml.v4.annotation.LabeledElementReference; +import org.apache.olingo.client.api.edm.xml.v4.annotation.NavigationPropertyPath; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Not; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Null; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Path; +import org.apache.olingo.client.api.edm.xml.v4.annotation.PropertyPath; +import org.apache.olingo.client.api.edm.xml.v4.annotation.PropertyValue; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Record; +import org.apache.olingo.client.api.edm.xml.v4.annotation.TwoParamsOpDynamicAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.v4.annotation.UrlRef; + +@JsonDeserialize(using = DynamicAnnotationExpressionDeserializer.class) +public abstract class AbstractDynamicAnnotationExpression + extends AbstractAnnotationExpression implements DynamicAnnotationExpression { + + private static final long serialVersionUID = -642012862023177349L; + + @Override + public boolean isNot() { + return this instanceof Not; + } + + @Override + public Not asNot() { + return isNot() ? (Not) this : null; + + } + + @Override + public boolean isTwoParamsOp() { + return this instanceof TwoParamsOpDynamicAnnotationExpression; + } + + @Override + public TwoParamsOpDynamicAnnotationExpression asTwoParamsOp() { + return isTwoParamsOp() ? (TwoParamsOpDynamicAnnotationExpression) this : null; + } + + @Override + public boolean isAnnotationPath() { + return this instanceof AnnotationPath; + } + + @Override + public AnnotationPath asAnnotationPath() { + return isAnnotationPath() ? (AnnotationPath) this : null; + } + + @Override + public boolean isApply() { + return this instanceof Apply; + } + + @Override + public Apply asApply() { + return isApply() ? (Apply) this : null; + } + + @Override + public boolean isCast() { + return this instanceof Cast; + } + + @Override + public Cast asCast() { + return isCast() ? (Cast) this : null; + } + + @Override + public boolean isCollection() { + return this instanceof Collection; + } + + @Override + public Collection asCollection() { + return isCollection() ? (Collection) this : null; + } + + @Override + public boolean isIf() { + return this instanceof If; + } + + @Override + public If asIf() { + return isIf() ? (If) this : null; + } + + @Override + public boolean isIsOf() { + return this instanceof IsOf; + } + + @Override + public IsOf asIsOf() { + return isIsOf() ? (IsOf) this : null; + } + + @Override + public boolean isLabeledElement() { + return this instanceof LabeledElement; + } + + @Override + public LabeledElement asLabeledElement() { + return isLabeledElement() ? (LabeledElement) this : null; + } + + @Override + public boolean isLabeledElementReference() { + return this instanceof LabeledElementReference; + } + + @Override + public LabeledElementReference asLabeledElementReference() { + return isLabeledElementReference() ? (LabeledElementReference) this : null; + } + + @Override + public boolean isNull() { + return this instanceof Null; + } + + @Override + public Null asNull() { + return isNull() ? (Null) this : null; + } + + @Override + public boolean isNavigationPropertyPath() { + return this instanceof NavigationPropertyPath; + } + + @Override + public NavigationPropertyPath asNavigationPropertyPath() { + return isNavigationPropertyPath() ? (NavigationPropertyPath) this : null; + } + + @Override + public boolean isPath() { + return this instanceof Path; + } + + @Override + public Path asPath() { + return isPath() ? (Path) this : null; + } + + @Override + public boolean isPropertyPath() { + return this instanceof PropertyPath; + } + + @Override + public PropertyPath asPropertyPath() { + return isPropertyPath() ? (PropertyPath) this : null; + } + + @Override + public boolean isPropertyValue() { + return this instanceof PropertyValue; + } + + @Override + public PropertyValue asPropertyValue() { + return isPropertyValue() ? (PropertyValue) this : null; + } + + @Override + public boolean isRecord() { + return this instanceof Record; + } + + @Override + public Record asRecord() { + return isRecord() ? (Record) this : null; + } + + @Override + public boolean isUrlRef() { + return this instanceof UrlRef; + } + + @Override + public UrlRef asUrlRef() { + return isUrlRef() ? (UrlRef) this : null; + } +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractElOrAttrConstruct.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractElementOrAttributeExpression.java similarity index 92% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractElOrAttrConstruct.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractElementOrAttributeExpression.java index c60f2ffe0..b438407a8 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractElOrAttrConstruct.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AbstractElementOrAttributeExpression.java @@ -21,7 +21,7 @@ package org.apache.olingo.client.core.edm.xml.v4.annotation; /** * Groups dynamic expressions that may be provided using element notation or attribute notation. */ -abstract class AbstractElOrAttrConstruct extends DynExprConstructImpl { +abstract class AbstractElementOrAttributeExpression extends AbstractDynamicAnnotationExpression { private static final long serialVersionUID = 5503275111425750339L; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ExprConstructImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AnnotationPathImpl.java similarity index 74% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ExprConstructImpl.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AnnotationPathImpl.java index c0bd62667..4d3765853 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ExprConstructImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/AnnotationPathImpl.java @@ -18,11 +18,10 @@ */ package org.apache.olingo.client.core.edm.xml.v4.annotation; -import org.apache.olingo.client.api.edm.xml.v4.annotation.ExprConstruct; -import org.apache.olingo.client.core.edm.xml.AbstractEdmItem; +import org.apache.olingo.client.api.edm.xml.v4.annotation.AnnotationPath; -public abstract class ExprConstructImpl extends AbstractEdmItem implements ExprConstruct { +public class AnnotationPathImpl extends AbstractElementOrAttributeExpression implements AnnotationPath { - private static final long serialVersionUID = 7108626008005050492L; + private static final long serialVersionUID = 6198019768659098819L; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ApplyDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ApplyDeserializer.java index 56251a3e8..433588048 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ApplyDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ApplyDeserializer.java @@ -28,13 +28,13 @@ import java.io.IOException; import org.apache.olingo.client.core.edm.xml.v4.AnnotationImpl; import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; -public class ApplyDeserializer extends AbstractEdmDeserializer { +public class ApplyDeserializer extends AbstractEdmDeserializer { @Override - protected Apply doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + protected ApplyImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { - final Apply apply = new Apply(); + final ApplyImpl apply = new ApplyImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); @@ -42,11 +42,11 @@ public class ApplyDeserializer extends AbstractEdmDeserializer { if ("Function".equals(jp.getCurrentName())) { apply.setFunction(jp.nextTextValue()); } else if ("Annotation".equals(jp.getCurrentName())) { - apply.setAnnotation(jp.readValueAs(AnnotationImpl.class)); + apply.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); } else if (isAnnotationConstExprConstruct(jp)) { apply.getParameters().add(parseAnnotationConstExprConstruct(jp)); } else { - apply.getParameters().add(jp.readValueAs(DynExprConstructImpl.class)); + apply.getParameters().add(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Apply.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ApplyImpl.java similarity index 72% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Apply.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ApplyImpl.java index 9c02f974e..40f8aa170 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Apply.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ApplyImpl.java @@ -23,23 +23,19 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.ArrayList; import java.util.List; -import org.apache.olingo.client.api.edm.xml.v4.annotation.ExprConstruct; +import org.apache.olingo.client.api.edm.xml.v4.annotation.AnnotationExpression; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Apply; @JsonDeserialize(using = ApplyDeserializer.class) -public class Apply extends AnnotatedDynExprConstruct { +public class ApplyImpl extends AbstractAnnotatableDynamicAnnotationExpression implements Apply { private static final long serialVersionUID = 6198019768659098819L; - public static final String CANONICAL_FUNCTION_CONCAT = "odata.concat"; - - public static final String CANONICAL_FUNCTION_FILLURITEMPLATE = "odata.fillUriTemplate"; - - public static final String CANONICAL_FUNCTION_URIENCODE = "odata.uriEncode"; - private String function; - private final List parameters = new ArrayList(); + private final List parameters = new ArrayList(); + @Override public String getFunction() { return function; } @@ -48,7 +44,8 @@ public class Apply extends AnnotatedDynExprConstruct { this.function = function; } - public List getParameters() { + @Override + public List getParameters() { return parameters; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CastDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CastDeserializer.java index 25ea59413..e29b9ff8c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CastDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CastDeserializer.java @@ -24,18 +24,18 @@ import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.DeserializationContext; import java.io.IOException; -import java.math.BigInteger; import org.apache.olingo.client.core.edm.xml.v4.AnnotationImpl; import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; +import org.apache.olingo.commons.api.edm.geo.SRID; -public class CastDeserializer extends AbstractEdmDeserializer { +public class CastDeserializer extends AbstractEdmDeserializer { @Override - protected Cast doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + protected CastImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { - final Cast cast = new Cast(); + final CastImpl cast = new CastImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); @@ -43,17 +43,22 @@ public class CastDeserializer extends AbstractEdmDeserializer { if ("Type".equals(jp.getCurrentName())) { cast.setType(jp.nextTextValue()); } else if ("Annotation".equals(jp.getCurrentName())) { - cast.setAnnotation(jp.readValueAs(AnnotationImpl.class)); + cast.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); } else if ("MaxLength".equals(jp.getCurrentName())) { - cast.setMaxLength(jp.nextTextValue()); + final String maxLenght = jp.nextTextValue(); + cast.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); } else if ("Precision".equals(jp.getCurrentName())) { - cast.setPrecision(BigInteger.valueOf(jp.nextLongValue(0L))); + cast.setPrecision(Integer.valueOf(jp.nextTextValue())); } else if ("Scale".equals(jp.getCurrentName())) { - cast.setScale(BigInteger.valueOf(jp.nextLongValue(0L))); + final String scale = jp.nextTextValue(); + cast.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); } else if ("SRID".equals(jp.getCurrentName())) { - cast.setSrid(jp.nextTextValue()); + final String srid = jp.nextTextValue(); + if (srid != null) { + cast.setSrid(SRID.valueOf(srid)); + } } else { - cast.setValue(jp.readValueAs(DynExprConstructImpl.class)); + cast.setValue(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Cast.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CastImpl.java similarity index 61% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Cast.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CastImpl.java index 812602ea1..4278a24df 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Cast.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CastImpl.java @@ -18,29 +18,30 @@ */ package org.apache.olingo.client.core.edm.xml.v4.annotation; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Cast; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.math.BigInteger; - -import org.apache.olingo.client.api.edm.xml.v4.annotation.DynExprConstruct; +import org.apache.olingo.client.api.edm.xml.v4.annotation.DynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.geo.SRID; @JsonDeserialize(using = CastDeserializer.class) -public class Cast extends AnnotatedDynExprConstruct { +public class CastImpl extends AbstractAnnotatableDynamicAnnotationExpression implements Cast { private static final long serialVersionUID = -7836626668653004926L; private String type; - private String maxLength; + private Integer maxLength; - private BigInteger precision; + private Integer precision; - private BigInteger scale; + private Integer scale; - private String srid; + private SRID srid; - private DynExprConstruct value; + private DynamicAnnotationExpression value; + @Override public String getType() { return type; } @@ -49,43 +50,48 @@ public class Cast extends AnnotatedDynExprConstruct { this.type = type; } - public String getMaxLength() { + @Override + public Integer getMaxLength() { return maxLength; } - public void setMaxLength(final String maxLength) { + public void setMaxLength(final Integer maxLength) { this.maxLength = maxLength; } - public BigInteger getPrecision() { + @Override + public Integer getPrecision() { return precision; } - public void setPrecision(final BigInteger precision) { + public void setPrecision(final Integer precision) { this.precision = precision; } - public BigInteger getScale() { + @Override + public Integer getScale() { return scale; } - public void setScale(final BigInteger scale) { + public void setScale(final Integer scale) { this.scale = scale; } - public String getSrid() { + @Override + public SRID getSrid() { return srid; } - public void setSrid(final String srid) { + public void setSrid(final SRID srid) { this.srid = srid; } - public DynExprConstruct getValue() { + @Override + public DynamicAnnotationExpression getValue() { return value; } - public void setValue(final DynExprConstruct value) { + public void setValue(final DynamicAnnotationExpression value) { this.value = value; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CollectionDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CollectionDeserializer.java index 8ef4018ae..8d6a53ca9 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CollectionDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CollectionDeserializer.java @@ -27,13 +27,13 @@ import java.io.IOException; import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; -public class CollectionDeserializer extends AbstractEdmDeserializer { +public class CollectionDeserializer extends AbstractEdmDeserializer { @Override - protected Collection doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + protected CollectionImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { - final Collection collection = new Collection(); + final CollectionImpl collection = new CollectionImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); @@ -41,7 +41,7 @@ public class CollectionDeserializer extends AbstractEdmDeserializer if (isAnnotationConstExprConstruct(jp)) { collection.getItems().add(parseAnnotationConstExprConstruct(jp)); } else { - collection.getItems().add(jp.readValueAs( DynExprConstructImpl.class)); + collection.getItems().add(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Collection.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CollectionImpl.java similarity index 74% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Collection.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CollectionImpl.java index c225043f7..ebe1a6588 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Collection.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/CollectionImpl.java @@ -18,21 +18,23 @@ */ package org.apache.olingo.client.core.edm.xml.v4.annotation; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Collection; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.ArrayList; import java.util.List; -import org.apache.olingo.client.api.edm.xml.v4.annotation.ExprConstruct; +import org.apache.olingo.client.api.edm.xml.v4.annotation.AnnotationExpression; @JsonDeserialize(using = CollectionDeserializer.class) -public class Collection extends DynExprConstructImpl { +public class CollectionImpl extends AbstractDynamicAnnotationExpression implements Collection { private static final long serialVersionUID = -4975881520695477686L; - private final List items = new ArrayList(); + private final List items = new ArrayList(); - public List getItems() { + @Override + public List getItems() { return items; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ConstExprConstructImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ConstantAnnotationExpressionImpl.java similarity index 85% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ConstExprConstructImpl.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ConstantAnnotationExpressionImpl.java index 7af136c39..591d783bf 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ConstExprConstructImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/ConstantAnnotationExpressionImpl.java @@ -18,9 +18,10 @@ */ package org.apache.olingo.client.core.edm.xml.v4.annotation; -import org.apache.olingo.client.api.edm.xml.v4.annotation.ConstExprConstruct; +import org.apache.olingo.client.api.edm.xml.v4.annotation.ConstantAnnotationExpression; -public class ConstExprConstructImpl extends ExprConstructImpl implements ConstExprConstruct { +public class ConstantAnnotationExpressionImpl + extends AbstractAnnotationExpression implements ConstantAnnotationExpression { private static final long serialVersionUID = 2250072064504668969L; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/DynExprConstructDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/DynExprConstructDeserializer.java deleted file mode 100644 index 59266a5aa..000000000 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/DynExprConstructDeserializer.java +++ /dev/null @@ -1,147 +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.client.core.edm.xml.v4.annotation; - -import com.fasterxml.jackson.core.JsonLocation; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; - -import java.io.IOException; - -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.ClassUtils; -import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; - -public class DynExprConstructDeserializer extends AbstractEdmDeserializer { - - private static final String[] EL_OR_ATTR = { AnnotationPath.class.getSimpleName(), Path.class.getSimpleName() }; - - private static final String APPLY = Apply.class.getSimpleName(); - - private static final String CAST = Cast.class.getSimpleName(); - - private static final String COLLECTION = Collection.class.getSimpleName(); - - private static final String IF = If.class.getSimpleName(); - - private static final String IS_OF = IsOf.class.getSimpleName(); - - private static final String LABELED_ELEMENT = LabeledElement.class.getSimpleName(); - - private static final String NULL = Null.class.getSimpleName(); - - private static final String RECORD = Record.class.getSimpleName(); - - private static final String URL_REF = UrlRef.class.getSimpleName(); - - private AbstractElOrAttrConstruct getElOrAttrInstance(final String simpleClassName) throws JsonParseException { - try { - @SuppressWarnings("unchecked") - Class elOrAttrClass = - (Class) ClassUtils.getClass( - getClass().getPackage().getName() + "." + simpleClassName); - return elOrAttrClass.newInstance(); - } catch (Exception e) { - throw new JsonParseException("Could not instantiate " + simpleClassName, JsonLocation.NA, e); - } - } - - private ExprConstructImpl parseConstOrEnumExprConstruct(final JsonParser jp) throws IOException { - ExprConstructImpl result; - if (isAnnotationConstExprConstruct(jp)) { - result = parseAnnotationConstExprConstruct(jp); - } else { - result = jp.readValueAs( DynExprConstructImpl.class); - } - jp.nextToken(); - - return result; - } - - @Override - protected DynExprConstructImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) - throws IOException, JsonProcessingException { - - DynExprConstructImpl construct = null; - - if (DynExprSingleParamOp.Type.fromString(jp.getCurrentName()) != null) { - final DynExprSingleParamOp dynExprSingleParamOp = new DynExprSingleParamOp(); - dynExprSingleParamOp.setType(DynExprSingleParamOp.Type.fromString(jp.getCurrentName())); - - jp.nextToken(); - jp.nextToken(); - dynExprSingleParamOp.setExpression(jp.readValueAs( DynExprConstructImpl.class)); - - construct = dynExprSingleParamOp; - } else if (DynExprDoubleParamOp.Type.fromString(jp.getCurrentName()) != null) { - final DynExprDoubleParamOp dynExprDoubleParamOp = new DynExprDoubleParamOp(); - dynExprDoubleParamOp.setType(DynExprDoubleParamOp.Type.fromString(jp.getCurrentName())); - - jp.nextToken(); - jp.nextToken(); - dynExprDoubleParamOp.setLeft(jp.readValueAs( DynExprConstructImpl.class)); - dynExprDoubleParamOp.setRight(jp.readValueAs( DynExprConstructImpl.class)); - - construct = dynExprDoubleParamOp; - } else if (ArrayUtils.contains(EL_OR_ATTR, jp.getCurrentName())) { - final AbstractElOrAttrConstruct elOrAttr = getElOrAttrInstance(jp.getCurrentName()); - elOrAttr.setValue(jp.nextTextValue()); - - construct = elOrAttr; - } else if (APPLY.equals(jp.getCurrentName())) { - jp.nextToken(); - construct = jp.readValueAs( Apply.class); - } else if (CAST.equals(jp.getCurrentName())) { - jp.nextToken(); - construct = jp.readValueAs( Cast.class); - } else if (COLLECTION.equals(jp.getCurrentName())) { - jp.nextToken(); - construct = jp.readValueAs( Collection.class); - } else if (IF.equals(jp.getCurrentName())) { - jp.nextToken(); - jp.nextToken(); - - final If _if = new If(); - _if.setGuard(parseConstOrEnumExprConstruct(jp)); - _if.setThen(parseConstOrEnumExprConstruct(jp)); - _if.setElse(parseConstOrEnumExprConstruct(jp)); - - construct = _if; - } else if (IS_OF.equals(jp.getCurrentName())) { - jp.nextToken(); - construct = jp.readValueAs( IsOf.class); - } else if (LABELED_ELEMENT.equals(jp.getCurrentName())) { - jp.nextToken(); - construct = jp.readValueAs( LabeledElement.class); - } else if (NULL.equals(jp.getCurrentName())) { - jp.nextToken(); - construct = jp.readValueAs( Null.class); - } else if (RECORD.equals(jp.getCurrentName())) { - jp.nextToken(); - construct = jp.readValueAs( Record.class); - } else if (URL_REF.equals(jp.getCurrentName())) { - jp.nextToken(); - construct = jp.readValueAs( UrlRef.class); - } - - return construct; - } -} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/DynamicAnnotationExpressionDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/DynamicAnnotationExpressionDeserializer.java new file mode 100644 index 000000000..c5054aac1 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/DynamicAnnotationExpressionDeserializer.java @@ -0,0 +1,173 @@ +/* + * 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.client.core.edm.xml.v4.annotation; + +import com.fasterxml.jackson.core.JsonLocation; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import java.io.IOException; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.ClassUtils; +import org.apache.olingo.client.api.edm.xml.v4.annotation.AnnotationPath; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Apply; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Cast; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Collection; +import org.apache.olingo.client.api.edm.xml.v4.annotation.If; +import org.apache.olingo.client.api.edm.xml.v4.annotation.IsOf; +import org.apache.olingo.client.api.edm.xml.v4.annotation.LabeledElement; +import org.apache.olingo.client.api.edm.xml.v4.annotation.NavigationPropertyPath; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Null; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Path; +import org.apache.olingo.client.api.edm.xml.v4.annotation.PropertyPath; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Record; +import org.apache.olingo.client.api.edm.xml.v4.annotation.TwoParamsOpDynamicAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.v4.annotation.UrlRef; +import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; + +public class DynamicAnnotationExpressionDeserializer + extends AbstractEdmDeserializer { + + private static final String[] EL_OR_ATTR = { + AnnotationPath.class.getSimpleName(), NavigationPropertyPath.class.getSimpleName(), + Path.class.getSimpleName(), PropertyPath.class.getSimpleName() + }; + + private static final String APPLY = Apply.class.getSimpleName(); + + private static final String CAST = Cast.class.getSimpleName(); + + private static final String COLLECTION = Collection.class.getSimpleName(); + + private static final String IF = If.class.getSimpleName(); + + private static final String IS_OF = IsOf.class.getSimpleName(); + + private static final String LABELED_ELEMENT = LabeledElement.class.getSimpleName(); + + private static final String NULL = Null.class.getSimpleName(); + + private static final String RECORD = Record.class.getSimpleName(); + + private static final String URL_REF = UrlRef.class.getSimpleName(); + + private AbstractElementOrAttributeExpression getElementOrAttributeExpressio(final String simpleClassName) + throws JsonParseException { + + try { + @SuppressWarnings("unchecked") + Class elOrAttrClass = + (Class) ClassUtils.getClass( + getClass().getPackage().getName() + "." + simpleClassName + "Impl"); + return elOrAttrClass.newInstance(); + } catch (Exception e) { + throw new JsonParseException("Could not instantiate " + simpleClassName, JsonLocation.NA, e); + } + } + + private AbstractAnnotationExpression parseConstOrEnumExpression(final JsonParser jp) throws IOException { + AbstractAnnotationExpression result; + if (isAnnotationConstExprConstruct(jp)) { + result = parseAnnotationConstExprConstruct(jp); + } else { + result = jp.readValueAs(AbstractDynamicAnnotationExpression.class); + } + jp.nextToken(); + + return result; + } + + @Override + protected AbstractDynamicAnnotationExpression doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + AbstractDynamicAnnotationExpression expression = null; + + if ("Not".equals(jp.getCurrentName())) { + final NotImpl not = new NotImpl(); + + jp.nextToken(); + for (; jp.getCurrentToken() != JsonToken.FIELD_NAME; jp.nextToken()) { + } + not.setExpression(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT || !jp.getCurrentName().equals("Not"); jp.nextToken()) { + } + + expression = not; + } else if (TwoParamsOpDynamicAnnotationExpression.Type.fromString(jp.getCurrentName()) != null) { + final TwoParamsOpDynamicAnnotationExpressionImpl dynExprDoubleParamOp = + new TwoParamsOpDynamicAnnotationExpressionImpl(); + dynExprDoubleParamOp.setType(TwoParamsOpDynamicAnnotationExpression.Type.fromString(jp.getCurrentName())); + + jp.nextToken(); + for (; jp.getCurrentToken() != JsonToken.FIELD_NAME; jp.nextToken()) { + } + dynExprDoubleParamOp.setLeftExpression(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); + dynExprDoubleParamOp.setRightExpression(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); + for (; jp.getCurrentToken() != JsonToken.END_OBJECT + || !jp.getCurrentName().equals(dynExprDoubleParamOp.getType().name()); jp.nextToken()) { + } + + expression = dynExprDoubleParamOp; + } else if (ArrayUtils.contains(EL_OR_ATTR, jp.getCurrentName())) { + final AbstractElementOrAttributeExpression elOrAttr = getElementOrAttributeExpressio(jp.getCurrentName()); + elOrAttr.setValue(jp.nextTextValue()); + + expression = elOrAttr; + } else if (APPLY.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(ApplyImpl.class); + } else if (CAST.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(CastImpl.class); + } else if (COLLECTION.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(CollectionImpl.class); + } else if (IF.equals(jp.getCurrentName())) { + jp.nextToken(); + jp.nextToken(); + + final IfImpl _if = new IfImpl(); + _if.setGuard(parseConstOrEnumExpression(jp)); + _if.setThen(parseConstOrEnumExpression(jp)); + _if.setElse(parseConstOrEnumExpression(jp)); + + expression = _if; + } else if (IS_OF.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(IsOfImpl.class); + } else if (LABELED_ELEMENT.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(LabeledElementImpl.class); + } else if (NULL.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(NullImpl.class); + } else if (RECORD.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(RecordImpl.class); + } else if (URL_REF.equals(jp.getCurrentName())) { + jp.nextToken(); + expression = jp.readValueAs(UrlRefImpl.class); + } + + return expression; + } +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/If.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/IfImpl.java similarity index 61% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/If.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/IfImpl.java index 8477bd4a7..aea0e1b1c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/If.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/IfImpl.java @@ -18,39 +18,43 @@ */ package org.apache.olingo.client.core.edm.xml.v4.annotation; -import org.apache.olingo.client.api.edm.xml.v4.annotation.ExprConstruct; +import org.apache.olingo.client.api.edm.xml.v4.annotation.If; +import org.apache.olingo.client.api.edm.xml.v4.annotation.AnnotationExpression; -public class If extends AnnotatedDynExprConstruct { +public class IfImpl extends AbstractAnnotatableDynamicAnnotationExpression implements If { private static final long serialVersionUID = 6752952406406218936L; - private ExprConstruct guard; + private AnnotationExpression guard; - private ExprConstruct _then; + private AnnotationExpression _then; - private ExprConstruct _else; + private AnnotationExpression _else; - public ExprConstruct getGuard() { + @Override + public AnnotationExpression getGuard() { return guard; } - public void setGuard(final ExprConstruct guard) { + public void setGuard(final AnnotationExpression guard) { this.guard = guard; } - public ExprConstruct getThen() { + @Override + public AnnotationExpression getThen() { return _then; } - public void setThen(final ExprConstruct _then) { + public void setThen(final AnnotationExpression _then) { this._then = _then; } - public ExprConstruct getElse() { + @Override + public AnnotationExpression getElse() { return _else; } - public void setElse(final ExprConstruct _else) { + public void setElse(final AnnotationExpression _else) { this._else = _else; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/IsOfDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/IsOfDeserializer.java index 160ce631f..6539cc44c 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/IsOfDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/IsOfDeserializer.java @@ -24,18 +24,18 @@ import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.DeserializationContext; import java.io.IOException; -import java.math.BigInteger; import org.apache.olingo.client.core.edm.xml.v4.AnnotationImpl; import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; +import org.apache.olingo.commons.api.edm.geo.SRID; -public class IsOfDeserializer extends AbstractEdmDeserializer { +public class IsOfDeserializer extends AbstractEdmDeserializer { @Override - protected IsOf doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + protected IsOfImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { - final IsOf isof = new IsOf(); + final IsOfImpl isof = new IsOfImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); @@ -43,17 +43,22 @@ public class IsOfDeserializer extends AbstractEdmDeserializer { if ("Type".equals(jp.getCurrentName())) { isof.setType(jp.nextTextValue()); } else if ("Annotation".equals(jp.getCurrentName())) { - isof.setAnnotation(jp.readValueAs(AnnotationImpl.class)); + isof.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); } else if ("MaxLength".equals(jp.getCurrentName())) { - isof.setMaxLength(jp.nextTextValue()); + final String maxLenght = jp.nextTextValue(); + isof.setMaxLength(maxLenght.equalsIgnoreCase("max") ? Integer.MAX_VALUE : Integer.valueOf(maxLenght)); } else if ("Precision".equals(jp.getCurrentName())) { - isof.setPrecision(BigInteger.valueOf(jp.nextLongValue(0L))); + isof.setPrecision(Integer.valueOf(jp.nextTextValue())); } else if ("Scale".equals(jp.getCurrentName())) { - isof.setScale(BigInteger.valueOf(jp.nextLongValue(0L))); + final String scale = jp.nextTextValue(); + isof.setScale(scale.equalsIgnoreCase("variable") ? 0 : Integer.valueOf(scale)); } else if ("SRID".equals(jp.getCurrentName())) { - isof.setSrid(jp.nextTextValue()); + final String srid = jp.nextTextValue(); + if (srid != null) { + isof.setSrid(SRID.valueOf(srid)); + } } else { - isof.setValue(jp.readValueAs(DynExprConstructImpl.class)); + isof.setValue(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/IsOf.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/IsOfImpl.java similarity index 60% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/IsOf.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/IsOfImpl.java index 6854fd2ea..a281ff890 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/IsOf.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/IsOfImpl.java @@ -18,29 +18,30 @@ */ package org.apache.olingo.client.core.edm.xml.v4.annotation; +import org.apache.olingo.client.api.edm.xml.v4.annotation.IsOf; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.math.BigInteger; - -import org.apache.olingo.client.api.edm.xml.v4.annotation.DynExprConstruct; +import org.apache.olingo.client.api.edm.xml.v4.annotation.DynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.geo.SRID; @JsonDeserialize(using = IsOfDeserializer.class) -public class IsOf extends AnnotatedDynExprConstruct { +public class IsOfImpl extends AbstractAnnotatableDynamicAnnotationExpression implements IsOf { private static final long serialVersionUID = 6958304670385303776L; private String type; - private String maxLength; + private Integer maxLength; - private BigInteger precision; + private Integer precision; - private BigInteger scale; + private Integer scale; - private String srid; + private SRID srid; - private DynExprConstruct value; + private DynamicAnnotationExpression value; + @Override public String getType() { return type; } @@ -49,43 +50,48 @@ public class IsOf extends AnnotatedDynExprConstruct { this.type = type; } - public String getMaxLength() { + @Override + public Integer getMaxLength() { return maxLength; } - public void setMaxLength(final String maxLength) { + public void setMaxLength(final Integer maxLength) { this.maxLength = maxLength; } - public BigInteger getPrecision() { + @Override + public Integer getPrecision() { return precision; } - public void setPrecision(final BigInteger precision) { + public void setPrecision(final Integer precision) { this.precision = precision; } - public BigInteger getScale() { + @Override + public Integer getScale() { return scale; } - public void setScale(final BigInteger scale) { + public void setScale(final Integer scale) { this.scale = scale; } - public String getSrid() { + @Override + public SRID getSrid() { return srid; } - public void setSrid(final String srid) { + public void setSrid(final SRID srid) { this.srid = srid; } - public DynExprConstruct getValue() { + @Override + public DynamicAnnotationExpression getValue() { return value; } - public void setValue(final DynExprConstruct value) { + public void setValue(final DynamicAnnotationExpression value) { this.value = value; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/LabeledElementDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/LabeledElementDeserializer.java index df3f7476c..78c5c514f 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/LabeledElementDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/LabeledElementDeserializer.java @@ -28,13 +28,13 @@ import java.io.IOException; import org.apache.olingo.client.core.edm.xml.v4.AnnotationImpl; import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; -public class LabeledElementDeserializer extends AbstractEdmDeserializer { +public class LabeledElementDeserializer extends AbstractEdmDeserializer { @Override - protected LabeledElement doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + protected LabeledElementImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { - final LabeledElement element = new LabeledElement(); + final LabeledElementImpl element = new LabeledElementImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); @@ -42,9 +42,9 @@ public class LabeledElementDeserializer extends AbstractEdmDeserializer { +public class NullDeserializer extends AbstractEdmDeserializer { @Override - protected Null doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + protected NullImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { - final Null _null = new Null(); + final NullImpl _null = new NullImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Annotation".equals(jp.getCurrentName())) { - _null.setAnnotation(jp.readValueAs(AnnotationImpl.class)); + _null.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Null.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/NullImpl.java similarity index 86% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Null.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/NullImpl.java index 0ff8a1e44..5609991b4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Null.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/NullImpl.java @@ -19,9 +19,10 @@ package org.apache.olingo.client.core.edm.xml.v4.annotation; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Null; @JsonDeserialize(using = NullDeserializer.class) -public class Null extends AnnotatedDynExprConstruct { +public class NullImpl extends AbstractAnnotatableDynamicAnnotationExpression implements Null { private static final long serialVersionUID = -3611384710172781951L; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PathImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PathImpl.java new file mode 100644 index 000000000..3033f7740 --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PathImpl.java @@ -0,0 +1,27 @@ +/* + * 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.client.core.edm.xml.v4.annotation; + +import org.apache.olingo.client.api.edm.xml.v4.annotation.Path; + +public class PathImpl extends AbstractElementOrAttributeExpression implements Path { + + private static final long serialVersionUID = -2551058493469292082L; + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyPathImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyPathImpl.java new file mode 100644 index 000000000..d319f4d5f --- /dev/null +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyPathImpl.java @@ -0,0 +1,27 @@ +/* + * 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.client.core.edm.xml.v4.annotation; + +import org.apache.olingo.client.api.edm.xml.v4.annotation.PropertyPath; + +public class PropertyPathImpl extends AbstractElementOrAttributeExpression implements PropertyPath { + + private static final long serialVersionUID = 2328584735437885159L; + +} diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyValueDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyValueDeserializer.java index 6841c6ea3..488c58176 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyValueDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/PropertyValueDeserializer.java @@ -28,13 +28,13 @@ import java.io.IOException; import org.apache.olingo.client.core.edm.xml.v4.AnnotationImpl; import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; -public class PropertyValueDeserializer extends AbstractEdmDeserializer { +public class PropertyValueDeserializer extends AbstractEdmDeserializer { @Override - protected PropertyValue doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + protected PropertyValueImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { - final PropertyValue propValue = new PropertyValue(); + final PropertyValueImpl propValue = new PropertyValueImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); @@ -42,11 +42,11 @@ public class PropertyValueDeserializer extends AbstractEdmDeserializer { +public class RecordDeserializer extends AbstractEdmDeserializer { @Override - protected Record doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + protected RecordImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { - final Record record = new Record(); + final RecordImpl record = new RecordImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { - if ("Tyoe".equals(jp.getCurrentName())) { + if ("Type".equals(jp.getCurrentName())) { record.setType(jp.nextTextValue()); } else if ("Annotation".equals(jp.getCurrentName())) { - record.setAnnotation(jp.readValueAs(AnnotationImpl.class)); + record.getAnnotations().add(jp.readValueAs(AnnotationImpl.class)); } else { - record.getPropertyValues().add(jp.readValueAs(PropertyValue.class)); + record.getPropertyValues().add(jp.readValueAs(PropertyValueImpl.class)); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Record.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/RecordImpl.java similarity index 84% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Record.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/RecordImpl.java index 862a67795..80255a37f 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/Record.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/RecordImpl.java @@ -18,12 +18,14 @@ */ package org.apache.olingo.client.core.edm.xml.v4.annotation; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Record; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import java.util.ArrayList; import java.util.List; +import org.apache.olingo.client.api.edm.xml.v4.annotation.PropertyValue; @JsonDeserialize(using = RecordDeserializer.class) -public class Record extends AnnotatedDynExprConstruct { +public class RecordImpl extends AbstractAnnotatableDynamicAnnotationExpression implements Record { private static final long serialVersionUID = -2886526224721870304L; @@ -31,6 +33,7 @@ public class Record extends AnnotatedDynExprConstruct { private final List propertyValues = new ArrayList(); + @Override public String getType() { return type; } @@ -39,6 +42,7 @@ public class Record extends AnnotatedDynExprConstruct { this.type = type; } + @Override public List getPropertyValues() { return propertyValues; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/DynExprDoubleParamOp.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/TwoParamsOpDynamicAnnotationExpressionImpl.java similarity index 61% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/DynExprDoubleParamOp.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/TwoParamsOpDynamicAnnotationExpressionImpl.java index 85ec0440d..ccdfb6a5d 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/DynExprDoubleParamOp.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/TwoParamsOpDynamicAnnotationExpressionImpl.java @@ -18,34 +18,21 @@ */ package org.apache.olingo.client.core.edm.xml.v4.annotation; -import org.apache.olingo.client.api.edm.xml.v4.annotation.DynExprConstruct; +import org.apache.olingo.client.api.edm.xml.v4.annotation.DynamicAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.v4.annotation.TwoParamsOpDynamicAnnotationExpression; -public class DynExprDoubleParamOp extends DynExprConstructImpl { +public class TwoParamsOpDynamicAnnotationExpressionImpl + extends AbstractDynamicAnnotationExpression implements TwoParamsOpDynamicAnnotationExpression { private static final long serialVersionUID = -7974475975925167731L; - public static enum Type { - - And, - Or; - - public static Type fromString(final String value) { - Type result = null; - for (Type type : values()) { - if (value.equals(type.name())) { - result = type; - } - } - return result; - } - } - private Type type; - private DynExprConstruct left; + private DynamicAnnotationExpression left; - private DynExprConstruct right; + private DynamicAnnotationExpression right; + @Override public Type getType() { return type; } @@ -54,19 +41,21 @@ public class DynExprDoubleParamOp extends DynExprConstructImpl { this.type = type; } - public DynExprConstruct getLeft() { + @Override + public DynamicAnnotationExpression getLeftExpression() { return left; } - public void setLeft(final DynExprConstruct left) { + public void setLeftExpression(final DynamicAnnotationExpression left) { this.left = left; } - public DynExprConstruct getRight() { + @Override + public DynamicAnnotationExpression getRightExpression() { return right; } - public void setRight(final DynExprConstruct right) { + public void setRightExpression(final DynamicAnnotationExpression right) { this.right = right; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefDeserializer.java index e2fcfbb1e..4e54af941 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefDeserializer.java @@ -27,13 +27,13 @@ import java.io.IOException; import org.apache.olingo.client.core.edm.xml.AbstractEdmDeserializer; -public class UrlRefDeserializer extends AbstractEdmDeserializer { +public class UrlRefDeserializer extends AbstractEdmDeserializer { @Override - protected UrlRef doDeserialize(final JsonParser jp, final DeserializationContext ctxt) + protected UrlRefImpl doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { - final UrlRef urlref = new UrlRef(); + final UrlRefImpl urlref = new UrlRefImpl(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); @@ -41,7 +41,7 @@ public class UrlRefDeserializer extends AbstractEdmDeserializer { if (isAnnotationConstExprConstruct(jp)) { urlref.setValue(parseAnnotationConstExprConstruct(jp)); } else { - urlref.setValue(jp.readValueAs( DynExprConstructImpl.class)); + urlref.setValue(jp.readValueAs(AbstractDynamicAnnotationExpression.class)); } } } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRef.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefImpl.java similarity index 74% rename from lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRef.java rename to lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefImpl.java index ebaea99ca..618b99d01 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRef.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/xml/v4/annotation/UrlRefImpl.java @@ -18,22 +18,24 @@ */ package org.apache.olingo.client.core.edm.xml.v4.annotation; +import org.apache.olingo.client.api.edm.xml.v4.annotation.UrlRef; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.apache.olingo.client.api.edm.xml.v4.annotation.ExprConstruct; +import org.apache.olingo.client.api.edm.xml.v4.annotation.AnnotationExpression; @JsonDeserialize(using = UrlRefDeserializer.class) -public class UrlRef extends DynExprConstructImpl { +public class UrlRefImpl extends AbstractDynamicAnnotationExpression implements UrlRef { private static final long serialVersionUID = 3755101394647430897L; - private ExprConstruct value; + private AnnotationExpression value; - public ExprConstruct getValue() { + @Override + public AnnotationExpression getValue() { return value; } - public void setValue(final ExprConstruct value) { + public void setValue(final AnnotationExpression value) { this.value = value; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java index 455ffb801..8c6273d36 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v3/ODataClientImpl.java @@ -25,7 +25,7 @@ import org.apache.olingo.client.api.communication.header.ODataHeaders; import org.apache.olingo.client.api.communication.request.batch.v3.BatchRequestFactory; import org.apache.olingo.client.api.communication.request.cud.v3.CUDRequestFactory; import org.apache.olingo.client.api.communication.request.cud.v3.UpdateType; -import org.apache.olingo.client.api.communication.request.invoke.v3.InvokeRequestFactory; +import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory; import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRequestFactory; import org.apache.olingo.client.api.communication.request.streamed.v3.StreamedRequestFactory; import org.apache.olingo.commons.api.op.ODataSerializer; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java index 3962786b8..3a43644ef 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/v4/ODataClientImpl.java @@ -25,7 +25,7 @@ import org.apache.olingo.client.api.communication.header.ODataHeaders; import org.apache.olingo.client.api.communication.request.batch.v4.BatchRequestFactory; import org.apache.olingo.client.api.communication.request.cud.v4.CUDRequestFactory; import org.apache.olingo.client.api.communication.request.cud.v4.UpdateType; -import org.apache.olingo.client.api.communication.request.invoke.v4.InvokeRequestFactory; +import org.apache.olingo.client.api.communication.request.invoke.InvokeRequestFactory; import org.apache.olingo.client.api.communication.request.retrieve.v4.RetrieveRequestFactory; import org.apache.olingo.client.api.communication.request.streamed.v4.StreamedRequestFactory; import org.apache.olingo.client.api.communication.request.v4.AsyncRequestFactory; diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java index ca226a379..116e98c97 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/uri/URIEscapeTest.java @@ -56,11 +56,11 @@ public class URIEscapeTest { @Test public void geospatial() throws UnsupportedEncodingException { - final Point point = new Point(Geospatial.Dimension.GEOGRAPHY, 0); + final Point point = new Point(Geospatial.Dimension.GEOGRAPHY, null); point.setX(142.1); point.setY(64.1); - assertEquals(URLEncoder.encode("geography'SRID=0;Point(142.1 64.1)'", Constants.UTF8), + assertEquals(URLEncoder.encode("geography'SRID=4326;Point(142.1 64.1)'", Constants.UTF8), URIUtils.escape(ODataServiceVersion.V40, point)); } diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java index 303d18ad8..51a2356c5 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java @@ -51,6 +51,7 @@ import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo; import org.apache.olingo.commons.api.edm.EdmNavigationProperty; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmReturnType; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.junit.Test; @@ -81,7 +82,7 @@ public class MetadataTest extends AbstractTest { assertNotNull(product); assertFalse(product.getPropertyNames().isEmpty()); assertFalse(product.getNavigationPropertyNames().isEmpty()); - + final EdmNavigationProperty detail = product.getNavigationProperty("Detail"); assertNotNull(detail); assertEquals("Product", detail.getPartner().getName()); @@ -122,6 +123,21 @@ public class MetadataTest extends AbstractTest { assertEquals(container.getEntitySet("Customer").getEntityContainer().getFullQualifiedName(), logins.getRelatedBindingTarget("Customer").getEntityContainer().getFullQualifiedName()); assertEquals(container.getEntitySet("Customer").getName(), logins.getRelatedBindingTarget("Customer").getName()); + + // 5. Operation + final EdmFunctionImport funcImp = container.getFunctionImport("InStreamErrorGetCustomer"); + assertNotNull(funcImp); + final EdmEntitySet returnedEntitySet = funcImp.getReturnedEntitySet(); + assertNotNull(returnedEntitySet); + assertEquals("Customer", returnedEntitySet.getName()); + + final EdmFunction function = funcImp.getUnboundFunction(null); + assertNotNull(function); + final EdmReturnType returnType = function.getReturnType(); + assertNotNull(returnType); + assertEquals("Microsoft.Test.OData.Services.AstoriaDefaultService.Customer", + returnType.getType().getFullQualifiedName().toString()); + assertTrue(returnType.isCollection()); } @Test diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java index 56de140d1..267083a72 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java @@ -18,13 +18,6 @@ */ package org.apache.olingo.client.core.v4; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.apache.olingo.client.api.v4.ODataClient; import org.apache.olingo.client.api.edm.xml.v4.Annotation; import org.apache.olingo.client.api.edm.xml.v4.Annotations; import org.apache.olingo.client.api.edm.xml.v4.ComplexType; @@ -35,13 +28,21 @@ import org.apache.olingo.client.api.edm.xml.v4.FunctionImport; import org.apache.olingo.client.api.edm.xml.v4.Schema; import org.apache.olingo.client.api.edm.xml.v4.Singleton; import org.apache.olingo.client.api.edm.xml.v4.XMLMetadata; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Apply; +import org.apache.olingo.client.api.edm.xml.v4.annotation.Collection; +import org.apache.olingo.client.api.edm.xml.v4.annotation.ConstantAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.v4.annotation.TwoParamsOpDynamicAnnotationExpression; +import org.apache.olingo.client.api.edm.xml.v4.annotation.UrlRef; +import org.apache.olingo.client.api.v4.ODataClient; import org.apache.olingo.client.core.AbstractTest; -import org.apache.olingo.client.core.edm.xml.v4.annotation.Apply; -import org.apache.olingo.client.core.edm.xml.v4.annotation.Collection; -import org.apache.olingo.client.core.edm.xml.v4.annotation.ConstExprConstructImpl; -import org.apache.olingo.client.core.edm.xml.v4.annotation.Path; +import org.apache.olingo.client.core.edm.xml.v4.annotation.ConstantAnnotationExpressionImpl; +import org.apache.olingo.client.core.edm.xml.v4.annotation.PathImpl; +import org.apache.olingo.commons.api.Constants; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmAnnotations; +import org.apache.olingo.commons.api.edm.EdmAnnotationsTarget; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntitySet; @@ -51,9 +52,19 @@ import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmSchema; +import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.annotation.EdmUrlRef; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; +import org.apache.olingo.commons.core.edm.primitivetype.EdmDecimal; +import org.apache.olingo.commons.core.edm.primitivetype.EdmInt32; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import org.junit.Test; public class MetadataTest extends AbstractTest { @@ -65,8 +76,7 @@ public class MetadataTest extends AbstractTest { @Test public void parse() { - final Edm edm = getClient().getReader(). - readMetadata(getClass().getResourceAsStream("metadata.xml")); + final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("metadata.xml")); assertNotNull(edm); // 1. Enum @@ -127,14 +137,39 @@ public class MetadataTest extends AbstractTest { toMetadata(getClass().getResourceAsStream("demo-metadata.xml")); assertNotNull(metadata); - assertFalse(metadata.getSchema(0).getAnnotationsList().isEmpty()); - final Annotations annots = metadata.getSchema(0).getAnnotationsList("ODataDemo.DemoService/Suppliers"); + assertFalse(metadata.getSchema(0).getAnnotationGroups().isEmpty()); + final Annotations annots = metadata.getSchema(0).getAnnotationGroup("ODataDemo.DemoService/Suppliers"); assertNotNull(annots); assertFalse(annots.getAnnotations().isEmpty()); - assertEquals(ConstExprConstructImpl.Type.String, - annots.getAnnotation("Org.OData.Publication.V1.PrivacyPolicyUrl").getConstExpr().getType()); + assertEquals(ConstantAnnotationExpression.Type.String, + annots.getAnnotation("Org.OData.Publication.V1.PrivacyPolicyUrl").getExpression().asConstant().getType()); assertEquals("http://www.odata.org/", - annots.getAnnotation("Org.OData.Publication.V1.PrivacyPolicyUrl").getConstExpr().getValue()); + annots.getAnnotation("Org.OData.Publication.V1.PrivacyPolicyUrl").getExpression().asConstant().getValue()); + + // Now let's test some edm:Annotations + final Edm edm = getClient().getReader(). + readMetadata(getClass().getResourceAsStream("demo-metadata.xml")); + assertNotNull(edm); + + final EdmSchema schema = edm.getSchema("ODataDemo"); + assertNotNull(schema); + assertTrue(schema.getAnnotations().isEmpty()); + assertFalse(schema.getAnnotationGroups().isEmpty()); + + final EdmAnnotations annotationGroup = schema.getAnnotationGroups().get(2); + assertNotNull(annotationGroup); + final EdmAnnotationsTarget annotationsTarget = annotationGroup.getTarget(); + assertNotNull(annotationsTarget); + assertTrue(EdmAnnotationsTarget.TargetType.Property == annotationsTarget.getAnnotationsTargetType()); + assertEquals(new FullQualifiedName("ODataDemo.Product"), annotationsTarget.getAnnotationsTargetFQN()); + assertEquals("Name", annotationsTarget.getAnnotationsTargetPath()); + + final EdmAnnotation annotation = annotationGroup.getAnnotations().get(0); + assertNotNull(annotation); + assertTrue(annotation.getExpression().isConstant()); + assertEquals("Edm.String", annotation.getExpression().asConstant().getValue().getTypeName()); + + assertEquals(10, schema.getAnnotationGroups().get(3).getAnnotations().size()); } @Test @@ -169,7 +204,7 @@ public class MetadataTest extends AbstractTest { final EntityType product = metadata.getSchema(0).getEntityType("Product"); assertTrue(product.isHasStream()); - assertEquals("UoM.ISOCurrency", product.getProperty("Price").getAnnotation().getTerm()); + assertEquals("UoM.ISOCurrency", product.getProperty("Price").getAnnotations().get(0).getTerm()); assertEquals("Products", product.getNavigationProperty("Supplier").getPartner()); final EntityType category = metadata.getSchema(0).getEntityType("Category"); @@ -197,8 +232,7 @@ public class MetadataTest extends AbstractTest { functionImport.getFunction()); // Now let's go high-level - final Edm edm = getClient().getReader(). - readMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml")); + final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc1-metadata.xml")); assertNotNull(edm); final EdmFunctionImportInfo fiInfo = edm.getServiceMetadata().getFunctionImportInfos().get(0); @@ -219,6 +253,12 @@ public class MetadataTest extends AbstractTest { fi.getUnboundFunction(null).getReturnType().getType().getName()); assertEquals(function.getReturnType().getType().getNamespace(), fi.getUnboundFunction(null).getReturnType().getType().getNamespace()); + + final EdmTypeDefinition weight = edm.getTypeDefinition(new FullQualifiedName("ODataDemo", "Weight")); + assertNotNull(weight); + assertEquals(EdmInt32.getInstance(), weight.getUnderlyingType()); + assertFalse(weight.getAnnotations().isEmpty()); + assertEquals("Kilograms", weight.getAnnotations().get(0).getExpression().asConstant().getValue().toString()); } /** @@ -231,42 +271,40 @@ public class MetadataTest extends AbstractTest { assertNotNull(metadata); // Check displayName - final Annotation displayName = metadata.getSchema(0).getAnnotationsList("ODataDemo.Supplier"). + final Annotation displayName = metadata.getSchema(0).getAnnotationGroup("ODataDemo.Supplier"). getAnnotation("Vocabulary1.DisplayName"); assertNotNull(displayName); - assertNull(displayName.getConstExpr()); - assertNotNull(displayName.getDynExpr()); + assertTrue(displayName.getExpression().isDynamic()); - assertTrue(displayName.getDynExpr() instanceof Apply); - final Apply apply = (Apply) displayName.getDynExpr(); - assertEquals(Apply.CANONICAL_FUNCTION_CONCAT, apply.getFunction()); + assertTrue(displayName.getExpression().asDynamic().isApply()); + final Apply apply = displayName.getExpression().asDynamic().asApply(); + assertEquals(Constants.CANONICAL_FUNCTION_CONCAT, apply.getFunction()); assertEquals(3, apply.getParameters().size()); - final Path firstArg = new Path(); + final PathImpl firstArg = new PathImpl(); firstArg.setValue("Name"); assertEquals(firstArg, apply.getParameters().get(0)); - final ConstExprConstructImpl secondArg = new ConstExprConstructImpl(); - secondArg.setType(ConstExprConstructImpl.Type.String); + final ConstantAnnotationExpression secondArg = new ConstantAnnotationExpressionImpl(); + secondArg.setType(ConstantAnnotationExpression.Type.String); secondArg.setValue(" in "); assertEquals(secondArg, apply.getParameters().get(1)); - final Path thirdArg = new Path(); + final PathImpl thirdArg = new PathImpl(); thirdArg.setValue("Address/CountryName"); assertEquals(thirdArg, apply.getParameters().get(2)); // Check Tags - final Annotation tags = metadata.getSchema(0).getAnnotationsList("ODataDemo.Product"). + final Annotation tags = metadata.getSchema(0).getAnnotationGroup("ODataDemo.Product"). getAnnotation("Vocabulary1.Tags"); assertNotNull(tags); - assertNull(tags.getConstExpr()); - assertNotNull(tags.getDynExpr()); + assertTrue(tags.getExpression().isDynamic()); - assertTrue(tags.getDynExpr() instanceof Collection); - final Collection collection = (Collection) tags.getDynExpr(); + assertTrue(tags.getExpression().asDynamic().isCollection()); + final Collection collection = tags.getExpression().asDynamic().asCollection(); assertEquals(1, collection.getItems().size()); - assertEquals(ConstExprConstructImpl.Type.String, ((ConstExprConstructImpl) collection.getItems().get(0)).getType()); - assertEquals("MasterData", ((ConstExprConstructImpl) collection.getItems().get(0)).getValue()); + assertEquals(ConstantAnnotationExpression.Type.String, collection.getItems().get(0).asConstant().getType()); + assertEquals("MasterData", collection.getItems().get(0).asConstant().getValue()); } /** @@ -274,8 +312,74 @@ public class MetadataTest extends AbstractTest { */ @Test public void fromdoc3() { - final Edm metadata = getClient().getReader(). - readMetadata(getClass().getResourceAsStream("fromdoc3-metadata.xml")); + final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc3-metadata.xml")); + assertNotNull(edm); + + final EdmAnnotations group = edm.getSchema("Annotations").getAnnotationGroups().get(0); + assertNotNull(group); + + final EdmAnnotation time1 = group.getAnnotations().get(0); + assertEquals("Edm.TimeOfDay", time1.getExpression().asConstant().getValue().getTypeName()); + + final EdmAnnotation time2 = group.getAnnotations().get(1); + assertEquals("Edm.TimeOfDay", time2.getExpression().asConstant().getValue().getTypeName()); + } + + /** + * Various annotation examples taken from CSDL specification. + */ + @Test + public void fromdoc4() { + final XMLMetadata metadata = getClient().getDeserializer(). + toMetadata(getClass().getResourceAsStream("fromdoc4-metadata.xml")); assertNotNull(metadata); + + final Annotations group = metadata.getSchema(0).getAnnotationGroups().get(0); + assertNotNull(group); + + Annotation annotation = group.getAnnotations().get(0); + assertTrue(annotation.getExpression().isDynamic()); + assertTrue(annotation.getExpression().asDynamic().isCast()); + assertEquals("Edm.Decimal", annotation.getExpression().asDynamic().asCast().getType()); + + annotation = group.getAnnotation("And"); + assertTrue(annotation.getExpression().isDynamic()); + assertTrue(annotation.getExpression().asDynamic().isTwoParamsOp()); + assertEquals(TwoParamsOpDynamicAnnotationExpression.Type.And, + annotation.getExpression().asDynamic().asTwoParamsOp().getType()); + assertTrue(annotation.getExpression().asDynamic().asTwoParamsOp().getLeftExpression().isPath()); + + annotation = group.getAnnotation("Vocab.Supplier"); + assertNotNull(annotation); + assertTrue(annotation.getExpression().isDynamic()); + assertTrue(annotation.getExpression().asDynamic().isUrlRef()); + final UrlRef urlRef = annotation.getExpression().asDynamic().asUrlRef(); + assertTrue(urlRef.getValue().isDynamic()); + assertTrue(urlRef.getValue().asDynamic().isApply()); + + // Now let's go high-level + final Edm edm = getClient().getReader().readMetadata(getClass().getResourceAsStream("fromdoc4-metadata.xml")); + assertNotNull(edm); + + final EdmAnnotations edmGroup = edm.getSchemas().get(0).getAnnotationGroups().get(0); + assertNotNull(edmGroup); + + EdmAnnotation edmAnnotation = edmGroup.getAnnotations().get(0); + assertTrue(edmAnnotation.getExpression().isDynamic()); + assertTrue(edmAnnotation.getExpression().asDynamic().isCast()); + assertEquals(EdmDecimal.getInstance(), edmAnnotation.getExpression().asDynamic().asCast().getType()); + + edmAnnotation = edmGroup.getAnnotations().get(1); + assertTrue(edmAnnotation.getExpression().isDynamic()); + assertTrue(edmAnnotation.getExpression().asDynamic().isAnd()); + assertTrue(edmAnnotation.getExpression().asDynamic().asAnd().getLeftExpression().isPath()); + + edmAnnotation = edmGroup.getAnnotations().get(edmGroup.getAnnotations().size() - 2); + assertNotNull(edmAnnotation); + assertTrue(edmAnnotation.getExpression().isDynamic()); + assertTrue(edmAnnotation.getExpression().asDynamic().isUrlRef()); + final EdmUrlRef edmUrlRef = edmAnnotation.getExpression().asDynamic().asUrlRef(); + assertTrue(edmUrlRef.getValue().isDynamic()); + assertTrue(edmUrlRef.getValue().asDynamic().isApply()); } } diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/demo-metadata.xml b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/demo-metadata.xml index 9b21e2f78..1f7585924 100644 --- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/demo-metadata.xml +++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/demo-metadata.xml @@ -24,139 +24,139 @@ - + - - - - - - - - - - + + + + + + + + + + - + - + - - - + + + - + - - - + + + - + - - - - - - + + + + + + - - - - - + + + + + - + - - - + + + - + - - - + + + - + - - - - - - - + + + + + + + - + - - - - + + + + - - - - + + + + - + - + - + - + - + - + - + - + - + - - - - - - - - - - + + + + + + + + + + diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fromdoc1-metadata.xml b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fromdoc1-metadata.xml index 5d872cafe..74a71d4fe 100644 --- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fromdoc1-metadata.xml +++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fromdoc1-metadata.xml @@ -43,7 +43,7 @@ - + diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fromdoc3-metadata.xml b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fromdoc3-metadata.xml index 2a00bd8c7..36e5216d5 100644 --- a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fromdoc3-metadata.xml +++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fromdoc3-metadata.xml @@ -29,70 +29,70 @@ - , + 21:45:00 - , - , + + IsMale - , + IsMale IsMarried - , - , + + Product/Supplier/@UI.LineItem - , + Name in Address/CountryName - , + Average - , + MasterData - , + true Female Male - , + IsFemale Female Male - , + Customer - , + - , + FirstName - , + @@ -107,7 +107,7 @@ - , + @@ -119,7 +119,7 @@ - , + http://host/wiki/HowToUse diff --git a/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fromdoc4-metadata.xml b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fromdoc4-metadata.xml new file mode 100644 index 000000000..660296027 --- /dev/null +++ b/lib/client-core/src/test/resources/org/apache/olingo/client/core/v4/fromdoc4-metadata.xml @@ -0,0 +1,164 @@ + + + + + + + + + Average + + + + + IsMale + IsMarried + + + + + IsMale + IsMarried + + + + + IsMale + + + + + + IsMale + + + + + + Supplier/@Communication.Contact + Customer/@Communication.Contact + + + + + Product: + ProductName + ( + Available/Quantity + + Available/Unit + available) + + + + + http://host/service/Genres('{genreName}') + + + + + + http://host/service/Genres({genreName}) + + + NameOfMovieGenre + + + + + + + Product + Supplier + Customer + + + + + IsFemale + Female + Male + + + + + Customer + + + + + + + + FirstName + + + + Model.CustomerFirstName + + + + + + + Supplier + Category + + + + + + + @vCard.Address#work/FullName + + + + + + + CreatedAt + ChangedAt + + + + + + + + http://host/service/Suppliers({suppID}) + + + SupplierId + + + + + + + + http://host/wiki/HowToUse + + + + + + diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java index 770f81cb7..17a65eb16 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/Constants.java @@ -236,11 +236,18 @@ public interface Constants { public static final String ATOM_ELEM_DELETED_ENTRY = "deleted-entry"; -// error stuff + // error stuff public static final String ERROR_CODE = "code"; public static final String ERROR_MESSAGE = "message"; public static final String ERROR_TARGET = "target"; + // canonical functions to be applied via dynamic annotation Apply + public static final String CANONICAL_FUNCTION_CONCAT = "odata.concat"; + + public static final String CANONICAL_FUNCTION_FILLURITEMPLATE = "odata.fillUriTemplate"; + + public static final String CANONICAL_FUNCTION_URIENCODE = "odata.uriEncode"; + } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java index fa417f155..ad6dfb46b 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/Edm.java @@ -34,6 +34,14 @@ public interface Edm { */ List getSchemas(); + /** + * Get schema by namespace. + * + * @param namespace must not be null + * @return {@link EdmSchema} + */ + EdmSchema getSchema(String namespace); + /** * Get entity container by full qualified name. *
@@ -132,6 +140,39 @@ public interface Edm { EdmFunction getBoundFunction(FullQualifiedName functionName, FullQualifiedName bindingParameterTypeName, Boolean isBindingParameterCollection, List parameterNames); + /** + * Get Term full by qualified name. + * + * @param termName must not be null + * @return {@link EdmTerm} + */ + EdmTerm getTerm(FullQualifiedName termName); + + /** + * Get {@link EdmAnnotations} by target. + * + * @param targetName edm:Annotations target + * @return {@link EdmAnnotations} + */ + EdmAnnotations getAnnotationGroup(FullQualifiedName targetName); + + /** + * Get all {@link EdmAnnotation} by element FQN. + * + * @param annotatableName must not be null + * @return {@link EdmAnnotation} + */ + List getAnnotations(FullQualifiedName annotatableName); + + /** + * Get {@link EdmAnnotation} by element FQN and term. + * + * @param annotatableName must not be null + * @param term edm:Annotation term + * @return {@link EdmAnnotation} + */ + EdmAnnotation getAnnotation(FullQualifiedName annotatableName, EdmTerm term); + /** * Get service metadata. *
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotatable.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotatable.java index 1ba20cd67..4366b5a40 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotatable.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotatable.java @@ -18,13 +18,12 @@ */ package org.apache.olingo.commons.api.edm; +import java.util.List; + /** - * EdmAnnotatable can be applied to CSDL elements as described in the Conceptual Schema Definition Language. + * Can be applied to CSDL elements as described in the Conceptual Schema Definition Language. */ public interface EdmAnnotatable { - EdmAnnotations getAnnotations(); - - // TODO: enhance annotations - Object getAnnotation(); + List getAnnotations(); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotation.java new file mode 100644 index 000000000..ed567f650 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotation.java @@ -0,0 +1,30 @@ +/* + * 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.api.edm; + +import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression; + +public interface EdmAnnotation extends EdmAnnotatable { + + EdmTerm getTerm(); + + String getQualifier(); + + EdmAnnotationExpression getExpression(); +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotations.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotations.java index 2aea695eb..3c1b9127c 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotations.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotations.java @@ -18,7 +18,24 @@ */ package org.apache.olingo.commons.api.edm; -//TODO: EDM Annotation Interfaces +import java.util.List; + +/** + * This is used to apply a group of annotations to a single model element. + */ public interface EdmAnnotations { + /** + * @return a model element in the entity model to which this annotations is targeted + */ + EdmAnnotationsTarget getTarget(); + + /** + * @return a string allowing annotation authors a means of conditionally applying an annotation + */ + String getQualifier(); + + EdmAnnotation getAnnotation(EdmTerm term); + + List getAnnotations(); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotationsTarget.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotationsTarget.java new file mode 100644 index 000000000..a66b114f7 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmAnnotationsTarget.java @@ -0,0 +1,71 @@ +/* + * 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.api.edm; + +/** + * Interface for CSDL elements thar can be evaluated as target for edm:Annotations. + * + * @see EdmAnnotations + */ +public interface EdmAnnotationsTarget { + + enum TargetType { + + ActionImport(EdmActionImport.class), + ComplexType(EdmComplexType.class), + EntityContainer(EdmEntityContainer.class), + EntitySet(EdmEntitySet.class), + EntityType(EdmEntityType.class), + EnumType(EdmEnumType.class), + FunctionImport(EdmFunctionImport.class), + Member(EdmMember.class), + NavigationProperty(EdmNavigationProperty.class), + Property(EdmProperty.class), + Singleton(EdmSingleton.class), + Term(EdmTerm.class), + TypeDefinition(EdmTypeDefinition.class); + + private final Class edmClass; + + TargetType(final Class edmClass) { + this.edmClass = edmClass; + } + + public Class getEdmClass() { + return edmClass; + } + + } + + /** + * @return {@link FullQualifiedName} of this target, or of the parent element if applicable + * + */ + FullQualifiedName getAnnotationsTargetFQN(); + + /** + * @return name of child element, not null if not needed + */ + String getAnnotationsTargetPath(); + + /** + * @return {@link TargetType} of this target + */ + TargetType getAnnotationsTargetType(); +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmBindingTarget.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmBindingTarget.java index 1c66b80f3..f09164f1b 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmBindingTarget.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmBindingTarget.java @@ -24,7 +24,7 @@ import java.util.List; * Entity Sets or Singletons can be bound to each other using a navigation property binding so an * {@link EdmBindingTarget} can either be an {@link EdmEntitySet} or an {@link EdmSingleton}. */ -public interface EdmBindingTarget extends EdmNamed { +public interface EdmBindingTarget extends EdmNamed, EdmAnnotationsTarget, EdmAnnotatable { /** * Returns the target for a given path. @@ -38,7 +38,7 @@ public interface EdmBindingTarget extends EdmNamed { * @return all navigation property bindings */ List getNavigationPropertyBindings(); - + /** * Returns the entity container this target is contained in. * diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntityContainer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntityContainer.java index 519c11da9..4db1e8e18 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntityContainer.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEntityContainer.java @@ -26,7 +26,7 @@ import java.util.List; *
* EdmEntityContainer hold the information of EntitySets, Singletons, ActionImports and FunctionImports contained */ -public interface EdmEntityContainer extends EdmNamed { +public interface EdmEntityContainer extends EdmNamed, EdmAnnotationsTarget, EdmAnnotatable { /** * @return namespace of this entity container @@ -37,7 +37,7 @@ public interface EdmEntityContainer extends EdmNamed { * @return full qualified name of this entity container */ FullQualifiedName getFullQualifiedName(); - + /** * Returns whether this container is the default container in the current schema. *
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEnumType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEnumType.java index dc1806d93..cc4c1d70c 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEnumType.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmEnumType.java @@ -23,7 +23,7 @@ import java.util.List; /** * An EdmEnumType represents a set of related values. */ -public interface EdmEnumType extends EdmPrimitiveType { +public interface EdmEnumType extends EdmPrimitiveType, EdmAnnotationsTarget { /** * @param name diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmMember.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmMember.java index 888fe778c..fe32c5c91 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmMember.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmMember.java @@ -21,7 +21,7 @@ package org.apache.olingo.commons.api.edm; /** * An {@link EdmEnumType} member element. */ -public interface EdmMember extends EdmNamed { +public interface EdmMember extends EdmNamed, EdmAnnotationsTarget, EdmAnnotatable { /** * @return value of this member as string diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmNavigationProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmNavigationProperty.java index b53e6170b..199de6cde 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmNavigationProperty.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmNavigationProperty.java @@ -25,7 +25,7 @@ import java.util.List; *
* EdmNavigationProperty allows navigation from one entity type to another via a relationship. */ -public interface EdmNavigationProperty extends EdmElement { +public interface EdmNavigationProperty extends EdmElement, EdmAnnotationsTarget, EdmAnnotatable { @Override EdmEntityType getType(); diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java index 28c19859b..c916aea17 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java @@ -23,7 +23,7 @@ import java.util.List; /** * A EdmOperation can either be an {@link EdmAction} or an {@link EdmFunction}. */ -public interface EdmOperation extends EdmType { +public interface EdmOperation extends EdmType, EdmAnnotatable { /** * @param name diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperationImport.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperationImport.java index ec0648d51..f1f596590 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperationImport.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperationImport.java @@ -21,13 +21,13 @@ package org.apache.olingo.commons.api.edm; /** * An EdmOperationImport can be an EdmActionImport or an EdmFunctionImport. */ -public interface EdmOperationImport extends EdmNamed { +public interface EdmOperationImport extends EdmNamed, EdmAnnotationsTarget, EdmAnnotatable { /** * @return {@link FullQualifiedName} of this OperationImport */ FullQualifiedName getFullQualifiedName(); - + /** * @return {@link EdmEntitySet} of this OperationImport */ diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmParameter.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmParameter.java index a0cfe6789..a3505f8f1 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmParameter.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmParameter.java @@ -18,10 +18,12 @@ */ package org.apache.olingo.commons.api.edm; +import org.apache.olingo.commons.api.edm.geo.SRID; + /** * A CSDL parameter element */ -public interface EdmParameter extends EdmElement, EdmMappable { +public interface EdmParameter extends EdmElement, EdmMappable, EdmAnnotatable { /** * @return true if nullable or null if not specified @@ -42,4 +44,9 @@ public interface EdmParameter extends EdmElement, EdmMappable { * @return the scale as an Integer or null if not specified */ Integer getScale(); + + /** + * @return a non-negative integer or the special value variable + */ + SRID getSrid(); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmProperty.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmProperty.java index fdaf67e5c..d6e75834a 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmProperty.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmProperty.java @@ -18,12 +18,14 @@ */ package org.apache.olingo.commons.api.edm; +import org.apache.olingo.commons.api.edm.geo.SRID; + /** * A CSDL Property element. *
* EdmProperty defines a simple type or a complex type. */ -public interface EdmProperty extends EdmElement, EdmMappable { +public interface EdmProperty extends EdmElement, EdmMappable, EdmAnnotationsTarget, EdmAnnotatable { /** * Gets the related MIME type for the property. @@ -59,6 +61,11 @@ public interface EdmProperty extends EdmElement, EdmMappable { */ Integer getScale(); + /** + * @return a non-negative integer or the special value variable + */ + SRID getSrid(); + /** * @return true if unicode or null if not specified */ diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmReferentialConstraint.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmReferentialConstraint.java index f30dea586..a61362f45 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmReferentialConstraint.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmReferentialConstraint.java @@ -21,7 +21,7 @@ package org.apache.olingo.commons.api.edm; /** * A referential constraint of a navigation property. */ -public interface EdmReferentialConstraint { +public interface EdmReferentialConstraint extends EdmAnnotatable { /** * @return property name of the property inside this entity type or complex type. diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmReturnType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmReturnType.java index 9bb849f22..540d2ab20 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmReturnType.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmReturnType.java @@ -18,6 +18,8 @@ */ package org.apache.olingo.commons.api.edm; +import org.apache.olingo.commons.api.edm.geo.SRID; + /** * An {@link EdmReturnType} of an {@link EdmOperation}. */ @@ -42,4 +44,9 @@ public interface EdmReturnType extends EdmTyped { * @return the scale as an Integer or null if not specified */ Integer getScale(); + + /** + * @return a non-negative integer or the special value variable + */ + SRID getSrid(); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmSchema.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmSchema.java index 73dcdfbb7..a2147d869 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmSchema.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmSchema.java @@ -23,7 +23,7 @@ import java.util.List; /** * A csdl schema element */ -public interface EdmSchema { +public interface EdmSchema extends EdmAnnotatable { /** * @return the namespace for this schema @@ -60,6 +60,21 @@ public interface EdmSchema { */ List getFunctions(); + /** + * @return all {@link EdmTypeDefinition} for this schema. + */ + List getTypeDefinitions(); + + /** + * @return all {@link EdmTerm} for this schema. + */ + List getTerms(); + + /** + * @return all {@link EdmAnnotations} for this schema. + */ + List getAnnotationGroups(); + /** * @return the entity container for this schema. May be null. */ @@ -83,9 +98,4 @@ public interface EdmSchema { */ EdmEntityContainer getEntityContainer(FullQualifiedName name); - /** - * @return all {@link EdmTypeDefinition} for this schema. - */ - List getTypeDefinitions(); - } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmServiceMetadata.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmServiceMetadata.java index b186fdd3b..01d685ff0 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmServiceMetadata.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmServiceMetadata.java @@ -20,6 +20,7 @@ package org.apache.olingo.commons.api.edm; import java.io.InputStream; import java.util.List; +import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; /** * This interface gives access to the metadata of a service, the calculated Data Service Version and an info list of all @@ -35,7 +36,7 @@ public interface EdmServiceMetadata { /** * @return String data service version of this service */ - String getDataServiceVersion(); + ODataServiceVersion getDataServiceVersion(); /** * @return a list of {@link EdmEntitySetInfo} objects inside the data model diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmStructuredType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmStructuredType.java index a0b5f1e03..5c6fcd89a 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmStructuredType.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmStructuredType.java @@ -25,7 +25,7 @@ import java.util.List; * * Complex types and entity types are described in the Conceptual Schema Definition of the OData protocol. */ -public interface EdmStructuredType extends EdmType { +public interface EdmStructuredType extends EdmType, EdmAnnotationsTarget, EdmAnnotatable { /** * Get property by name diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmTerm.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmTerm.java index 25a2459e2..237bbb130 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmTerm.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmTerm.java @@ -18,10 +18,34 @@ */ package org.apache.olingo.commons.api.edm; +import java.util.List; +import org.apache.olingo.commons.api.edm.geo.SRID; + /** * An {@link EdmTerm} defines a term in a vocabulary. */ -public interface EdmTerm extends EdmNamed { +public interface EdmTerm extends EdmNamed, EdmAnnotationsTarget, EdmAnnotatable { + + /** + * @return type of value returned by the expression contained in an annotation using this term + */ + EdmType getType(); + + FullQualifiedName getFullQualifiedName(); + + /** + * When applying a term with a base term,the base term MUST also be applied with the same qualifier, and so on until a + * term without a base term is reached. + * + * @return the base term if found or null otherwise + */ + EdmTerm getBaseTerm(); + + /** + * @return list of CSDL element that this term can be applied to; if no value is supplied, the term is not restricted + * in its application. + */ + List> getAppliesTo(); /** * @return true if nullable or null if not specified @@ -43,8 +67,14 @@ public interface EdmTerm extends EdmNamed { */ Integer getScale(); + /** + * @return a non-negative integer or the special value variable + */ + SRID getSrid(); + /** * @return the default value as a String or null if not specified */ String getDefaultValue(); + } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmTypeDefinition.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmTypeDefinition.java index c16ed8510..9a1eaa82f 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmTypeDefinition.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmTypeDefinition.java @@ -18,12 +18,14 @@ */ package org.apache.olingo.commons.api.edm; +import org.apache.olingo.commons.api.edm.geo.SRID; + /** * An {@link EdmTypeDefinition} defines a specialization of one of the possible primitive types. *
* For more information on primitive types refer to {@link EdmPrimitiveType}. */ -public interface EdmTypeDefinition extends EdmPrimitiveType { +public interface EdmTypeDefinition extends EdmPrimitiveType, EdmAnnotationsTarget, EdmAnnotatable { /** * @return {@link EdmPrimitiveType} this type definition is based upon @@ -45,6 +47,11 @@ public interface EdmTypeDefinition extends EdmPrimitiveType { */ Integer getScale(); + /** + * @return a non-negative integer or the special value variable + */ + SRID getSrid(); + /** * @return true if unicode or null if not specified */ diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmAnd.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmAnd.java new file mode 100644 index 000000000..a232c2efd --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmAnd.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.api.edm.annotation; + +public interface EdmAnd extends EdmTwoParamsOpDynamicAnnotationExpression { + +} diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/v3/InvokeRequestFactory.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmAnnotationExpression.java similarity index 77% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/v3/InvokeRequestFactory.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmAnnotationExpression.java index 476678e8a..2da9692d7 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/invoke/v3/InvokeRequestFactory.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmAnnotationExpression.java @@ -16,9 +16,15 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.communication.request.invoke.v3; +package org.apache.olingo.commons.api.edm.annotation; -import org.apache.olingo.client.api.communication.request.invoke.CommonInvokeRequestFactory; +public interface EdmAnnotationExpression { -public interface InvokeRequestFactory extends CommonInvokeRequestFactory { + boolean isConstant(); + + EdmConstantAnnotationExpression asConstant(); + + boolean isDynamic(); + + EdmDynamicAnnotationExpression asDynamic(); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmAnnotationPath.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmAnnotationPath.java new file mode 100644 index 000000000..b55e2260f --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmAnnotationPath.java @@ -0,0 +1,25 @@ +/* + * 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.api.edm.annotation; + +public interface EdmAnnotationPath extends EdmDynamicAnnotationExpression { + + String getValue(); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmApply.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmApply.java new file mode 100644 index 000000000..cb666cadf --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmApply.java @@ -0,0 +1,41 @@ +/* + * 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.api.edm.annotation; + +import java.util.List; +import org.apache.olingo.commons.api.edm.EdmAnnotatable; + +public interface EdmApply extends EdmDynamicAnnotationExpression, EdmAnnotatable { + + /** + * A QualifiedName specifying the name of the client-side function to apply. + *
+ * OData defines three canonical functions. Services MAY support additional functions that MUST be qualified with a + * namespace or alias other than odata. Function names qualified with odata are reserved for this specification and + * its future versions. + * + * @see org.apache.olingo.commons.api.Constants#CANONICAL_FUNCTION_CONCAT + * @see org.apache.olingo.commons.api.Constants#CANONICAL_FUNCTION_FILLURITEMPLATE + * @see org.apache.olingo.commons.api.Constants#CANONICAL_FUNCTION_URIENCODE + * @return function full qualified name + */ + String getFunction(); + + List getParameters(); +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmCast.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmCast.java new file mode 100644 index 000000000..cb28d08ba --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmCast.java @@ -0,0 +1,38 @@ +/* + * 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.api.edm.annotation; + +import org.apache.olingo.commons.api.edm.EdmAnnotatable; +import org.apache.olingo.commons.api.edm.EdmType; +import org.apache.olingo.commons.api.edm.geo.SRID; + +public interface EdmCast extends EdmDynamicAnnotationExpression, EdmAnnotatable { + + Integer getMaxLength(); + + Integer getPrecision(); + + Integer getScale(); + + SRID getSrid(); + + EdmType getType(); + + EdmDynamicAnnotationExpression getValue(); +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmCollection.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmCollection.java new file mode 100644 index 000000000..7523d78ad --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmCollection.java @@ -0,0 +1,27 @@ +/* + * 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.api.edm.annotation; + +import java.util.List; + +public interface EdmCollection extends EdmDynamicAnnotationExpression { + + List getItems(); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmConstantAnnotationExpression.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmConstantAnnotationExpression.java new file mode 100644 index 000000000..c10138f36 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmConstantAnnotationExpression.java @@ -0,0 +1,27 @@ +/* + * 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.api.edm.annotation; + +import org.apache.olingo.commons.api.domain.v4.ODataValue; + +public interface EdmConstantAnnotationExpression extends EdmAnnotationExpression { + + ODataValue getValue(); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmDynamicAnnotationExpression.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmDynamicAnnotationExpression.java new file mode 100644 index 000000000..6815e4c47 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmDynamicAnnotationExpression.java @@ -0,0 +1,118 @@ +/* + * 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.api.edm.annotation; + +public interface EdmDynamicAnnotationExpression extends EdmAnnotationExpression { + + boolean isNot(); + + EdmNot asNot(); + + boolean isAnd(); + + EdmAnd asAnd(); + + boolean isOr(); + + EdmOr asOr(); + + boolean isEq(); + + EdmEq asEq(); + + boolean isNe(); + + EdmNe asNe(); + + boolean isGt(); + + EdmGt asGt(); + + boolean isGe(); + + EdmGe asGe(); + + boolean isLt(); + + EdmLt asLt(); + + boolean isLe(); + + EdmLe asLe(); + + boolean isAnnotationPath(); + + EdmAnnotationPath asAnnotationPath(); + + boolean isApply(); + + EdmApply asApply(); + + boolean isCast(); + + EdmCast asCast(); + + boolean isCollection(); + + EdmCollection asCollection(); + + boolean isIf(); + + EdmIf asIf(); + + boolean isIsOf(); + + EdmIsOf asIsOf(); + + boolean isLabeledElement(); + + EdmLabeledElement asLabeledElement(); + + boolean isLabeledElementReference(); + + EdmLabeledElementReference asLabeledElementReference(); + + boolean isNull(); + + EdmNull asNull(); + + boolean isNavigationPropertyPath(); + + EdmNavigationPropertyPath asNavigationPropertyPath(); + + boolean isPath(); + + EdmPath asPath(); + + boolean isPropertyPath(); + + EdmPropertyPath asPropertyPath(); + + boolean isPropertyValue(); + + EdmPropertyValue asPropertyValue(); + + boolean isRecord(); + + EdmRecord asRecord(); + + boolean isUrlRef(); + + EdmUrlRef asUrlRef(); +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmEq.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmEq.java new file mode 100644 index 000000000..b5fdf99ab --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmEq.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.api.edm.annotation; + +public interface EdmEq extends EdmTwoParamsOpDynamicAnnotationExpression { + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmGe.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmGe.java new file mode 100644 index 000000000..fa21571f3 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmGe.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.api.edm.annotation; + +public interface EdmGe extends EdmTwoParamsOpDynamicAnnotationExpression { + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmGt.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmGt.java new file mode 100644 index 000000000..63742045b --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmGt.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.api.edm.annotation; + +public interface EdmGt extends EdmTwoParamsOpDynamicAnnotationExpression { + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmIf.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmIf.java new file mode 100644 index 000000000..fc95c0aab --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmIf.java @@ -0,0 +1,30 @@ +/* + * 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.api.edm.annotation; + +import org.apache.olingo.commons.api.edm.EdmAnnotatable; + +public interface EdmIf extends EdmDynamicAnnotationExpression, EdmAnnotatable { + + EdmAnnotationExpression getGuard(); + + EdmAnnotationExpression getThen(); + + EdmAnnotationExpression getElse(); +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmIsOf.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmIsOf.java new file mode 100644 index 000000000..dceba29ee --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmIsOf.java @@ -0,0 +1,38 @@ +/* + * 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.api.edm.annotation; + +import org.apache.olingo.commons.api.edm.EdmAnnotatable; +import org.apache.olingo.commons.api.edm.EdmType; +import org.apache.olingo.commons.api.edm.geo.SRID; + +public interface EdmIsOf extends EdmDynamicAnnotationExpression, EdmAnnotatable { + + Integer getMaxLength(); + + Integer getPrecision(); + + Integer getScale(); + + SRID getSrid(); + + EdmType getType(); + + EdmDynamicAnnotationExpression getValue(); +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmLabeledElement.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmLabeledElement.java new file mode 100644 index 000000000..aaa6dbd17 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmLabeledElement.java @@ -0,0 +1,28 @@ +/* + * 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.api.edm.annotation; + +import org.apache.olingo.commons.api.edm.EdmAnnotatable; + +public interface EdmLabeledElement extends EdmDynamicAnnotationExpression, EdmAnnotatable { + + String getName(); + + EdmDynamicAnnotationExpression getValue(); +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmLabeledElementReference.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmLabeledElementReference.java new file mode 100644 index 000000000..4bf7c6333 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmLabeledElementReference.java @@ -0,0 +1,25 @@ +/* + * 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.api.edm.annotation; + +public interface EdmLabeledElementReference extends EdmDynamicAnnotationExpression { + + String getValue(); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmLe.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmLe.java new file mode 100644 index 000000000..814f8a2d6 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmLe.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.api.edm.annotation; + +public interface EdmLe extends EdmTwoParamsOpDynamicAnnotationExpression { + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmLt.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmLt.java new file mode 100644 index 000000000..afa212b55 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmLt.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.api.edm.annotation; + +public interface EdmLt extends EdmTwoParamsOpDynamicAnnotationExpression { + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNavigationPropertyPath.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNavigationPropertyPath.java new file mode 100644 index 000000000..1233d1f41 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNavigationPropertyPath.java @@ -0,0 +1,25 @@ +/* + * 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.api.edm.annotation; + +public interface EdmNavigationPropertyPath extends EdmDynamicAnnotationExpression { + + String getValue(); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNe.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNe.java new file mode 100644 index 000000000..5c8f93d00 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNe.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.api.edm.annotation; + +public interface EdmNe extends EdmTwoParamsOpDynamicAnnotationExpression { + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNot.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNot.java new file mode 100644 index 000000000..d0f2ce2f5 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNot.java @@ -0,0 +1,24 @@ +/* + * 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.api.edm.annotation; + +public interface EdmNot extends EdmDynamicAnnotationExpression { + + EdmDynamicAnnotationExpression getExpression(); +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNull.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNull.java new file mode 100644 index 000000000..8baed8068 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmNull.java @@ -0,0 +1,25 @@ +/* + * 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.api.edm.annotation; + +import org.apache.olingo.commons.api.edm.EdmAnnotatable; + +public interface EdmNull extends EdmDynamicAnnotationExpression, EdmAnnotatable { + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmOr.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmOr.java new file mode 100644 index 000000000..ee7627f84 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmOr.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.api.edm.annotation; + +public interface EdmOr extends EdmTwoParamsOpDynamicAnnotationExpression { + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmPath.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmPath.java new file mode 100644 index 000000000..93f5a5e6f --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmPath.java @@ -0,0 +1,25 @@ +/* + * 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.api.edm.annotation; + +public interface EdmPath extends EdmDynamicAnnotationExpression { + + String getValue(); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmPropertyPath.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmPropertyPath.java new file mode 100644 index 000000000..869fe2aff --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmPropertyPath.java @@ -0,0 +1,25 @@ +/* + * 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.api.edm.annotation; + +public interface EdmPropertyPath extends EdmDynamicAnnotationExpression { + + String getValue(); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmPropertyValue.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmPropertyValue.java new file mode 100644 index 000000000..0bdc125b3 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmPropertyValue.java @@ -0,0 +1,29 @@ +/* + * 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.api.edm.annotation; + +import org.apache.olingo.commons.api.edm.EdmAnnotatable; + +public interface EdmPropertyValue extends EdmDynamicAnnotationExpression, EdmAnnotatable { + + String getProperty(); + + EdmAnnotationExpression getValue(); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmRecord.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmRecord.java new file mode 100644 index 000000000..063d32fcc --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmRecord.java @@ -0,0 +1,31 @@ +/* + * 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.api.edm.annotation; + +import java.util.List; +import org.apache.olingo.commons.api.edm.EdmAnnotatable; +import org.apache.olingo.commons.api.edm.EdmStructuredType; + +public interface EdmRecord extends EdmDynamicAnnotationExpression, EdmAnnotatable { + + List getPropertyValues(); + + EdmStructuredType getType(); + +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmTwoParamsOpDynamicAnnotationExpression.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmTwoParamsOpDynamicAnnotationExpression.java new file mode 100644 index 000000000..4b75b3c5d --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmTwoParamsOpDynamicAnnotationExpression.java @@ -0,0 +1,26 @@ +/* + * 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.api.edm.annotation; + +public interface EdmTwoParamsOpDynamicAnnotationExpression extends EdmDynamicAnnotationExpression { + + EdmDynamicAnnotationExpression getLeftExpression(); + + EdmDynamicAnnotationExpression getRightExpression(); +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmUrlRef.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmUrlRef.java new file mode 100644 index 000000000..aea36ea47 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmUrlRef.java @@ -0,0 +1,24 @@ +/* + * 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.api.edm.annotation; + +public interface EdmUrlRef extends EdmDynamicAnnotationExpression { + + EdmAnnotationExpression getValue(); +} diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java index cbc56851a..449253c9b 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java @@ -31,7 +31,7 @@ public abstract class ComposedGeospatial extends Geospatia protected final List geospatials; - protected ComposedGeospatial(final Dimension dimension, final Type type, final Integer srid, + protected ComposedGeospatial(final Dimension dimension, final Type type, final SRID srid, final List geospatials) { super(dimension, type, srid); diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java index 19b98dd71..66dac2c61 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java @@ -31,6 +31,8 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; */ public abstract class Geospatial implements Serializable { + private static final long serialVersionUID = 5409612902190067390L; + public enum Dimension { GEOMETRY, @@ -78,7 +80,7 @@ public abstract class Geospatial implements Serializable { /** * Null value means it is expected to vary per instance. */ - protected final Integer srid; + protected final SRID srid; /** * Constructor. @@ -87,10 +89,13 @@ public abstract class Geospatial implements Serializable { * @param type type. * @param srid SRID */ - protected Geospatial(final Dimension dimension, final Type type, final Integer srid) { + protected Geospatial(final Dimension dimension, final Type type, final SRID srid) { this.dimension = dimension; this.type = type; - this.srid = srid; + this.srid = srid == null + ? new SRID() + : srid; + this.srid.setDimension(dimension); } /** @@ -118,7 +123,7 @@ public abstract class Geospatial implements Serializable { * * @return s-rid. */ - public Integer getSrid() { + public SRID getSrid() { return srid; } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java index 5b0b85763..4ac3ff836 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java @@ -28,7 +28,7 @@ public class GeospatialCollection extends ComposedGeospatial { private static final long serialVersionUID = -9181547636133878977L; - public GeospatialCollection(final Dimension dimension, final Integer srid, final List geospatials) { + public GeospatialCollection(final Dimension dimension, final SRID srid, final List geospatials) { super(dimension, Type.GEOSPATIALCOLLECTION, srid, geospatials); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.java index bc6afafcc..2ececb26b 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.java @@ -25,7 +25,7 @@ public class LineString extends ComposedGeospatial { private static final long serialVersionUID = 3207958185407535907L; - public LineString(final Dimension dimension, final Integer srid, final List points) { + public LineString(final Dimension dimension, final SRID srid, final List points) { super(dimension, Type.LINESTRING, srid, points); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.java index d38f3b013..fda8eb688 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.java @@ -25,7 +25,7 @@ public class MultiLineString extends ComposedGeospatial { private static final long serialVersionUID = -5042414471218124125L; - public MultiLineString(final Dimension dimension, final Integer srid, final List lineStrings) { + public MultiLineString(final Dimension dimension, final SRID srid, final List lineStrings) { super(dimension, Type.MULTILINESTRING, srid, lineStrings); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.java index 7229d05b2..04ff9fb6c 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.java @@ -25,7 +25,7 @@ public class MultiPoint extends ComposedGeospatial { private static final long serialVersionUID = 4951011255142116129L; - public MultiPoint(final Dimension dimension, final Integer srid, final List points) { + public MultiPoint(final Dimension dimension, final SRID srid, final List points) { super(dimension, Type.MULTIPOINT, srid, points); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.java index dbbfb2450..d19701e24 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.java @@ -25,7 +25,7 @@ public class MultiPolygon extends ComposedGeospatial { private static final long serialVersionUID = -160184788048512883L; - public MultiPolygon(final Dimension dimension, final Integer srid, final List polygons) { + public MultiPolygon(final Dimension dimension, final SRID srid, final List polygons) { super(dimension, Type.MULTIPOLYGON, srid, polygons); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java index c8c8a3725..5bb69fc43 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java @@ -40,7 +40,7 @@ public class Point extends Geospatial { */ private double z; - public Point(final Dimension dimension, final Integer srid) { + public Point(final Dimension dimension, final SRID srid) { super(dimension, Type.POINT, srid); } diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java index 6d93ef25a..d984deec7 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java @@ -32,7 +32,7 @@ public class Polygon extends Geospatial { final ComposedGeospatial exterior; - public Polygon(final Dimension dimension, final Integer srid, + public Polygon(final Dimension dimension, final SRID srid, final List interior, final List exterior) { super(dimension, Type.POLYGON, srid); diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/SRID.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/SRID.java new file mode 100644 index 000000000..ff494a742 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/SRID.java @@ -0,0 +1,106 @@ +/* + * 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.api.edm.geo; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension; + +/** + * A geometry or geography property MAY define a value for the SRID attribute. The value of this attribute identifies + * which spatial reference system is applied to values of the property on type instances. + *
+ * The value of the SRID attribute MUST be a non-negative integer or the special value variable. If no value is + * specified, the attribute defaults to 0 for Geometry types or 4326 for Geography types. + *
+ * Standards Track Work Product Copyright © OASIS Open 2013. All Rights Reserved. 19 November 2013 Page 22 of 83The + * valid values of the SRID attribute and their meanings are as defined by the European Petroleum Survey Group [EPSG]. + */ +public class SRID { + + private static final String VARIABLE = "variable"; + + private Dimension dimension = Dimension.GEOGRAPHY; + + private Integer value; + + private Boolean variable; + + public static SRID valueOf(final String exp) { + final SRID instance = new SRID(); + + if (VARIABLE.equalsIgnoreCase(exp)) { + instance.variable = Boolean.TRUE; + } else { + instance.value = Integer.valueOf(exp); + if (instance.value < 0) { + throw new IllegalArgumentException( + "The value of the SRID attribute MUST be a non-negative integer or the special value 'variable'"); + } + } + + return instance; + } + + protected SRID() { + // empty constructor for package instantiation + } + + public Dimension getDimension() { + return dimension; + } + + public void setDimension(final Dimension dimension) { + this.dimension = dimension; + } + + private String getValue() { + return value == null + ? dimension == Dimension.GEOMETRY + ? "0" + : "4326" + : value.toString(); + } + + private boolean isVariable() { + return variable != null && variable; + } + + public boolean isNotDefault() { + return value != null || variable != null; + } + + @Override + public int hashCode() { + return HashCodeBuilder.reflectionHashCode(this); + } + + @Override + public boolean equals(final Object obj) { + return EqualsBuilder.reflectionEquals(this, obj); + } + + @Override + public String toString() { + return isVariable() + ? VARIABLE + : getValue(); + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java index 0444fbab3..4d579bfa4 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java @@ -39,12 +39,13 @@ import org.apache.olingo.commons.api.edm.geo.MultiPoint; import org.apache.olingo.commons.api.edm.geo.MultiPolygon; import org.apache.olingo.commons.api.edm.geo.Point; import org.apache.olingo.commons.api.edm.geo.Polygon; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble; class AtomGeoValueDeserializer { private List points(final XMLEventReader reader, final StartElement start, - final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException { + final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException { final List result = new ArrayList(); @@ -76,7 +77,7 @@ class AtomGeoValueDeserializer { } private MultiPoint multipoint(final XMLEventReader reader, final StartElement start, - final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException { + final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException { List points = Collections.emptyList(); @@ -97,13 +98,13 @@ class AtomGeoValueDeserializer { } private LineString lineString(final XMLEventReader reader, final StartElement start, - final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException { + final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException { return new LineString(GeoUtils.getDimension(type), srid, points(reader, start, type, null)); } private Polygon polygon(final XMLEventReader reader, final StartElement start, - final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException { + final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException { List extPoints = null; List intPoints = null; @@ -130,7 +131,7 @@ class AtomGeoValueDeserializer { } private MultiLineString multiLineString(final XMLEventReader reader, final StartElement start, - final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException { + final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException { final List lineStrings = new ArrayList(); @@ -151,7 +152,7 @@ class AtomGeoValueDeserializer { } private MultiPolygon multiPolygon(final XMLEventReader reader, final StartElement start, - final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException { + final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException { final List polygons = new ArrayList(); @@ -172,7 +173,7 @@ class AtomGeoValueDeserializer { } private GeospatialCollection collection(final XMLEventReader reader, final StartElement start, - final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException { + final EdmPrimitiveTypeKind type, final SRID srid) throws XMLStreamException { final List geospatials = new ArrayList(); @@ -207,10 +208,10 @@ class AtomGeoValueDeserializer { public Geospatial deserialize(final XMLEventReader reader, final StartElement start, final EdmPrimitiveTypeKind type) throws XMLStreamException { - Integer srid = null; + SRID srid = null; final Attribute srsName = start.getAttributeByName(Constants.QNAME_ATTR_SRSNAME); if (srsName != null) { - srid = Integer.valueOf(StringUtils.substringAfterLast(srsName.getValue(), "/")); + srid = SRID.valueOf(StringUtils.substringAfterLast(srsName.getValue(), "/")); } Geospatial value; diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueSerializer.java index d1636d4fa..7b83e8a09 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueSerializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueSerializer.java @@ -118,9 +118,9 @@ class AtomGeoValueSerializer { } private void writeSrsName(final XMLStreamWriter writer, final Geospatial value) throws XMLStreamException { - if (value.getSrid() != null) { + if (value.getSrid() != null && value.getSrid().isNotDefault()) { writer.writeAttribute(Constants.PREFIX_GML, Constants.NS_GML, Constants.ATTR_SRSNAME, - Constants.SRS_URLPREFIX + value.getSrid()); + Constants.SRS_URLPREFIX + value.getSrid().toString()); } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueDeserializer.java index 09ecbdf51..d645587c1 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueDeserializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueDeserializer.java @@ -36,6 +36,7 @@ import org.apache.olingo.commons.api.edm.geo.MultiPoint; import org.apache.olingo.commons.api.edm.geo.MultiPolygon; import org.apache.olingo.commons.api.edm.geo.Point; import org.apache.olingo.commons.api.edm.geo.Polygon; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble; @@ -47,7 +48,7 @@ class JSONGeoValueDeserializer { this.version = version; } - private Point point(final Iterator itor, final EdmPrimitiveTypeKind type, final Integer srid) { + private Point point(final Iterator itor, final EdmPrimitiveTypeKind type, final SRID srid) { Point point = null; if (itor.hasNext()) { @@ -65,7 +66,7 @@ class JSONGeoValueDeserializer { return point; } - private MultiPoint multipoint(final Iterator itor, final EdmPrimitiveTypeKind type, final Integer srid) { + private MultiPoint multipoint(final Iterator itor, final EdmPrimitiveTypeKind type, final SRID srid) { final MultiPoint multiPoint; if (itor.hasNext()) { @@ -82,7 +83,7 @@ class JSONGeoValueDeserializer { return multiPoint; } - private LineString lineString(final Iterator itor, final EdmPrimitiveTypeKind type, final Integer srid) { + private LineString lineString(final Iterator itor, final EdmPrimitiveTypeKind type, final SRID srid) { final LineString lineString; if (itor.hasNext()) { @@ -100,7 +101,7 @@ class JSONGeoValueDeserializer { } private MultiLineString multiLineString(final Iterator itor, final EdmPrimitiveTypeKind type, - final Integer srid) { + final SRID srid) { final MultiLineString multiLineString; @@ -118,9 +119,7 @@ class JSONGeoValueDeserializer { return multiLineString; } - private Polygon polygon(final Iterator itor, final EdmPrimitiveTypeKind type, - final Integer srid) { - + private Polygon polygon(final Iterator itor, final EdmPrimitiveTypeKind type, final SRID srid) { List extPoints = null; if (itor.hasNext()) { final Iterator extItor = itor.next().elements(); @@ -148,9 +147,7 @@ class JSONGeoValueDeserializer { return new Polygon(GeoUtils.getDimension(type), srid, intPoints, extPoints); } - private MultiPolygon multiPolygon(final Iterator itor, final EdmPrimitiveTypeKind type, - final Integer srid) { - + private MultiPolygon multiPolygon(final Iterator itor, final EdmPrimitiveTypeKind type, final SRID srid) { final MultiPolygon multiPolygon; if (itor.hasNext()) { @@ -168,7 +165,7 @@ class JSONGeoValueDeserializer { } private GeospatialCollection collection(final Iterator itor, final EdmPrimitiveTypeKind type, - final Integer srid) { + final SRID srid) { final GeospatialCollection collection; @@ -219,9 +216,9 @@ class JSONGeoValueDeserializer { ? node.get(Constants.JSON_COORDINATES).elements() : Collections.emptyList().iterator(); - Integer srid = null; + SRID srid = null; if (node.has(Constants.JSON_CRS)) { - srid = Integer.valueOf( + srid = SRID.valueOf( node.get(Constants.JSON_CRS).get(Constants.PROPERTIES).get(Constants.JSON_NAME).asText().split(":")[1]); } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueSerializer.java index 470872e35..4578e527c 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueSerializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueSerializer.java @@ -33,15 +33,16 @@ import org.apache.olingo.commons.api.edm.geo.MultiPoint; import org.apache.olingo.commons.api.edm.geo.MultiPolygon; import org.apache.olingo.commons.api.edm.geo.Point; import org.apache.olingo.commons.api.edm.geo.Polygon; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble; class JSONGeoValueSerializer { - private void srid(final JsonGenerator jgen, final Integer srid) throws IOException { + private void srid(final JsonGenerator jgen, final SRID srid) throws IOException { jgen.writeObjectFieldStart(Constants.JSON_CRS); jgen.writeStringField(Constants.ATTR_TYPE, Constants.JSON_NAME); jgen.writeObjectFieldStart(Constants.PROPERTIES); - jgen.writeStringField(Constants.JSON_NAME, "EPSG:" + srid); + jgen.writeStringField(Constants.JSON_NAME, "EPSG:" + srid.toString()); jgen.writeEndObject(); jgen.writeEndObject(); } @@ -175,7 +176,7 @@ class JSONGeoValueSerializer { default: } - if (value.getSrid() != null) { + if (value.getSrid() != null && value.getSrid().isNotDefault()) { srid(jgen, value.getSrid()); } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPrimitiveValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPrimitiveValueImpl.java index 6dc3034d4..93e525f6f 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPrimitiveValueImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v3/ODataPrimitiveValueImpl.java @@ -39,6 +39,11 @@ public class ODataPrimitiveValueImpl extends AbstractODataPrimitiveValue { return instance; } + @Override + public ODataPrimitiveValueImpl build() { + return (ODataPrimitiveValueImpl) super.build(); + } + } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPrimitiveValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPrimitiveValueImpl.java index dcf51c9eb..74d060185 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPrimitiveValueImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/v4/ODataPrimitiveValueImpl.java @@ -42,6 +42,11 @@ public class ODataPrimitiveValueImpl extends AbstractODataPrimitiveValue impleme return instance; } + @Override + public ODataPrimitiveValueImpl build() { + return (ODataPrimitiveValueImpl) super.build(); + } + } @Override diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java index 98a22c5e4..58c979c11 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdm.java @@ -19,12 +19,15 @@ package org.apache.olingo.commons.core.edm; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmAnnotations; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntityType; @@ -32,11 +35,16 @@ import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmSchema; import org.apache.olingo.commons.api.edm.EdmServiceMetadata; +import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; public abstract class AbstractEdm implements Edm { + protected Map schemas; + + protected List schemaList; + private final Map entityContainers = new HashMap(); @@ -60,19 +68,26 @@ public abstract class AbstractEdm implements Edm { private final Map boundFunctions = new HashMap(); + private final Map terms = new HashMap(); + + private final Map annotationGroups = + new HashMap(); + + private final Map> annotations = + new HashMap>(); + private EdmServiceMetadata serviceMetadata; private Map aliasToNamespaceInfo; - private List schemas; - @Override public List getSchemas() { if (schemas == null) { schemas = createSchemas(); if (schemas != null) { + schemaList = Collections.unmodifiableList(new ArrayList(schemas.values())); aliasToNamespaceInfo = new HashMap(); - for (EdmSchema schema : schemas) { + for (EdmSchema schema : schemas.values()) { final String namespace = schema.getNamespace(); if (schema.getAlias() != null) { aliasToNamespaceInfo.put(schema.getAlias(), namespace); @@ -151,7 +166,19 @@ public abstract class AbstractEdm implements Edm { } } } - return schemas; + return schemaList; + } + + @Override + public EdmSchema getSchema(final String namespace) { + // enusure schemas are loaded + getSchemas(); + + EdmSchema schema = null; + if (schemas != null) { + schema = schemas.get(namespace); + } + return schema; } @Override @@ -314,6 +341,58 @@ public abstract class AbstractEdm implements Edm { return function; } + @Override + public EdmTerm getTerm(final FullQualifiedName termName) { + final FullQualifiedName fqn = resolvePossibleAlias(termName); + EdmTerm term = terms.get(fqn); + if (term == null) { + term = createTerm(fqn); + if (term != null) { + terms.put(fqn, term); + } + } + return term; + } + + @Override + public EdmAnnotations getAnnotationGroup(final FullQualifiedName targetName) { + EdmAnnotations _annotations = annotationGroups.get(targetName); + if (_annotations == null) { + _annotations = createAnnotationGroup(targetName); + if (_annotations != null) { + annotationGroups.put(targetName, _annotations); + } + } + return _annotations; + } + + @Override + public List getAnnotations(final FullQualifiedName annotatableName) { + final FullQualifiedName fqn = resolvePossibleAlias(annotatableName); + List _annotations = annotations.get(fqn); + if (_annotations == null) { + _annotations = createAnnotations(fqn); + if (_annotations != null) { + annotations.put(fqn, _annotations); + } + } + return _annotations; + } + + @Override + public EdmAnnotation getAnnotation(final FullQualifiedName annotatableName, final EdmTerm term) { + final List _annotations = getAnnotations(annotatableName); + EdmAnnotation result = null; + if (_annotations != null) { + for (EdmAnnotation annotation : _annotations) { + if (term.getFullQualifiedName().equals(annotation.getTerm().getFullQualifiedName())) { + result = annotation; + } + } + } + return result; + } + @Override public EdmServiceMetadata getServiceMetadata() { if (serviceMetadata == null) { @@ -339,6 +418,8 @@ public abstract class AbstractEdm implements Edm { return finalFQN; } + protected abstract Map createSchemas(); + protected abstract Map createAliasToNamespaceInfo(); protected abstract EdmEntityContainer createEntityContainer(FullQualifiedName containerName); @@ -367,6 +448,9 @@ public abstract class AbstractEdm implements Edm { protected abstract EdmServiceMetadata createServiceMetadata(); - protected abstract List createSchemas(); + protected abstract EdmTerm createTerm(FullQualifiedName termName); + protected abstract EdmAnnotations createAnnotationGroup(FullQualifiedName targetName); + + protected abstract List createAnnotations(FullQualifiedName annotatedName); } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmBindingTarget.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmBindingTarget.java index bb7dd98b2..d4efd430b 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmBindingTarget.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmBindingTarget.java @@ -52,4 +52,15 @@ public abstract class AbstractEdmBindingTarget extends EdmNamedImpl implements E } return entityType; } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return container.getFullQualifiedName(); + } + + @Override + public String getAnnotationsTargetPath() { + return getName(); + } + } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmComplexType.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmComplexType.java index 541058255..390db2afb 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmComplexType.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmComplexType.java @@ -28,9 +28,9 @@ import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; public abstract class AbstractEdmComplexType extends AbstractEdmStructuredType implements EdmComplexType { public AbstractEdmComplexType( - final Edm edm, - final FullQualifiedName typeName, - final FullQualifiedName baseTypeName) { + final Edm edm, + final FullQualifiedName typeName, + final FullQualifiedName baseTypeName) { super(edm, typeName, EdmTypeKind.COMPLEX, baseTypeName); } @@ -41,7 +41,7 @@ public abstract class AbstractEdmComplexType extends AbstractEdmStructuredType i baseType = edm.getComplexType(baseTypeName); if (baseType == null) { throw new EdmException("Can't find base type with name: " + baseTypeName + " for complex type: " - + getName()); + + getName()); } } return baseType; @@ -59,4 +59,9 @@ public abstract class AbstractEdmComplexType extends AbstractEdmStructuredType i baseType = buildBaseType(baseTypeName); } } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.ComplexType; + } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityContainer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityContainer.java index cf08fe324..5c387fc44 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityContainer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityContainer.java @@ -171,4 +171,20 @@ public abstract class AbstractEdmEntityContainer extends EdmNamedImpl implements public FullQualifiedName getParentContainerName() { return parentContainerName; } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.EntityContainer; + } + + @Override + public String getAnnotationsTargetPath() { + return null; + } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return getFullQualifiedName(); + } + } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityType.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityType.java index 3dcab9bd9..151cd0f30 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityType.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEntityType.java @@ -120,4 +120,9 @@ public abstract class AbstractEdmEntityType extends AbstractEdmStructuredType im protected void checkBaseType() { //Current Client implementation doesn`t need this so I implemented an empty body here. } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.EntityType; + } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEnumType.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEnumType.java index d6f4fd339..1ff154b31 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEnumType.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmEnumType.java @@ -186,7 +186,7 @@ public abstract class AbstractEdmEnumType extends EdmTypeImpl implements EdmEnum @Override public String toUriLiteral(final String literal) { return literal == null ? null - : uriPrefix.isEmpty() && uriSuffix.isEmpty() ? literal : uriPrefix + literal + uriSuffix; + : uriPrefix.isEmpty() && uriSuffix.isEmpty() ? literal : uriPrefix + literal + uriSuffix; } @Override @@ -196,16 +196,31 @@ public abstract class AbstractEdmEnumType extends EdmTypeImpl implements EdmEnum } else if (uriPrefix.isEmpty() && uriSuffix.isEmpty()) { return literal; } else if (literal.length() >= uriPrefix.length() + uriSuffix.length() - && literal.startsWith(uriPrefix) && literal.endsWith(uriSuffix)) { + && literal.startsWith(uriPrefix) && literal.endsWith(uriSuffix)) { return literal.substring(uriPrefix.length(), literal.length() - uriSuffix.length()); } else { throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(literal)"); } } - + @Override public boolean isFlags() { return isFlags; } + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.EnumType; + } + + @Override + public String getAnnotationsTargetPath() { + return null; + } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return getFullQualifiedName(); + } + } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmMember.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmMember.java new file mode 100644 index 000000000..ec5c1937e --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmMember.java @@ -0,0 +1,58 @@ +/* + * 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; + +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmMember; +import org.apache.olingo.commons.api.edm.FullQualifiedName; + +public abstract class AbstractEdmMember extends EdmNamedImpl implements EdmMember { + + private final String value; + + private final FullQualifiedName enumFQN; + + public AbstractEdmMember(final Edm edm, final FullQualifiedName enumFQN, final String name, String value) { + super(edm, name); + + this.enumFQN = enumFQN; + this.value = value; + } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.Member; + } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return enumFQN; + } + + @Override + public String getAnnotationsTargetPath() { + return getName(); + } + + @Override + public String getValue() { + return value; + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmNavigationProperty.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmNavigationProperty.java index 2e398f565..2ac876c1a 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmNavigationProperty.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmNavigationProperty.java @@ -62,7 +62,7 @@ public abstract class AbstractEdmNavigationProperty extends EdmElementImpl imple property = type.getNavigationProperty(element); if (property == null) { throw new EdmException("Cannot find navigation property with name: " + element - + " at type " + type.getName()); + + " at type " + type.getName()); } type = (EdmStructuredType) property.getType(); } @@ -73,4 +73,15 @@ public abstract class AbstractEdmNavigationProperty extends EdmElementImpl imple } public abstract String getReferencingPropertyName(String referencedPropertyName); + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.NavigationProperty; + } + + @Override + public String getAnnotationsTargetPath() { + return getName(); + } + } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperation.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperation.java index 9be59aabf..12931400e 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperation.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperation.java @@ -49,6 +49,7 @@ public abstract class AbstractEdmOperation extends EdmTypeImpl implements EdmOpe final Edm edm, final FullQualifiedName fqn, final EdmTypeKind kind) { + super(edm, fqn, kind); } @@ -90,8 +91,7 @@ public abstract class AbstractEdmOperation extends EdmTypeImpl implements EdmOpe public EdmEntitySet getReturnedEntitySet(final EdmEntitySet bindingParameterEntitySet) { EdmEntitySet returnedEntitySet = null; if (bindingParameterEntitySet != null && entitySetPath != null) { - final EdmBindingTarget relatedBindingTarget = bindingParameterEntitySet. - getRelatedBindingTarget(entitySetPath); + final EdmBindingTarget relatedBindingTarget = bindingParameterEntitySet.getRelatedBindingTarget(entitySetPath); if (relatedBindingTarget == null) { throw new EdmException("Cannot find entity set with path: " + entitySetPath); } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperationImport.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperationImport.java index 364232e62..c8b49575d 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperationImport.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmOperationImport.java @@ -69,4 +69,15 @@ public abstract class AbstractEdmOperationImport extends EdmNamedImpl implements public EdmEntityContainer getEntityContainer() { return container; } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return container.getFullQualifiedName(); + } + + @Override + public String getAnnotationsTargetPath() { + return getName(); + } + } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmParameter.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmParameter.java index 90761a7c0..db1d9a16f 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmParameter.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmParameter.java @@ -22,54 +22,32 @@ import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmMapping; import org.apache.olingo.commons.api.edm.EdmParameter; -import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; public abstract class AbstractEdmParameter extends EdmElementImpl implements EdmParameter { - private final FullQualifiedName paramType; + private final EdmTypeInfo typeInfo; private EdmType typeImpl; public AbstractEdmParameter(final Edm edm, final String name, final FullQualifiedName paramType) { super(edm, name); - this.paramType = paramType; + this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(paramType.toString()).build(); } @Override public EdmType getType() { if (typeImpl == null) { - if (EdmPrimitiveType.EDM_NAMESPACE.equals(paramType.getNamespace())) { - try { - typeImpl = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.valueOf(paramType.getName())); - } catch (IllegalArgumentException e) { - throw new EdmException("Cannot find type with name: " + paramType, e); - } - } else { - typeImpl = edm.getComplexType(paramType); - if (typeImpl == null) { - typeImpl = edm.getEntityType(paramType); - if (typeImpl == null) { - typeImpl = edm.getEnumType(paramType); - if (typeImpl == null) { - typeImpl = edm.getTypeDefinition(paramType); - if (typeImpl == null) { - throw new EdmException("Cannot find type with name: " + paramType); - } - } - } - } + typeImpl = typeInfo.getType(); + if (typeImpl == null) { + throw new EdmException("Cannot find type with name: " + typeInfo.getFullQualifiedName()); } } + return typeImpl; } - @Override - public abstract boolean isCollection(); - @Override public abstract EdmMapping getMapping(); diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmProperty.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmProperty.java index c54239f89..a0396fe4a 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmProperty.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmProperty.java @@ -20,12 +20,8 @@ package org.apache.olingo.commons.core.edm; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmException; -import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.EdmProperty; import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; public abstract class AbstractEdmProperty extends EdmElementImpl implements EdmProperty { @@ -35,37 +31,38 @@ public abstract class AbstractEdmProperty extends EdmElementImpl implements EdmP super(edm, name); } - protected abstract FullQualifiedName getTypeFQN(); + protected abstract EdmTypeInfo getTypeInfo(); @Override public boolean isPrimitive() { - return EdmPrimitiveType.EDM_NAMESPACE.equals(getTypeFQN().getNamespace()); + return getTypeInfo().isPrimitiveType(); } @Override public EdmType getType() { if (propertyType == null) { - final FullQualifiedName typeName = getTypeFQN(); - if (isPrimitive()) { - try { - propertyType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.valueOf(typeName.getName())); - } catch (IllegalArgumentException e) { - throw new EdmException("Cannot find type with name: " + typeName, e); - } - } else { - propertyType = edm.getComplexType(typeName); - if (propertyType == null) { - propertyType = edm.getEnumType(typeName); - if (propertyType == null) { - propertyType = edm.getTypeDefinition(typeName); - if (propertyType == null) { - throw new EdmException("Cannot find type with name: " + typeName); - } - } - } + propertyType = getTypeInfo().getType(); + if (propertyType == null) { + throw new EdmException("Cannot find type with name: " + getTypeInfo().getFullQualifiedName()); } } return propertyType; } + + @Override + public boolean isCollection() { + return getTypeInfo().isCollection(); + } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.Property; + } + + @Override + public String getAnnotationsTargetPath() { + return getName(); + } + } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmReferentialConstraintImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmReferentialConstraint.java similarity index 86% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmReferentialConstraintImpl.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmReferentialConstraint.java index ed3f5c315..1116af3d3 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmReferentialConstraintImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmReferentialConstraint.java @@ -20,13 +20,13 @@ package org.apache.olingo.commons.core.edm; import org.apache.olingo.commons.api.edm.EdmReferentialConstraint; -public class EdmReferentialConstraintImpl implements EdmReferentialConstraint { +public abstract class AbstractEdmReferentialConstraint implements EdmReferentialConstraint { private final String property; private final String referencedProperty; - public EdmReferentialConstraintImpl(final String property, final String referencedProperty) { + public AbstractEdmReferentialConstraint(final String property, final String referencedProperty) { this.property = property; this.referencedProperty = referencedProperty; } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmReturnType.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmReturnType.java index 532f6666b..db2217487 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmReturnType.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmReturnType.java @@ -20,67 +20,30 @@ package org.apache.olingo.commons.core.edm; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmException; -import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.EdmReturnType; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; public abstract class AbstractEdmReturnType implements EdmReturnType { - private final Edm edm; - - private final FullQualifiedName typeName; + private final EdmTypeInfo typeInfo; private EdmType typeImpl; public AbstractEdmReturnType(final Edm edm, final FullQualifiedName typeName) { - this.edm = edm; - this.typeName = typeName; + this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(typeName.toString()).build(); } @Override public EdmType getType() { if (typeImpl == null) { - if (EdmPrimitiveType.EDM_NAMESPACE.equals(typeName.getNamespace())) { - try { - typeImpl = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.valueOf(typeName.getName())); - } catch (IllegalArgumentException e) { - throw new EdmException("Cannot find type with name: " + typeName, e); - } - } else { - typeImpl = edm.getComplexType(typeName); - if (typeImpl == null) { - typeImpl = edm.getEntityType(typeName); - if (typeImpl == null) { - typeImpl = edm.getEnumType(typeName); - if (typeImpl == null) { - typeImpl = edm.getTypeDefinition(typeName); - if (typeImpl == null) { - throw new EdmException("Cant find type with name: " + typeName); - } - } - } - } + typeImpl = typeInfo.getType(); + if (typeImpl == null) { + throw new EdmException("Cannot find type with name: " + typeInfo.getFullQualifiedName()); } } + return typeImpl; } - @Override - public abstract Boolean isNullable(); - - @Override - public abstract Integer getMaxLength(); - - @Override - public abstract Integer getPrecision(); - - @Override - public abstract Integer getScale(); - - @Override - public abstract boolean isCollection(); - } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmSchema.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmSchema.java index 6c4184d81..6e1356e48 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmSchema.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmSchema.java @@ -22,12 +22,15 @@ import java.util.Collections; import java.util.List; import org.apache.olingo.commons.api.edm.EdmAction; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmAnnotations; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmSchema; +import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; @@ -37,8 +40,6 @@ public abstract class AbstractEdmSchema implements EdmSchema { private final String alias; - private List typeDefinitions; - private List enumTypes; private List entityTypes; @@ -49,6 +50,14 @@ public abstract class AbstractEdmSchema implements EdmSchema { private List functions; + private List typeDefinitions; + + private List terms; + + private List annotationGroups; + + private List annotations; + private EdmEntityContainer entityContainer; public AbstractEdmSchema(String namespace, String alias) { @@ -58,8 +67,6 @@ public abstract class AbstractEdmSchema implements EdmSchema { protected abstract EdmEntityContainer createEntityContainer(); - protected abstract List createTypeDefinitions(); - protected abstract List createEnumTypes(); protected abstract List createEntityTypes(); @@ -70,13 +77,13 @@ public abstract class AbstractEdmSchema implements EdmSchema { protected abstract List createFunctions(); - @Override - public List getTypeDefinitions() { - if (typeDefinitions == null) { - typeDefinitions = createTypeDefinitions(); - } - return typeDefinitions; - } + protected abstract List createTypeDefinitions(); + + protected abstract List createTerms(); + + protected abstract List createAnnotationGroups(); + + protected abstract List createAnnotations(); @Override public List getEnumTypes() { @@ -118,6 +125,38 @@ public abstract class AbstractEdmSchema implements EdmSchema { return functions; } + @Override + public List getTypeDefinitions() { + if (typeDefinitions == null) { + typeDefinitions = createTypeDefinitions(); + } + return typeDefinitions; + } + + @Override + public List getTerms() { + if (terms == null) { + terms = createTerms(); + } + return terms; + } + + @Override + public List getAnnotationGroups() { + if (annotationGroups == null) { + annotationGroups = createAnnotationGroups(); + } + return annotationGroups; + } + + @Override + public List getAnnotations() { + if (annotations == null) { + annotations = createAnnotations(); + } + return annotations; + } + @Override public EdmEntityContainer getEntityContainer() { if (entityContainer == null) { diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmStructuredType.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmStructuredType.java index af4f2dd5a..1ee515c90 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmStructuredType.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmStructuredType.java @@ -139,4 +139,14 @@ public abstract class AbstractEdmStructuredType extends EdmTypeImpl implements E return true; } + @Override + public String getAnnotationsTargetPath() { + return null; + } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return getFullQualifiedName(); + } + } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmTypeDefinition.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmTypeDefinition.java index 12b1dd19e..51fb01500 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmTypeDefinition.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmTypeDefinition.java @@ -109,4 +109,19 @@ public abstract class AbstractEdmTypeDefinition extends EdmNamedImpl implements @Override public abstract Boolean isUnicode(); + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.TypeDefinition; + } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return getFullQualifiedName(); + } + + @Override + public String getAnnotationsTargetPath() { + return null; + } + } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationHelper.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationHelper.java new file mode 100644 index 000000000..db4ef6fe9 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmAnnotationHelper.java @@ -0,0 +1,27 @@ +/* + * 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; + +import java.util.List; +import org.apache.olingo.commons.api.edm.EdmAnnotation; + +public interface EdmAnnotationHelper { + + List getAnnotations(); +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java index 37d52dd0d..5e4f13ef5 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmTypeInfo.java @@ -25,8 +25,11 @@ import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmType; +import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,6 +76,8 @@ public class EdmTypeInfo { private EdmPrimitiveTypeKind primitiveType; + private EdmTypeDefinition typeDefinition; + private EdmEnumType enumType; private EdmComplexType complexType; @@ -128,11 +133,14 @@ public class EdmTypeInfo { LOG.debug("{} does not appear to refer to an Edm primitive type", this.fullQualifiedName); } if (this.primitiveType == null && this.edm != null) { - this.enumType = this.edm.getEnumType(this.fullQualifiedName); - if (this.enumType == null) { - this.complexType = this.edm.getComplexType(this.fullQualifiedName); - if (this.complexType == null) { - this.entityType = this.edm.getEntityType(this.fullQualifiedName); + this.typeDefinition = this.edm.getTypeDefinition(this.fullQualifiedName); + if (this.typeDefinition == null) { + this.enumType = this.edm.getEnumType(this.fullQualifiedName); + if (this.enumType == null) { + this.complexType = this.edm.getComplexType(this.fullQualifiedName); + if (this.complexType == null) { + this.entityType = this.edm.getEntityType(this.fullQualifiedName); + } } } } @@ -197,6 +205,14 @@ public class EdmTypeInfo { return primitiveType; } + public boolean isTypeDefinition() { + return this.typeDefinition != null; + } + + public EdmTypeDefinition getTypeDefinition() { + return this.typeDefinition; + } + public boolean isEnumType() { return this.enumType != null; } @@ -220,4 +236,18 @@ public class EdmTypeInfo { public EdmEntityType getEntityType() { return entityType; } + + public EdmType getType() { + return isPrimitiveType() + ? EdmPrimitiveTypeFactory.getInstance(getPrimitiveTypeKind()) + : isTypeDefinition() + ? getTypeDefinition() + : isEnumType() + ? getEnumType() + : isComplexType() + ? getComplexType() + : isEntityType() + ? getEntityType() + : null; + } } diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmAnnotatableDynamicAnnotationExpression.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmAnnotatableDynamicAnnotationExpression.java new file mode 100644 index 000000000..711c505f8 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmAnnotatableDynamicAnnotationExpression.java @@ -0,0 +1,35 @@ +/* + * 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.olingo.commons.api.edm.EdmAnnotatable; +import org.apache.olingo.commons.api.edm.EdmAnnotation; + +public abstract class AbstractEdmAnnotatableDynamicAnnotationExpression + extends AbstractEdmDynamicAnnotationExpression implements EdmAnnotatable { + + private final List annotations = new ArrayList(); + + @Override + public List getAnnotations() { + return annotations; + } +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmAnnotationEspression.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmAnnotationEspression.java new file mode 100644 index 000000000..a1fda4717 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmAnnotationEspression.java @@ -0,0 +1,46 @@ +/* + * 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.EdmConstantAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression; + +public abstract class AbstractEdmAnnotationEspression implements EdmAnnotationExpression { + + @Override + public boolean isConstant() { + return this instanceof EdmConstantAnnotationExpression; + } + + @Override + public EdmConstantAnnotationExpression asConstant() { + return isConstant() ? (EdmConstantAnnotationExpression) this : null; + } + + @Override + public boolean isDynamic() { + return this instanceof EdmDynamicAnnotationExpression; + } + + @Override + public EdmDynamicAnnotationExpression asDynamic() { + return isDynamic() ? (EdmDynamicAnnotationExpression) this : null; + } +} 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 new file mode 100644 index 000000000..b1ee53d4f --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmDynamicAnnotationExpression.java @@ -0,0 +1,291 @@ +/* + * 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 AbstractEdmAnnotationEspression 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; + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmMemberImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmElementOrAttributeNotation.java similarity index 73% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmMemberImpl.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmElementOrAttributeNotation.java index 79be011d0..867055e8d 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/EdmMemberImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmElementOrAttributeNotation.java @@ -16,23 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.commons.core.edm; +package org.apache.olingo.commons.core.edm.annotation; -import org.apache.olingo.commons.api.edm.Edm; -import org.apache.olingo.commons.api.edm.EdmMember; - -public class EdmMemberImpl extends EdmNamedImpl implements EdmMember { +/** + * Groups dynamic expressions that may be provided using element notation or attribute notation. + */ +public abstract class AbstractEdmElementOrAttributeNotation extends AbstractEdmDynamicAnnotationExpression { private final String value; - public EdmMemberImpl(final Edm edm, final String name, final String value) { - super(edm, name); + public AbstractEdmElementOrAttributeNotation(final String value) { this.value = value; } - @Override public String getValue() { return value; } - } 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 new file mode 100644 index 000000000..59c60fdd8 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/AbstractEdmTwoParamsOpDynamicAnnotationExpression.java @@ -0,0 +1,47 @@ +/* + * 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.EdmDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmTwoParamsOpDynamicAnnotationExpression; + +public abstract class AbstractEdmTwoParamsOpDynamicAnnotationExpression + extends AbstractEdmDynamicAnnotationExpression implements EdmTwoParamsOpDynamicAnnotationExpression { + + private final EdmDynamicAnnotationExpression left; + + private final EdmDynamicAnnotationExpression right; + + public AbstractEdmTwoParamsOpDynamicAnnotationExpression( + final EdmDynamicAnnotationExpression left, final EdmDynamicAnnotationExpression right) { + + this.left = left; + this.right = right; + } + + @Override + public EdmDynamicAnnotationExpression getLeftExpression() { + return left; + } + + @Override + public EdmDynamicAnnotationExpression getRightExpression() { + return right; + } +} 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 new file mode 100644 index 000000000..c0fc2db4d --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmAndImpl.java @@ -0,0 +1,30 @@ +/* + * 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.EdmDynamicAnnotationExpression; + +public class EdmAndImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmAnd { + + public EdmAndImpl(final EdmDynamicAnnotationExpression left, final EdmDynamicAnnotationExpression right) { + super(left, right); + } + +} 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 new file mode 100644 index 000000000..b1283bb58 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmAnnotationPathImpl.java @@ -0,0 +1,29 @@ +/* + * 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.EdmAnnotationPath; + +public class EdmAnnotationPathImpl extends AbstractEdmElementOrAttributeNotation implements EdmAnnotationPath { + + public EdmAnnotationPathImpl(final String value) { + super(value); + } + +} 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 new file mode 100644 index 000000000..36bee4b9e --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmApplyImpl.java @@ -0,0 +1,46 @@ +/* + * 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.List; +import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmApply; + +public class EdmApplyImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmApply { + + private final String function; + + private final List parameters; + + public EdmApplyImpl(final String function, final List parameters) { + this.function = function; + this.parameters = parameters; + } + + @Override + public String getFunction() { + return function; + } + + @Override + public List getParameters() { + return parameters; + } + +} 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 new file mode 100644 index 000000000..4508df5a5 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmCollectionImpl.java @@ -0,0 +1,38 @@ +/* + * 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.List; +import org.apache.olingo.commons.api.edm.annotation.EdmAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmCollection; + +public class EdmCollectionImpl extends AbstractEdmDynamicAnnotationExpression implements EdmCollection { + + private final List items; + + public EdmCollectionImpl(final List items) { + this.items = items; + } + + @Override + public List getItems() { + return items; + } + +} 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 new file mode 100644 index 000000000..a53243d0a --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmEqImpl.java @@ -0,0 +1,30 @@ +/* + * 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.EdmDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmEq; + +public class EdmEqImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmEq { + + public EdmEqImpl(final EdmDynamicAnnotationExpression left, final EdmDynamicAnnotationExpression right) { + super(left, right); + } + +} 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 new file mode 100644 index 000000000..e000dbf53 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmGeImpl.java @@ -0,0 +1,30 @@ +/* + * 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.EdmDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmGe; + +public class EdmGeImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmGe { + + public EdmGeImpl(final EdmDynamicAnnotationExpression left, final EdmDynamicAnnotationExpression right) { + super(left, right); + } + +} 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 new file mode 100644 index 000000000..96d5c3033 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmGtImpl.java @@ -0,0 +1,30 @@ +/* + * 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.EdmDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmGt; + +public class EdmGtImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmGt { + + public EdmGtImpl(final EdmDynamicAnnotationExpression left, final EdmDynamicAnnotationExpression right) { + super(left, right); + } + +} 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 new file mode 100644 index 000000000..76ff0aedf --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmIfImpl.java @@ -0,0 +1,55 @@ +/* + * 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.EdmIf; + +public class EdmIfImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmIf { + + private final EdmAnnotationExpression guard; + + 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; + } + + @Override + public EdmAnnotationExpression getGuard() { + return guard; + } + + @Override + public EdmAnnotationExpression getThen() { + return _then; + } + + @Override + public EdmAnnotationExpression getElse() { + return _else; + } + +} 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 new file mode 100644 index 000000000..0d7ca8883 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLabeledElementImpl.java @@ -0,0 +1,46 @@ +/* + * 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.EdmDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmLabeledElement; + +public class EdmLabeledElementImpl + extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmLabeledElement { + + private final String name; + + private final EdmDynamicAnnotationExpression value; + + public EdmLabeledElementImpl(final String name, final EdmDynamicAnnotationExpression value) { + this.name = name; + this.value = value; + } + + @Override + public String getName() { + return name; + } + + @Override + public EdmDynamicAnnotationExpression getValue() { + return value; + } + +} 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 new file mode 100644 index 000000000..b731e25ff --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLabeledElementReferenceImpl.java @@ -0,0 +1,30 @@ +/* + * 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.EdmLabeledElementReference; + +public class EdmLabeledElementReferenceImpl + extends AbstractEdmElementOrAttributeNotation implements EdmLabeledElementReference { + + public EdmLabeledElementReferenceImpl(final String value) { + super(value); + } + +} 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 new file mode 100644 index 000000000..d3fe46fe4 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLeImpl.java @@ -0,0 +1,30 @@ +/* + * 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.EdmDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmLe; + +public class EdmLeImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmLe { + + public EdmLeImpl(final EdmDynamicAnnotationExpression left, final EdmDynamicAnnotationExpression right) { + super(left, right); + } + +} 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 new file mode 100644 index 000000000..5d278774d --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmLtImpl.java @@ -0,0 +1,30 @@ +/* + * 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.EdmDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmLt; + +public class EdmLtImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmLt { + + public EdmLtImpl(final EdmDynamicAnnotationExpression left, final EdmDynamicAnnotationExpression right) { + super(left, right); + } + +} 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 new file mode 100644 index 000000000..727b96370 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNavigationPropertyPathImpl.java @@ -0,0 +1,30 @@ +/* + * 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.EdmNavigationPropertyPath; + +public class EdmNavigationPropertyPathImpl + extends AbstractEdmElementOrAttributeNotation implements EdmNavigationPropertyPath { + + public EdmNavigationPropertyPathImpl(final String value) { + super(value); + } + +} 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 new file mode 100644 index 000000000..487768ee7 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNeImpl.java @@ -0,0 +1,30 @@ +/* + * 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.EdmDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmNe; + +public class EdmNeImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmNe { + + public EdmNeImpl(final EdmDynamicAnnotationExpression left, final EdmDynamicAnnotationExpression right) { + super(left, right); + } + +} 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 new file mode 100644 index 000000000..80d3df9bd --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNotImpl.java @@ -0,0 +1,37 @@ +/* + * 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.EdmDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmNot; + +public class EdmNotImpl extends AbstractEdmDynamicAnnotationExpression implements EdmNot { + + private final EdmDynamicAnnotationExpression expression; + + public EdmNotImpl(final EdmDynamicAnnotationExpression expression) { + this.expression = expression; + } + + @Override + public EdmDynamicAnnotationExpression getExpression() { + return expression; + } + +} 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 new file mode 100644 index 000000000..43e9d41b5 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmNullImpl.java @@ -0,0 +1,25 @@ +/* + * 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.EdmNull; + +public class EdmNullImpl extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmNull { + +} 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 new file mode 100644 index 000000000..0d0af23bd --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmOrImpl.java @@ -0,0 +1,30 @@ +/* + * 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.EdmDynamicAnnotationExpression; +import org.apache.olingo.commons.api.edm.annotation.EdmOr; + +public class EdmOrImpl extends AbstractEdmTwoParamsOpDynamicAnnotationExpression implements EdmOr { + + public EdmOrImpl(final EdmDynamicAnnotationExpression left, final EdmDynamicAnnotationExpression right) { + super(left, right); + } + +} 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 new file mode 100644 index 000000000..f5587451e --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPathImpl.java @@ -0,0 +1,29 @@ +/* + * 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.EdmPath; + +public class EdmPathImpl extends AbstractEdmElementOrAttributeNotation implements EdmPath { + + public EdmPathImpl(final String value) { + super(value); + } + +} 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 new file mode 100644 index 000000000..4b7ce1446 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPropertyPathImpl.java @@ -0,0 +1,29 @@ +/* + * 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.EdmPropertyPath; + +public class EdmPropertyPathImpl extends AbstractEdmElementOrAttributeNotation implements EdmPropertyPath { + + public EdmPropertyPathImpl(final String value) { + super(value); + } + +} 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 new file mode 100644 index 000000000..423bce625 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmPropertyValueImpl.java @@ -0,0 +1,46 @@ +/* + * 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.EdmPropertyValue; + +public class EdmPropertyValueImpl + extends AbstractEdmAnnotatableDynamicAnnotationExpression implements EdmPropertyValue { + + private final String property; + + private final EdmAnnotationExpression value; + + public EdmPropertyValueImpl(final String property, final EdmAnnotationExpression value) { + this.property = property; + this.value = value; + } + + @Override + public String getProperty() { + return property; + } + + @Override + public EdmAnnotationExpression getValue() { + return value; + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmUrlRefImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmUrlRefImpl.java new file mode 100644 index 000000000..497554ae4 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmUrlRefImpl.java @@ -0,0 +1,37 @@ +/* + * 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.EdmUrlRef; + +public class EdmUrlRefImpl extends AbstractEdmDynamicAnnotationExpression implements EdmUrlRef { + + private final EdmAnnotationExpression value; + + public EdmUrlRefImpl(final EdmAnnotationExpression value) { + this.value = value; + } + + @Override + public EdmAnnotationExpression getValue() { + return value; + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractGeospatialType.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractGeospatialType.java index 7a61a53cd..18c3f0a84 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractGeospatialType.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractGeospatialType.java @@ -36,6 +36,7 @@ import org.apache.olingo.commons.api.edm.geo.MultiPoint; import org.apache.olingo.commons.api.edm.geo.MultiPolygon; import org.apache.olingo.commons.api.edm.geo.Point; import org.apache.olingo.commons.api.edm.geo.Polygon; +import org.apache.olingo.commons.api.edm.geo.SRID; public abstract class AbstractGeospatialType extends SingletonPrimitiveType { @@ -83,7 +84,7 @@ public abstract class AbstractGeospatialType extends Singl return matcher; } - private Point newPoint(final Integer srid, final String point, final Boolean isNullable, + private Point newPoint(final SRID srid, final String point, final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException { @@ -106,7 +107,7 @@ public abstract class AbstractGeospatialType extends Singl final Matcher matcher = getMatcher(PATTERN, value); - return newPoint(Integer.valueOf(matcher.group(2)), matcher.group(4), + return newPoint(SRID.valueOf(matcher.group(2)), matcher.group(4), isNullable, maxLength, precision, scale, isUnicode); } @@ -121,10 +122,10 @@ public abstract class AbstractGeospatialType extends Singl isNullable, maxLength, precision, scale, isUnicode)); } - return new MultiPoint(dimension, Integer.valueOf(matcher.group(2)), points); + return new MultiPoint(dimension, SRID.valueOf(matcher.group(2)), points); } - private LineString newLineString(final Integer srid, final String lineString, final Boolean isNullable, + private LineString newLineString(final SRID srid, final String lineString, final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException { @@ -141,7 +142,7 @@ public abstract class AbstractGeospatialType extends Singl final Matcher matcher = getMatcher(PATTERN, value); - return newLineString(Integer.valueOf(matcher.group(2)), matcher.group(4), + return newLineString(SRID.valueOf(matcher.group(2)), matcher.group(4), isNullable, maxLength, precision, scale, isUnicode); } @@ -166,10 +167,10 @@ public abstract class AbstractGeospatialType extends Singl lineStrings.add(newLineString(null, lineString, isNullable, maxLength, precision, scale, isUnicode)); } - return new MultiLineString(this.dimension, Integer.valueOf(matcher.group(2)), lineStrings); + return new MultiLineString(this.dimension, SRID.valueOf(matcher.group(2)), lineStrings); } - private Polygon newPolygon(final Integer srid, final String polygon, final Boolean isNullable, + private Polygon newPolygon(final SRID srid, final String polygon, final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException { @@ -192,7 +193,7 @@ public abstract class AbstractGeospatialType extends Singl final Matcher matcher = getMatcher(PATTERN, value); - return newPolygon(Integer.valueOf(matcher.group(2)), matcher.group(4), + return newPolygon(SRID.valueOf(matcher.group(2)), matcher.group(4), isNullable, maxLength, precision, scale, isUnicode); } @@ -222,7 +223,7 @@ public abstract class AbstractGeospatialType extends Singl polygons.add(newPolygon(null, polygon, isNullable, maxLength, precision, scale, isUnicode)); } - return new MultiPolygon(dimension, Integer.valueOf(matcher.group(2)), polygons); + return new MultiPolygon(dimension, SRID.valueOf(matcher.group(2)), polygons); } protected GeospatialCollection stringToCollection(final String value, final Boolean isNullable, @@ -234,7 +235,7 @@ public abstract class AbstractGeospatialType extends Singl Geospatial item = null; switch (Geospatial.Type.valueOf(matcher.group(3).toUpperCase())) { case POINT: - item = newPoint(Integer.valueOf(matcher.group(2)), matcher.group(4), + item = newPoint(SRID.valueOf(matcher.group(2)), matcher.group(4), isNullable, maxLength, precision, scale, isUnicode); break; @@ -245,11 +246,11 @@ public abstract class AbstractGeospatialType extends Singl isNullable, maxLength, precision, scale, isUnicode)); } - item = new MultiPoint(dimension, Integer.valueOf(matcher.group(2)), points); + item = new MultiPoint(dimension, SRID.valueOf(matcher.group(2)), points); break; case LINESTRING: - item = newLineString(Integer.valueOf(matcher.group(2)), matcher.group(4), + item = newLineString(SRID.valueOf(matcher.group(2)), matcher.group(4), isNullable, maxLength, precision, scale, isUnicode); break; @@ -260,11 +261,11 @@ public abstract class AbstractGeospatialType extends Singl isNullable, maxLength, precision, scale, isUnicode)); } - item = new MultiLineString(this.dimension, Integer.valueOf(matcher.group(2)), lineStrings); + item = new MultiLineString(this.dimension, SRID.valueOf(matcher.group(2)), lineStrings); break; case POLYGON: - item = newPolygon(Integer.valueOf(matcher.group(2)), matcher.group(4), + item = newPolygon(SRID.valueOf(matcher.group(2)), matcher.group(4), isNullable, maxLength, precision, scale, isUnicode); break; @@ -275,17 +276,17 @@ public abstract class AbstractGeospatialType extends Singl isNullable, maxLength, precision, scale, isUnicode)); } - item = new MultiPolygon(dimension, Integer.valueOf(matcher.group(2)), polygons); + item = new MultiPolygon(dimension, SRID.valueOf(matcher.group(2)), polygons); break; default: } - return new GeospatialCollection(dimension, Integer.valueOf(matcher.group(2)), + return new GeospatialCollection(dimension, SRID.valueOf(matcher.group(2)), Collections.singletonList(item)); } - private StringBuilder toStringBuilder(final Integer srid) { + private StringBuilder toStringBuilder(final SRID srid) { return new StringBuilder(dimension.name().toLowerCase()).append('\''). append("SRID=").append(srid).append(';'); } diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java index 287f7c28c..6d9fbaba7 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCachingTest.java @@ -30,9 +30,12 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.commons.lang3.StringUtils; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmAnnotations; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntityType; @@ -40,6 +43,7 @@ import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmSchema; import org.apache.olingo.commons.api.edm.EdmServiceMetadata; +import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.junit.Before; @@ -416,11 +420,26 @@ public class EdmImplCachingTest { } @Override - public List createSchemas() { - List schemas = new ArrayList(); - EdmSchema schema = mock(EdmSchema.class); - schemas.add(schema); - return schemas; + protected Map createSchemas() { + return Collections.singletonMap(StringUtils.EMPTY, mock(EdmSchema.class)); + } + + @Override + protected EdmTerm createTerm(final FullQualifiedName termName) { + // TODO: implement + return null; + } + + @Override + protected EdmAnnotations createAnnotationGroup(final FullQualifiedName target) { + // TODO: implement + return null; + } + + @Override + protected List createAnnotations(final FullQualifiedName annotatedName) { + // TODO: implement + return null; } } } diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java index bc83cafec..e483df559 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/EdmImplCallCreateTest.java @@ -33,6 +33,8 @@ import java.util.Map; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmAnnotations; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntityType; @@ -40,6 +42,7 @@ import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmSchema; import org.apache.olingo.commons.api.edm.EdmServiceMetadata; +import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.junit.Before; @@ -284,8 +287,26 @@ public class EdmImplCallCreateTest { } @Override - public List createSchemas() { - return new ArrayList(); + protected Map createSchemas() { + return Collections.emptyMap(); + } + + @Override + protected EdmTerm createTerm(final FullQualifiedName termName) { + // TODO: implement + return null; + } + + @Override + protected EdmAnnotations createAnnotationGroup(final FullQualifiedName targetName) { + // TODO: implement + return null; + } + + @Override + protected List createAnnotations(FullQualifiedName annotatedName) { + // TODO: implement + return null; } } } diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeoTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeoTest.java index 6b9dc9a3f..138f82d58 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeoTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeoTest.java @@ -45,7 +45,7 @@ public class EdmGeoTest extends PrimitiveTypeBaseTest { final Point point = EdmGeometryPoint.getInstance().valueOfString(input, null, null, null, null, null, Point.class); assertNotNull(point); - assertEquals(0, point.getSrid(), 0); + assertEquals("0", point.getSrid().toString()); assertEquals(142.1, point.getX(), 0); assertEquals(64.1, point.getY(), 0); @@ -61,7 +61,7 @@ public class EdmGeoTest extends PrimitiveTypeBaseTest { MultiPoint multipoint = EdmGeographyMultiPoint.getInstance(). valueOfString(input, null, null, null, null, null, MultiPoint.class); assertNotNull(multipoint); - assertEquals(0, multipoint.getSrid(), 0); + assertEquals("0", multipoint.getSrid().toString()); assertEquals(142.1, multipoint.iterator().next().getX(), 0); assertEquals(64.1, multipoint.iterator().next().getY(), 0); @@ -82,7 +82,7 @@ public class EdmGeoTest extends PrimitiveTypeBaseTest { final LineString lineString = EdmGeographyLineString.getInstance(). valueOfString(input, null, null, null, null, null, LineString.class); assertNotNull(lineString); - assertEquals(0, lineString.getSrid(), 0); + assertEquals("0", lineString.getSrid().toString()); final Iterator itor = lineString.iterator(); assertEquals(142.1, itor.next().getX(), 0); assertEquals(2.78, itor.next().getY(), 0); @@ -100,7 +100,7 @@ public class EdmGeoTest extends PrimitiveTypeBaseTest { final MultiLineString multiLineString = EdmGeographyMultiLineString.getInstance(). valueOfString(input, null, null, null, null, null, MultiLineString.class); assertNotNull(multiLineString); - assertEquals(0, multiLineString.getSrid(), 0); + assertEquals("0", multiLineString.getSrid().toString()); final Iterator itor = multiLineString.iterator(); assertEquals(142.1, itor.next().iterator().next().getX(), 0); assertEquals(64.7, itor.next().iterator().next().getY(), 0); @@ -118,7 +118,7 @@ public class EdmGeoTest extends PrimitiveTypeBaseTest { final Polygon polygon = EdmGeographyPolygon.getInstance(). valueOfString(input, null, null, null, null, null, Polygon.class); assertNotNull(polygon); - assertEquals(0, polygon.getSrid(), 0); + assertEquals("0", polygon.getSrid().toString()); Iterator itor = polygon.getInterior().iterator(); assertEquals(1, itor.next().getX(), 0); assertEquals(1, itor.next().getY(), 0); @@ -142,7 +142,7 @@ public class EdmGeoTest extends PrimitiveTypeBaseTest { final MultiPolygon multiPolygon = EdmGeometryMultiPolygon.getInstance(). valueOfString(input, null, null, null, null, null, MultiPolygon.class); assertNotNull(multiPolygon); - assertEquals(0, multiPolygon.getSrid(), 0); + assertEquals("0", multiPolygon.getSrid().toString()); final Iterator itor = multiPolygon.iterator(); assertEquals(1, itor.next().getInterior().iterator().next().getX(), 0); assertEquals(1, itor.next().getInterior().iterator().next().getX(), 0); @@ -162,7 +162,7 @@ public class EdmGeoTest extends PrimitiveTypeBaseTest { final GeospatialCollection collection = EdmGeometryCollection.getInstance(). valueOfString(input, null, null, null, null, null, GeospatialCollection.class); assertNotNull(collection); - assertEquals(0, collection.getSrid(), 0); + assertEquals("0", collection.getSrid().toString()); final Geospatial item = collection.iterator().next(); assertNotNull(item); diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/edm/provider/EnumMember.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/edm/provider/EnumMember.java index e017e4282..6b83ab0c3 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/edm/provider/EnumMember.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/edm/provider/EnumMember.java @@ -18,16 +18,12 @@ */ package org.apache.olingo.server.api.edm.provider; -import org.apache.olingo.commons.api.edm.EdmMember; - -public class EnumMember implements EdmMember { +public class EnumMember { private String name; private String value; - // Annotations? - @Override public String getName() { return name; } @@ -37,7 +33,6 @@ public class EnumMember implements EdmMember { return this; } - @Override public String getValue() { return value; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmActionImportImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmActionImportImpl.java index 8796671d7..0278f6ba7 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmActionImportImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmActionImportImpl.java @@ -39,4 +39,9 @@ public class EdmActionImportImpl extends EdmOperationImportImpl implements EdmAc return edm.getUnboundAction(actionImport.getAction()); } + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.ActionImport; + } + } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmComplexTypeImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmComplexTypeImpl.java index a7bb4de69..2ffd793af 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmComplexTypeImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmComplexTypeImpl.java @@ -18,9 +18,11 @@ */ package org.apache.olingo.server.core.edm.provider; +import java.util.List; import java.util.Map; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmNavigationProperty; import org.apache.olingo.commons.api.edm.EdmProperty; import org.apache.olingo.commons.api.edm.FullQualifiedName; @@ -33,7 +35,7 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType { private final EdmStructuredTypeHelper helper; public static EdmComplexTypeImpl getInstance( - final Edm edm, final FullQualifiedName name, final ComplexType complexType) { + final Edm edm, final FullQualifiedName name, final ComplexType complexType) { final EdmComplexTypeImpl instance = new EdmComplexTypeImpl(edm, name, complexType); return instance; @@ -41,7 +43,7 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType { private EdmComplexTypeImpl(final Edm edm, final FullQualifiedName name, final ComplexType complexType) { super(edm, name, complexType.getBaseType()); - helper = new EdmStructuredTypeHelperImpl(edm, complexType); + helper = new EdmStructuredTypeHelperImpl(edm, name, complexType); } @Override @@ -63,4 +65,10 @@ public class EdmComplexTypeImpl extends AbstractEdmComplexType { public boolean isAbstract() { return helper.isAbstract(); } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEntityContainerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEntityContainerImpl.java index 1a1012aef..f50064865 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEntityContainerImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEntityContainerImpl.java @@ -23,6 +23,7 @@ import java.util.List; import org.apache.olingo.commons.api.ODataException; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmActionImport; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntitySet; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmFunctionImport; @@ -40,16 +41,17 @@ import org.apache.olingo.server.api.edm.provider.Singleton; public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { private final EdmProvider provider; + private EntityContainer container; public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider, - final EntityContainerInfo entityContainerInfo) { + final EntityContainerInfo entityContainerInfo) { super(edm, entityContainerInfo.getContainerName(), entityContainerInfo.getExtendsContainer()); this.provider = provider; } public EdmEntityContainerImpl(final Edm edm, final EdmProvider provider, final FullQualifiedName containerFQN, - final EntityContainer entityContainer) { + final EntityContainer entityContainer) { super(edm, containerFQN, entityContainer.getExtendsContainer()); this.provider = provider; container = entityContainer; @@ -192,4 +194,10 @@ public class EdmEntityContainerImpl extends AbstractEdmEntityContainer { } } } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEntitySetImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEntitySetImpl.java index 680511719..882022f18 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEntitySetImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEntitySetImpl.java @@ -18,7 +18,9 @@ */ package org.apache.olingo.server.core.edm.provider; +import java.util.List; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntitySet; import org.apache.olingo.server.api.edm.provider.EntitySet; @@ -36,4 +38,15 @@ public class EdmEntitySetImpl extends EdmBindingTargetImpl implements EdmEntityS public boolean isIncludeInServiceDocument() { return entitySet.isIncludeInServiceDocument(); } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.EntitySet; + } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEntityTypeImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEntityTypeImpl.java index 99fbb3277..04a12566f 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEntityTypeImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEntityTypeImpl.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; import org.apache.olingo.commons.api.edm.EdmNavigationProperty; @@ -42,7 +43,7 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType { private boolean baseTypeChecked = false; public static EdmEntityTypeImpl getInstance(final Edm edm, final FullQualifiedName name, - final EntityType entityType) { + final EntityType entityType) { final EdmEntityTypeImpl instance = new EdmEntityTypeImpl(edm, name, entityType); return instance; @@ -51,7 +52,7 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType { private EdmEntityTypeImpl(final Edm edm, final FullQualifiedName name, final EntityType entityType) { super(edm, name, entityType.getBaseType(), entityType.hasStream()); this.entityType = entityType; - helper = new EdmStructuredTypeHelperImpl(edm, entityType); + helper = new EdmStructuredTypeHelperImpl(edm, name, entityType); } @Override @@ -97,4 +98,10 @@ public class EdmEntityTypeImpl extends AbstractEdmEntityType { public boolean isAbstract() { return helper.isAbstract(); } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEnumTypeImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEnumTypeImpl.java index 5c16963b9..1b19bc0ca 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEnumTypeImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEnumTypeImpl.java @@ -18,6 +18,7 @@ */ package org.apache.olingo.server.core.edm.provider; +import java.util.ArrayList; import java.util.List; import org.apache.olingo.commons.api.edm.Edm; @@ -28,6 +29,7 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.AbstractEdmEnumType; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; +import org.apache.olingo.server.api.edm.provider.EnumMember; import org.apache.olingo.server.api.edm.provider.EnumType; public class EdmEnumTypeImpl extends AbstractEdmEnumType implements EdmEnumType { @@ -36,6 +38,8 @@ public class EdmEnumTypeImpl extends AbstractEdmEnumType implements EdmEnumType private final EnumType enumType; + private List members; + public EdmEnumTypeImpl(final Edm edm, final FullQualifiedName enumName, final EnumType enumType) { super(edm, enumName, enumType.isFlags()); @@ -43,7 +47,7 @@ public class EdmEnumTypeImpl extends AbstractEdmEnumType implements EdmEnumType underlyingType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32); } else { underlyingType = EdmPrimitiveTypeFactory.getInstance( - EdmPrimitiveTypeKind.valueOf(enumType.getUnderlyingType().getName())); + EdmPrimitiveTypeKind.valueOf(enumType.getUnderlyingType().getName())); // TODO: Should we validate that the underlying type is of byte, sbyte, in16, int32 or int64? } @@ -57,7 +61,13 @@ public class EdmEnumTypeImpl extends AbstractEdmEnumType implements EdmEnumType @Override protected List getMembers() { - return enumType.getMembers(); + if (members == null) { + members = new ArrayList(enumType.getMembers().size()); + for (EnumMember member : enumType.getMembers()) { + members.add(new EdmMemberImpl(edm, getFullQualifiedName(), member.getName(), member.getValue())); + } + } + return members; } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmFunctionImportImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmFunctionImportImpl.java index 23111eb61..d370d08f0 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmFunctionImportImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmFunctionImportImpl.java @@ -21,6 +21,7 @@ package org.apache.olingo.server.core.edm.provider; import java.util.List; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmFunctionImport; @@ -57,4 +58,14 @@ public class EdmFunctionImportImpl extends EdmOperationImportImpl implements Edm return functionImport.isIncludeInServiceDocument(); } + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.FunctionImport; + } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmMemberImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmMemberImpl.java new file mode 100644 index 000000000..f91ccd3e6 --- /dev/null +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmMemberImpl.java @@ -0,0 +1,39 @@ +/* + * 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.server.core.edm.provider; + +import java.util.List; +import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.core.edm.AbstractEdmMember; + +public class EdmMemberImpl extends AbstractEdmMember { + + public EdmMemberImpl(final Edm edm, final FullQualifiedName enumFQN, final String name, final String value) { + super(edm, enumFQN, name, value); + } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } + +} diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmNavigationPropertyImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmNavigationPropertyImpl.java index 89811b8e4..f48ddb3bb 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmNavigationPropertyImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmNavigationPropertyImpl.java @@ -22,21 +22,27 @@ import java.util.ArrayList; import java.util.List; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmReferentialConstraint; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.AbstractEdmNavigationProperty; -import org.apache.olingo.commons.core.edm.EdmReferentialConstraintImpl; import org.apache.olingo.server.api.edm.provider.NavigationProperty; import org.apache.olingo.server.api.edm.provider.ReferentialConstraint; public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty { + private final FullQualifiedName structuredTypeName; + private final NavigationProperty navigationProperty; private List referentialConstraints; - public EdmNavigationPropertyImpl(final Edm edm, final NavigationProperty navigationProperty) { + public EdmNavigationPropertyImpl( + final Edm edm, final FullQualifiedName structuredTypeName, final NavigationProperty navigationProperty) { + super(edm, navigationProperty.getName()); + + this.structuredTypeName = structuredTypeName; this.navigationProperty = navigationProperty; } @@ -85,11 +91,22 @@ public class EdmNavigationPropertyImpl extends AbstractEdmNavigationProperty { referentialConstraints = new ArrayList(); if (providerConstraints != null) { for (ReferentialConstraint constraint : providerConstraints) { - referentialConstraints.add(new EdmReferentialConstraintImpl(constraint.getProperty(), constraint - .getReferencedProperty())); + referentialConstraints.add( + new EdmReferentialConstraintImpl(constraint.getProperty(), constraint.getReferencedProperty())); } } } return referentialConstraints; } + + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return structuredTypeName; + } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmOperationImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmOperationImpl.java index e1d0f4c01..0667c5011 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmOperationImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmOperationImpl.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmParameter; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; @@ -59,7 +60,7 @@ public abstract class EdmOperationImpl extends AbstractEdmOperation { } protected EdmOperationImpl(final Edm edm, final FullQualifiedName name, final Operation operation, - final EdmTypeKind kind) { + final EdmTypeKind kind) { super(edm, name, kind); this.operation = operation; @@ -82,4 +83,11 @@ public abstract class EdmOperationImpl extends AbstractEdmOperation { } return null; } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } + } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmOperationImportImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmOperationImportImpl.java index afb6d9616..3c7324eb0 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmOperationImportImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmOperationImportImpl.java @@ -18,7 +18,9 @@ */ package org.apache.olingo.server.core.edm.provider; +import java.util.List; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.core.edm.AbstractEdmOperationImport; import org.apache.olingo.server.api.edm.provider.OperationImport; @@ -26,7 +28,13 @@ import org.apache.olingo.server.api.edm.provider.OperationImport; public abstract class EdmOperationImportImpl extends AbstractEdmOperationImport { public EdmOperationImportImpl(final Edm edm, final EdmEntityContainer container, - final OperationImport operationImport) { + final OperationImport operationImport) { super(edm, container, operationImport.getName(), operationImport.getEntitySet()); } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmParameterImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmParameterImpl.java index ce46b9ee2..e3abedc3f 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmParameterImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmParameterImpl.java @@ -18,8 +18,11 @@ */ package org.apache.olingo.server.core.edm.provider; +import java.util.List; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmMapping; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.core.edm.AbstractEdmParameter; import org.apache.olingo.server.api.edm.provider.Parameter; @@ -62,4 +65,14 @@ public class EdmParameterImpl extends AbstractEdmParameter { return parameter.getScale(); } + @Override + public SRID getSrid() { + return null; // TODO: provide implementation + } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImpl.java index 2fb494401..82c9c44c7 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImpl.java @@ -18,25 +18,36 @@ */ package org.apache.olingo.server.core.edm.provider; +import java.util.List; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmMapping; import org.apache.olingo.commons.api.edm.EdmProperty; import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.core.edm.AbstractEdmProperty; +import org.apache.olingo.commons.core.edm.EdmTypeInfo; import org.apache.olingo.server.api.edm.provider.Property; public class EdmPropertyImpl extends AbstractEdmProperty implements EdmProperty { + private final FullQualifiedName structuredTypeName; + private final Property property; - public EdmPropertyImpl(final Edm edm, final Property property) { + private final EdmTypeInfo typeInfo; + + public EdmPropertyImpl(final Edm edm, final FullQualifiedName structuredTypeName, final Property property) { super(edm, property.getName()); + + this.structuredTypeName = structuredTypeName; this.property = property; + this.typeInfo = new EdmTypeInfo.Builder().setEdm(edm).setTypeExpression(property.getType().toString()).build(); } @Override - protected FullQualifiedName getTypeFQN() { - return property.getType(); + public EdmTypeInfo getTypeInfo() { + return typeInfo; } @Override @@ -74,6 +85,11 @@ public class EdmPropertyImpl extends AbstractEdmProperty implements EdmProperty return property.getScale(); } + @Override + public SRID getSrid() { + return null; // TODO: provide implementation + } + @Override public Boolean isUnicode() { return property.isUnicode(); @@ -84,4 +100,14 @@ public class EdmPropertyImpl extends AbstractEdmProperty implements EdmProperty return property.getDefaultValue(); } + @Override + public FullQualifiedName getAnnotationsTargetFQN() { + return structuredTypeName; + } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java index 8f3674c46..cb16aee1b 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmProviderImpl.java @@ -21,11 +21,14 @@ package org.apache.olingo.server.core.edm.provider; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.olingo.commons.api.ODataException; import org.apache.olingo.commons.api.edm.EdmAction; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmAnnotations; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntityType; @@ -34,6 +37,7 @@ import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmSchema; import org.apache.olingo.commons.api.edm.EdmServiceMetadata; +import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.AbstractEdm; @@ -129,7 +133,7 @@ public class EdmProviderImpl extends AbstractEdm { @Override public EdmAction createBoundAction(final FullQualifiedName actionName, - final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) { + final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection) { try { List actions = actionsMap.get(actionName); @@ -147,7 +151,7 @@ public class EdmProviderImpl extends AbstractEdm { final List parameters = action.getParameters(); final Parameter parameter = parameters.get(0); if (bindingParameterTypeName.equals(parameter.getType()) - && isBindingParameterCollection.booleanValue() == parameter.isCollection()) { + && isBindingParameterCollection.booleanValue() == parameter.isCollection()) { return EdmActionImpl.getInstance(this, actionName, action); } @@ -162,8 +166,8 @@ public class EdmProviderImpl extends AbstractEdm { @Override public EdmFunction createBoundFunction(final FullQualifiedName functionName, - final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection, - final List parameterNames) { + final FullQualifiedName bindingParameterTypeName, final Boolean isBindingParameterCollection, + final List parameterNames) { try { List functions = functionsMap.get(functionName); @@ -175,8 +179,8 @@ public class EdmProviderImpl extends AbstractEdm { functionsMap.put(functionName, functions); } } - final List parameterNamesCopy = - parameterNames == null ? Collections. emptyList() : parameterNames; + final List parameterNamesCopy + = parameterNames == null ? Collections.emptyList() : parameterNames; for (Function function : functions) { if (function.isBound()) { List providerParameters = function.getParameters(); @@ -185,7 +189,7 @@ public class EdmProviderImpl extends AbstractEdm { } final Parameter bindingParameter = providerParameters.get(0); if (bindingParameterTypeName.equals(bindingParameter.getType()) - && isBindingParameterCollection.booleanValue() == bindingParameter.isCollection()) { + && isBindingParameterCollection.booleanValue() == bindingParameter.isCollection()) { if (parameterNamesCopy.size() == providerParameters.size() - 1) { final List providerParameterNames = new ArrayList(); @@ -289,8 +293,8 @@ public class EdmProviderImpl extends AbstractEdm { } } - final List parameterNamesCopy = - parameterNames == null ? Collections. emptyList() : parameterNames; + final List parameterNamesCopy + = parameterNames == null ? Collections.emptyList() : parameterNames; for (Function function : functions) { if (!function.isBound()) { List providerParameters = function.getParameters(); @@ -316,15 +320,33 @@ public class EdmProviderImpl extends AbstractEdm { } @Override - protected List createSchemas() { + protected Map createSchemas() { try { - List schemas = new ArrayList(); + final Map _schemas = new LinkedHashMap(); for (Schema schema : provider.getSchemas()) { - schemas.add(new EdmSchemaImpl(this, provider, schema)); + _schemas.put(schema.getNamespace(), new EdmSchemaImpl(this, provider, schema)); } - return schemas; + return _schemas; } catch (ODataException e) { throw new EdmException(e); } } + + @Override + protected EdmTerm createTerm(final FullQualifiedName termName) { + // TODO: implement + return null; + } + + @Override + protected EdmAnnotations createAnnotationGroup(final FullQualifiedName targetName) { + // TODO: implement + return null; + } + + @Override + protected List createAnnotations(final FullQualifiedName annotatedName) { + // TODO: implement + return null; + } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReferentialConstraintImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReferentialConstraintImpl.java new file mode 100644 index 000000000..24a0ea35c --- /dev/null +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReferentialConstraintImpl.java @@ -0,0 +1,36 @@ +/* + * 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.server.core.edm.provider; + +import java.util.List; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.core.edm.AbstractEdmReferentialConstraint; + +public class EdmReferentialConstraintImpl extends AbstractEdmReferentialConstraint { + + public EdmReferentialConstraintImpl(final String property, final String referencedProperty) { + super(property, referencedProperty); + } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } +} diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReturnTypeImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReturnTypeImpl.java index c810ba75e..270456543 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReturnTypeImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmReturnTypeImpl.java @@ -19,6 +19,7 @@ package org.apache.olingo.server.core.edm.provider; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.core.edm.AbstractEdmReturnType; import org.apache.olingo.server.api.edm.provider.ReturnType; @@ -56,4 +57,8 @@ public class EdmReturnTypeImpl extends AbstractEdmReturnType { return returnType.getScale(); } + @Override + public SRID getSrid() { + return null; // TODO: provide implementation + } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImpl.java index f95338e61..c8f64be11 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSchemaImpl.java @@ -19,15 +19,19 @@ package org.apache.olingo.server.core.edm.provider; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; +import org.apache.olingo.commons.api.edm.EdmAnnotation; +import org.apache.olingo.commons.api.edm.EdmAnnotations; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmFunction; +import org.apache.olingo.commons.api.edm.EdmTerm; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.AbstractEdmSchema; @@ -43,7 +47,9 @@ import org.apache.olingo.server.api.edm.provider.TypeDefinition; public class EdmSchemaImpl extends AbstractEdmSchema { private final Schema schema; + private final Edm edm; + private final EdmProvider provider; public EdmSchemaImpl(final Edm edm, final EdmProvider provider, final Schema schema) { @@ -56,8 +62,7 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override protected EdmEntityContainer createEntityContainer() { if (schema.getEntityContainer() != null) { - FullQualifiedName containerFQN = - new FullQualifiedName(namespace, schema.getEntityContainer().getName()); + FullQualifiedName containerFQN = new FullQualifiedName(namespace, schema.getEntityContainer().getName()); return new EdmEntityContainerImpl(edm, provider, containerFQN, schema.getEntityContainer()); } return null; @@ -65,8 +70,8 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override protected List createTypeDefinitions() { - List typeDefinitions = new ArrayList(); - List providerTypeDefinitions = schema.getTypeDefinitions(); + final List typeDefinitions = new ArrayList(); + final List providerTypeDefinitions = schema.getTypeDefinitions(); if (providerTypeDefinitions != null) { for (TypeDefinition def : providerTypeDefinitions) { typeDefinitions.add(new EdmTypeDefinitionImpl(edm, new FullQualifiedName("namespace", def.getName()), def)); @@ -77,8 +82,8 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override protected List createEnumTypes() { - List enumTypes = new ArrayList(); - List providerEnumTypes = schema.getEnumTypes(); + final List enumTypes = new ArrayList(); + final List providerEnumTypes = schema.getEnumTypes(); if (providerEnumTypes != null) { for (EnumType enumType : providerEnumTypes) { enumTypes.add(new EdmEnumTypeImpl(edm, new FullQualifiedName(namespace, enumType.getName()), enumType)); @@ -89,12 +94,12 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override protected List createEntityTypes() { - List entityTypes = new ArrayList(); - List providerEntityTypes = schema.getEntityTypes(); + final List entityTypes = new ArrayList(); + final List providerEntityTypes = schema.getEntityTypes(); if (providerEntityTypes != null) { for (EntityType entityType : providerEntityTypes) { entityTypes.add(EdmEntityTypeImpl.getInstance(edm, new FullQualifiedName(namespace, entityType.getName()), - entityType)); + entityType)); } } return entityTypes; @@ -102,12 +107,12 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override protected List createComplexTypes() { - List complexTypes = new ArrayList(); - List providerComplexTypes = schema.getComplexTypes(); + final List complexTypes = new ArrayList(); + final List providerComplexTypes = schema.getComplexTypes(); if (providerComplexTypes != null) { for (ComplexType complexType : providerComplexTypes) { complexTypes.add(EdmComplexTypeImpl.getInstance(edm, new FullQualifiedName(namespace, complexType.getName()), - complexType)); + complexType)); } } return complexTypes; @@ -115,8 +120,8 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override protected List createActions() { - List actions = new ArrayList(); - List providerActions = schema.getActions(); + final List actions = new ArrayList(); + final List providerActions = schema.getActions(); if (providerActions != null) { for (Action action : providerActions) { actions.add(EdmActionImpl.getInstance(edm, new FullQualifiedName(namespace, action.getName()), action)); @@ -127,8 +132,8 @@ public class EdmSchemaImpl extends AbstractEdmSchema { @Override protected List createFunctions() { - List functions = new ArrayList(); - List providerFunctions = schema.getFunctions(); + final List functions = new ArrayList(); + final List providerFunctions = schema.getFunctions(); if (providerFunctions != null) { for (Function function : providerFunctions) { functions.add(EdmFunctionImpl.getInstance(edm, new FullQualifiedName(namespace, function.getName()), function)); @@ -136,4 +141,28 @@ public class EdmSchemaImpl extends AbstractEdmSchema { } return functions; } + + @Override + protected List createTerms() { + // TODO: implement + return Collections.emptyList(); + } + + @Override + protected List createAnnotationGroups() { + // TODO: implement + return Collections.emptyList(); + } + + @Override + protected List createAnnotations() { + // TODO: implement + return Collections.emptyList(); + } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImpl.java index ed6c7999f..a7d0f8683 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImpl.java @@ -66,8 +66,8 @@ public class EdmServiceMetadataImpl implements EdmServiceMetadata { } @Override - public String getDataServiceVersion() { - return ODataServiceVersion.V40.toString(); + public ODataServiceVersion getDataServiceVersion() { + return ODataServiceVersion.V40; } @Override @@ -175,7 +175,7 @@ public class EdmServiceMetadataImpl implements EdmServiceMetadata { if (functionImports != null) { for (FunctionImport functionImport : functionImports) { functionImportInfos.add( - new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName())); + new EdmFunctionImportInfoImpl(entityContainer.getName(), functionImport.getName())); } } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSingletonImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSingletonImpl.java index 6f9bb7845..9b9bc6037 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSingletonImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmSingletonImpl.java @@ -18,7 +18,9 @@ */ package org.apache.olingo.server.core.edm.provider; +import java.util.List; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmSingleton; import org.apache.olingo.server.api.edm.provider.Singleton; @@ -28,4 +30,15 @@ public class EdmSingletonImpl extends EdmBindingTargetImpl implements EdmSinglet public EdmSingletonImpl(final Edm edm, final EdmEntityContainer container, final Singleton singleton) { super(edm, container, singleton); } + + @Override + public TargetType getAnnotationsTargetType() { + return TargetType.Singleton; + } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmStructuredTypeHelperImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmStructuredTypeHelperImpl.java index f610fc2e8..83aa387ce 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmStructuredTypeHelperImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmStructuredTypeHelperImpl.java @@ -24,6 +24,7 @@ import java.util.Map; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmNavigationProperty; import org.apache.olingo.commons.api.edm.EdmProperty; +import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.EdmStructuredTypeHelper; import org.apache.olingo.server.api.edm.provider.NavigationProperty; import org.apache.olingo.server.api.edm.provider.Property; @@ -33,14 +34,19 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper { private final Edm edm; + private final FullQualifiedName structuredTypeName; + private final StructuredType structuredType; private Map properties; private Map navigationProperties; - public EdmStructuredTypeHelperImpl(final Edm edm, final StructuredType structuredType) { + public EdmStructuredTypeHelperImpl( + final Edm edm, final FullQualifiedName structuredTypeName, final StructuredType structuredType) { + this.edm = edm; + this.structuredTypeName = structuredTypeName; this.structuredType = structuredType; } @@ -50,7 +56,7 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper { properties = new LinkedHashMap(); if (structuredType.getProperties() != null) { for (Property property : structuredType.getProperties()) { - properties.put(property.getName(), new EdmPropertyImpl(edm, property)); + properties.put(property.getName(), new EdmPropertyImpl(edm, structuredTypeName, property)); } } } @@ -64,7 +70,7 @@ public class EdmStructuredTypeHelperImpl implements EdmStructuredTypeHelper { if (structuredType.getNavigationProperties() != null) { for (NavigationProperty navigationProperty : structuredType.getNavigationProperties()) { navigationProperties.put(navigationProperty.getName(), - new EdmNavigationPropertyImpl(edm, navigationProperty)); + new EdmNavigationPropertyImpl(edm, structuredTypeName, navigationProperty)); } } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImpl.java index 391ba9348..29e47b9ed 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImpl.java @@ -18,12 +18,15 @@ */ package org.apache.olingo.server.core.edm.provider; +import java.util.List; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmAnnotation; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.geo.SRID; import org.apache.olingo.commons.core.edm.AbstractEdmTypeDefinition; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.apache.olingo.server.api.edm.provider.TypeDefinition; @@ -35,7 +38,7 @@ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements private EdmPrimitiveType edmPrimitiveTypeInstance; public EdmTypeDefinitionImpl(final Edm edm, final FullQualifiedName typeDefinitionName, - final TypeDefinition typeDefinition) { + final TypeDefinition typeDefinition) { super(edm, typeDefinitionName); this.typeDefinition = typeDefinition; @@ -46,7 +49,7 @@ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements if (edmPrimitiveTypeInstance == null) { try { edmPrimitiveTypeInstance = EdmPrimitiveTypeFactory.getInstance( - EdmPrimitiveTypeKind.valueOf(typeDefinition.getUnderlyingType().getName())); + EdmPrimitiveTypeKind.valueOf(typeDefinition.getUnderlyingType().getName())); } catch (IllegalArgumentException e) { throw new EdmException("Invalid underlying type: " + typeDefinition.getUnderlyingType(), e); } @@ -69,8 +72,19 @@ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements return typeDefinition.getScale(); } + @Override + public SRID getSrid() { + return null; // TODO: provide implementation + } + @Override public Boolean isUnicode() { return typeDefinition.getIsUnicode(); } + + @Override + public List getAnnotations() { + // TODO: implement + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java index 9b5a5aee4..0cdf99d3e 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java @@ -18,6 +18,7 @@ */ package org.apache.olingo.server.core.edm.provider; +import org.apache.olingo.server.api.edm.provider.EnumMember; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -33,7 +34,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; -import org.apache.olingo.server.api.edm.provider.EnumMember; import org.apache.olingo.server.api.edm.provider.EnumType; import org.junit.Test; diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMemberImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMemberImplTest.java index f0383f665..d3839dab8 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMemberImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmMemberImplTest.java @@ -18,19 +18,19 @@ */ package org.apache.olingo.server.core.edm.provider; +import org.apache.olingo.server.api.edm.provider.EnumMember; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; -import org.apache.olingo.commons.core.edm.EdmMemberImpl; -import org.apache.olingo.server.api.edm.provider.EnumMember; import org.junit.Test; public class EdmMemberImplTest { @Test public void enumMember() { - EnumMember member = new EnumMember().setName("name").setValue("value"); - EdmMemberImpl memberImpl = new EdmMemberImpl(mock(EdmProviderImpl.class), member.getName(), member.getValue()); + final EnumMember member = new EnumMember().setName("name").setValue("value"); + final EdmMemberImpl memberImpl = + new EdmMemberImpl(mock(EdmProviderImpl.class), null, member.getName(), member.getValue()); assertEquals("name", memberImpl.getName()); assertEquals("value", memberImpl.getValue()); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmNavigationPropertyImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmNavigationPropertyImplTest.java index dd3a8b57c..be508c585 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmNavigationPropertyImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmNavigationPropertyImplTest.java @@ -55,7 +55,7 @@ public class EdmNavigationPropertyImplTest { NavigationProperty propertyProvider = new NavigationProperty(); propertyProvider.setType(entityTypeName); propertyProvider.setNullable(false); - EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider); + EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, entityTypeName, propertyProvider); assertFalse(property.isCollection()); assertFalse(property.isNullable()); EdmType type = property.getType(); @@ -85,7 +85,7 @@ public class EdmNavigationPropertyImplTest { referentialConstraints.add(new ReferentialConstraint().setProperty("property").setReferencedProperty( "referencedProperty")); propertyProvider.setReferentialConstraints(referentialConstraints); - EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider); + EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, entityTypeName, propertyProvider); assertEquals("property", property.getReferencingPropertyName("referencedProperty")); assertNull(property.getReferencingPropertyName("wrong")); } @@ -106,7 +106,7 @@ public class EdmNavigationPropertyImplTest { propertyProvider.setType(entityTypeName); propertyProvider.setNullable(false); propertyProvider.setPartner("partnerName"); - EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider); + EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, entityTypeName, propertyProvider); EdmNavigationProperty partner = property.getPartner(); assertNotNull(partner); @@ -130,7 +130,7 @@ public class EdmNavigationPropertyImplTest { propertyProvider.setType(entityTypeName); propertyProvider.setNullable(false); propertyProvider.setPartner("wrong"); - EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider); + EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, entityTypeName, propertyProvider); property.getPartner(); } @@ -138,7 +138,7 @@ public class EdmNavigationPropertyImplTest { public void navigationPropertyWithNonExistentType() throws Exception { EdmProviderImpl edm = mock(EdmProviderImpl.class); NavigationProperty propertyProvider = new NavigationProperty(); - EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, propertyProvider); + EdmNavigationProperty property = new EdmNavigationPropertyImpl(edm, null, propertyProvider); property.getType(); } } \ No newline at end of file diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImplTest.java index e85a4d75c..d8a28dd4a 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImplTest.java @@ -47,7 +47,7 @@ public class EdmPropertyImplTest { EdmProviderImpl edm = new EdmProviderImpl(mock(EdmProvider.class)); Property propertyProvider = new Property(); propertyProvider.setType(EdmPrimitiveTypeKind.Binary.getFullQualifiedName()); - final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider); + final EdmProperty property = new EdmPropertyImpl(edm, null, propertyProvider); assertTrue(property.isPrimitive()); final EdmType type = property.getType(); assertEquals(EdmTypeKind.PRIMITIVE, type.getKind()); @@ -64,7 +64,7 @@ public class EdmPropertyImplTest { when(provider.getComplexType(complexTypeName)).thenReturn(complexTypeProvider); Property propertyProvider = new Property(); propertyProvider.setType(complexTypeName); - final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider); + final EdmProperty property = new EdmPropertyImpl(edm, complexTypeName, propertyProvider); assertFalse(property.isCollection()); assertFalse(property.isPrimitive()); final EdmType type = property.getType(); @@ -82,7 +82,7 @@ public class EdmPropertyImplTest { when(provider.getEnumType(enumTypeName)).thenReturn(enumTypeProvider); Property propertyProvider = new Property(); propertyProvider.setType(enumTypeName); - final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider); + final EdmProperty property = new EdmPropertyImpl(edm, null, propertyProvider); assertFalse(property.isCollection()); assertFalse(property.isPrimitive()); final EdmType type = property.getType(); @@ -100,7 +100,7 @@ public class EdmPropertyImplTest { when(provider.getTypeDefinition(typeName)).thenReturn(typeProvider); Property propertyProvider = new Property(); propertyProvider.setType(typeName); - final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider); + final EdmProperty property = new EdmPropertyImpl(edm, null, propertyProvider); assertFalse(property.isPrimitive()); final EdmType type = property.getType(); assertEquals(EdmTypeKind.DEFINITION, type.getKind()); @@ -114,7 +114,7 @@ public class EdmPropertyImplTest { EdmProviderImpl edm = new EdmProviderImpl(provider); final Property propertyProvider = new Property() .setType(new FullQualifiedName("ns", "wrong")); - final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider); + final EdmProperty property = new EdmPropertyImpl(edm, null, propertyProvider); property.getType(); fail(); } @@ -125,7 +125,7 @@ public class EdmPropertyImplTest { EdmProviderImpl edm = new EdmProviderImpl(provider); final Property propertyProvider = new Property() .setType(new FullQualifiedName(EdmPrimitiveType.EDM_NAMESPACE, "type")); - final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider); + final EdmProperty property = new EdmPropertyImpl(edm, null, propertyProvider); property.getType(); fail(); } @@ -141,7 +141,7 @@ public class EdmPropertyImplTest { propertyProvider.setUnicode(true); propertyProvider.setNullable(false); propertyProvider.setDefaultValue("x"); - final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider); + final EdmProperty property = new EdmPropertyImpl(edm, null, propertyProvider); assertTrue(property.isPrimitive()); assertNull(property.getMapping()); assertNull(property.getMimeType()); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmProviderImplOverloadingTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmProviderImplOverloadingTest.java index 1a4795f24..7e3642012 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmProviderImplOverloadingTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmProviderImplOverloadingTest.java @@ -83,12 +83,12 @@ public class EdmProviderImplOverloadingTest { functions.add(function); List function3Parameters = new ArrayList(); function3Parameters.add(new Parameter().setName("a").setType(operationType1)); - function3Parameters.add(new Parameter().setName("b")); + function3Parameters.add(new Parameter().setName("b").setType(operationType1)); function = new Function().setName(operationName1.getName()).setParameters(function3Parameters).setBound(true); functions.add(function); List function4Parameters = new ArrayList(); function4Parameters.add(new Parameter().setName("a").setType(operationType2)); - function4Parameters.add(new Parameter().setName("b")); + function4Parameters.add(new Parameter().setName("b").setType(operationType2)); function = new Function().setName(operationName1.getName()).setParameters(function4Parameters).setBound(true); functions.add(function); when(provider.getFunctions(operationName1)).thenReturn(functions); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImplTest.java index 16bc0fb53..b29836022 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmServiceMetadataImplTest.java @@ -74,7 +74,7 @@ public class EdmServiceMetadataImplTest { public void initialProvider() { EdmProvider provider = new EdmProvider() {}; EdmServiceMetadata serviceMetadata = new EdmServiceMetadataImpl(provider); - assertEquals(ODataServiceVersion.V40.toString(), serviceMetadata.getDataServiceVersion()); + assertEquals(ODataServiceVersion.V40, serviceMetadata.getDataServiceVersion()); } @Test(expected = EdmException.class) diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java index bcededcd9..143871a1f 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java @@ -49,7 +49,6 @@ import org.apache.olingo.server.core.uri.UriResourceNavigationPropertyImpl; import org.apache.olingo.server.core.uri.UriResourcePrimitivePropertyImpl; import org.apache.olingo.server.core.uri.UriResourceSingletonImpl; import org.apache.olingo.server.core.uri.UriResourceWithKeysImpl; -import org.apache.olingo.server.core.uri.parser.UriParserException; import org.apache.olingo.server.core.uri.queryoption.CustomQueryOptionImpl; import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl; import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl;