You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/03/22 16:13:03 UTC
[06/11] git commit: [OLINGO-65] Geospatial types implemented,
EdmStream mock implemented with URI as backend, V3 pruned types implemented,
EdmSimpleTypeKind adapted, EdmSimpleTypeFactory introduces
[OLINGO-65] Geospatial types implemented, EdmStream mock implemented with URI as backend, V3 pruned types implemented, EdmSimpleTypeKind adapted, EdmSimpleTypeFactory introduces
Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/commit/559698d4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/tree/559698d4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/diff/559698d4
Branch: refs/heads/olingo200
Commit: 559698d4dbb14dd8085f0b829fa980f01abdf139
Parents: bab0362
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Fri Mar 21 11:51:11 2014 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Fri Mar 21 11:51:11 2014 +0100
----------------------------------------------------------------------
lib/client-api/pom.xml | 4 -
.../apache/olingo/client/api/data/GeoUtils.java | 90 ++++++
.../olingo/client/api/data/GeospatialValue.java | 2 +-
.../client/api/domain/ODataGeospatialValue.java | 9 +-
.../domain/ODataJClientEdmPrimitiveType.java | 45 +--
.../client/api/domain/ODataPrimitiveValue.java | 108 +++++--
.../client/api/domain/ODataTimestamp.java | 23 +-
.../domain/geospatial/ComposedGeospatial.java | 78 -----
.../api/domain/geospatial/Geospatial.java | 169 -----------
.../domain/geospatial/GeospatialCollection.java | 49 ---
.../api/domain/geospatial/LineString.java | 39 ---
.../api/domain/geospatial/MultiLineString.java | 39 ---
.../api/domain/geospatial/MultiPoint.java | 39 ---
.../api/domain/geospatial/MultiPolygon.java | 39 ---
.../client/api/domain/geospatial/Point.java | 77 -----
.../client/api/domain/geospatial/Polygon.java | 74 -----
.../olingo/client/api/utils/GeoUtils.java | 90 ------
.../cud/ODataValueUpdateRequestImpl.java | 4 +-
.../request/retrieve/ODataValueRequestImpl.java | 4 +-
.../core/data/AbstractJsonDeserializer.java | 43 +--
.../core/data/AbstractJsonSerializer.java | 22 +-
.../core/data/AtomGeoValueDeserializer.java | 35 +--
.../core/data/AtomGeoValueSerializer.java | 18 +-
.../core/data/AtomPropertyDeserializer.java | 4 +-
.../olingo/client/core/data/GeoUtils.java | 90 ------
.../client/core/data/GeospatialValueImpl.java | 2 +-
.../core/data/JSONGeoValueDeserializer.java | 74 +++--
.../core/data/JSONGeoValueSerializer.java | 32 +-
.../olingo/client/core/edm/EdmClientImpl.java | 12 +-
.../olingo/client/core/edm/EdmEnumTypeImpl.java | 14 +-
.../olingo/client/core/edm/EdmSchemaImpl.java | 15 +-
.../client/core/edm/EdmTypeDefinitionImpl.java | 12 +-
.../olingo/client/core/edm/EdmTypeInfo.java | 26 +-
.../core/op/impl/AbstractODataBinder.java | 10 +-
.../core/op/impl/AbstractODataReader.java | 4 +-
.../client/core/op/impl/v3/ODataReaderImpl.java | 2 +-
.../client/core/op/impl/v4/ODataReaderImpl.java | 2 +-
.../client/core/AbstractPrimitiveTest.java | 60 ++--
.../client/core/AbstractPropertyTest.java | 7 +-
.../client/core/it/AbstractTestITCase.java | 14 +-
.../core/it/v3/EntityCreateTestITCase.java | 22 +-
.../core/it/v3/EntityUpdateTestITCase.java | 4 +-
.../it/v3/NavigationLinkCreateTestITCase.java | 22 +-
.../client/core/it/v3/OpenTypeTestITCase.java | 106 +++----
.../olingo/client/core/v3/EntityTest.java | 10 +-
.../olingo/client/core/v3/MetadataTest.java | 13 +-
.../client/core/v3/PrimitiveValueTest.java | 107 ++++---
.../client/core/v4/FilterFactoryTest.java | 3 +-
.../olingo/client/core/v4/MetadataTest.java | 9 +-
.../client/core/v4/PrimitiveValueTest.java | 14 +-
lib/commons-api/pom.xml | 8 +
.../commons/api/edm/EdmGeospatialType.java | 34 +++
.../commons/api/edm/EdmPrimitiveTypeKind.java | 139 +++++++++
.../commons/api/edm/geo/ComposedGeospatial.java | 78 +++++
.../olingo/commons/api/edm/geo/Geospatial.java | 169 +++++++++++
.../api/edm/geo/GeospatialCollection.java | 48 +++
.../olingo/commons/api/edm/geo/LineString.java | 38 +++
.../commons/api/edm/geo/MultiLineString.java | 39 +++
.../olingo/commons/api/edm/geo/MultiPoint.java | 39 +++
.../commons/api/edm/geo/MultiPolygon.java | 38 +++
.../olingo/commons/api/edm/geo/Point.java | 77 +++++
.../olingo/commons/api/edm/geo/Polygon.java | 73 +++++
.../commons/core/edm/AbstractEdmParameter.java | 5 +-
.../commons/core/edm/AbstractEdmProperty.java | 5 +-
.../commons/core/edm/AbstractEdmReturnType.java | 5 +-
.../AbstractEdmGeospatialType.java | 76 +++++
.../commons/core/edm/primitivetype/EdmDate.java | 5 +-
.../core/edm/primitivetype/EdmDateTime.java | 124 ++++++++
.../core/edm/primitivetype/EdmGeography.java | 36 +++
.../primitivetype/EdmGeographyCollection.java | 37 +++
.../primitivetype/EdmGeographyLineString.java | 37 +++
.../EdmGeographyMultiLineString.java | 37 +++
.../primitivetype/EdmGeographyMultiPoint.java | 37 +++
.../primitivetype/EdmGeographyMultiPolygon.java | 37 +++
.../edm/primitivetype/EdmGeographyPoint.java | 37 +++
.../edm/primitivetype/EdmGeographyPolygon.java | 37 +++
.../core/edm/primitivetype/EdmGeometry.java | 36 +++
.../primitivetype/EdmGeometryCollection.java | 37 +++
.../primitivetype/EdmGeometryLineString.java | 37 +++
.../EdmGeometryMultiLineString.java | 37 +++
.../primitivetype/EdmGeometryMultiPoint.java | 37 +++
.../primitivetype/EdmGeometryMultiPolygon.java | 37 +++
.../edm/primitivetype/EdmGeometryPoint.java | 37 +++
.../edm/primitivetype/EdmGeometryPolygon.java | 37 +++
.../commons/core/edm/primitivetype/EdmNull.java | 75 -----
.../primitivetype/EdmPrimitiveTypeFactory.java | 138 +++++++++
.../edm/primitivetype/EdmPrimitiveTypeKind.java | 95 ------
.../core/edm/primitivetype/EdmStream.java | 88 ++++++
.../commons/core/edm/primitivetype/EdmTime.java | 77 +++++
.../primitivetype/CommonPrimitiveTypeTest.java | 191 ++++++------
.../core/edm/primitivetype/EdmBinaryTest.java | 30 +-
.../core/edm/primitivetype/EdmBooleanTest.java | 4 +-
.../core/edm/primitivetype/EdmByteTest.java | 5 +-
.../core/edm/primitivetype/EdmDateTest.java | 4 +-
.../primitivetype/EdmDateTimeOffsetTest.java | 4 +-
.../core/edm/primitivetype/EdmDecimalTest.java | 19 +-
.../core/edm/primitivetype/EdmDoubleTest.java | 17 +-
.../core/edm/primitivetype/EdmDurationTest.java | 4 +-
.../core/edm/primitivetype/EdmGuidTest.java | 4 +-
.../core/edm/primitivetype/EdmInt16Test.java | 9 +-
.../core/edm/primitivetype/EdmInt32Test.java | 11 +-
.../core/edm/primitivetype/EdmInt64Test.java | 13 +-
.../core/edm/primitivetype/EdmNullTest.java | 24 +-
.../core/edm/primitivetype/EdmSByteTest.java | 5 +-
.../core/edm/primitivetype/EdmSingleTest.java | 15 +-
.../core/edm/primitivetype/EdmStringTest.java | 4 +-
.../edm/primitivetype/EdmTimeOfDayTest.java | 4 +-
.../core/edm/primitivetype/UInt7Test.java | 6 +-
.../core/edm/provider/EdmEnumTypeImpl.java | 9 +-
.../edm/provider/EdmTypeDefinitionImpl.java | 9 +-
.../core/uri/UriResourceLambdaAllImpl.java | 16 +-
.../core/uri/UriResourceLambdaAnyImpl.java | 15 +-
.../olingo/server/core/uri/parser/Parser.java | 1 -
.../server/core/uri/parser/UriContext.java | 4 -
.../core/uri/parser/UriParseTreeVisitor.java | 302 +++++++++----------
.../core/uri/queryoption/ExpandItemImpl.java | 1 -
.../edm/provider/EdmComplexTypeImplTest.java | 13 +-
.../edm/provider/EdmEntityTypeImplTest.java | 14 +-
.../server/core/edm/provider/EdmEnumTest.java | 9 +-
.../edm/provider/EdmFunctionImportImplTest.java | 31 +-
.../core/edm/provider/EdmParameterImplTest.java | 6 +-
.../core/edm/provider/EdmPropertyImplTest.java | 4 +-
.../edm/provider/EdmReturnTypeImplTest.java | 9 +-
.../edm/provider/EdmTypeDefinitionImplTest.java | 23 +-
.../server/core/testutil/EdmTechProvider.java | 2 +-
.../server/core/uri/UriResourceImplTest.java | 43 +--
.../core/uri/testutil/ExpandValidator.java | 1 -
.../core/uri/testutil/ResourceValidator.java | 1 -
128 files changed, 2916 insertions(+), 1823 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/pom.xml
----------------------------------------------------------------------
diff --git a/lib/client-api/pom.xml b/lib/client-api/pom.xml
index e506a97..eb3f9e3 100644
--- a/lib/client-api/pom.xml
+++ b/lib/client-api/pom.xml
@@ -46,10 +46,6 @@
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/data/GeoUtils.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/data/GeoUtils.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/data/GeoUtils.java
new file mode 100644
index 0000000..083b4e0
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/data/GeoUtils.java
@@ -0,0 +1,90 @@
+/*
+ * 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.data;
+
+import org.apache.olingo.client.api.Constants;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+
+public final class GeoUtils {
+
+ private GeoUtils() {
+ // Empty private constructor for static utility classes
+ }
+
+ public static Geospatial.Dimension getDimension(final EdmPrimitiveTypeKind type) {
+ Geospatial.Dimension dimension;
+
+ switch (type) {
+ case Geography:
+ case GeographyCollection:
+ case GeographyLineString:
+ case GeographyMultiLineString:
+ case GeographyPoint:
+ case GeographyMultiPoint:
+ case GeographyPolygon:
+ case GeographyMultiPolygon:
+ dimension = Geospatial.Dimension.GEOGRAPHY;
+ break;
+
+ default:
+ dimension = Geospatial.Dimension.GEOMETRY;
+ }
+
+ return dimension;
+ }
+
+ public static EdmPrimitiveTypeKind getType(final Geospatial.Dimension dimension, final String elementName) {
+ EdmPrimitiveTypeKind type = null;
+
+ if (Constants.ELEM_POINT.equals(elementName)) {
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyPoint
+ : EdmPrimitiveTypeKind.GeometryPoint;
+ } else if (Constants.ELEM_MULTIPOINT.equals(elementName)) {
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyMultiPoint
+ : EdmPrimitiveTypeKind.GeometryMultiPoint;
+ } else if (Constants.ELEM_LINESTRING.equals(elementName)) {
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyLineString
+ : EdmPrimitiveTypeKind.GeometryLineString;
+ } else if (Constants.ELEM_MULTILINESTRING.equals(elementName)) {
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyMultiLineString
+ : EdmPrimitiveTypeKind.GeometryMultiLineString;
+ } else if (Constants.ELEM_POLYGON.equals(elementName)) {
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyPolygon
+ : EdmPrimitiveTypeKind.GeometryPolygon;
+ } else if (Constants.ELEM_MULTIPOLYGON.equals(elementName)) {
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyMultiPolygon
+ : EdmPrimitiveTypeKind.GeometryMultiPolygon;
+ } else if (Constants.ELEM_GEOCOLLECTION.equals(elementName)
+ || Constants.ELEM_GEOMEMBERS.equals(elementName)) {
+
+ type = dimension == Geospatial.Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyCollection
+ : EdmPrimitiveTypeKind.GeometryCollection;
+ }
+
+ return type;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/data/GeospatialValue.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/data/GeospatialValue.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/data/GeospatialValue.java
index b0deea4..c5d4d2a 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/data/GeospatialValue.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/data/GeospatialValue.java
@@ -18,7 +18,7 @@
*/
package org.apache.olingo.client.api.data;
-import org.apache.olingo.client.api.domain.geospatial.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
public interface GeospatialValue extends Value {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataGeospatialValue.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataGeospatialValue.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataGeospatialValue.java
index 93c4cfb..bd96587 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataGeospatialValue.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataGeospatialValue.java
@@ -19,7 +19,8 @@
package org.apache.olingo.client.api.domain;
import org.apache.olingo.client.api.CommonODataClient;
-import org.apache.olingo.client.api.domain.geospatial.Geospatial;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
public class ODataGeospatialValue extends ODataPrimitiveValue {
@@ -57,7 +58,7 @@ public class ODataGeospatialValue extends ODataPrimitiveValue {
* @param type type.
* @return the current builder.
*/
- public Builder setType(final ODataJClientEdmPrimitiveType type) {
+ public Builder setType(final EdmPrimitiveTypeKind type) {
isSupported(type);
if (type != null && !type.isGeospatial()) {
@@ -65,7 +66,7 @@ public class ODataGeospatialValue extends ODataPrimitiveValue {
"Use " + ODataPrimitiveValue.class.getSimpleName() + " for non-geospatial types");
}
- if (type == ODataJClientEdmPrimitiveType.Geography || type == ODataJClientEdmPrimitiveType.Geometry) {
+ if (type == EdmPrimitiveTypeKind.Geography || type == EdmPrimitiveTypeKind.Geometry) {
throw new IllegalArgumentException(
type + " is not an instantiable type. "
+ "An entity can declare a property to be of type Geometry. "
@@ -86,7 +87,7 @@ public class ODataGeospatialValue extends ODataPrimitiveValue {
throw new IllegalArgumentException("No Geospatial value provided");
}
if (this.ogv.type == null) {
- this.ogv.type = ((Geospatial) this.ogv.value).getEdmSimpleType();
+ this.ogv.type = ((Geospatial) this.ogv.value).getEdmPrimitiveTypeKind();
}
return this.ogv;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataJClientEdmPrimitiveType.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataJClientEdmPrimitiveType.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataJClientEdmPrimitiveType.java
index 4b1decc..5ea5edf 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataJClientEdmPrimitiveType.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataJClientEdmPrimitiveType.java
@@ -22,15 +22,15 @@ import java.math.BigDecimal;
import java.net.URI;
import java.util.UUID;
-import org.apache.olingo.client.api.domain.geospatial.Geospatial;
-import org.apache.olingo.client.api.domain.geospatial.GeospatialCollection;
-import org.apache.olingo.client.api.domain.geospatial.LineString;
-import org.apache.olingo.client.api.domain.geospatial.MultiLineString;
-import org.apache.olingo.client.api.domain.geospatial.MultiPoint;
-import org.apache.olingo.client.api.domain.geospatial.MultiPolygon;
-import org.apache.olingo.client.api.domain.geospatial.Point;
-import org.apache.olingo.client.api.domain.geospatial.Polygon;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
+import org.apache.olingo.commons.api.edm.geo.LineString;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
+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;
/**
* Represent the primitive types of the Entity Data Model (EDM).
@@ -72,11 +72,11 @@ public enum ODataJClientEdmPrimitiveType {
/**
* A 64-bit value expressed as Coordinated Universal Time (UTC).
*/
- DateTime(new ODataServiceVersion[]{ODataServiceVersion.V30}, ODataTimestamp.class, "yyyy-MM-dd'T'HH:mm:ss"),
+ DateTime(new ODataServiceVersion[] {ODataServiceVersion.V30}, ODataTimestamp.class, "yyyy-MM-dd'T'HH:mm:ss"),
/**
* Date without a time-zone offset.
*/
- Date(new ODataServiceVersion[]{ODataServiceVersion.V40}, ODataTimestamp.class, "yyyy-MM-dd"),
+ Date(new ODataServiceVersion[] {ODataServiceVersion.V40}, ODataTimestamp.class, "yyyy-MM-dd"),
/**
* Date and time as an Offset in minutes from GMT.
*/
@@ -84,15 +84,15 @@ public enum ODataJClientEdmPrimitiveType {
/**
* The time of day with values ranging from 0:00:00.x to 23:59:59.y, where x and y depend upon the precision.
*/
- Time(new ODataServiceVersion[]{ODataServiceVersion.V30}, ODataDuration.class),
+ Time(new ODataServiceVersion[] {ODataServiceVersion.V30}, ODataDuration.class),
/**
* The time of day with values ranging from 0:00:00.x to 23:59:59.y, where x and y depend upon the precision.
*/
- TimeOfDay(new ODataServiceVersion[]{ODataServiceVersion.V40}, ODataDuration.class),
+ TimeOfDay(new ODataServiceVersion[] {ODataServiceVersion.V40}, ODataDuration.class),
/**
* Signed duration in days, hours, minutes, and (sub)seconds.
*/
- Duration(new ODataServiceVersion[]{ODataServiceVersion.V40}, ODataDuration.class),
+ Duration(new ODataServiceVersion[] {ODataServiceVersion.V40}, ODataDuration.class),
/**
* Numeric values with fixed precision and scale.
*/
@@ -257,25 +257,6 @@ public enum ODataJClientEdmPrimitiveType {
}
/**
- * Gets <tt>EdmSimpleType</tt> from object instance.
- *
- * @param workingVersion OData version.
- * @param obj object.
- * @return <tt>EdmSimpleType</tt> object.
- */
- public static ODataJClientEdmPrimitiveType fromObject(final ODataServiceVersion workingVersion, final Object obj) {
- for (ODataJClientEdmPrimitiveType edmSimpleType : ODataJClientEdmPrimitiveType.values()) {
- if (edmSimpleType.javaType().equals(obj.getClass())) {
- return edmSimpleType == DateTimeOffset || edmSimpleType == DateTime || edmSimpleType == Date
- ? ((ODataTimestamp) obj).isOffset()
- ? DateTimeOffset : workingVersion == ODataServiceVersion.V30 ? DateTime : Date
- : edmSimpleType;
- }
- }
- throw new IllegalArgumentException(obj.getClass().getSimpleName() + " is not a simple type");
- }
-
- /**
* Gets namespace.
*
* @return namespace.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataPrimitiveValue.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataPrimitiveValue.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataPrimitiveValue.java
index df69d1f..21d8562 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataPrimitiveValue.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataPrimitiveValue.java
@@ -28,9 +28,8 @@ import java.util.UUID;
import javax.xml.datatype.Duration;
import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
/**
* OData primitive property value.
@@ -50,8 +49,8 @@ public class ODataPrimitiveValue extends ODataValue {
this.client = client;
}
- public AbstractBuilder isSupported(final ODataJClientEdmPrimitiveType type) {
- if (type != null && !ArrayUtils.contains(type.getSupportedVersions(), client.getServiceVersion())) {
+ public AbstractBuilder isSupported(final EdmPrimitiveTypeKind type) {
+ if (type != null && !type.getSupportedVersions().contains(client.getServiceVersion())) {
throw new IllegalArgumentException(String.format(
"Type %s not supported by the current OData working version", type.toString()));
}
@@ -103,12 +102,12 @@ public class ODataPrimitiveValue extends ODataValue {
* @param type type.
* @return the current builder.
*/
- public Builder setType(final ODataJClientEdmPrimitiveType type) {
+ public Builder setType(final EdmPrimitiveTypeKind type) {
isSupported(type);
- if (type == ODataJClientEdmPrimitiveType.Stream) {
+ if (type == EdmPrimitiveTypeKind.Stream) {
throw new IllegalArgumentException(String.format(
- "Cannot build a primitive value for %s", ODataJClientEdmPrimitiveType.Stream.toString()));
+ "Cannot build a primitive value for %s", EdmPrimitiveTypeKind.Stream.toString()));
}
this.opv.type = type;
@@ -129,7 +128,7 @@ public class ODataPrimitiveValue extends ODataValue {
}
if (this.opv.type == null) {
- this.opv.type = ODataJClientEdmPrimitiveType.String;
+ this.opv.type = EdmPrimitiveTypeKind.String;
}
if (this.opv.type.isGeospatial()) {
@@ -147,7 +146,7 @@ public class ODataPrimitiveValue extends ODataValue {
this.opv.value = new ODataDuration((Duration) this.opv.value);
}
- if (this.opv.value != null && !this.opv.type.javaType().isAssignableFrom(this.opv.value.getClass())) {
+ if (this.opv.value != null && !this.opv.getJavaType().isAssignableFrom(this.opv.value.getClass())) {
throw new IllegalArgumentException("Provided value is not compatible with " + this.opv.type.toString());
}
@@ -177,7 +176,7 @@ public class ODataPrimitiveValue extends ODataValue {
/**
* Value type.
*/
- protected ODataJClientEdmPrimitiveType type;
+ protected EdmPrimitiveTypeKind type;
/**
* Protected constructor, need to use the builder to instantiate this class.
@@ -189,15 +188,82 @@ public class ODataPrimitiveValue extends ODataValue {
this.client = client;
}
+ private Class<?> getJavaType() {
+ Class<?> javaType = null;
+
+ switch (this.type) {
+ case Binary:
+ javaType = byte[].class;
+ break;
+
+ case SByte:
+ javaType = Byte.class;
+ break;
+
+ case Boolean:
+ javaType = Boolean.class;
+ break;
+
+ case Date:
+ case DateTime:
+ case DateTimeOffset:
+ javaType = ODataTimestamp.class;
+ break;
+
+ case Time:
+ case TimeOfDay:
+ javaType = ODataDuration.class;
+ break;
+
+ case Decimal:
+ javaType = BigDecimal.class;
+ break;
+
+ case Single:
+ javaType = Float.class;
+ break;
+
+ case Double:
+ javaType = Double.class;
+ break;
+
+ case Guid:
+ javaType = UUID.class;
+ break;
+
+ case Int16:
+ javaType = Short.class;
+ break;
+
+ case Byte:
+ case Int32:
+ javaType = Integer.class;
+ break;
+
+ case Int64:
+ javaType = Long.class;
+ break;
+
+ case Stream:
+ javaType = URI.class;
+ break;
+
+ case String:
+ javaType = String.class;
+ break;
+
+ default:
+ javaType = this.value.getClass();
+ }
+
+ return javaType;
+ }
+
/**
* Parses given text as object value.
*/
private void parseText() {
switch (this.type) {
- case Null:
- this.value = null;
- break;
-
case Binary:
this.value = Base64.decodeBase64(this.toString());
break;
@@ -267,10 +333,6 @@ public class ODataPrimitiveValue extends ODataValue {
*/
private void formatValue() {
switch (this.type) {
- case Null:
- this.text = StringUtils.EMPTY;
- break;
-
case Binary:
this.text = Base64.encodeBase64String(this.<byte[]>toCastValue());
break;
@@ -295,15 +357,15 @@ public class ODataPrimitiveValue extends ODataValue {
break;
case Decimal:
- this.text = new DecimalFormat(this.type.pattern()).format(this.<BigDecimal>toCastValue());
+ this.text = new DecimalFormat("#.#######################").format(this.<BigDecimal>toCastValue());
break;
case Single:
- this.text = new DecimalFormat(this.type.pattern()).format(this.<Float>toCastValue());
+ this.text = new DecimalFormat("#.#######E0").format(this.<Float>toCastValue());
break;
case Double:
- this.text = new DecimalFormat(this.type.pattern()).format(this.<Double>toCastValue());
+ this.text = new DecimalFormat("#.#######################E0").format(this.<Double>toCastValue());
break;
case Guid:
@@ -341,7 +403,7 @@ public class ODataPrimitiveValue extends ODataValue {
* @return type name.
*/
public String getTypeName() {
- return type.toString();
+ return type.getFullQualifiedName().toString();
}
/**
@@ -369,6 +431,6 @@ public class ODataPrimitiveValue extends ODataValue {
*/
@SuppressWarnings("unchecked")
public <T> T toCastValue() {
- return (T) type.javaType().cast(toValue());
+ return (T) getJavaType().cast(toValue());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataTimestamp.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataTimestamp.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataTimestamp.java
index a1f3e3d..3f3eb9c 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataTimestamp.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/ODataTimestamp.java
@@ -25,6 +25,7 @@ import java.util.Date;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
/**
* Helper class for handling datetime and datetime-offset primitive values.
@@ -41,17 +42,25 @@ public final class ODataTimestamp implements Serializable {
private final boolean offset;
- public static ODataTimestamp getInstance(final ODataJClientEdmPrimitiveType type, final Timestamp timestamp) {
- return new ODataTimestamp(new SimpleDateFormat(type.pattern()),
- new Date(timestamp.getTime()), timestamp.getNanos(), type == ODataJClientEdmPrimitiveType.DateTimeOffset);
+ private static String getPattern(final EdmPrimitiveTypeKind type) {
+ return type == EdmPrimitiveTypeKind.DateTime
+ ? "yyyy-MM-dd'T'HH:mm:ss"
+ : type == EdmPrimitiveTypeKind.Date
+ ? "yyyy-MM-dd"
+ : "yyyy-MM-dd'T'HH:mm:ss";
}
- public static ODataTimestamp parse(final ODataJClientEdmPrimitiveType type, final String input) {
+ public static ODataTimestamp getInstance(final EdmPrimitiveTypeKind type, final Timestamp timestamp) {
+ return new ODataTimestamp(new SimpleDateFormat(getPattern(type)),
+ new Date(timestamp.getTime()), timestamp.getNanos(), type == EdmPrimitiveTypeKind.DateTimeOffset);
+ }
+
+ public static ODataTimestamp parse(final EdmPrimitiveTypeKind type, final String input) {
final ODataTimestamp instance;
final String[] dateParts = input.split("\\.");
- final SimpleDateFormat sdf = new SimpleDateFormat(type.pattern());
- final boolean isOffset = type == ODataJClientEdmPrimitiveType.DateTimeOffset;
+ final SimpleDateFormat sdf = new SimpleDateFormat(getPattern(type));
+ final boolean isOffset = type == EdmPrimitiveTypeKind.DateTimeOffset;
try {
final Date date = sdf.parse(dateParts[0]);
@@ -70,7 +79,7 @@ public final class ODataTimestamp implements Serializable {
instance = new ODataTimestamp(sdf, date, isOffset);
}
} catch (Exception e) {
- throw new IllegalArgumentException("Cannot parse " + type.pattern(), e);
+ throw new IllegalArgumentException("Cannot parse " + getPattern(type), e);
}
return instance;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/ComposedGeospatial.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/ComposedGeospatial.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/ComposedGeospatial.java
deleted file mode 100644
index 2ef65e8..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/ComposedGeospatial.java
+++ /dev/null
@@ -1,78 +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.api.domain.geospatial;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Abstract base class for all Geometries that are composed out of other geospatial elements.
- */
-public abstract class ComposedGeospatial<T extends Geospatial> extends Geospatial implements Iterable<T> {
-
- private static final long serialVersionUID = 8796254901098541307L;
-
- protected final List<T> geospatials;
-
- /**
- * Constructor.
- *
- * @param dimension dimension.
- * @param type type.
- * @param crs crs.
- * @param geospatials geospatials info.
- */
- protected ComposedGeospatial(final Dimension dimension, final Type type, final String crs,
- final List<T> geospatials) {
-
- super(dimension, type, crs);
- this.geospatials = new ArrayList<T>();
- if (geospatials != null) {
- this.geospatials.addAll(geospatials);
- }
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public Iterator<T> iterator() {
- return this.geospatials.iterator();
- }
-
- /**
- * Checks if is empty.
- *
- * @return 'TRUE' if is empty; 'FALSE' otherwise.
- */
- public boolean isEmpty() {
- return geospatials.isEmpty();
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public void setSrid(final Integer srid) {
- for (Geospatial geospatial : this.geospatials) {
- geospatial.setSrid(srid);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Geospatial.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Geospatial.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Geospatial.java
deleted file mode 100644
index 44e9558..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Geospatial.java
+++ /dev/null
@@ -1,169 +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.api.domain.geospatial;
-
-import java.io.Serializable;
-
-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.domain.ODataJClientEdmPrimitiveType;
-
-/**
- * Base class for all geospatial info.
- */
-public abstract class Geospatial implements Serializable {
-
- public enum Dimension {
-
- GEOMETRY,
- GEOGRAPHY;
-
- }
-
- public enum Type {
-
- /**
- * The OGIS geometry type number for points.
- */
- POINT,
- /**
- * The OGIS geometry type number for lines.
- */
- LINESTRING,
- /**
- * The OGIS geometry type number for polygons.
- */
- POLYGON,
- /**
- * The OGIS geometry type number for aggregate points.
- */
- MULTIPOINT,
- /**
- * The OGIS geometry type number for aggregate lines.
- */
- MULTILINESTRING,
- /**
- * The OGIS geometry type number for aggregate polygons.
- */
- MULTIPOLYGON,
- /**
- * The OGIS geometry type number for feature collections.
- */
- GEOSPATIALCOLLECTION;
-
- }
-
- protected final Dimension dimension;
-
- protected final Type type;
-
- protected String crs;
-
- /**
- * Null value means it is expected to vary per instance.
- */
- protected Integer srid;
-
- /**
- * Constructor.
- *
- * @param dimension dimension.
- * @param type type.
- */
- protected Geospatial(final Dimension dimension, final Type type, final String crs) {
- this.dimension = dimension;
- this.type = type;
- this.crs = crs;
- }
-
- /**
- * Gets dimension.
- *
- * @return dimension.
- * @see Dimension
- */
- public Dimension getDimension() {
- return dimension;
- }
-
- /**
- * Gets type.
- *
- * @return type.
- * @see Type
- */
- public Type getType() {
- return type;
- }
-
- /**
- * Gets CRS.
- *
- * @return CRS
- */
- public String getCrs() {
- return crs;
- }
-
- /**
- * Gets s-rid.
- *
- * @return s-rid.
- */
- public Integer getSrid() {
- return srid;
- }
-
- /**
- * Sets s-rid.
- *
- * @param srid s-rid.
- */
- public void setSrid(final Integer srid) {
- this.srid = srid;
- }
-
- public abstract ODataJClientEdmPrimitiveType getEdmSimpleType();
-
- /**
- * {@inheritDoc }
- */
- @Override
- public boolean equals(final Object obj) {
- return EqualsBuilder.reflectionEquals(this, obj);
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public int hashCode() {
- return HashCodeBuilder.reflectionHashCode(this);
- }
-
- /**
- * {@inheritDoc }
- */
- @Override
- public String toString() {
- return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/GeospatialCollection.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/GeospatialCollection.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/GeospatialCollection.java
deleted file mode 100644
index 6409212..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/GeospatialCollection.java
+++ /dev/null
@@ -1,49 +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.api.domain.geospatial;
-
-import java.util.List;
-
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
-
-/**
- * Wrapper for a collection of geospatials info.
- */
-public class GeospatialCollection extends ComposedGeospatial<Geospatial> {
-
- private static final long serialVersionUID = -9181547636133878977L;
-
- /**
- * Constructor.
- *
- * @param dimension dimension.
- * @param crs crs.
- * @param geospatials geospatials info.
- */
- public GeospatialCollection(final Dimension dimension, final String crs, final List<Geospatial> geospatials) {
- super(dimension, Type.GEOSPATIALCOLLECTION, crs, geospatials);
- }
-
- @Override
- public ODataJClientEdmPrimitiveType getEdmSimpleType() {
- return dimension == Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyCollection
- : ODataJClientEdmPrimitiveType.GeometryCollection;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/LineString.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/LineString.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/LineString.java
deleted file mode 100644
index 474b578..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/LineString.java
+++ /dev/null
@@ -1,39 +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.api.domain.geospatial;
-
-import java.util.List;
-
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
-
-public class LineString extends ComposedGeospatial<Point> {
-
- private static final long serialVersionUID = 3207958185407535907L;
-
- public LineString(final Dimension dimension, final String crs, final List<Point> points) {
- super(dimension, Type.LINESTRING, crs, points);
- }
-
- @Override
- public ODataJClientEdmPrimitiveType getEdmSimpleType() {
- return dimension == Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyLineString
- : ODataJClientEdmPrimitiveType.GeometryLineString;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiLineString.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiLineString.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiLineString.java
deleted file mode 100644
index 3eb0466..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiLineString.java
+++ /dev/null
@@ -1,39 +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.api.domain.geospatial;
-
-import java.util.List;
-
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
-
-public class MultiLineString extends ComposedGeospatial<LineString> {
-
- private static final long serialVersionUID = -5042414471218124125L;
-
- public MultiLineString(final Dimension dimension, final String crs, final List<LineString> lineStrings) {
- super(dimension, Type.MULTILINESTRING, crs, lineStrings);
- }
-
- @Override
- public ODataJClientEdmPrimitiveType getEdmSimpleType() {
- return dimension == Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyMultiLineString
- : ODataJClientEdmPrimitiveType.GeometryMultiLineString;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPoint.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPoint.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPoint.java
deleted file mode 100644
index 8ea16b9..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPoint.java
+++ /dev/null
@@ -1,39 +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.api.domain.geospatial;
-
-import java.util.List;
-
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
-
-public class MultiPoint extends ComposedGeospatial<Point> {
-
- private static final long serialVersionUID = 4951011255142116129L;
-
- public MultiPoint(final Dimension dimension, final String crs, final List<Point> points) {
- super(dimension, Type.MULTIPOINT, crs, points);
- }
-
- @Override
- public ODataJClientEdmPrimitiveType getEdmSimpleType() {
- return dimension == Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyMultiPoint
- : ODataJClientEdmPrimitiveType.GeometryMultiPoint;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPolygon.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPolygon.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPolygon.java
deleted file mode 100644
index ed55b92..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPolygon.java
+++ /dev/null
@@ -1,39 +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.api.domain.geospatial;
-
-import java.util.List;
-
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
-
-public class MultiPolygon extends ComposedGeospatial<Polygon> {
-
- private static final long serialVersionUID = -160184788048512883L;
-
- public MultiPolygon(final Dimension dimension, final String crs, final List<Polygon> polygons) {
- super(dimension, Type.MULTIPOLYGON, crs, polygons);
- }
-
- @Override
- public ODataJClientEdmPrimitiveType getEdmSimpleType() {
- return dimension == Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyMultiPolygon
- : ODataJClientEdmPrimitiveType.GeometryMultiPolygon;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Point.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Point.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Point.java
deleted file mode 100644
index 63b9166..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Point.java
+++ /dev/null
@@ -1,77 +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.api.domain.geospatial;
-
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
-
-public class Point extends Geospatial {
-
- private static final long serialVersionUID = 4917380107331557828L;
-
- /**
- * The X coordinate of the point. In most long/lat systems, this is the longitude.
- */
- private double x;
-
- /**
- * The Y coordinate of the point. In most long/lat systems, this is the latitude.
- */
- private double y;
-
- /**
- * The Z coordinate of the point. In most long/lat systems, this is a radius from the center of the earth, or the
- * height / elevation over the ground.
- */
- private double z;
-
- public Point(final Dimension dimension, final String crs) {
- super(dimension, Type.POINT, crs);
- }
-
- public double getX() {
- return x;
- }
-
- public void setX(double x) {
- this.x = x;
- }
-
- public double getY() {
- return y;
- }
-
- public void setY(double y) {
- this.y = y;
- }
-
- public double getZ() {
- return z;
- }
-
- public void setZ(double z) {
- this.z = z;
- }
-
- @Override
- public ODataJClientEdmPrimitiveType getEdmSimpleType() {
- return dimension == Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyPoint
- : ODataJClientEdmPrimitiveType.GeometryPoint;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Polygon.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Polygon.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Polygon.java
deleted file mode 100644
index 2aa1787..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Polygon.java
+++ /dev/null
@@ -1,74 +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.api.domain.geospatial;
-
-import java.util.List;
-
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
-
-/**
- * Polygon.
- */
-public class Polygon extends Geospatial {
-
- private static final long serialVersionUID = 7797602503445391678L;
-
- final ComposedGeospatial<Point> interior;
-
- final ComposedGeospatial<Point> exterior;
-
- /**
- * Constructor.
- *
- * @param dimension dimension.
- * @param crs crs.
- * @param interior interior points.
- * @param exterior exterior points.
- */
- public Polygon(final Dimension dimension, final String crs, final List<Point> interior, final List<Point> exterior) {
- super(dimension, Type.POLYGON, crs);
- this.interior = new MultiPoint(dimension, crs, interior);
- this.exterior = new MultiPoint(dimension, crs, exterior);
- }
-
- /**
- * Gest interior points.
- *
- * @return interior points.
- */
- public ComposedGeospatial<Point> getInterior() {
- return interior;
- }
-
- /**
- * Gets exterior points.
- *
- * @return exterior points.I
- */
- public ComposedGeospatial<Point> getExterior() {
- return exterior;
- }
-
- @Override
- public ODataJClientEdmPrimitiveType getEdmSimpleType() {
- return dimension == Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyPolygon
- : ODataJClientEdmPrimitiveType.GeometryPolygon;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-api/src/main/java/org/apache/olingo/client/api/utils/GeoUtils.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/utils/GeoUtils.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/utils/GeoUtils.java
deleted file mode 100644
index c4270fe..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/utils/GeoUtils.java
+++ /dev/null
@@ -1,90 +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.api.utils;
-
-import org.apache.olingo.client.api.Constants;
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
-import org.apache.olingo.client.api.domain.geospatial.Geospatial;
-
-public final class GeoUtils {
-
- private GeoUtils() {
- // Empty private constructor for static utility classes
- }
-
- public static Geospatial.Dimension getDimension(final ODataJClientEdmPrimitiveType type) {
- Geospatial.Dimension dimension;
-
- switch (type) {
- case Geography:
- case GeographyCollection:
- case GeographyLineString:
- case GeographyMultiLineString:
- case GeographyPoint:
- case GeographyMultiPoint:
- case GeographyPolygon:
- case GeographyMultiPolygon:
- dimension = Geospatial.Dimension.GEOGRAPHY;
- break;
-
- default:
- dimension = Geospatial.Dimension.GEOMETRY;
- }
-
- return dimension;
- }
-
- public static ODataJClientEdmPrimitiveType getType(final Geospatial.Dimension dimension, final String elementName) {
- ODataJClientEdmPrimitiveType type = null;
-
- if (Constants.ELEM_POINT.equals(elementName)) {
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyPoint
- : ODataJClientEdmPrimitiveType.GeometryPoint;
- } else if (Constants.ELEM_MULTIPOINT.equals(elementName)) {
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyMultiPoint
- : ODataJClientEdmPrimitiveType.GeometryMultiPoint;
- } else if (Constants.ELEM_LINESTRING.equals(elementName)) {
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyLineString
- : ODataJClientEdmPrimitiveType.GeometryLineString;
- } else if (Constants.ELEM_MULTILINESTRING.equals(elementName)) {
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyMultiLineString
- : ODataJClientEdmPrimitiveType.GeometryMultiLineString;
- } else if (Constants.ELEM_POLYGON.equals(elementName)) {
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyPolygon
- : ODataJClientEdmPrimitiveType.GeometryPolygon;
- } else if (Constants.ELEM_MULTIPOLYGON.equals(elementName)) {
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyMultiPolygon
- : ODataJClientEdmPrimitiveType.GeometryMultiPolygon;
- } else if (Constants.ELEM_GEOCOLLECTION.equals(elementName)
- || Constants.ELEM_GEOMEMBERS.equals(elementName)) {
-
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyCollection
- : ODataJClientEdmPrimitiveType.GeometryCollection;
- }
-
- return type;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
index 53e0c05..af0eba6 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/cud/ODataValueUpdateRequestImpl.java
@@ -29,7 +29,6 @@ import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
import org.apache.olingo.client.api.communication.response.ODataValueUpdateResponse;
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
import org.apache.olingo.client.api.domain.ODataPrimitiveValue;
import org.apache.olingo.client.api.domain.ODataValue;
import org.apache.olingo.client.api.format.ODataValueFormat;
@@ -38,6 +37,7 @@ import org.apache.olingo.client.api.http.HttpMethod;
import org.apache.olingo.client.api.utils.URIUtils;
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
/**
* This class implements an OData update entity property value request.
@@ -125,7 +125,7 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
try {
value = new ODataPrimitiveValue.Builder(odataClient).
setType(format == ODataValueFormat.TEXT
- ? ODataJClientEdmPrimitiveType.String : ODataJClientEdmPrimitiveType.Stream).
+ ? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
setText(IOUtils.toString(getRawResponse())).
build();
} catch (IOException e) {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
index 964ec42..7a2ef0c 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataValueRequestImpl.java
@@ -26,11 +26,11 @@ import org.apache.http.client.HttpClient;
import org.apache.olingo.client.api.CommonODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
import org.apache.olingo.client.api.domain.ODataPrimitiveValue;
import org.apache.olingo.client.api.domain.ODataValue;
import org.apache.olingo.client.api.format.ODataValueFormat;
import org.apache.olingo.client.api.http.HttpClientException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
/**
* This class implements an OData entity property value query request.
@@ -93,7 +93,7 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ODataVal
try {
value = new ODataPrimitiveValue.Builder(odataClient).
setType(format == ODataValueFormat.TEXT
- ? ODataJClientEdmPrimitiveType.String : ODataJClientEdmPrimitiveType.Stream).
+ ? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
setText(IOUtils.toString(getRawResponse())).
build();
} catch (IOException e) {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractJsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractJsonDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractJsonDeserializer.java
index d353c07..74b29fb 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractJsonDeserializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractJsonDeserializer.java
@@ -27,23 +27,30 @@ import org.apache.olingo.client.api.Constants;
import org.apache.olingo.client.api.data.CollectionValue;
import org.apache.olingo.client.api.data.ComplexValue;
import org.apache.olingo.client.api.data.Value;
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
-import org.apache.olingo.client.api.domain.ODataJClientEdmType;
import org.apache.olingo.client.api.domain.ODataPropertyType;
+import org.apache.olingo.client.core.edm.EdmTypeInfo;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
- private final JSONGeoValueDeserializer geoDeserializer = new JSONGeoValueDeserializer();
+ private JSONGeoValueDeserializer geoDeserializer;
- protected ODataJClientEdmPrimitiveType getPrimitiveType(final JsonNode node) {
- ODataJClientEdmPrimitiveType result = ODataJClientEdmPrimitiveType.String;
+ private JSONGeoValueDeserializer getGeoDeserializer() {
+ if (geoDeserializer == null) {
+ geoDeserializer = new JSONGeoValueDeserializer(client.getServiceVersion());
+ }
+ return geoDeserializer;
+ }
+
+ protected EdmPrimitiveTypeKind getPrimitiveType(final JsonNode node) {
+ EdmPrimitiveTypeKind result = EdmPrimitiveTypeKind.String;
if (node.isIntegralNumber()) {
- result = ODataJClientEdmPrimitiveType.Int32;
+ result = EdmPrimitiveTypeKind.Int32;
} else if (node.isBoolean()) {
- result = ODataJClientEdmPrimitiveType.Boolean;
+ result = EdmPrimitiveTypeKind.Boolean;
} else if (node.isFloatingPointNumber()) {
- result = ODataJClientEdmPrimitiveType.Double;
+ result = EdmPrimitiveTypeKind.Double;
}
return result;
@@ -65,16 +72,14 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
return type;
}
- private Value fromPrimitive(final JsonNode node, final ODataJClientEdmType typeInfo) {
+ private Value fromPrimitive(final JsonNode node, final EdmTypeInfo typeInfo) {
Value value = null;
if (node.isNull()) {
value = new NullValueImpl();
} else {
- if (typeInfo != null && typeInfo.isGeospatialType()) {
- final ODataJClientEdmPrimitiveType geoType = ODataJClientEdmPrimitiveType.fromValue(typeInfo.getBaseType());
-
- value = new GeospatialValueImpl(this.geoDeserializer.deserialize(node, geoType));
+ if (typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
+ value = new GeospatialValueImpl(getGeoDeserializer().deserialize(node, typeInfo));
} else {
value = new PrimitiveValueImpl(node.asText());
}
@@ -106,12 +111,12 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
return value;
}
- private CollectionValue fromCollection(final Iterator<JsonNode> nodeItor, final ODataJClientEdmType typeInfo) {
+ private CollectionValue fromCollection(final Iterator<JsonNode> nodeItor, final EdmTypeInfo typeInfo) {
final CollectionValueImpl value = new CollectionValueImpl();
- final ODataJClientEdmType type = typeInfo == null
+ final EdmTypeInfo type = typeInfo == null
? null
- : new ODataJClientEdmType(typeInfo.getBaseType());
+ : new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
while (nodeItor.hasNext()) {
final JsonNode child = nodeItor.next();
@@ -130,9 +135,9 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
}
protected void value(final JSONPropertyImpl property, final JsonNode node) {
- final ODataJClientEdmType typeInfo = StringUtils.isBlank(property.getType())
+ final EdmTypeInfo typeInfo = StringUtils.isBlank(property.getType())
? null
- : new ODataJClientEdmType(property.getType());
+ : new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
final ODataPropertyType propType = typeInfo == null
? guessPropertyType(node)
@@ -157,7 +162,7 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
case PRIMITIVE:
if (property.getType() == null) {
- property.setType(getPrimitiveType(node).toString());
+ property.setType(getPrimitiveType(node).getFullQualifiedName().toString());
}
property.setValue(fromPrimitive(node, typeInfo));
break;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractJsonSerializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractJsonSerializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractJsonSerializer.java
index 3398ed9..7427845 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractJsonSerializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AbstractJsonSerializer.java
@@ -26,15 +26,15 @@ import org.apache.commons.lang3.math.NumberUtils;
import org.apache.olingo.client.api.data.CollectionValue;
import org.apache.olingo.client.api.data.Property;
import org.apache.olingo.client.api.data.Value;
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
-import org.apache.olingo.client.api.domain.ODataJClientEdmType;
+import org.apache.olingo.client.core.edm.EdmTypeInfo;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
- private static final ODataJClientEdmPrimitiveType[] NUMBER_TYPES = {
- ODataJClientEdmPrimitiveType.Byte, ODataJClientEdmPrimitiveType.SByte,
- ODataJClientEdmPrimitiveType.Single, ODataJClientEdmPrimitiveType.Double,
- ODataJClientEdmPrimitiveType.Int16, ODataJClientEdmPrimitiveType.Int32, ODataJClientEdmPrimitiveType.Int64
+ private static final EdmPrimitiveTypeKind[] NUMBER_TYPES = {
+ EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte,
+ EdmPrimitiveTypeKind.Single, EdmPrimitiveTypeKind.Double,
+ EdmPrimitiveTypeKind.Int16, EdmPrimitiveTypeKind.Int32, EdmPrimitiveTypeKind.Int64
};
private final JSONGeoValueSerializer geoSerializer = new JSONGeoValueSerializer();
@@ -50,20 +50,20 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
}
private void value(final JsonGenerator jgen, final String type, final Value value) throws IOException {
- final ODataJClientEdmType typeInfo = type == null
+ final EdmTypeInfo typeInfo = type == null
? null
- : new ODataJClientEdmType(type);
+ : new EdmTypeInfo.Builder().setTypeExpression(type).build();
if (value.isNull()) {
jgen.writeNull();
} else if (value.isSimple()) {
final boolean isNumber = typeInfo == null
? NumberUtils.isNumber(value.asSimple().get())
- : ArrayUtils.contains(NUMBER_TYPES, typeInfo.getPrimitiveType());
+ : ArrayUtils.contains(NUMBER_TYPES, typeInfo.getPrimitiveTypeKind());
final boolean isBoolean = typeInfo == null
? (value.asSimple().get().equalsIgnoreCase(Boolean.TRUE.toString())
|| value.asSimple().get().equalsIgnoreCase(Boolean.FALSE.toString()))
- : typeInfo.getPrimitiveType() == ODataJClientEdmPrimitiveType.Boolean;
+ : typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Boolean;
if (isNumber) {
jgen.writeNumber(value.asSimple().get());
@@ -77,7 +77,7 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
geoSerializer.serialize(jgen, value.asGeospatial().get());
jgen.writeEndObject();
} else if (value.isCollection()) {
- collection(jgen, typeInfo == null ? null : typeInfo.getBaseType(), value.asCollection());
+ collection(jgen, typeInfo == null ? null : typeInfo.getFullQualifiedName().toString(), value.asCollection());
} else if (value.isComplex()) {
jgen.writeStartObject();
for (Property property : value.asComplex().get()) {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomGeoValueDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomGeoValueDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomGeoValueDeserializer.java
index e733d2a..20dd164 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomGeoValueDeserializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomGeoValueDeserializer.java
@@ -28,20 +28,21 @@ import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.Constants;
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
-import org.apache.olingo.client.api.domain.geospatial.Geospatial;
-import org.apache.olingo.client.api.domain.geospatial.GeospatialCollection;
-import org.apache.olingo.client.api.domain.geospatial.LineString;
-import org.apache.olingo.client.api.domain.geospatial.MultiLineString;
-import org.apache.olingo.client.api.domain.geospatial.MultiPoint;
-import org.apache.olingo.client.api.domain.geospatial.MultiPolygon;
-import org.apache.olingo.client.api.domain.geospatial.Point;
-import org.apache.olingo.client.api.domain.geospatial.Polygon;
+import org.apache.olingo.client.api.data.GeoUtils;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
+import org.apache.olingo.commons.api.edm.geo.LineString;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
+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;
class AtomGeoValueDeserializer {
private List<Point> points(final XMLEventReader reader, final StartElement start,
- final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
+ final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
final List<Point> result = new ArrayList<Point>();
@@ -67,7 +68,7 @@ class AtomGeoValueDeserializer {
}
private MultiPoint multipoint(final XMLEventReader reader, final StartElement start,
- final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
+ final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
List<Point> points = Collections.<Point>emptyList();
@@ -88,13 +89,13 @@ class AtomGeoValueDeserializer {
}
private LineString lineString(final XMLEventReader reader, final StartElement start,
- final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
+ final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
return new LineString(GeoUtils.getDimension(type), crs, points(reader, start, type, null));
}
private Polygon polygon(final XMLEventReader reader, final StartElement start,
- final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
+ final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
List<Point> extPoints = null;
List<Point> intPoints = null;
@@ -121,7 +122,7 @@ class AtomGeoValueDeserializer {
}
private MultiLineString multiLineString(final XMLEventReader reader, final StartElement start,
- final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
+ final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
final List<LineString> lineStrings = new ArrayList<LineString>();
@@ -142,7 +143,7 @@ class AtomGeoValueDeserializer {
}
private MultiPolygon multiPolygon(final XMLEventReader reader, final StartElement start,
- final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
+ final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
final List<Polygon> polygons = new ArrayList<Polygon>();
@@ -163,7 +164,7 @@ class AtomGeoValueDeserializer {
}
private GeospatialCollection collection(final XMLEventReader reader, final StartElement start,
- final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
+ final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
final List<Geospatial> geospatials = new ArrayList<Geospatial>();
@@ -196,7 +197,7 @@ class AtomGeoValueDeserializer {
}
public Geospatial deserialize(final XMLEventReader reader, final StartElement start,
- final ODataJClientEdmPrimitiveType type) throws XMLStreamException {
+ final EdmPrimitiveTypeKind type) throws XMLStreamException {
String crs = null;
final Attribute srsName = start.getAttributeByName(Constants.QNAME_ATTR_SRSNAME);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomGeoValueSerializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomGeoValueSerializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomGeoValueSerializer.java
index 409ff99..2d69ef7 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomGeoValueSerializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomGeoValueSerializer.java
@@ -25,14 +25,14 @@ import java.util.Iterator;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import org.apache.olingo.client.api.Constants;
-import org.apache.olingo.client.api.domain.geospatial.Geospatial;
-import org.apache.olingo.client.api.domain.geospatial.GeospatialCollection;
-import org.apache.olingo.client.api.domain.geospatial.LineString;
-import org.apache.olingo.client.api.domain.geospatial.MultiLineString;
-import org.apache.olingo.client.api.domain.geospatial.MultiPoint;
-import org.apache.olingo.client.api.domain.geospatial.MultiPolygon;
-import org.apache.olingo.client.api.domain.geospatial.Point;
-import org.apache.olingo.client.api.domain.geospatial.Polygon;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
+import org.apache.olingo.commons.api.edm.geo.LineString;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
+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;
class AtomGeoValueSerializer {
@@ -126,7 +126,7 @@ class AtomGeoValueSerializer {
}
public void serialize(final XMLStreamWriter writer, final Geospatial value) throws XMLStreamException {
- switch (value.getEdmSimpleType()) {
+ switch (value.getEdmPrimitiveTypeKind()) {
case GeographyPoint:
case GeometryPoint:
writer.writeStartElement(Constants.PREFIX_GML, Constants.ELEM_POINT, Constants.NS_GML);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomPropertyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomPropertyDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomPropertyDeserializer.java
index 9a24e38..00e6ac7 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomPropertyDeserializer.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/AtomPropertyDeserializer.java
@@ -28,9 +28,9 @@ import org.apache.olingo.client.api.Constants;
import org.apache.olingo.client.api.data.CollectionValue;
import org.apache.olingo.client.api.data.ComplexValue;
import org.apache.olingo.client.api.data.Value;
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
import org.apache.olingo.client.api.domain.ODataJClientEdmType;
import org.apache.olingo.client.api.domain.ODataPropertyType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
class AtomPropertyDeserializer extends AbstractAtomDealer {
@@ -53,7 +53,7 @@ class AtomPropertyDeserializer extends AbstractAtomDealer {
if (event.isStartElement()) {
if (typeInfo != null && typeInfo.isGeospatialType()) {
- final ODataJClientEdmPrimitiveType geoType = ODataJClientEdmPrimitiveType.fromValue(typeInfo.getBaseType());
+ final EdmPrimitiveTypeKind geoType = EdmPrimitiveTypeKind.valueOfFQN(version, typeInfo.getBaseType());
value = new GeospatialValueImpl(this.geoDeserializer.deserialize(reader, event.asStartElement(), geoType));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-core/src/main/java/org/apache/olingo/client/core/data/GeoUtils.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/GeoUtils.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/GeoUtils.java
deleted file mode 100644
index e0574be..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/GeoUtils.java
+++ /dev/null
@@ -1,90 +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.data;
-
-import org.apache.olingo.client.api.Constants;
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
-import org.apache.olingo.client.api.domain.geospatial.Geospatial;
-
-public final class GeoUtils {
-
- private GeoUtils() {
- // Empty private constructor for static utility classes
- }
-
- public static Geospatial.Dimension getDimension(final ODataJClientEdmPrimitiveType type) {
- Geospatial.Dimension dimension;
-
- switch (type) {
- case Geography:
- case GeographyCollection:
- case GeographyLineString:
- case GeographyMultiLineString:
- case GeographyPoint:
- case GeographyMultiPoint:
- case GeographyPolygon:
- case GeographyMultiPolygon:
- dimension = Geospatial.Dimension.GEOGRAPHY;
- break;
-
- default:
- dimension = Geospatial.Dimension.GEOMETRY;
- }
-
- return dimension;
- }
-
- public static ODataJClientEdmPrimitiveType getType(final Geospatial.Dimension dimension, final String elementName) {
- ODataJClientEdmPrimitiveType type = null;
-
- if (Constants.ELEM_POINT.equals(elementName)) {
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyPoint
- : ODataJClientEdmPrimitiveType.GeometryPoint;
- } else if (Constants.ELEM_MULTIPOINT.equals(elementName)) {
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyMultiPoint
- : ODataJClientEdmPrimitiveType.GeometryMultiPoint;
- } else if (Constants.ELEM_LINESTRING.equals(elementName)) {
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyLineString
- : ODataJClientEdmPrimitiveType.GeometryLineString;
- } else if (Constants.ELEM_MULTILINESTRING.equals(elementName)) {
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyMultiLineString
- : ODataJClientEdmPrimitiveType.GeometryMultiLineString;
- } else if (Constants.ELEM_POLYGON.equals(elementName)) {
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyPolygon
- : ODataJClientEdmPrimitiveType.GeometryPolygon;
- } else if (Constants.ELEM_MULTIPOLYGON.equals(elementName)) {
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyMultiPolygon
- : ODataJClientEdmPrimitiveType.GeometryMultiPolygon;
- } else if (Constants.ELEM_GEOCOLLECTION.equals(elementName)
- || Constants.ELEM_GEOMEMBERS.equals(elementName)) {
-
- type = dimension == Geospatial.Dimension.GEOGRAPHY
- ? ODataJClientEdmPrimitiveType.GeographyCollection
- : ODataJClientEdmPrimitiveType.GeometryCollection;
- }
-
- return type;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-core/src/main/java/org/apache/olingo/client/core/data/GeospatialValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/GeospatialValueImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/GeospatialValueImpl.java
index 040b4f8..fdb0f44 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/GeospatialValueImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/GeospatialValueImpl.java
@@ -19,7 +19,7 @@
package org.apache.olingo.client.core.data;
import org.apache.olingo.client.api.data.GeospatialValue;
-import org.apache.olingo.client.api.domain.geospatial.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
public class GeospatialValueImpl extends AbstractValue implements GeospatialValue {