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/24 10:42:04 UTC
[15/50] [abbrv] [OLINGO-65] Geospatial types implemented,
EdmStream mock implemented with URI as backend, V3 pruned types implemented,
EdmSimpleTypeKind adapted, EdmSimpleTypeFactory introduces
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java
index 641fafa..c5e4aee 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java
@@ -29,21 +29,21 @@ import java.util.List;
import java.util.UUID;
import org.apache.commons.codec.binary.Base64;
import org.apache.olingo.client.api.v3.ODataClient;
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
import org.apache.olingo.client.api.domain.ODataDuration;
import org.apache.olingo.client.api.domain.ODataPrimitiveValue;
import org.apache.olingo.client.api.domain.ODataTimestamp;
import org.apache.olingo.client.api.domain.ODataValue;
-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.core.AbstractTest;
import org.apache.olingo.client.core.ODataClientFactory;
+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;
import org.junit.Test;
public class PrimitiveValueTest extends AbstractTest {
@@ -56,24 +56,24 @@ public class PrimitiveValueTest extends AbstractTest {
@Test
public void manageInt32() {
final int primitive = -10;
- ODataValue value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Int32).
+ ODataValue value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Int32).
setValue(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.Int32.toString(), value.asPrimitive().getTypeName());
+ assertEquals(EdmPrimitiveTypeKind.Int32.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
assertEquals(Integer.valueOf(primitive), value.asPrimitive().<Integer>toCastValue());
- value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Int32).setText("9").build();
+ value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Int32).setText("9").build();
assertEquals("9", value.asPrimitive().<Integer>toCastValue().toString());
}
@Test
public void manageString() {
final String primitive = UUID.randomUUID().toString();
- ODataValue value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.String).
+ ODataValue value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.String).
setText(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.String.toString(), value.asPrimitive().getTypeName());
+ assertEquals(EdmPrimitiveTypeKind.String.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
assertEquals(primitive, value.toString());
- value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.String).
+ value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.String).
setText("1126a28b-a4af-4bbd-bf0a-2b2c22635565").build();
assertEquals("1126a28b-a4af-4bbd-bf0a-2b2c22635565", value.asPrimitive().<String>toCastValue().toString());
}
@@ -81,12 +81,12 @@ public class PrimitiveValueTest extends AbstractTest {
@Test
public void manageDecimal() {
final BigDecimal primitive = new BigDecimal("-79228162514264337593543950335");
- ODataValue value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Decimal).
+ ODataValue value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Decimal).
setValue(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.Decimal.toString(), value.asPrimitive().getTypeName());
+ assertEquals(EdmPrimitiveTypeKind.Decimal.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
assertEquals(primitive, value.asPrimitive().<BigDecimal>toCastValue());
- value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Decimal).
+ value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Decimal).
setText("-79228162514264337593543950335").build();
assertEquals("-79228162514264337593543950335", value.asPrimitive().<BigDecimal>toCastValue().toString());
}
@@ -97,15 +97,15 @@ public class PrimitiveValueTest extends AbstractTest {
final String primitive = "2013-01-10T06:27:51.1667673";
try {
new ODataPrimitiveValue.Builder(ODataClientFactory.getV4()).
- setType(ODataJClientEdmPrimitiveType.DateTime).setText(primitive).build();
+ setType(EdmPrimitiveTypeKind.DateTime).setText(primitive).build();
fail();
} catch (IllegalArgumentException iae) {
// ignore
}
final ODataValue value =
- getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.DateTime).
+ getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.DateTime).
setText(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.DateTime.toString(), value.asPrimitive().getTypeName());
+ assertEquals(EdmPrimitiveTypeKind.DateTime.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
// performed cast to improve the check
assertEquals(primitive, value.asPrimitive().<ODataTimestamp>toCastValue().toString());
}
@@ -116,16 +116,16 @@ public class PrimitiveValueTest extends AbstractTest {
final String primitive = "-P9DT51M10.5063807S";
try {
new ODataPrimitiveValue.Builder(ODataClientFactory.getV4()).
- setType(ODataJClientEdmPrimitiveType.Time).setText(primitive).build();
+ setType(EdmPrimitiveTypeKind.Time).setText(primitive).build();
fail();
} catch (IllegalArgumentException iae) {
// ignore
}
final ODataValue value =
- getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Time).
+ getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Time).
setText(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.Time.toString(), value.asPrimitive().getTypeName());
+ assertEquals(EdmPrimitiveTypeKind.Time.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
// performed cast to improve the check
assertEquals(primitive, value.asPrimitive().<ODataDuration>toCastValue().toString());
}
@@ -134,8 +134,9 @@ public class PrimitiveValueTest extends AbstractTest {
public void manageDateTimeOffset() {
final String primitive = "2013-01-10T02:00:00";
final ODataValue value = getClient().getPrimitiveValueBuilder().
- setType(ODataJClientEdmPrimitiveType.DateTimeOffset).setText(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.DateTimeOffset.toString(), value.asPrimitive().getTypeName());
+ setType(EdmPrimitiveTypeKind.DateTimeOffset).setText(primitive).build();
+ assertEquals(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName().toString(),
+ value.asPrimitive().getTypeName());
// performed cast to improve the check
assertEquals(primitive, value.asPrimitive().<ODataTimestamp>toCastValue().toString());
}
@@ -143,12 +144,12 @@ public class PrimitiveValueTest extends AbstractTest {
@Test
public void manageGuid() {
final UUID primitive = UUID.fromString("1126a28b-a4af-4bbd-bf0a-2b2c22635565");
- ODataValue value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Guid).
+ ODataValue value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Guid).
setValue(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.Guid.toString(), value.asPrimitive().getTypeName());
+ assertEquals(EdmPrimitiveTypeKind.Guid.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
assertEquals(primitive, value.asPrimitive().<UUID>toCastValue());
- value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Guid).
+ value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Guid).
setText("1126a28b-a4af-4bbd-bf0a-2b2c22635565").build();
assertEquals("1126a28b-a4af-4bbd-bf0a-2b2c22635565", value.asPrimitive().<UUID>toCastValue().toString());
}
@@ -156,14 +157,14 @@ public class PrimitiveValueTest extends AbstractTest {
@Test
public void manageBinary() {
final byte[] primitive = UUID.randomUUID().toString().getBytes();
- ODataValue value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Binary).
+ ODataValue value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Binary).
setValue(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.Binary.toString(), value.asPrimitive().getTypeName());
+ assertEquals(EdmPrimitiveTypeKind.Binary.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
assertEquals(
Base64.encodeBase64String(primitive),
Base64.encodeBase64String(value.asPrimitive().<byte[]>toCastValue()));
- value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Binary).
+ value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Binary).
setText(Base64.encodeBase64String("primitive".getBytes())).build();
assertEquals("primitive", new String(value.asPrimitive().<byte[]>toCastValue()));
}
@@ -175,7 +176,7 @@ public class PrimitiveValueTest extends AbstractTest {
primitive.setY(173.334);
try {
- getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyPoint).
+ getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.GeographyPoint).
setValue(primitive).build();
fail();
} catch (IllegalArgumentException iae) {
@@ -183,10 +184,11 @@ public class PrimitiveValueTest extends AbstractTest {
}
final ODataValue value =
- getClient().getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyPoint).
+ getClient().getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeographyPoint).
setValue(primitive).
build();
- assertEquals(ODataJClientEdmPrimitiveType.GeographyPoint.toString(), value.asPrimitive().getTypeName());
+ assertEquals(EdmPrimitiveTypeKind.GeographyPoint.getFullQualifiedName().toString(),
+ value.asPrimitive().getTypeName());
assertEquals(Double.valueOf(primitive.getX()), Double.valueOf(value.asPrimitive().<Point>toCastValue().getX()));
assertEquals(Double.valueOf(primitive.getY()), Double.valueOf(value.asPrimitive().<Point>toCastValue().getY()));
}
@@ -217,8 +219,9 @@ public class PrimitiveValueTest extends AbstractTest {
final LineString primitive = new LineString(Geospatial.Dimension.GEOGRAPHY, null, points);
final ODataValue value = getClient().getGeospatialValueBuilder().
- setType(ODataJClientEdmPrimitiveType.GeographyLineString).setValue(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.GeographyLineString.toString(), value.asPrimitive().getTypeName());
+ setType(EdmPrimitiveTypeKind.GeographyLineString).setValue(primitive).build();
+ assertEquals(EdmPrimitiveTypeKind.GeographyLineString.getFullQualifiedName().toString(),
+ value.asPrimitive().getTypeName());
final Iterator<Point> iter = value.asPrimitive().<LineString>toCastValue().iterator();
@@ -242,8 +245,9 @@ public class PrimitiveValueTest extends AbstractTest {
final MultiPoint primitive = new MultiPoint(Geospatial.Dimension.GEOMETRY, null, points);
final ODataValue value = getClient().getGeospatialValueBuilder().
- setType(ODataJClientEdmPrimitiveType.GeometryMultiPoint).setValue(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.GeometryMultiPoint.toString(), value.asPrimitive().getTypeName());
+ setType(EdmPrimitiveTypeKind.GeometryMultiPoint).setValue(primitive).build();
+ assertEquals(EdmPrimitiveTypeKind.GeometryMultiPoint.getFullQualifiedName().toString(),
+ value.asPrimitive().getTypeName());
final Iterator<Point> iter = value.asPrimitive().<MultiPoint>toCastValue().iterator();
point = iter.next();
@@ -302,9 +306,10 @@ public class PrimitiveValueTest extends AbstractTest {
final MultiLineString primitive = new MultiLineString(Geospatial.Dimension.GEOMETRY, null, lines);
final ODataValue value =
- getClient().getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeometryMultiLineString).
+ getClient().getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeometryMultiLineString).
setValue(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.GeometryMultiLineString.toString(), value.asPrimitive().getTypeName());
+ assertEquals(EdmPrimitiveTypeKind.GeometryMultiLineString.getFullQualifiedName().toString(),
+ value.asPrimitive().getTypeName());
final Iterator<LineString> lineIter = value.asPrimitive().<MultiLineString>toCastValue().iterator();
@@ -355,9 +360,10 @@ public class PrimitiveValueTest extends AbstractTest {
final Polygon primitive = new Polygon(Geospatial.Dimension.GEOGRAPHY, null, interior, exterior);
final ODataValue value =
- getClient().getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyPolygon).
+ getClient().getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeographyPolygon).
setValue(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.GeographyPolygon.toString(), value.asPrimitive().getTypeName());
+ assertEquals(EdmPrimitiveTypeKind.GeographyPolygon.getFullQualifiedName().toString(),
+ value.asPrimitive().getTypeName());
assertTrue(value.asPrimitive().<Polygon>toCastValue().getInterior().isEmpty());
final Iterator<Point> iter = value.asPrimitive().<Polygon>toCastValue().getExterior().iterator();
@@ -461,9 +467,10 @@ public class PrimitiveValueTest extends AbstractTest {
final MultiPolygon primitive = new MultiPolygon(Geospatial.Dimension.GEOMETRY, null, polygons);
final ODataValue value =
- getClient().getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeometryMultiPolygon).
+ getClient().getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeometryMultiPolygon).
setValue(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.GeometryMultiPolygon.toString(), value.asPrimitive().getTypeName());
+ assertEquals(EdmPrimitiveTypeKind.GeometryMultiPolygon.getFullQualifiedName().toString(),
+ value.asPrimitive().getTypeName());
final Iterator<Polygon> iter = value.asPrimitive().<MultiPolygon>toCastValue().iterator();
@@ -507,9 +514,10 @@ public class PrimitiveValueTest extends AbstractTest {
final GeospatialCollection primitive = new GeospatialCollection(Geospatial.Dimension.GEOMETRY, null, collection);
final ODataValue value =
- getClient().getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeometryCollection).
+ getClient().getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeometryCollection).
setValue(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.GeometryCollection.toString(), value.asPrimitive().getTypeName());
+ assertEquals(EdmPrimitiveTypeKind.GeometryCollection.getFullQualifiedName().toString(),
+ value.asPrimitive().getTypeName());
final Iterator<Geospatial> iter = value.asPrimitive().<GeospatialCollection>toCastValue().iterator();
iter.next();
@@ -539,9 +547,10 @@ public class PrimitiveValueTest extends AbstractTest {
final GeospatialCollection primitive = new GeospatialCollection(Geospatial.Dimension.GEOGRAPHY, null, collection);
final ODataValue value =
- getClient().getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyCollection).
+ getClient().getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeographyCollection).
setValue(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.GeographyCollection.toString(), value.asPrimitive().getTypeName());
+ assertEquals(EdmPrimitiveTypeKind.GeographyCollection.getFullQualifiedName().toString(),
+ value.asPrimitive().getTypeName());
final Iterator<Geospatial> iter = value.asPrimitive().<GeospatialCollection>toCastValue().iterator();
iter.next();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/FilterFactoryTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/FilterFactoryTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/FilterFactoryTest.java
index 3d74f7b..fd2a696 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/FilterFactoryTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/FilterFactoryTest.java
@@ -27,6 +27,7 @@ import org.apache.olingo.client.core.edm.EdmEnumTypeImpl;
import org.apache.olingo.client.core.edm.xml.v4.EnumTypeImpl;
import org.apache.olingo.commons.api.edm.EdmEnumType;
import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
import static org.junit.Assert.assertEquals;
@@ -49,7 +50,7 @@ public class FilterFactoryTest extends AbstractTest {
@Test
public void has() {
- final EdmEnumType pattern = new EdmEnumTypeImpl(
+ final EdmEnumType pattern = new EdmEnumTypeImpl(ODataServiceVersion.V40,
null, new FullQualifiedName("Sales", "Pattern"), new EnumTypeImpl());
final URIFilter filter = getFilterFactory().has(getFilterArgFactory().property("style"), pattern, "Yellow");
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/MetadataTest.java
----------------------------------------------------------------------
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 afeba92..fb2ba5c 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
@@ -50,9 +50,10 @@ import org.apache.olingo.commons.api.edm.EdmEnumType;
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.FullQualifiedName;
import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
import org.junit.Test;
public class MetadataTest extends AbstractTest {
@@ -82,7 +83,7 @@ public class MetadataTest extends AbstractTest {
assertNotNull(responseStatus);
assertTrue(responseStatus.getNavigationPropertyNames().isEmpty());
assertEquals("Recipient", responseStatus.getBaseType().getName());
- assertEquals(EdmPrimitiveTypeKind.DateTimeOffset.getEdmPrimitiveTypeInstance(),
+ assertEquals(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.DateTimeOffset),
responseStatus.getProperty("Time").getType());
// 3. Entity
@@ -106,8 +107,8 @@ public class MetadataTest extends AbstractTest {
assertNotNull(move);
assertTrue(move.isBound());
assertEquals(2, move.getParameterNames().size());
- assertEquals(
- EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance(), move.getParameter("DestinationId").getType());
+ assertEquals(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.String),
+ move.getParameter("DestinationId").getType());
// 5. EntityContainer
final EdmEntityContainer container = edm.getEntityContainer(
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PrimitiveValueTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PrimitiveValueTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PrimitiveValueTest.java
index c146fee..d72861d 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PrimitiveValueTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v4/PrimitiveValueTest.java
@@ -22,13 +22,13 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.apache.olingo.client.api.v4.ODataClient;
-import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
import org.apache.olingo.client.api.domain.ODataDuration;
import org.apache.olingo.client.api.domain.ODataPrimitiveValue;
import org.apache.olingo.client.api.domain.ODataTimestamp;
import org.apache.olingo.client.api.domain.ODataValue;
import org.apache.olingo.client.core.AbstractTest;
import org.apache.olingo.client.core.ODataClientFactory;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
import org.junit.Test;
public class PrimitiveValueTest extends AbstractTest {
@@ -44,15 +44,15 @@ public class PrimitiveValueTest extends AbstractTest {
final String primitive = "-P9DT51M12.5063807S";
try {
new ODataPrimitiveValue.Builder(ODataClientFactory.getV3()).
- setType(ODataJClientEdmPrimitiveType.TimeOfDay).setText(primitive).build();
+ setType(EdmPrimitiveTypeKind.TimeOfDay).setText(primitive).build();
fail();
} catch (IllegalArgumentException iae) {
// ignore
}
final ODataValue value = getClient().getPrimitiveValueBuilder().
- setType(ODataJClientEdmPrimitiveType.TimeOfDay).setText(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.TimeOfDay.toString(), value.asPrimitive().getTypeName());
+ setType(EdmPrimitiveTypeKind.TimeOfDay).setText(primitive).build();
+ assertEquals(EdmPrimitiveTypeKind.TimeOfDay.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
// performed cast to improve the check
assertEquals(primitive, value.asPrimitive().<ODataDuration>toCastValue().toString());
}
@@ -63,15 +63,15 @@ public class PrimitiveValueTest extends AbstractTest {
final String primitive = "2013-01-10";
try {
new ODataPrimitiveValue.Builder(ODataClientFactory.getV3()).
- setType(ODataJClientEdmPrimitiveType.Date).setText(primitive).build();
+ setType(EdmPrimitiveTypeKind.Date).setText(primitive).build();
fail();
} catch (IllegalArgumentException iae) {
// ignore
}
final ODataValue value = getClient().getPrimitiveValueBuilder().
- setType(ODataJClientEdmPrimitiveType.Date).setText(primitive).build();
- assertEquals(ODataJClientEdmPrimitiveType.Date.toString(), value.asPrimitive().getTypeName());
+ setType(EdmPrimitiveTypeKind.Date).setText(primitive).build();
+ assertEquals(EdmPrimitiveTypeKind.Date.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
// performed cast to improve the check
assertEquals(primitive, value.asPrimitive().<ODataTimestamp>toCastValue().toString());
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-api/pom.xml
----------------------------------------------------------------------
diff --git a/lib/commons-api/pom.xml b/lib/commons-api/pom.xml
index 42c42b4..e398eaa 100644
--- a/lib/commons-api/pom.xml
+++ b/lib/commons-api/pom.xml
@@ -33,4 +33,12 @@
<version>0.1.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ </dependencies>
+
</project>
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmGeospatialType.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmGeospatialType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmGeospatialType.java
new file mode 100644
index 0000000..898b6b2
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmGeospatialType.java
@@ -0,0 +1,34 @@
+/*
+ * 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.geo.Geospatial;
+
+public interface EdmGeospatialType extends EdmType {
+
+ String EDM_NAMESPACE = EdmPrimitiveType.EDM_NAMESPACE;
+
+ /**
+ * Returns the Java type for this EDM geospatial type.
+ *
+ * @return the geospatial Java type
+ */
+ Class<? extends Geospatial> getJavaType();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmPrimitiveTypeKind.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmPrimitiveTypeKind.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmPrimitiveTypeKind.java
new file mode 100644
index 0000000..069d9e5
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmPrimitiveTypeKind.java
@@ -0,0 +1,139 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+
+public enum EdmPrimitiveTypeKind {
+
+ Binary,
+ Boolean,
+ Byte,
+ SByte,
+ Date(new ODataServiceVersion[] {ODataServiceVersion.V40}),
+ DateTime(new ODataServiceVersion[] {ODataServiceVersion.V30}),
+ DateTimeOffset,
+ Time(new ODataServiceVersion[] {ODataServiceVersion.V30}),
+ TimeOfDay(new ODataServiceVersion[] {ODataServiceVersion.V40}),
+ Duration(new ODataServiceVersion[] {ODataServiceVersion.V40}),
+ Decimal,
+ Single,
+ Double,
+ Guid,
+ Int16,
+ Int32,
+ Int64,
+ String,
+ Stream,
+ Geography,
+ GeographyPoint,
+ GeographyLineString,
+ GeographyPolygon,
+ GeographyMultiPoint,
+ GeographyMultiLineString,
+ GeographyMultiPolygon,
+ GeographyCollection,
+ Geometry,
+ GeometryPoint,
+ GeometryLineString,
+ GeometryPolygon,
+ GeometryMultiPoint,
+ GeometryMultiLineString,
+ GeometryMultiPolygon,
+ GeometryCollection;
+
+ private final List<ODataServiceVersion> versions;
+
+ EdmPrimitiveTypeKind() {
+ this.versions = Collections.unmodifiableList(
+ Arrays.asList(new ODataServiceVersion[] {ODataServiceVersion.V30, ODataServiceVersion.V40}));
+ }
+
+ EdmPrimitiveTypeKind(final ODataServiceVersion[] versions) {
+ this.versions = Collections.unmodifiableList(Arrays.asList(versions.clone()));
+ }
+
+ public List<ODataServiceVersion> getSupportedVersions() {
+ return this.versions;
+ }
+
+ /**
+ * Checks if is a geospatial type.
+ *
+ * @return <tt>true</tt> if is geospatial type; <tt>false</tt> otherwise.
+ */
+ public boolean isGeospatial() {
+ return name().startsWith("Geo");
+ }
+
+ /**
+ * Returns the {@link FullQualifiedName} for this type kind.
+ *
+ * @return {@link FullQualifiedName}
+ */
+ public FullQualifiedName getFullQualifiedName() {
+ return new FullQualifiedName(EdmPrimitiveType.EDM_NAMESPACE, toString());
+ }
+
+ public static EdmPrimitiveTypeKind valueOf(final ODataServiceVersion version, final String name) {
+ final EdmPrimitiveTypeKind kind = valueOf(name);
+ if (!kind.versions.contains(version)) {
+ throw new IllegalArgumentException(kind + " not allowed in " + version);
+ }
+ return kind;
+ }
+
+ /**
+ * Gets <tt>EdmPrimitiveTypeKind</tt> from a full-qualified type name, for the given OData protocol version.
+ *
+ * @param version OData protocol version.
+ * @param fqn full-qualified type name.
+ * @return <tt>EdmPrimitiveTypeKind</tt> object.
+ */
+ public static EdmPrimitiveTypeKind valueOfFQN(final ODataServiceVersion version, final FullQualifiedName fqn) {
+ return valueOfFQN(version, fqn.toString());
+ }
+
+ /**
+ * Gets <tt>EdmPrimitiveTypeKind</tt> from a full type expression (as <tt>Edm.Int32</tt>), for the given OData
+ * protocol version.
+ *
+ * @param version OData protocol version.
+ * @param fqn string value type.
+ * @return <tt>EdmPrimitiveTypeKind</tt> object.
+ */
+ public static EdmPrimitiveTypeKind valueOfFQN(final ODataServiceVersion version, final String fqn) {
+ if (version == null) {
+ throw new IllegalArgumentException("No OData protocol version provided");
+ }
+ if (!fqn.startsWith(EdmPrimitiveType.EDM_NAMESPACE + ".")) {
+ throw new IllegalArgumentException(fqn + " does not look like an Edm primitive type");
+ }
+
+ final EdmPrimitiveTypeKind kind = valueOf(fqn.substring(4));
+ if (!kind.versions.contains(version)) {
+ throw new IllegalArgumentException(kind + " not allowed in " + version);
+ }
+ return kind;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..82a13fe
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.api.edm.geo;
+
+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/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..62de5ec
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java
@@ -0,0 +1,169 @@
+/*
+ * 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 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.commons.api.edm.EdmPrimitiveTypeKind;
+
+/**
+ * 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 EdmPrimitiveTypeKind getEdmPrimitiveTypeKind();
+
+ /**
+ * {@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/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..b3e3f9f
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java
@@ -0,0 +1,48 @@
+/*
+ * 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 java.util.List;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+
+/**
+ * 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 EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyCollection
+ : EdmPrimitiveTypeKind.GeometryCollection;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..297a962
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.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.geo;
+
+import java.util.List;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+
+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 EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyLineString
+ : EdmPrimitiveTypeKind.GeometryLineString;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..2f98d63
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.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.commons.api.edm.geo;
+
+import java.util.List;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+
+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 EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyMultiLineString
+ : EdmPrimitiveTypeKind.GeometryMultiLineString;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..999f24b
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.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.commons.api.edm.geo;
+
+import java.util.List;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+
+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 EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyMultiPoint
+ : EdmPrimitiveTypeKind.GeometryMultiPoint;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..fd0fdae
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.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.geo;
+
+import java.util.List;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+
+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 EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyMultiPolygon
+ : EdmPrimitiveTypeKind.GeometryMultiPolygon;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..a9e0c39
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java
@@ -0,0 +1,77 @@
+/*
+ * 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.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+
+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 EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyPoint
+ : EdmPrimitiveTypeKind.GeometryPoint;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..2501d4e
--- /dev/null
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.api.edm.geo;
+
+import java.util.List;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+
+/**
+ * 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 EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
+ return dimension == Dimension.GEOGRAPHY
+ ? EdmPrimitiveTypeKind.GeographyPolygon
+ : EdmPrimitiveTypeKind.GeometryPolygon;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmParameter.java
----------------------------------------------------------------------
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 b1d551b..09bd8ce 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
@@ -23,9 +23,10 @@ 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.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
public abstract class AbstractEdmParameter extends EdmElementImpl implements EdmParameter {
@@ -43,7 +44,7 @@ public abstract class AbstractEdmParameter extends EdmElementImpl implements Edm
if (typeImpl == null) {
if (EdmPrimitiveType.EDM_NAMESPACE.equals(paramType.getNamespace())) {
try {
- typeImpl = EdmPrimitiveTypeKind.valueOf(paramType.getName()).getEdmPrimitiveTypeInstance();
+ typeImpl = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.valueOf(paramType.getName()));
} catch (IllegalArgumentException e) {
throw new EdmException("Cannot find type with name: " + paramType, e);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmProperty.java
----------------------------------------------------------------------
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 11e0365..c54239f 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
@@ -21,10 +21,11 @@ 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.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
public abstract class AbstractEdmProperty extends EdmElementImpl implements EdmProperty {
@@ -47,7 +48,7 @@ public abstract class AbstractEdmProperty extends EdmElementImpl implements EdmP
final FullQualifiedName typeName = getTypeFQN();
if (isPrimitive()) {
try {
- propertyType = EdmPrimitiveTypeKind.valueOf(typeName.getName()).getEdmPrimitiveTypeInstance();
+ propertyType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.valueOf(typeName.getName()));
} catch (IllegalArgumentException e) {
throw new EdmException("Cannot find type with name: " + typeName, e);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmReturnType.java
----------------------------------------------------------------------
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 a6a6a84..532f666 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
@@ -21,10 +21,11 @@ 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.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
public abstract class AbstractEdmReturnType implements EdmReturnType {
@@ -44,7 +45,7 @@ public abstract class AbstractEdmReturnType implements EdmReturnType {
if (typeImpl == null) {
if (EdmPrimitiveType.EDM_NAMESPACE.equals(typeName.getNamespace())) {
try {
- typeImpl = EdmPrimitiveTypeKind.valueOf(typeName.getName()).getEdmPrimitiveTypeInstance();
+ typeImpl = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.valueOf(typeName.getName()));
} catch (IllegalArgumentException e) {
throw new EdmException("Cannot find type with name: " + typeName, e);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractEdmGeospatialType.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractEdmGeospatialType.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractEdmGeospatialType.java
new file mode 100644
index 0000000..8e5cb6f
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractEdmGeospatialType.java
@@ -0,0 +1,76 @@
+/*
+ * 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.primitivetype;
+
+import org.apache.olingo.commons.api.edm.EdmGeospatialType;
+import org.apache.olingo.commons.api.edm.FullQualifiedName;
+import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
+
+public abstract class AbstractEdmGeospatialType<T extends Geospatial> implements EdmGeospatialType {
+
+ private final Class<T> reference;
+
+ protected final Dimension dimension;
+
+ protected final Type type;
+
+ protected AbstractEdmGeospatialType(final Class<T> reference, final Dimension dimension, final Type type) {
+ this.reference = reference;
+ this.dimension = dimension;
+ this.type = type;
+ }
+
+ @Override
+ public Class<? extends Geospatial> getJavaType() {
+ return reference;
+ }
+
+ @Override
+ public String getNamespace() {
+ return EDM_NAMESPACE;
+ }
+
+ @Override
+ public String getName() {
+ return getClass().getSimpleName().substring(3);
+ }
+
+ @Override
+ public EdmTypeKind getKind() {
+ return EdmTypeKind.PRIMITIVE;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ return this == obj || obj != null && getClass() == obj.getClass();
+ }
+
+ @Override
+ public int hashCode() {
+ return getClass().hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return new FullQualifiedName(getNamespace(), getName()).getFullQualifiedNameAsString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDate.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDate.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDate.java
index 5f141c0..9aa660e 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDate.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDate.java
@@ -64,10 +64,11 @@ public final class EdmDate extends SingletonPrimitiveType {
try {
return EdmDateTimeOffset.convertDateTime(dateTimeValue, returnType);
} catch (final IllegalArgumentException e) {
- throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value), e");
+ throw new EdmPrimitiveTypeException(
+ "EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e);
} catch (final ClassCastException e) {
throw new EdmPrimitiveTypeException(
- "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType), e");
+ "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)", e);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTime.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTime.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTime.java
new file mode 100644
index 0000000..e061388
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTime.java
@@ -0,0 +1,124 @@
+/*
+ * 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.primitivetype;
+
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+
+/**
+ * Implementation of the EDM primitive type DateTime.
+ */
+public final class EdmDateTime extends SingletonPrimitiveType {
+
+ public static final ThreadLocal<SimpleDateFormat> DATE_FORMAT = new ThreadLocal<SimpleDateFormat>() {
+ @Override
+ protected SimpleDateFormat initialValue() {
+ return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+ }
+ };
+
+ private static final EdmDateTime INSTANCE = new EdmDateTime();
+
+ public static EdmDateTime getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public Class<?> getDefaultType() {
+ return Calendar.class;
+ }
+
+ @Override
+ protected <T> T internalValueOfString(final String value,
+ final Boolean isNullable, final Integer maxLength, final Integer precision,
+ final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
+
+ Calendar calendar = null;
+ Timestamp timestamp = null;
+
+ final String[] dateParts = value.split("\\.");
+ try {
+ final Date date = DATE_FORMAT.get().parse(dateParts[0]);
+ if (dateParts.length > 1) {
+ int idx = dateParts[1].indexOf('+');
+ if (idx == -1) {
+ idx = dateParts[1].indexOf('-');
+ }
+ if (idx == -1) {
+ calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ calendar.setTime(date);
+
+ timestamp = new Timestamp(calendar.getTimeInMillis());
+ timestamp.setNanos(Integer.parseInt(dateParts[1]));
+ } else {
+ calendar = Calendar.getInstance(TimeZone.getTimeZone(dateParts[1].substring(idx)));
+ calendar.setTime(date);
+
+ timestamp = new Timestamp(calendar.getTimeInMillis());
+ timestamp.setNanos(Integer.parseInt(dateParts[1].substring(0, idx)));
+ }
+ } else {
+ timestamp = new Timestamp(date.getTime());
+ }
+ } catch (Exception e) {
+ throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e);
+ }
+
+ if (returnType.isAssignableFrom(Calendar.class)) {
+ return returnType.cast(calendar);
+ } else if (returnType.isAssignableFrom(Timestamp.class)) {
+ return returnType.cast(timestamp);
+ } else {
+ throw new EdmPrimitiveTypeException(
+ "EdmPrimitiveTypeException.LITERAL_UNCONVERTIBLE_TO_VALUE_TYPE.addContent(value, returnType)");
+ }
+ }
+
+ @Override
+ protected <T> String internalValueToString(final T value,
+ final Boolean isNullable, final Integer maxLength, final Integer precision,
+ final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+ if (value instanceof Calendar) {
+ final Calendar calendar = (Calendar) value;
+
+ final StringBuilder formatted = new StringBuilder().append(DATE_FORMAT.get().format(calendar.getTime()));
+ formatted.append(calendar.getTimeZone());
+
+ return formatted.toString();
+ } else if (value instanceof Timestamp) {
+ final Timestamp timestamp = (Timestamp) value;
+
+ final StringBuilder formatted = new StringBuilder().append(DATE_FORMAT.get().format(timestamp));
+ if (timestamp.getNanos() > 0) {
+ formatted.append('.').append(String.valueOf(timestamp.getNanos()));
+ }
+
+ return formatted.toString();
+ } else {
+ throw new EdmPrimitiveTypeException(
+ "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeography.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeography.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeography.java
new file mode 100644
index 0000000..f5951cb
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeography.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.commons.core.edm.primitivetype;
+
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
+
+public final class EdmGeography extends AbstractEdmGeospatialType<Geospatial> {
+
+ private static final EdmGeography INSTANCE = new EdmGeography();
+
+ public static EdmGeography getInstance() {
+ return INSTANCE;
+ }
+
+ public EdmGeography() {
+ super(Geospatial.class, Dimension.GEOGRAPHY, null);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyCollection.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyCollection.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyCollection.java
new file mode 100644
index 0000000..aab7210
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyCollection.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.primitivetype;
+
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
+import org.apache.olingo.commons.api.edm.geo.Point;
+
+public final class EdmGeographyCollection extends AbstractEdmGeospatialType<Point> {
+
+ private static final EdmGeographyCollection INSTANCE = new EdmGeographyCollection();
+
+ public static EdmGeographyCollection getInstance() {
+ return INSTANCE;
+ }
+
+ public EdmGeographyCollection() {
+ super(Point.class, Dimension.GEOGRAPHY, Type.GEOSPATIALCOLLECTION);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyLineString.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyLineString.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyLineString.java
new file mode 100644
index 0000000..23c92cc
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyLineString.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.primitivetype;
+
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
+import org.apache.olingo.commons.api.edm.geo.Point;
+
+public final class EdmGeographyLineString extends AbstractEdmGeospatialType<Point> {
+
+ private static final EdmGeographyLineString INSTANCE = new EdmGeographyLineString();
+
+ public static EdmGeographyLineString getInstance() {
+ return INSTANCE;
+ }
+
+ public EdmGeographyLineString() {
+ super(Point.class, Dimension.GEOGRAPHY, Type.LINESTRING);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiLineString.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiLineString.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiLineString.java
new file mode 100644
index 0000000..9b5901d
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiLineString.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.primitivetype;
+
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
+import org.apache.olingo.commons.api.edm.geo.Point;
+
+public final class EdmGeographyMultiLineString extends AbstractEdmGeospatialType<Point> {
+
+ private static final EdmGeographyMultiLineString INSTANCE = new EdmGeographyMultiLineString();
+
+ public static EdmGeographyMultiLineString getInstance() {
+ return INSTANCE;
+ }
+
+ public EdmGeographyMultiLineString() {
+ super(Point.class, Dimension.GEOGRAPHY, Type.MULTILINESTRING);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPoint.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPoint.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPoint.java
new file mode 100644
index 0000000..db66041
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPoint.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.primitivetype;
+
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
+import org.apache.olingo.commons.api.edm.geo.Point;
+
+public final class EdmGeographyMultiPoint extends AbstractEdmGeospatialType<Point> {
+
+ private static final EdmGeographyMultiPoint INSTANCE = new EdmGeographyMultiPoint();
+
+ public static EdmGeographyMultiPoint getInstance() {
+ return INSTANCE;
+ }
+
+ public EdmGeographyMultiPoint() {
+ super(Point.class, Dimension.GEOGRAPHY, Type.MULTIPOINT);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPolygon.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPolygon.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPolygon.java
new file mode 100644
index 0000000..4b53a30
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPolygon.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.primitivetype;
+
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
+import org.apache.olingo.commons.api.edm.geo.Point;
+
+public final class EdmGeographyMultiPolygon extends AbstractEdmGeospatialType<Point> {
+
+ private static final EdmGeographyMultiPolygon INSTANCE = new EdmGeographyMultiPolygon();
+
+ public static EdmGeographyMultiPolygon getInstance() {
+ return INSTANCE;
+ }
+
+ public EdmGeographyMultiPolygon() {
+ super(Point.class, Dimension.GEOGRAPHY, Type.MULTIPOLYGON);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPoint.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPoint.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPoint.java
new file mode 100644
index 0000000..61abce3
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPoint.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.primitivetype;
+
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
+import org.apache.olingo.commons.api.edm.geo.Point;
+
+public final class EdmGeographyPoint extends AbstractEdmGeospatialType<Point> {
+
+ private static final EdmGeographyPoint INSTANCE = new EdmGeographyPoint();
+
+ public static EdmGeographyPoint getInstance() {
+ return INSTANCE;
+ }
+
+ public EdmGeographyPoint() {
+ super(Point.class, Dimension.GEOGRAPHY, Type.POINT);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata4/blob/559698d4/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPolygon.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPolygon.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPolygon.java
new file mode 100644
index 0000000..a7a1a6c
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPolygon.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.primitivetype;
+
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
+import org.apache.olingo.commons.api.edm.geo.Point;
+
+public final class EdmGeographyPolygon extends AbstractEdmGeospatialType<Point> {
+
+ private static final EdmGeographyPolygon INSTANCE = new EdmGeographyPolygon();
+
+ public static EdmGeographyPolygon getInstance() {
+ return INSTANCE;
+ }
+
+ public EdmGeographyPolygon() {
+ super(Point.class, Dimension.GEOGRAPHY, Type.POLYGON);
+ }
+
+}