diff --git a/lib/client-api/pom.xml b/lib/client-api/pom.xml index e506a97b2..eb3f9e3b9 100644 --- a/lib/client-api/pom.xml +++ b/lib/client-api/pom.xml @@ -45,10 +45,6 @@ commons-io commons-io - - org.apache.commons - commons-lang3 - org.apache.httpcomponents httpclient 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/data/GeoUtils.java similarity index 63% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/utils/GeoUtils.java rename to lib/client-api/src/main/java/org/apache/olingo/client/api/data/GeoUtils.java index c4270fea0..083b4e059 100644 --- 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/data/GeoUtils.java @@ -16,11 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.utils; +package org.apache.olingo.client.api.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; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.geo.Geospatial; public final class GeoUtils { @@ -28,7 +28,7 @@ public final class GeoUtils { // Empty private constructor for static utility classes } - public static Geospatial.Dimension getDimension(final ODataJClientEdmPrimitiveType type) { + public static Geospatial.Dimension getDimension(final EdmPrimitiveTypeKind type) { Geospatial.Dimension dimension; switch (type) { @@ -50,39 +50,39 @@ public final class GeoUtils { return dimension; } - public static ODataJClientEdmPrimitiveType getType(final Geospatial.Dimension dimension, final String elementName) { - ODataJClientEdmPrimitiveType type = null; + 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 - ? ODataJClientEdmPrimitiveType.GeographyPoint - : ODataJClientEdmPrimitiveType.GeometryPoint; + ? EdmPrimitiveTypeKind.GeographyPoint + : EdmPrimitiveTypeKind.GeometryPoint; } else if (Constants.ELEM_MULTIPOINT.equals(elementName)) { type = dimension == Geospatial.Dimension.GEOGRAPHY - ? ODataJClientEdmPrimitiveType.GeographyMultiPoint - : ODataJClientEdmPrimitiveType.GeometryMultiPoint; + ? EdmPrimitiveTypeKind.GeographyMultiPoint + : EdmPrimitiveTypeKind.GeometryMultiPoint; } else if (Constants.ELEM_LINESTRING.equals(elementName)) { type = dimension == Geospatial.Dimension.GEOGRAPHY - ? ODataJClientEdmPrimitiveType.GeographyLineString - : ODataJClientEdmPrimitiveType.GeometryLineString; + ? EdmPrimitiveTypeKind.GeographyLineString + : EdmPrimitiveTypeKind.GeometryLineString; } else if (Constants.ELEM_MULTILINESTRING.equals(elementName)) { type = dimension == Geospatial.Dimension.GEOGRAPHY - ? ODataJClientEdmPrimitiveType.GeographyMultiLineString - : ODataJClientEdmPrimitiveType.GeometryMultiLineString; + ? EdmPrimitiveTypeKind.GeographyMultiLineString + : EdmPrimitiveTypeKind.GeometryMultiLineString; } else if (Constants.ELEM_POLYGON.equals(elementName)) { type = dimension == Geospatial.Dimension.GEOGRAPHY - ? ODataJClientEdmPrimitiveType.GeographyPolygon - : ODataJClientEdmPrimitiveType.GeometryPolygon; + ? EdmPrimitiveTypeKind.GeographyPolygon + : EdmPrimitiveTypeKind.GeometryPolygon; } else if (Constants.ELEM_MULTIPOLYGON.equals(elementName)) { type = dimension == Geospatial.Dimension.GEOGRAPHY - ? ODataJClientEdmPrimitiveType.GeographyMultiPolygon - : ODataJClientEdmPrimitiveType.GeometryMultiPolygon; + ? EdmPrimitiveTypeKind.GeographyMultiPolygon + : EdmPrimitiveTypeKind.GeometryMultiPolygon; } else if (Constants.ELEM_GEOCOLLECTION.equals(elementName) || Constants.ELEM_GEOMEMBERS.equals(elementName)) { type = dimension == Geospatial.Dimension.GEOGRAPHY - ? ODataJClientEdmPrimitiveType.GeographyCollection - : ODataJClientEdmPrimitiveType.GeometryCollection; + ? EdmPrimitiveTypeKind.GeographyCollection + : EdmPrimitiveTypeKind.GeometryCollection; } return type; 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 b0deea4bd..c5d4d2aeb 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 { 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 93c4cfbdd..bd9658763 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; 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 4b1deccba..5ea5edfa9 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. */ @@ -256,25 +256,6 @@ public enum ODataJClientEdmPrimitiveType { throw new IllegalArgumentException(value); } - /** - * Gets EdmSimpleType from object instance. - * - * @param workingVersion OData version. - * @param obj object. - * @return EdmSimpleType 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. * 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 df69d1f35..21d85620c 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.toCastValue()); break; @@ -295,15 +357,15 @@ public class ODataPrimitiveValue extends ODataValue { break; case Decimal: - this.text = new DecimalFormat(this.type.pattern()).format(this.toCastValue()); + this.text = new DecimalFormat("#.#######################").format(this.toCastValue()); break; case Single: - this.text = new DecimalFormat(this.type.pattern()).format(this.toCastValue()); + this.text = new DecimalFormat("#.#######E0").format(this.toCastValue()); break; case Double: - this.text = new DecimalFormat(this.type.pattern()).format(this.toCastValue()); + this.text = new DecimalFormat("#.#######################E0").format(this.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 toCastValue() { - return (T) type.javaType().cast(toValue()); + return (T) getJavaType().cast(toValue()); } } 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 a1f3e3d7b..3f3eb9c6d 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; 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 53e0c0540..af0eba616 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 extends ODataJacksonDeserializer { - 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 extends ODataJacksonDeserializer { 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 extends ODataJacksonDeserializer { return value; } - private CollectionValue fromCollection(final Iterator nodeItor, final ODataJClientEdmType typeInfo) { + private CollectionValue fromCollection(final Iterator 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 extends ODataJacksonDeserializer { } 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 extends ODataJacksonDeserializer { case PRIMITIVE: if (property.getType() == null) { - property.setType(getPrimitiveType(node).toString()); + property.setType(getPrimitiveType(node).getFullQualifiedName().toString()); } property.setValue(fromPrimitive(node, typeInfo)); break; 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 3398ed95b..742784538 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 extends ODataJacksonSerializer { - 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 extends ODataJacksonSerializer { } 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 extends ODataJacksonSerializer { 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()) { 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 e733d2a44..20dd1646a 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 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 result = new ArrayList(); @@ -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 points = Collections.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 extPoints = null; List 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 lineStrings = new ArrayList(); @@ -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 polygons = new ArrayList(); @@ -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 geospatials = new ArrayList(); @@ -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); 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 409ff994b..2d69ef787 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); 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 9a24e38d3..00e6ac7e9 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)); } } 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 e0574be0a..000000000 --- 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; - } -} 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 040b4f8c4..fdb0f445d 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 { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONGeoValueDeserializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONGeoValueDeserializer.java index 1e92babb4..eebfef3bb 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONGeoValueDeserializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONGeoValueDeserializer.java @@ -24,19 +24,28 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; 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.client.core.edm.EdmTypeInfo; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; +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; class JSONGeoValueDeserializer { - private Point point(final Iterator itor, final ODataJClientEdmPrimitiveType type, final String crs) { + private final ODataServiceVersion version; + + public JSONGeoValueDeserializer(final ODataServiceVersion version) { + this.version = version; + } + + private Point point(final Iterator itor, final EdmPrimitiveTypeKind type, final String crs) { Point point = null; if (itor.hasNext()) { @@ -48,7 +57,7 @@ class JSONGeoValueDeserializer { return point; } - private MultiPoint multipoint(final Iterator itor, final ODataJClientEdmPrimitiveType type, + private MultiPoint multipoint(final Iterator itor, final EdmPrimitiveTypeKind type, final String crs) { MultiPoint multiPoint = null; @@ -67,7 +76,7 @@ class JSONGeoValueDeserializer { return multiPoint; } - private LineString lineString(final Iterator itor, final ODataJClientEdmPrimitiveType type, + private LineString lineString(final Iterator itor, final EdmPrimitiveTypeKind type, final String crs) { LineString lineString = null; @@ -86,7 +95,7 @@ class JSONGeoValueDeserializer { return lineString; } - private MultiLineString multiLineString(final Iterator itor, final ODataJClientEdmPrimitiveType type, + private MultiLineString multiLineString(final Iterator itor, final EdmPrimitiveTypeKind type, final String crs) { MultiLineString multiLineString = null; @@ -105,7 +114,7 @@ class JSONGeoValueDeserializer { return multiLineString; } - private Polygon polygon(final Iterator itor, final ODataJClientEdmPrimitiveType type, + private Polygon polygon(final Iterator itor, final EdmPrimitiveTypeKind type, final String crs) { List extPoints = null; @@ -135,7 +144,7 @@ class JSONGeoValueDeserializer { return new Polygon(GeoUtils.getDimension(type), crs, intPoints, extPoints); } - private MultiPolygon multiPolygon(final Iterator itor, final ODataJClientEdmPrimitiveType type, + private MultiPolygon multiPolygon(final Iterator itor, final EdmPrimitiveTypeKind type, final String crs) { MultiPolygon multiPolygon = null; @@ -154,7 +163,7 @@ class JSONGeoValueDeserializer { return multiPolygon; } - private GeospatialCollection collection(final Iterator itor, final ODataJClientEdmPrimitiveType type, + private GeospatialCollection collection(final Iterator itor, final EdmPrimitiveTypeKind type, final String crs) { GeospatialCollection collection = null; @@ -166,16 +175,16 @@ class JSONGeoValueDeserializer { final JsonNode geo = itor.next(); final String collItemType = geo.get(Constants.ATTR_TYPE).asText(); final String callAsType; - if (ODataJClientEdmPrimitiveType.GeographyCollection.name().equals(collItemType) - || ODataJClientEdmPrimitiveType.GeometryCollection.name().equals(collItemType)) { + if (EdmPrimitiveTypeKind.GeographyCollection.name().equals(collItemType) + || EdmPrimitiveTypeKind.GeometryCollection.name().equals(collItemType)) { callAsType = collItemType; } else { - callAsType = (type == ODataJClientEdmPrimitiveType.GeographyCollection ? "Geography" : "Geometry") + callAsType = (type == EdmPrimitiveTypeKind.GeographyCollection ? "Geography" : "Geometry") + collItemType; } - geospatials.add(deserialize(geo, ODataJClientEdmPrimitiveType.valueOf(callAsType))); + geospatials.add(deserialize(geo, new EdmTypeInfo.Builder().setTypeExpression(callAsType).build())); } collection = new GeospatialCollection(GeoUtils.getDimension(type), crs, geospatials); @@ -186,9 +195,10 @@ class JSONGeoValueDeserializer { return collection; } - public Geospatial deserialize(final JsonNode node, final ODataJClientEdmPrimitiveType type) { - final ODataJClientEdmPrimitiveType actualType; - if ((type == ODataJClientEdmPrimitiveType.Geography || type == ODataJClientEdmPrimitiveType.Geometry) + public Geospatial deserialize(final JsonNode node, final EdmTypeInfo typeInfo) { + final EdmPrimitiveTypeKind actualType; + if ((typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Geography + || typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Geometry) && node.has(Constants.ATTR_TYPE)) { String nodeType = node.get(Constants.ATTR_TYPE).asText(); @@ -196,9 +206,9 @@ class JSONGeoValueDeserializer { final int yIdx = nodeType.indexOf('y'); nodeType = nodeType.substring(yIdx + 1); } - actualType = ODataJClientEdmPrimitiveType.fromValue(type.toString() + nodeType); + actualType = EdmPrimitiveTypeKind.valueOfFQN(version, typeInfo.getFullQualifiedName().toString() + nodeType); } else { - actualType = type; + actualType = typeInfo.getPrimitiveTypeKind(); } final Iterator cooItor = node.has(Constants.JSON_COORDINATES) @@ -214,37 +224,37 @@ class JSONGeoValueDeserializer { switch (actualType) { case GeographyPoint: case GeometryPoint: - value = point(cooItor, type, crs); + value = point(cooItor, actualType, crs); break; case GeographyMultiPoint: case GeometryMultiPoint: - value = multipoint(cooItor, type, crs); + value = multipoint(cooItor, actualType, crs); break; case GeographyLineString: case GeometryLineString: - value = lineString(cooItor, type, crs); + value = lineString(cooItor, actualType, crs); break; case GeographyMultiLineString: case GeometryMultiLineString: - value = multiLineString(cooItor, type, crs); + value = multiLineString(cooItor, actualType, crs); break; case GeographyPolygon: case GeometryPolygon: - value = polygon(cooItor, type, crs); + value = polygon(cooItor, actualType, crs); break; case GeographyMultiPolygon: case GeometryMultiPolygon: - value = multiPolygon(cooItor, type, crs); + value = multiPolygon(cooItor, actualType, crs); break; case GeographyCollection: case GeometryCollection: - value = collection(node.get(Constants.JSON_GEOMETRIES).elements(), type, crs); + value = collection(node.get(Constants.JSON_GEOMETRIES).elements(), actualType, crs); break; default: diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONGeoValueSerializer.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONGeoValueSerializer.java index 207ded63c..2e692ae06 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONGeoValueSerializer.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/data/JSONGeoValueSerializer.java @@ -22,16 +22,16 @@ import com.fasterxml.jackson.core.JsonGenerator; import java.io.IOException; import java.util.Iterator; import org.apache.olingo.client.api.Constants; -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; -import org.apache.olingo.client.api.domain.geospatial.ComposedGeospatial; -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.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.geo.ComposedGeospatial; +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 JSONGeoValueSerializer { @@ -106,17 +106,17 @@ class JSONGeoValueSerializer { } public void serialize(final JsonGenerator jgen, final Geospatial value) throws IOException { - if (value.getEdmSimpleType().equals(ODataJClientEdmPrimitiveType.GeographyCollection) - || value.getEdmSimpleType().equals(ODataJClientEdmPrimitiveType.GeometryCollection)) { + if (value.getEdmPrimitiveTypeKind().equals(EdmPrimitiveTypeKind.GeographyCollection) + || value.getEdmPrimitiveTypeKind().equals(EdmPrimitiveTypeKind.GeometryCollection)) { - jgen.writeStringField(Constants.ATTR_TYPE, ODataJClientEdmPrimitiveType.GeometryCollection.name()); + jgen.writeStringField(Constants.ATTR_TYPE, EdmPrimitiveTypeKind.GeometryCollection.name()); } else { - final int yIdx = value.getEdmSimpleType().name().indexOf('y'); - final String itemType = value.getEdmSimpleType().name().substring(yIdx + 1); + final int yIdx = value.getEdmPrimitiveTypeKind().name().indexOf('y'); + final String itemType = value.getEdmPrimitiveTypeKind().name().substring(yIdx + 1); jgen.writeStringField(Constants.ATTR_TYPE, itemType); } - switch (value.getEdmSimpleType()) { + switch (value.getEdmPrimitiveTypeKind()) { case GeographyPoint: case GeometryPoint: jgen.writeArrayFieldStart(Constants.JSON_COORDINATES); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java index da6f0fd10..948a930c9 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmClientImpl.java @@ -56,15 +56,19 @@ import org.apache.olingo.commons.api.edm.EdmSchema; import org.apache.olingo.commons.api.edm.EdmServiceMetadata; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; import org.apache.olingo.commons.core.edm.AbstractEdmImpl; public class EdmClientImpl extends AbstractEdmImpl { + private final ODataServiceVersion version; + private final XMLMetadata xmlMetadata; private final EdmServiceMetadata serviceMetadata; - public EdmClientImpl(final XMLMetadata xmlMetadata) { + public EdmClientImpl(final ODataServiceVersion version, final XMLMetadata xmlMetadata) { + this.version = version; this.xmlMetadata = xmlMetadata; this.serviceMetadata = AbstractEdmServiceMetadataImpl.getInstance(xmlMetadata); } @@ -115,7 +119,7 @@ public class EdmClientImpl extends AbstractEdmImpl { if (schema != null) { final EnumType xmlEnumType = schema.getEnumType(enumName.getName()); if (xmlEnumType != null) { - result = new EdmEnumTypeImpl(this, enumName, xmlEnumType); + result = new EdmEnumTypeImpl(version, this, enumName, xmlEnumType); } } @@ -131,7 +135,7 @@ public class EdmClientImpl extends AbstractEdmImpl { final TypeDefinition xmlTypeDefinition = ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema). getTypeDefinition(typeDefinitionName.getName()); if (xmlTypeDefinition != null) { - result = new EdmTypeDefinitionImpl(this, typeDefinitionName, xmlTypeDefinition); + result = new EdmTypeDefinitionImpl(version, this, typeDefinitionName, xmlTypeDefinition); } } else { throw new UnsupportedInV3Exception(); @@ -378,7 +382,7 @@ public class EdmClientImpl extends AbstractEdmImpl { protected List createSchemas() { final List schemas = new ArrayList(); for (Schema schema : xmlMetadata.getSchemas()) { - schemas.add(new EdmSchemaImpl(this, xmlMetadata, schema)); + schemas.add(new EdmSchemaImpl(version, this, xmlMetadata, schema)); } return schemas; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java index 10a1b2e92..05cfa27be 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmEnumTypeImpl.java @@ -27,7 +27,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveType; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.AbstractEdmEnumType; import org.apache.olingo.commons.core.edm.EdmMemberImpl; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; import java.util.ArrayList; import java.util.Collection; @@ -37,6 +36,9 @@ import java.util.List; import java.util.Map; import org.apache.commons.lang3.ArrayUtils; import org.apache.olingo.commons.api.edm.EdmException; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; public class EdmEnumTypeImpl extends AbstractEdmEnumType implements EdmEnumType { @@ -54,14 +56,16 @@ public class EdmEnumTypeImpl extends AbstractEdmEnumType implements EdmEnumType private final Map members; - public EdmEnumTypeImpl(final Edm edm, final FullQualifiedName fqn, final EnumType xmlEnumType) { + public EdmEnumTypeImpl(final ODataServiceVersion version, final Edm edm, final FullQualifiedName fqn, + final EnumType xmlEnumType) { + super(edm, fqn, xmlEnumType.isFlags()); if (xmlEnumType.getUnderlyingType() == null) { - this.underlyingType = EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance(); + this.underlyingType = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int32); } else { - this.underlyingType = EdmPrimitiveTypeKind.valueOfFQN(xmlEnumType.getUnderlyingType()). - getEdmPrimitiveTypeInstance(); + this.underlyingType = EdmPrimitiveTypeFactory.getNonGeoInstance( + EdmPrimitiveTypeKind.valueOfFQN(version, xmlEnumType.getUnderlyingType())); if (!ArrayUtils.contains(VALID_UNDERLYING_TYPES, this.underlyingType.getKind())) { throw new EdmException("Not allowed as underlying type: " + this.underlyingType.getKind()); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java index 58c9496ab..ffe41cde4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmSchemaImpl.java @@ -41,18 +41,25 @@ import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; import org.apache.olingo.commons.core.edm.AbstractEdmSchemaImpl; public class EdmSchemaImpl extends AbstractEdmSchemaImpl { + private final ODataServiceVersion version; + private final Edm edm; private final XMLMetadata xmlMetadata; private final Schema schema; - public EdmSchemaImpl(Edm edm, XMLMetadata xmlMetadata, Schema schema) { + public EdmSchemaImpl(final ODataServiceVersion version, final Edm edm, + final XMLMetadata xmlMetadata, final Schema schema) { + super(schema.getNamespace(), schema.getAlias()); + + this.version = version; this.edm = edm; this.xmlMetadata = xmlMetadata; this.schema = schema; @@ -77,7 +84,8 @@ public class EdmSchemaImpl extends AbstractEdmSchemaImpl { ((org.apache.olingo.client.api.edm.xml.v4.Schema) schema).getTypeDefinitions(); if (providerTypeDefinitions != null) { for (TypeDefinition def : providerTypeDefinitions) { - typeDefinitions.add(new EdmTypeDefinitionImpl(edm, new FullQualifiedName("namespace", def.getName()), def)); + typeDefinitions.add( + new EdmTypeDefinitionImpl(version, edm, new FullQualifiedName("namespace", def.getName()), def)); } } } @@ -90,7 +98,8 @@ public class EdmSchemaImpl extends AbstractEdmSchemaImpl { final List providerEnumTypes = schema.getEnumTypes(); if (providerEnumTypes != null) { for (EnumType enumType : providerEnumTypes) { - enumTypes.add(new EdmEnumTypeImpl(edm, new FullQualifiedName(namespace, enumType.getName()), enumType)); + enumTypes.add( + new EdmEnumTypeImpl(version, edm, new FullQualifiedName(namespace, enumType.getName()), enumType)); } } return enumTypes; diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java index cf2ad47e7..199d61e72 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeDefinitionImpl.java @@ -22,10 +22,12 @@ import org.apache.olingo.client.api.edm.xml.v4.TypeDefinition; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; +import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; import org.apache.olingo.commons.core.edm.AbstractEdmTypeDefinition; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements EdmTypeDefinition { @@ -33,14 +35,14 @@ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements private EdmPrimitiveType edmPrimitiveTypeInstance; - public EdmTypeDefinitionImpl(final Edm edm, final FullQualifiedName typeDefinitionName, - final TypeDefinition typeDefinition) { + public EdmTypeDefinitionImpl(final ODataServiceVersion version, final Edm edm, + final FullQualifiedName typeDefinitionName, final TypeDefinition typeDefinition) { super(edm, typeDefinitionName); this.typeDefinition = typeDefinition; try { - edmPrimitiveTypeInstance = EdmPrimitiveTypeKind.valueOfFQN(typeDefinition.getUnderlyingType()). - getEdmPrimitiveTypeInstance(); + this.edmPrimitiveTypeInstance = EdmPrimitiveTypeFactory.getNonGeoInstance( + EdmPrimitiveTypeKind.valueOfFQN(version, typeDefinition.getUnderlyingType())); } catch (IllegalArgumentException e) { throw new EdmException("Invalid underlying type: " + typeDefinition.getUnderlyingType(), e); } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java index 3ed86dc0d..461e829a8 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/EdmTypeInfo.java @@ -18,15 +18,13 @@ */ package org.apache.olingo.client.core.edm; -import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.StringUtils; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmEnumType; -import org.apache.olingo.commons.api.edm.EdmPrimitiveType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -72,9 +70,7 @@ public class EdmTypeInfo { private final FullQualifiedName fullQualifiedName; - private EdmPrimitiveType primitiveType; - - private final boolean geospatialType; + private EdmPrimitiveTypeKind primitiveType; private EdmEnumType enumType; @@ -114,14 +110,10 @@ public class EdmTypeInfo { this.fullQualifiedName = new FullQualifiedName(namespace, typeName); try { - this.primitiveType = EdmPrimitiveTypeKind.valueOf(this.fullQualifiedName.getName()). - getEdmPrimitiveTypeInstance(); + this.primitiveType = EdmPrimitiveTypeKind.valueOf(this.fullQualifiedName.getName()); } catch (IllegalArgumentException e) { LOG.debug("{} does not appear to refer to an Edm primitive type", this.fullQualifiedName); } - // TODO - OLINGO-65 implement Geospatial types! - this.geospatialType = this.fullQualifiedName.getNamespace().equals(EdmPrimitiveType.EDM_NAMESPACE) - && this.fullQualifiedName.getName().startsWith("Geo"); if (this.primitiveType == null && this.edm != null) { this.enumType = this.edm.getEnumType(this.fullQualifiedName); if (this.enumType == null) { @@ -146,21 +138,13 @@ public class EdmTypeInfo { } public boolean isPrimitiveType() { - return this.primitiveType != null || isGeospatialType(); + return this.primitiveType != null; } - public EdmPrimitiveType getPrimitiveType() { + public EdmPrimitiveTypeKind getPrimitiveTypeKind() { return primitiveType; } - public boolean isGeospatialType() { - return geospatialType; - } - - public Object getGeospatialType() { - throw new NotImplementedException("Geospatial types missing"); - } - public boolean isEnumType() { return this.enumType != null; } diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataBinder.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataBinder.java index 69a278fad..b185d5da7 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataBinder.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataBinder.java @@ -38,7 +38,6 @@ import org.apache.olingo.client.api.domain.ODataEntitySet; import org.apache.olingo.client.api.domain.ODataGeospatialValue; import org.apache.olingo.client.api.domain.ODataInlineEntity; import org.apache.olingo.client.api.domain.ODataInlineEntitySet; -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; import org.apache.olingo.client.api.domain.ODataLink; import org.apache.olingo.client.api.domain.ODataOperation; import org.apache.olingo.client.api.domain.ODataPrimitiveValue; @@ -55,6 +54,7 @@ import org.apache.olingo.client.core.data.JSONPropertyImpl; import org.apache.olingo.client.core.data.LinkImpl; import org.apache.olingo.client.core.data.NullValueImpl; import org.apache.olingo.client.core.data.PrimitiveValueImpl; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -378,14 +378,14 @@ public abstract class AbstractODataBinder implements CommonODataBinder { value = new ODataPrimitiveValue.Builder(client).setText(resource.getValue().asSimple().get()). setType(resource.getType() == null ? null - : ODataJClientEdmPrimitiveType.fromValue(resource.getType())).build(); + : EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), resource.getType())).build(); } else if (resource.getValue().isGeospatial()) { value = new ODataGeospatialValue.Builder(client).setValue(resource.getValue().asGeospatial().get()). setType(resource.getType() == null - || ODataJClientEdmPrimitiveType.Geography.toString().equals(resource.getType()) - || ODataJClientEdmPrimitiveType.Geometry.toString().equals(resource.getType()) + || EdmPrimitiveTypeKind.Geography.getFullQualifiedName().toString().equals(resource.getType()) + || EdmPrimitiveTypeKind.Geometry.getFullQualifiedName().toString().equals(resource.getType()) ? null - : ODataJClientEdmPrimitiveType.fromValue(resource.getType())).build(); + : EdmPrimitiveTypeKind.valueOfFQN(client.getServiceVersion(), resource.getType())).build(); } else if (resource.getValue().isComplex()) { value = new ODataComplexValue(resource.getType()); diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataReader.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataReader.java index cfe08ecc3..596e8fdcd 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataReader.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/AbstractODataReader.java @@ -26,7 +26,6 @@ import org.apache.olingo.client.api.data.Property; import org.apache.olingo.client.api.domain.ODataEntity; import org.apache.olingo.client.api.domain.ODataEntitySet; import org.apache.olingo.client.api.domain.ODataEntitySetIterator; -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; import org.apache.olingo.client.api.domain.ODataProperty; import org.apache.olingo.client.api.domain.ODataServiceDocument; import org.apache.olingo.client.api.domain.ODataValue; @@ -35,6 +34,7 @@ import org.apache.olingo.client.api.format.ODataFormat; import org.apache.olingo.client.api.format.ODataPubFormat; import org.apache.olingo.client.api.format.ODataValueFormat; import org.apache.olingo.client.api.op.CommonODataReader; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -91,7 +91,7 @@ public abstract class AbstractODataReader implements CommonODataReader { } else if (ODataValue.class.isAssignableFrom(reference)) { res = client.getPrimitiveValueBuilder(). setType(ODataValueFormat.fromString(format) == ODataValueFormat.TEXT - ? ODataJClientEdmPrimitiveType.String : ODataJClientEdmPrimitiveType.Stream). + ? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream). setText(IOUtils.toString(src)). build(); } else if (XMLMetadata.class.isAssignableFrom(reference)) { diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java index 54e4ad0df..6649a3900 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v3/ODataReaderImpl.java @@ -40,7 +40,7 @@ public class ODataReaderImpl extends AbstractODataReader implements ODataReader @Override public Edm readMetadata(final InputStream input) { - return new EdmClientImpl(client.getDeserializer().toMetadata(input)); + return new EdmClientImpl(client.getServiceVersion(), client.getDeserializer().toMetadata(input)); } @Override diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java index 5a64d63e9..8324ccac4 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/op/impl/v4/ODataReaderImpl.java @@ -38,7 +38,7 @@ public class ODataReaderImpl extends AbstractODataReader implements ODataReader @Override public Edm readMetadata(final InputStream input) { - return new EdmClientImpl(client.getDeserializer().toMetadata(input)); + return new EdmClientImpl(client.getServiceVersion(), client.getDeserializer().toMetadata(input)); } @Override diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractPrimitiveTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractPrimitiveTest.java index a40da387e..5326602e6 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractPrimitiveTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractPrimitiveTest.java @@ -32,22 +32,22 @@ import java.util.List; import java.util.UUID; import org.apache.commons.codec.binary.Base64; import org.apache.olingo.client.api.Constants; -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; import org.apache.olingo.client.api.domain.ODataGeospatialValue; import org.apache.olingo.client.api.domain.ODataPrimitiveValue; import org.apache.olingo.client.api.domain.ODataProperty; import org.apache.olingo.client.api.domain.ODataTimestamp; -import org.apache.olingo.client.api.domain.geospatial.Geospatial; -import org.apache.olingo.client.api.domain.geospatial.Geospatial.Dimension; -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.format.ODataFormat; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; 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.Geospatial.Dimension; +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; public abstract class AbstractPrimitiveTest extends AbstractTest { @@ -66,13 +66,15 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { protected ODataPrimitiveValue writePrimitiveValue(final ODataPrimitiveValue value) { final ODataPrimitiveValue newValue; - if (ODataJClientEdmPrimitiveType.isGeospatial(value.getTypeName())) { + final EdmPrimitiveTypeKind typeKind = EdmPrimitiveTypeKind.valueOfFQN( + getClient().getServiceVersion(), value.getTypeName()); + if (typeKind.isGeospatial()) { newValue = getClient().getGeospatialValueBuilder(). - setType(ODataJClientEdmPrimitiveType.fromValue(value.getTypeName())). + setType(EdmPrimitiveTypeKind.valueOfFQN(getVersion(), value.getTypeName())). setValue(((ODataGeospatialValue) value).getGeospatial()).build(); } else { newValue = getClient().getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.fromValue(value.getTypeName())). + setType(EdmPrimitiveTypeKind.valueOfFQN(getClient().getServiceVersion(), value.getTypeName())). setValue(value.toValue()).build(); } @@ -95,7 +97,9 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { final ODataPrimitiveValue value = readPrimitiveValue(getClass().getResourceAsStream(getFilename(entity, propertyName))); - if (ODataJClientEdmPrimitiveType.isGeospatial(value.getTypeName())) { + final EdmPrimitiveTypeKind typeKind = EdmPrimitiveTypeKind.valueOfFQN( + getClient().getServiceVersion(), value.getTypeName()); + if (typeKind.isGeospatial()) { assertEquals(value.toValue(), writePrimitiveValue(value).toValue()); } else { assertEquals(value.toString(), writePrimitiveValue(value).toString()); @@ -106,7 +110,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { protected void int32(final String entity, final String propertyName, final int check) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); - assertEquals(ODataJClientEdmPrimitiveType.Int32.toString(), opv.getTypeName()); + assertEquals(EdmPrimitiveTypeKind.Int32.toString(), opv.getTypeName()); final Integer value = opv.toCastValue(); assertNotNull(value); @@ -115,7 +119,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { protected void string(final String entity, final String propertyName, final String check) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); - assertEquals(ODataJClientEdmPrimitiveType.String.toString(), opv.getTypeName()); + assertEquals(EdmPrimitiveTypeKind.String.toString(), opv.getTypeName()); final String value = opv.toCastValue(); assertNotNull(value); @@ -126,7 +130,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { protected void decimal(final String entity, final String propertyName, final BigDecimal check) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); - assertEquals(ODataJClientEdmPrimitiveType.Decimal.toString(), opv.getTypeName()); + assertEquals(EdmPrimitiveTypeKind.Decimal.toString(), opv.getTypeName()); final BigDecimal value = opv.toCastValue(); assertNotNull(value); @@ -135,7 +139,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { protected void datetime(final String entity, final String propertyName, final String check) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); - assertEquals(ODataJClientEdmPrimitiveType.DateTime.toString(), opv.getTypeName()); + assertEquals(EdmPrimitiveTypeKind.DateTime.toString(), opv.getTypeName()); final ODataTimestamp value = opv.toCastValue(); assertNotNull(value); @@ -144,7 +148,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { protected void guid(final String entity, final String propertyName, final String check) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); - assertEquals(ODataJClientEdmPrimitiveType.Guid.toString(), opv.getTypeName()); + assertEquals(EdmPrimitiveTypeKind.Guid.toString(), opv.getTypeName()); final UUID value = opv.toCastValue(); assertNotNull(value); @@ -153,7 +157,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { protected void binary(final String entity, final String propertyName) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); - assertEquals(ODataJClientEdmPrimitiveType.Binary.toString(), opv.getTypeName()); + assertEquals(EdmPrimitiveTypeKind.Binary.toString(), opv.getTypeName()); final byte[] value = opv.toCastValue(); assertNotNull(value); @@ -171,7 +175,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { final String entity, final String propertyName, final Point expectedValues, - final ODataJClientEdmPrimitiveType expectedType, + final EdmPrimitiveTypeKind expectedType, final Dimension expectedDimension) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); @@ -202,7 +206,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { final String entity, final String propertyName, final List check, - final ODataJClientEdmPrimitiveType expectedType, + final EdmPrimitiveTypeKind expectedType, final Dimension expectedDimension) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); @@ -219,7 +223,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { final String entity, final String propertyName, final List check, - final ODataJClientEdmPrimitiveType expectedType, + final EdmPrimitiveTypeKind expectedType, final Dimension expectedDimension) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); @@ -246,7 +250,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { final String entity, final String propertyName, final List> check, - final ODataJClientEdmPrimitiveType expectedType, + final EdmPrimitiveTypeKind expectedType, final Dimension expectedDimension) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); @@ -301,7 +305,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { final String propertyName, final List checkInterior, final List checkExterior, - final ODataJClientEdmPrimitiveType expectedType, + final EdmPrimitiveTypeKind expectedType, final Dimension expectedDimension) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); @@ -321,7 +325,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { final String propertyName, final List> checkInterior, final List> checkExterior, - final ODataJClientEdmPrimitiveType expectedType, + final EdmPrimitiveTypeKind expectedType, final Dimension expectedDimension) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); @@ -344,7 +348,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { protected void geomCollection( final String entity, final String propertyName, - final ODataJClientEdmPrimitiveType expectedType, + final EdmPrimitiveTypeKind expectedType, final Dimension expectedDimension) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); @@ -373,7 +377,7 @@ public abstract class AbstractPrimitiveTest extends AbstractTest { protected void geogCollection( final String entity, final String propertyName, - final ODataJClientEdmPrimitiveType expectedType, + final EdmPrimitiveTypeKind expectedType, final Dimension expectedDimension) { final ODataPrimitiveValue opv = readPrimitiveValue(entity, propertyName); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractPropertyTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractPropertyTest.java index 48e17e73a..e9b97f21e 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractPropertyTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/AbstractPropertyTest.java @@ -27,13 +27,13 @@ import java.io.IOException; import java.io.InputStream; import java.util.Iterator; import org.apache.commons.io.IOUtils; -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; import org.apache.olingo.client.api.domain.ODataCollectionValue; import org.apache.olingo.client.api.domain.ODataComplexValue; import org.apache.olingo.client.api.domain.ODataPrimitiveValue; import org.apache.olingo.client.api.domain.ODataProperty; import org.apache.olingo.client.api.domain.ODataValue; import org.apache.olingo.client.api.format.ODataFormat; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; import org.junit.Test; @@ -52,7 +52,7 @@ public abstract class AbstractPropertyTest extends AbstractTest { + "Customer_-10_CustomerId_value.txt"); final ODataValue value = getClient().getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.String). + setType(EdmPrimitiveTypeKind.String). setText(IOUtils.toString(input)). build(); assertNotNull(value); @@ -76,7 +76,8 @@ public abstract class AbstractPropertyTest extends AbstractTest { } else { // This is needed because type information gets lost with JSON serialization final ODataPrimitiveValue typedValue = getClient().getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.fromValue(property.getPrimitiveValue().getTypeName())). + setType(EdmPrimitiveTypeKind.valueOfFQN( + getClient().getServiceVersion(), property.getPrimitiveValue().getTypeName())). setText(written.getPrimitiveValue().toString()). build(); comparable = getClient().getObjectFactory().newPrimitiveProperty(written.getName(), typedValue); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractTestITCase.java index 589affa10..e87b87730 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/AbstractTestITCase.java @@ -58,7 +58,6 @@ import org.apache.olingo.client.api.domain.ODataEntity; import org.apache.olingo.client.api.domain.ODataEntitySet; import org.apache.olingo.client.api.domain.ODataInlineEntity; import org.apache.olingo.client.api.domain.ODataInlineEntitySet; -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; import org.apache.olingo.client.api.domain.ODataLink; import org.apache.olingo.client.api.domain.ODataProperty; import org.apache.olingo.client.api.domain.ODataValue; @@ -68,6 +67,7 @@ import org.apache.olingo.client.api.uri.CommonURIBuilder; import org.apache.olingo.client.api.utils.URIUtils; import org.apache.olingo.client.core.data.AtomEntryImpl; import org.apache.olingo.client.core.data.JSONEntryImpl; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.BeforeClass; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -214,7 +214,7 @@ public abstract class AbstractTestITCase { entity.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Information", getClient().getPrimitiveValueBuilder().setText(sampleinfo).setType( - ODataJClientEdmPrimitiveType.String).build())); + EdmPrimitiveTypeKind.String).build())); return entity; } @@ -228,12 +228,12 @@ public abstract class AbstractTestITCase { // add name attribute entity.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("Name", getClient().getPrimitiveValueBuilder().setText(sampleName).setType( - ODataJClientEdmPrimitiveType.String).build())); + EdmPrimitiveTypeKind.String).build())); // add key attribute entity.getProperties().add(getClient().getObjectFactory().newPrimitiveProperty("CustomerId", getClient().getPrimitiveValueBuilder().setText(String.valueOf(id)).setType( - ODataJClientEdmPrimitiveType.Int32).build())); + EdmPrimitiveTypeKind.Int32).build())); // add BackupContactInfo attribute (collection) final ODataCollectionValue backupContactInfoValue = new ODataCollectionValue( @@ -249,13 +249,13 @@ public abstract class AbstractTestITCase { // add BackupContactInfo.ContactDetails.AlternativeNames attribute (collection) final ODataCollectionValue altNamesValue = new ODataCollectionValue("Collection(Edm.String)"); altNamesValue.add(getClient().getPrimitiveValueBuilder(). - setText("myname").setType(ODataJClientEdmPrimitiveType.String).build()); + setText("myname").setType(EdmPrimitiveTypeKind.String).build()); contactDetails.add(getClient().getObjectFactory().newCollectionProperty("AlternativeNames", altNamesValue)); // add BackupContactInfo.ContactDetails.EmailBag attribute (collection) final ODataCollectionValue emailBagValue = new ODataCollectionValue("Collection(Edm.String)"); emailBagValue.add(getClient().getPrimitiveValueBuilder(). - setText("myname@mydomain.com").setType(ODataJClientEdmPrimitiveType.String).build()); + setText("myname@mydomain.com").setType(EdmPrimitiveTypeKind.String).build()); contactDetails.add(getClient().getObjectFactory().newCollectionProperty("EmailBag", emailBagValue)); // add BackupContactInfo.ContactDetails.ContactAlias attribute (complex) @@ -266,7 +266,7 @@ public abstract class AbstractTestITCase { // add BackupContactInfo.ContactDetails.ContactAlias.AlternativeNames attribute (collection) final ODataCollectionValue aliasAltNamesValue = new ODataCollectionValue("Collection(Edm.String)"); aliasAltNamesValue.add(getClient().getPrimitiveValueBuilder(). - setText("myAlternativeName").setType(ODataJClientEdmPrimitiveType.String).build()); + setText("myAlternativeName").setType(EdmPrimitiveTypeKind.String).build()); contactAliasValue.add(getClient().getObjectFactory().newCollectionProperty("AlternativeNames", aliasAltNamesValue)); if (withInlineInfo) { diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java index 0d7bac2c2..465dc07e5 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityCreateTestITCase.java @@ -42,13 +42,13 @@ import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse import org.apache.olingo.client.api.domain.ODataEntity; import org.apache.olingo.client.api.domain.ODataEntitySet; import org.apache.olingo.client.api.domain.ODataInlineEntitySet; -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; import org.apache.olingo.client.api.domain.ODataLink; import org.apache.olingo.client.api.domain.ODataProperty; import org.apache.olingo.client.api.format.ODataPubFormat; import org.apache.olingo.client.api.http.NoContentException; import org.apache.olingo.client.api.uri.CommonURIBuilder; import org.apache.olingo.client.api.utils.URIUtils; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Ignore; import org.junit.Test; @@ -288,10 +288,10 @@ public class EntityCreateTestITCase extends AbstractTestITCase { client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Order"); order.getProperties().add(client.getObjectFactory().newPrimitiveProperty("OrderId", - client.getPrimitiveValueBuilder().setValue(key).setType(ODataJClientEdmPrimitiveType.Int32) + client.getPrimitiveValueBuilder().setValue(key).setType(EdmPrimitiveTypeKind.Int32) .build())); order.getProperties().add(client.getObjectFactory().newPrimitiveProperty("CustomerId", - client.getPrimitiveValueBuilder().setValue(id).setType(ODataJClientEdmPrimitiveType.Int32) + client.getPrimitiveValueBuilder().setValue(id).setType(EdmPrimitiveTypeKind.Int32) .build())); final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().getEntityCreateRequest( @@ -383,9 +383,9 @@ public class EntityCreateTestITCase extends AbstractTestITCase { ODataEntity order = client.getObjectFactory().newEntity( "Microsoft.Test.OData.Services.AstoriaDefaultService.Order"); order.getProperties().add(client.getObjectFactory().newPrimitiveProperty("CustomerId", - client.getPrimitiveValueBuilder().setValue(id).setType(ODataJClientEdmPrimitiveType.Int32).build())); + client.getPrimitiveValueBuilder().setValue(id).setType(EdmPrimitiveTypeKind.Int32).build())); order.getProperties().add(client.getObjectFactory().newPrimitiveProperty("OrderId", - client.getPrimitiveValueBuilder().setValue(id).setType(ODataJClientEdmPrimitiveType.Int32).build())); + client.getPrimitiveValueBuilder().setValue(id).setType(EdmPrimitiveTypeKind.Int32).build())); order.addLink(client.getObjectFactory().newEntityNavigationLink( "Customer", URIUtils.getURI(getServiceRoot(), customer.getEditLink().toASCIIString()))); @@ -442,22 +442,22 @@ public class EntityCreateTestITCase extends AbstractTestITCase { message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("MessageId", client.getPrimitiveValueBuilder().setValue(1000). - setType(ODataJClientEdmPrimitiveType.Int32).build())); + setType(EdmPrimitiveTypeKind.Int32).build())); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("FromUsername", client.getPrimitiveValueBuilder().setValue("1"). - setType(ODataJClientEdmPrimitiveType.String).build())); + setType(EdmPrimitiveTypeKind.String).build())); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("ToUsername", client.getPrimitiveValueBuilder().setValue("xlodhxzzusxecbzptxlfxprneoxkn"). - setType(ODataJClientEdmPrimitiveType.String).build())); + setType(EdmPrimitiveTypeKind.String).build())); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Subject", client.getPrimitiveValueBuilder().setValue("Test subject"). - setType(ODataJClientEdmPrimitiveType.String).build())); + setType(EdmPrimitiveTypeKind.String).build())); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Body", client.getPrimitiveValueBuilder().setValue("Test body"). - setType(ODataJClientEdmPrimitiveType.String).build())); + setType(EdmPrimitiveTypeKind.String).build())); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("IsRead", client.getPrimitiveValueBuilder().setValue(false). - setType(ODataJClientEdmPrimitiveType.Boolean).build())); + setType(EdmPrimitiveTypeKind.Boolean).build())); final CommonURIBuilder builder = client.getURIBuilder(getServiceRoot()).appendEntitySetSegment("Message"); diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java index 77172267b..8399494e0 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/EntityUpdateTestITCase.java @@ -32,8 +32,8 @@ import org.apache.olingo.client.api.communication.request.cud.ODataEntityUpdateR import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRequest; import org.apache.olingo.client.api.communication.response.ODataEntityUpdateResponse; import org.apache.olingo.client.api.domain.ODataEntity; -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; import org.apache.olingo.client.api.format.ODataPubFormat; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; /** @@ -184,7 +184,7 @@ public class EntityUpdateTestITCase extends AbstractTestITCase { message.getProperties().remove(message.getProperty("IsRead")); message.getProperties().add(client.getObjectFactory().newPrimitiveProperty("IsRead", client.getPrimitiveValueBuilder().setValue(!before). - setType(ODataJClientEdmPrimitiveType.Boolean).build())); + setType(EdmPrimitiveTypeKind.Boolean).build())); return client.getCUDRequestFactory().getEntityUpdateRequest(UpdateType.MERGE, message); } diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java index 6b23f142e..b8ce3b4fb 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/NavigationLinkCreateTestITCase.java @@ -44,7 +44,6 @@ import org.apache.olingo.client.api.domain.ODataEntity; import org.apache.olingo.client.api.domain.ODataEntitySet; import org.apache.olingo.client.api.domain.ODataInlineEntity; import org.apache.olingo.client.api.domain.ODataInlineEntitySet; -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; import org.apache.olingo.client.api.domain.ODataLink; import org.apache.olingo.client.api.domain.ODataProperty; import org.apache.olingo.client.api.domain.ODataValue; @@ -52,6 +51,7 @@ import org.apache.olingo.client.api.format.ODataPubFormat; import org.apache.olingo.client.api.http.HttpClientException; import org.apache.olingo.client.api.uri.CommonURIBuilder; import org.apache.olingo.client.api.utils.URIUtils; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; @@ -209,9 +209,9 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase { client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.AstoriaDefaultService.Order"); orderEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("OrderId", - client.getPrimitiveValueBuilder().setValue(key).setType(ODataJClientEdmPrimitiveType.Int32).build())); + client.getPrimitiveValueBuilder().setValue(key).setType(EdmPrimitiveTypeKind.Int32).build())); orderEntity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("CustomerId", - client.getPrimitiveValueBuilder().setValue(id).setType(ODataJClientEdmPrimitiveType.Int32).build())); + client.getPrimitiveValueBuilder().setValue(id).setType(EdmPrimitiveTypeKind.Int32).build())); final ODataEntityCreateRequest createReq = client.getCUDRequestFactory().getEntityCreateRequest( client.getURIBuilder(testStaticServiceRootURL).appendEntitySetSegment("Order").build(), @@ -267,13 +267,13 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase { // add name attribute entity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Name", - client.getPrimitiveValueBuilder().setText(name).setType(ODataJClientEdmPrimitiveType.String).build())); + client.getPrimitiveValueBuilder().setText(name).setType(EdmPrimitiveTypeKind.String).build())); // add key attribute if (id != 0) { entity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("CustomerId", client.getPrimitiveValueBuilder().setText(String.valueOf(id)). - setType(ODataJClientEdmPrimitiveType.Int32).build())); + setType(EdmPrimitiveTypeKind.Int32).build())); } final ODataCollectionValue backupContactInfoValue = new ODataCollectionValue( "Collection(Microsoft.Test.OData.Services.AstoriaDefaultService.ContactDetails)"); @@ -285,12 +285,12 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase { final ODataCollectionValue altNamesValue = new ODataCollectionValue("Collection(Edm.String)"); altNamesValue.add(client.getPrimitiveValueBuilder(). - setText("My Alternative name").setType(ODataJClientEdmPrimitiveType.String).build()); + setText("My Alternative name").setType(EdmPrimitiveTypeKind.String).build()); contactDetails.add(client.getObjectFactory().newCollectionProperty("AlternativeNames", altNamesValue)); final ODataCollectionValue emailBagValue = new ODataCollectionValue("Collection(Edm.String)"); emailBagValue.add(client.getPrimitiveValueBuilder(). - setText("altname@mydomain.com").setType(ODataJClientEdmPrimitiveType.String).build()); + setText("altname@mydomain.com").setType(EdmPrimitiveTypeKind.String).build()); contactDetails.add(client.getObjectFactory().newCollectionProperty("EmailBag", emailBagValue)); final ODataComplexValue contactAliasValue = new ODataComplexValue( @@ -299,17 +299,17 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase { final ODataCollectionValue aliasAltNamesValue = new ODataCollectionValue("Collection(Edm.String)"); aliasAltNamesValue.add(client.getPrimitiveValueBuilder(). - setText("myAlternativeName").setType(ODataJClientEdmPrimitiveType.String).build()); + setText("myAlternativeName").setType(EdmPrimitiveTypeKind.String).build()); contactAliasValue.add(client.getObjectFactory().newCollectionProperty("AlternativeNames", aliasAltNamesValue)); final ODataComplexValue homePhone = new ODataComplexValue( "Microsoft.Test.OData.Services.AstoriaDefaultService.Phone"); homePhone.add(client.getObjectFactory().newPrimitiveProperty("PhoneNumber", client.getPrimitiveValueBuilder().setText("8437568356834568"). - setType(ODataJClientEdmPrimitiveType.String).build())); + setType(EdmPrimitiveTypeKind.String).build())); homePhone.add(client.getObjectFactory().newPrimitiveProperty("Extension", client.getPrimitiveValueBuilder().setText("124365426534621534423ttrf"). - setType(ODataJClientEdmPrimitiveType.String). + setType(EdmPrimitiveTypeKind.String). build())); contactDetails.add(client.getObjectFactory().newComplexProperty("HomePhone", homePhone)); @@ -372,7 +372,7 @@ public class NavigationLinkCreateTestITCase extends AbstractTestITCase { entity.setMediaEntity(true); entity.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Information", - client.getPrimitiveValueBuilder().setText(info).setType(ODataJClientEdmPrimitiveType.String).build())); + client.getPrimitiveValueBuilder().setText(info).setType(EdmPrimitiveTypeKind.String).build())); return entity; } // validate newly created entities diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java index 7718317b8..c64d7bb2c 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v3/OpenTypeTestITCase.java @@ -30,19 +30,19 @@ import org.apache.olingo.client.api.communication.response.ODataDeleteResponse; import org.apache.olingo.client.api.communication.response.ODataEntityCreateResponse; import org.apache.olingo.client.api.domain.ODataComplexValue; import org.apache.olingo.client.api.domain.ODataEntity; -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.format.ODataPubFormat; import org.apache.olingo.client.api.uri.CommonURIBuilder; import org.apache.olingo.commons.api.edm.Edm; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.EdmSchema; +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.Ignore; import org.junit.Test; @@ -70,15 +70,15 @@ public class OpenTypeTestITCase extends AbstractTestITCase { private void read(final ODataPubFormat format) { ODataEntity row = readRow(format, "71f7d0dc-ede4-45eb-b421-555a2aa1e58f"); assertEquals( - ODataJClientEdmPrimitiveType.Double.toString(), + EdmPrimitiveTypeKind.Double.toString(), row.getProperty("Double").getPrimitiveValue().getTypeName()); assertEquals( - ODataJClientEdmPrimitiveType.Guid.toString(), + EdmPrimitiveTypeKind.Guid.toString(), row.getProperty("Id").getPrimitiveValue().getTypeName()); row = readRow(format, "672b8250-1e6e-4785-80cf-b94b572e42b3"); assertEquals( - ODataJClientEdmPrimitiveType.Decimal.toString(), + EdmPrimitiveTypeKind.Decimal.toString(), row.getProperty("Decimal").getPrimitiveValue().getTypeName()); } @@ -99,50 +99,50 @@ public class OpenTypeTestITCase extends AbstractTestITCase { ODataEntity row = client.getObjectFactory().newEntity("Microsoft.Test.OData.Services.OpenTypesService.Row"); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("Id", - client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Guid).setValue(guid). + client.getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Guid).setValue(guid). build())); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aString", - client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.String).setValue("string"). + client.getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.String).setValue("string"). build())); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aBoolean", - client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Boolean).setValue(true). + client.getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Boolean).setValue(true). build())); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aLong", - client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Int64).setValue(15L). + client.getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Int64).setValue(15L). build())); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aDouble", - client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Double).setValue(1.5D). + client.getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Double).setValue(1.5D). build())); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aByte", - client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.SByte).setValue(Byte.MAX_VALUE). + client.getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.SByte).setValue(Byte.MAX_VALUE). build())); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aDate", - client.getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.DateTime).setValue(new Date()). + client.getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.DateTime).setValue(new Date()). build())); final Point point = new Point(Geospatial.Dimension.GEOGRAPHY, null); point.setX(1.2); point.setY(2.1); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aPoint", - client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyPoint). + client.getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeographyPoint). setValue(point).build())); final List points = new ArrayList(); points.add(point); points.add(point); final MultiPoint multipoint = new MultiPoint(Geospatial.Dimension.GEOMETRY, null, points); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aMultiPoint", - client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeometryMultiPoint). + client.getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeometryMultiPoint). setValue(multipoint).build())); final LineString lineString = new LineString(Geospatial.Dimension.GEOMETRY, null, points); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aLineString", - client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeometryLineString). + client.getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeometryLineString). setValue(lineString).build())); final List lineStrings = new ArrayList(); lineStrings.add(lineString); lineStrings.add(lineString); final MultiLineString multiLineString = new MultiLineString(Geospatial.Dimension.GEOGRAPHY, null, lineStrings); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aMultiLineString", - client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeometryMultiLineString). + client.getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeometryMultiLineString). setValue(multiLineString).build())); final Point otherPoint = new Point(Geospatial.Dimension.GEOGRAPHY, null); otherPoint.setX(3.4); @@ -152,14 +152,14 @@ public class OpenTypeTestITCase extends AbstractTestITCase { points.add(point); final Polygon polygon = new Polygon(Geospatial.Dimension.GEOGRAPHY, null, points, points); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aPolygon", - client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyPolygon). + client.getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeographyPolygon). setValue(polygon).build())); final List polygons = new ArrayList(); polygons.add(polygon); polygons.add(polygon); final MultiPolygon multiPolygon = new MultiPolygon(Geospatial.Dimension.GEOGRAPHY, null, polygons); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aMultiPolygon", - client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyMultiPolygon). + client.getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeographyMultiPolygon). setValue(multiPolygon).build())); final List geospatials = new ArrayList(); geospatials.add(otherPoint); @@ -168,47 +168,47 @@ public class OpenTypeTestITCase extends AbstractTestITCase { geospatials.add(multiPolygon); final GeospatialCollection geoColl = new GeospatialCollection(Geospatial.Dimension.GEOGRAPHY, null, geospatials); row.getProperties().add(client.getObjectFactory().newPrimitiveProperty("aCollection", - client.getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyCollection). + client.getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeographyCollection). setValue(geoColl).build())); final ODataComplexValue contactDetails = new ODataComplexValue("Microsoft.Test.OData.Services.OpenTypesService.ContactDetails"); contactDetails.add(client.getObjectFactory().newPrimitiveProperty("FirstContacted", client.getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.Binary).setValue("text".getBytes()).build())); + setType(EdmPrimitiveTypeKind.Binary).setValue("text".getBytes()).build())); contactDetails.add(client.getObjectFactory().newPrimitiveProperty("LastContacted", client.getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.DateTimeOffset).setText("2001-04-05T05:05:05.001+00:01").build())); + setType(EdmPrimitiveTypeKind.DateTimeOffset).setText("2001-04-05T05:05:05.001+00:01").build())); contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Contacted", client.getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.DateTime).setText("2001-04-05T05:05:04.001").build())); + setType(EdmPrimitiveTypeKind.DateTime).setText("2001-04-05T05:05:04.001").build())); contactDetails.add(client.getObjectFactory().newPrimitiveProperty("GUID", client.getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.Guid).setValue(UUID.randomUUID()).build())); + setType(EdmPrimitiveTypeKind.Guid).setValue(UUID.randomUUID()).build())); contactDetails.add(client.getObjectFactory().newPrimitiveProperty("PreferedContactTime", client.getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.Time).setText("-P9DT51M10.5063807S").build())); + setType(EdmPrimitiveTypeKind.Time).setText("-P9DT51M10.5063807S").build())); contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Byte", client.getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.Byte).setValue(Integer.valueOf(241)).build())); + setType(EdmPrimitiveTypeKind.Byte).setValue(Integer.valueOf(241)).build())); contactDetails.add(client.getObjectFactory().newPrimitiveProperty("SignedByte", client.getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.SByte).setValue(Byte.MAX_VALUE).build())); + setType(EdmPrimitiveTypeKind.SByte).setValue(Byte.MAX_VALUE).build())); contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Double", client.getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.Double).setValue(Double.MAX_VALUE).build())); + setType(EdmPrimitiveTypeKind.Double).setValue(Double.MAX_VALUE).build())); contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Single", client.getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.Single).setValue(Float.MAX_VALUE).build())); + setType(EdmPrimitiveTypeKind.Single).setValue(Float.MAX_VALUE).build())); contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Short", client.getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.Int16).setValue(Short.MAX_VALUE).build())); + setType(EdmPrimitiveTypeKind.Int16).setValue(Short.MAX_VALUE).build())); contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Int", client.getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.Int32).setValue(Integer.MAX_VALUE).build())); + setType(EdmPrimitiveTypeKind.Int32).setValue(Integer.MAX_VALUE).build())); contactDetails.add(client.getObjectFactory().newPrimitiveProperty("Long", client.getPrimitiveValueBuilder(). - setType(ODataJClientEdmPrimitiveType.Int64).setValue(Long.MAX_VALUE).build())); + setType(EdmPrimitiveTypeKind.Int64).setValue(Long.MAX_VALUE).build())); row.getProperties().add(client.getObjectFactory().newComplexProperty("aContact", contactDetails)); final ODataEntityCreateRequest createReq = client.getCUDRequestFactory(). @@ -220,37 +220,37 @@ public class OpenTypeTestITCase extends AbstractTestITCase { row = readRow(format, guid.toString()); assertNotNull(row); - assertEquals(ODataJClientEdmPrimitiveType.Guid.toString(), + assertEquals(EdmPrimitiveTypeKind.Guid.toString(), row.getProperty("Id").getPrimitiveValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.String.toString(), + assertEquals(EdmPrimitiveTypeKind.String.toString(), row.getProperty("aString").getPrimitiveValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.Boolean.toString(), + assertEquals(EdmPrimitiveTypeKind.Boolean.toString(), row.getProperty("aBoolean").getPrimitiveValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.Int64.toString(), + assertEquals(EdmPrimitiveTypeKind.Int64.toString(), row.getProperty("aLong").getPrimitiveValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.Double.toString(), + assertEquals(EdmPrimitiveTypeKind.Double.toString(), row.getProperty("aDouble").getPrimitiveValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.SByte.toString(), + assertEquals(EdmPrimitiveTypeKind.SByte.toString(), row.getProperty("aByte").getPrimitiveValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.DateTime.toString(), + assertEquals(EdmPrimitiveTypeKind.DateTime.toString(), row.getProperty("aDate").getPrimitiveValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.GeographyPoint.toString(), + assertEquals(EdmPrimitiveTypeKind.GeographyPoint.toString(), row.getProperty("aPoint").getPrimitiveValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.GeometryMultiPoint.toString(), + assertEquals(EdmPrimitiveTypeKind.GeometryMultiPoint.toString(), row.getProperty("aMultiPoint").getPrimitiveValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.GeometryLineString.toString(), + assertEquals(EdmPrimitiveTypeKind.GeometryLineString.toString(), row.getProperty("aLineString").getPrimitiveValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.GeometryMultiLineString.toString(), + assertEquals(EdmPrimitiveTypeKind.GeometryMultiLineString.toString(), row.getProperty("aMultiLineString").getPrimitiveValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.GeographyPolygon.toString(), + assertEquals(EdmPrimitiveTypeKind.GeographyPolygon.toString(), row.getProperty("aPolygon").getPrimitiveValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.GeographyMultiPolygon.toString(), + assertEquals(EdmPrimitiveTypeKind.GeographyMultiPolygon.toString(), row.getProperty("aMultiPolygon").getPrimitiveValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.GeographyCollection.toString(), + assertEquals(EdmPrimitiveTypeKind.GeographyCollection.toString(), row.getProperty("aCollection").getPrimitiveValue().getTypeName()); assertEquals("Microsoft.Test.OData.Services.OpenTypesService.ContactDetails", row.getProperty("aContact").getComplexValue().getTypeName()); - assertEquals(ODataJClientEdmPrimitiveType.SByte.toString(), + assertEquals(EdmPrimitiveTypeKind.SByte.toString(), row.getProperty("aContact").getComplexValue().get("SignedByte").getPrimitiveValue().getTypeName()); final ODataDeleteResponse deleteRes = client.getCUDRequestFactory().getDeleteRequest(row.getEditLink()). diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java index 8559d4ff1..903adf805 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/EntityTest.java @@ -25,14 +25,14 @@ import static org.junit.Assert.assertTrue; import java.io.InputStream; import org.apache.olingo.client.api.v3.ODataClient; import org.apache.olingo.client.api.domain.ODataEntity; -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; import org.apache.olingo.client.api.domain.ODataLink; import org.apache.olingo.client.api.domain.ODataProperty; -import org.apache.olingo.client.api.domain.geospatial.Geospatial; -import org.apache.olingo.client.api.domain.geospatial.GeospatialCollection; import org.apache.olingo.client.api.format.ODataPubFormat; import org.apache.olingo.client.core.AbstractTest; import org.apache.olingo.client.core.op.impl.ResourceFactory; +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.junit.Test; public class EntityTest extends AbstractTest { @@ -89,7 +89,7 @@ public class EntityTest extends AbstractTest { if ("GeogMultiLine".equals(property.getName())) { found = true; assertTrue(property.hasPrimitiveValue()); - assertEquals(ODataJClientEdmPrimitiveType.GeographyMultiLineString.toString(), + assertEquals(EdmPrimitiveTypeKind.GeographyMultiLineString.getFullQualifiedName().toString(), property.getPrimitiveValue().getTypeName()); } } @@ -168,7 +168,7 @@ public class EntityTest extends AbstractTest { assertNotNull(entity); final ODataProperty geogCollection = entity.getProperty("GeogCollection"); - assertEquals(ODataJClientEdmPrimitiveType.GeographyCollection.toString(), + assertEquals(EdmPrimitiveTypeKind.GeographyCollection.getFullQualifiedName().toString(), geogCollection.getPrimitiveValue().getTypeName()); int count = 0; diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java index fea25ca9b..5dca101b7 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/MetadataTest.java @@ -49,8 +49,9 @@ import org.apache.olingo.commons.api.edm.EdmEntityType; 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.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.junit.Test; public class MetadataTest extends AbstractTest { @@ -133,7 +134,7 @@ public class MetadataTest extends AbstractTest { new FullQualifiedName("Microsoft.Test.OData.Services.AstoriaDefaultService", "ProductReview")); assertNotNull(entity); assertFalse(entity.getPropertyNames().isEmpty()); - assertEquals(EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance(), + assertEquals(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int32), entity.getProperty("ProductId").getType()); assertFalse(entity.getKeyPropertyRefs().isEmpty()); @@ -150,7 +151,7 @@ public class MetadataTest extends AbstractTest { for (EdmActionImportInfo info : metadata.getServiceMetadata().getActionImportInfos()) { actionImports.add(info.getActionImportName()); } - final Set expectedAI = new HashSet(Arrays.asList(new String[]{ + final Set expectedAI = new HashSet(Arrays.asList(new String[] { "ResetDataSource", "IncreaseSalaries", "Sack", @@ -162,7 +163,7 @@ public class MetadataTest extends AbstractTest { for (EdmFunctionImportInfo info : metadata.getServiceMetadata().getFunctionImportInfos()) { functionImports.add(info.getFunctionImportName()); } - final Set expectedFI = new HashSet(Arrays.asList(new String[]{ + final Set expectedFI = new HashSet(Arrays.asList(new String[] { "GetPrimitiveString", "GetSpecificCustomer", "GetCustomerCount", @@ -177,7 +178,7 @@ public class MetadataTest extends AbstractTest { final EdmFunctionImport getArgumentPlusOne = container.getFunctionImport("GetArgumentPlusOne"); assertNotNull(getArgumentPlusOne); - assertEquals(EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance(), + assertEquals(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int32), getArgumentPlusOne.getFunction(null).getReturnType().getType()); final EdmActionImport resetDataSource = container.getActionImport("ResetDataSource"); @@ -191,7 +192,7 @@ public class MetadataTest extends AbstractTest { final EdmFunction getComputer = metadata.getFunction( new FullQualifiedName(container.getNamespace(), "GetComputer"), new FullQualifiedName(container.getNamespace(), computer.getName()), - Boolean.FALSE, Arrays.asList(new String[]{"computer"})); + Boolean.FALSE, Arrays.asList(new String[] {"computer"})); assertNotNull(getComputer); assertEquals(computer, getComputer.getParameter("computer").getType()); assertEquals(computer, getComputer.getReturnType().getType()); 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 641fafa10..c5e4aee4d 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().toCastValue()); - value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Int32).setText("9").build(); + value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Int32).setText("9").build(); assertEquals("9", value.asPrimitive().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().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().toCastValue()); - value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Decimal). + value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Decimal). setText("-79228162514264337593543950335").build(); assertEquals("-79228162514264337593543950335", value.asPrimitive().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().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().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().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().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().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().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().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().toCastValue().getX())); assertEquals(Double.valueOf(primitive.getY()), Double.valueOf(value.asPrimitive().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 iter = value.asPrimitive().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 iter = value.asPrimitive().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 lineIter = value.asPrimitive().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().toCastValue().getInterior().isEmpty()); final Iterator iter = value.asPrimitive().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 iter = value.asPrimitive().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 iter = value.asPrimitive().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 iter = value.asPrimitive().toCastValue().iterator(); iter.next(); 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 3d74f7bf3..fd2a69694 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"); 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 afeba9252..fb2ba5ca7 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( 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 c146feef4..d72861dcf 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().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().toCastValue().toString()); } diff --git a/lib/commons-api/pom.xml b/lib/commons-api/pom.xml index 42c42b429..e398eaa88 100644 --- a/lib/commons-api/pom.xml +++ b/lib/commons-api/pom.xml @@ -33,4 +33,12 @@ 0.1.0-SNAPSHOT .. + + + + org.apache.commons + commons-lang3 + + + 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 000000000..898b6b284 --- /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 getJavaType(); + +} 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 000000000..069d9e507 --- /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 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 getSupportedVersions() { + return this.versions; + } + + /** + * Checks if is a geospatial type. + * + * @return true if is geospatial type; false 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 EdmPrimitiveTypeKind from a full-qualified type name, for the given OData protocol version. + * + * @param version OData protocol version. + * @param fqn full-qualified type name. + * @return EdmPrimitiveTypeKind object. + */ + public static EdmPrimitiveTypeKind valueOfFQN(final ODataServiceVersion version, final FullQualifiedName fqn) { + return valueOfFQN(version, fqn.toString()); + } + + /** + * Gets EdmPrimitiveTypeKind from a full type expression (as Edm.Int32), for the given OData + * protocol version. + * + * @param version OData protocol version. + * @param fqn string value type. + * @return EdmPrimitiveTypeKind 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; + } + +} diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/ComposedGeospatial.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java similarity index 97% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/ComposedGeospatial.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java index 2ef65e87a..82a13fe80 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/ComposedGeospatial.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/ComposedGeospatial.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.domain.geospatial; +package org.apache.olingo.commons.api.edm.geo; import java.util.ArrayList; import java.util.Iterator; diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Geospatial.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java similarity index 94% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Geospatial.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java index 44e95584b..62de5ec3d 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Geospatial.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Geospatial.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.domain.geospatial; +package org.apache.olingo.commons.api.edm.geo; import java.io.Serializable; @@ -24,7 +24,7 @@ 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; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; /** * Base class for all geospatial info. @@ -141,7 +141,7 @@ public abstract class Geospatial implements Serializable { this.srid = srid; } - public abstract ODataJClientEdmPrimitiveType getEdmSimpleType(); + public abstract EdmPrimitiveTypeKind getEdmPrimitiveTypeKind(); /** * {@inheritDoc } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/GeospatialCollection.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java similarity index 81% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/GeospatialCollection.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java index 64092121d..b3e3f9fd5 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/GeospatialCollection.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/GeospatialCollection.java @@ -16,11 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.domain.geospatial; +package org.apache.olingo.commons.api.edm.geo; import java.util.List; - -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; /** * Wrapper for a collection of geospatials info. @@ -41,9 +40,9 @@ public class GeospatialCollection extends ComposedGeospatial { } @Override - public ODataJClientEdmPrimitiveType getEdmSimpleType() { + public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() { return dimension == Dimension.GEOGRAPHY - ? ODataJClientEdmPrimitiveType.GeographyCollection - : ODataJClientEdmPrimitiveType.GeometryCollection; + ? EdmPrimitiveTypeKind.GeographyCollection + : EdmPrimitiveTypeKind.GeometryCollection; } } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/LineString.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.java similarity index 78% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/LineString.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.java index 474b57829..297a96260 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/LineString.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/LineString.java @@ -16,11 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.domain.geospatial; +package org.apache.olingo.commons.api.edm.geo; import java.util.List; - -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; public class LineString extends ComposedGeospatial { @@ -31,9 +30,9 @@ public class LineString extends ComposedGeospatial { } @Override - public ODataJClientEdmPrimitiveType getEdmSimpleType() { + public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() { return dimension == Dimension.GEOGRAPHY - ? ODataJClientEdmPrimitiveType.GeographyLineString - : ODataJClientEdmPrimitiveType.GeometryLineString; + ? EdmPrimitiveTypeKind.GeographyLineString + : EdmPrimitiveTypeKind.GeometryLineString; } } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiLineString.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.java similarity index 78% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiLineString.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.java index 3eb0466df..2f98d63fd 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiLineString.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiLineString.java @@ -16,11 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.domain.geospatial; +package org.apache.olingo.commons.api.edm.geo; import java.util.List; - -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; public class MultiLineString extends ComposedGeospatial { @@ -31,9 +30,10 @@ public class MultiLineString extends ComposedGeospatial { } @Override - public ODataJClientEdmPrimitiveType getEdmSimpleType() { + public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() { return dimension == Dimension.GEOGRAPHY - ? ODataJClientEdmPrimitiveType.GeographyMultiLineString - : ODataJClientEdmPrimitiveType.GeometryMultiLineString; + ? EdmPrimitiveTypeKind.GeographyMultiLineString + : EdmPrimitiveTypeKind.GeometryMultiLineString; } + } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPoint.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.java similarity index 78% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPoint.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.java index 8ea16b958..999f24bcb 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPoint.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPoint.java @@ -16,11 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.domain.geospatial; +package org.apache.olingo.commons.api.edm.geo; import java.util.List; - -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; public class MultiPoint extends ComposedGeospatial { @@ -31,9 +30,10 @@ public class MultiPoint extends ComposedGeospatial { } @Override - public ODataJClientEdmPrimitiveType getEdmSimpleType() { + public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() { return dimension == Dimension.GEOGRAPHY - ? ODataJClientEdmPrimitiveType.GeographyMultiPoint - : ODataJClientEdmPrimitiveType.GeometryMultiPoint; + ? EdmPrimitiveTypeKind.GeographyMultiPoint + : EdmPrimitiveTypeKind.GeometryMultiPoint; } + } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPolygon.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.java similarity index 78% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPolygon.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.java index ed55b922f..fd0fdae51 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/MultiPolygon.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/MultiPolygon.java @@ -16,11 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.domain.geospatial; +package org.apache.olingo.commons.api.edm.geo; import java.util.List; - -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; public class MultiPolygon extends ComposedGeospatial { @@ -31,9 +30,9 @@ public class MultiPolygon extends ComposedGeospatial { } @Override - public ODataJClientEdmPrimitiveType getEdmSimpleType() { + public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() { return dimension == Dimension.GEOGRAPHY - ? ODataJClientEdmPrimitiveType.GeographyMultiPolygon - : ODataJClientEdmPrimitiveType.GeometryMultiPolygon; + ? EdmPrimitiveTypeKind.GeographyMultiPolygon + : EdmPrimitiveTypeKind.GeometryMultiPolygon; } } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Point.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java similarity index 85% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Point.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java index 63b91664e..a9e0c39e6 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Point.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Point.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.domain.geospatial; +package org.apache.olingo.commons.api.edm.geo; -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; public class Point extends Geospatial { @@ -69,9 +69,9 @@ public class Point extends Geospatial { } @Override - public ODataJClientEdmPrimitiveType getEdmSimpleType() { + public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() { return dimension == Dimension.GEOGRAPHY - ? ODataJClientEdmPrimitiveType.GeographyPoint - : ODataJClientEdmPrimitiveType.GeometryPoint; + ? EdmPrimitiveTypeKind.GeographyPoint + : EdmPrimitiveTypeKind.GeometryPoint; } } diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Polygon.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java similarity index 85% rename from lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Polygon.java rename to lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java index 2aa1787cd..2501d4eae 100644 --- a/lib/client-api/src/main/java/org/apache/olingo/client/api/domain/geospatial/Polygon.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java @@ -16,11 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.olingo.client.api.domain.geospatial; +package org.apache.olingo.commons.api.edm.geo; import java.util.List; - -import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; /** * Polygon. @@ -66,9 +65,9 @@ public class Polygon extends Geospatial { } @Override - public ODataJClientEdmPrimitiveType getEdmSimpleType() { + public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() { return dimension == Dimension.GEOGRAPHY - ? ODataJClientEdmPrimitiveType.GeographyPolygon - : ODataJClientEdmPrimitiveType.GeometryPolygon; + ? EdmPrimitiveTypeKind.GeographyPolygon + : EdmPrimitiveTypeKind.GeometryPolygon; } } 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 b1d551bcc..09bd8ce0f 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); } 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 11e036562..c54239f89 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); } 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 a6a6a8409..532f6666b 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); } 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 000000000..8e5cb6ff5 --- /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 implements EdmGeospatialType { + + private final Class reference; + + protected final Dimension dimension; + + protected final Type type; + + protected AbstractEdmGeospatialType(final Class reference, final Dimension dimension, final Type type) { + this.reference = reference; + this.dimension = dimension; + this.type = type; + } + + @Override + public Class 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(); + } +} 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 5f141c08f..9aa660e77 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); } } 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 000000000..e06138851 --- /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 DATE_FORMAT = new ThreadLocal() { + @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 internalValueOfString(final String value, + final Boolean isNullable, final Integer maxLength, final Integer precision, + final Integer scale, final Boolean isUnicode, final Class 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 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())"); + } + } +} 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 000000000..f5951cbc7 --- /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 { + + private static final EdmGeography INSTANCE = new EdmGeography(); + + public static EdmGeography getInstance() { + return INSTANCE; + } + + public EdmGeography() { + super(Geospatial.class, Dimension.GEOGRAPHY, null); + } + +} 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 000000000..aab7210c9 --- /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 { + + private static final EdmGeographyCollection INSTANCE = new EdmGeographyCollection(); + + public static EdmGeographyCollection getInstance() { + return INSTANCE; + } + + public EdmGeographyCollection() { + super(Point.class, Dimension.GEOGRAPHY, Type.GEOSPATIALCOLLECTION); + } + +} 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 000000000..23c92cc20 --- /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 { + + private static final EdmGeographyLineString INSTANCE = new EdmGeographyLineString(); + + public static EdmGeographyLineString getInstance() { + return INSTANCE; + } + + public EdmGeographyLineString() { + super(Point.class, Dimension.GEOGRAPHY, Type.LINESTRING); + } + +} 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 000000000..9b5901df4 --- /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 { + + private static final EdmGeographyMultiLineString INSTANCE = new EdmGeographyMultiLineString(); + + public static EdmGeographyMultiLineString getInstance() { + return INSTANCE; + } + + public EdmGeographyMultiLineString() { + super(Point.class, Dimension.GEOGRAPHY, Type.MULTILINESTRING); + } + +} 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 000000000..db6604188 --- /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 { + + private static final EdmGeographyMultiPoint INSTANCE = new EdmGeographyMultiPoint(); + + public static EdmGeographyMultiPoint getInstance() { + return INSTANCE; + } + + public EdmGeographyMultiPoint() { + super(Point.class, Dimension.GEOGRAPHY, Type.MULTIPOINT); + } + +} 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 000000000..4b53a30a2 --- /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 { + + private static final EdmGeographyMultiPolygon INSTANCE = new EdmGeographyMultiPolygon(); + + public static EdmGeographyMultiPolygon getInstance() { + return INSTANCE; + } + + public EdmGeographyMultiPolygon() { + super(Point.class, Dimension.GEOGRAPHY, Type.MULTIPOLYGON); + } + +} 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 000000000..61abce333 --- /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 { + + private static final EdmGeographyPoint INSTANCE = new EdmGeographyPoint(); + + public static EdmGeographyPoint getInstance() { + return INSTANCE; + } + + public EdmGeographyPoint() { + super(Point.class, Dimension.GEOGRAPHY, Type.POINT); + } + +} 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 000000000..a7a1a6cd0 --- /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 { + + private static final EdmGeographyPolygon INSTANCE = new EdmGeographyPolygon(); + + public static EdmGeographyPolygon getInstance() { + return INSTANCE; + } + + public EdmGeographyPolygon() { + super(Point.class, Dimension.GEOGRAPHY, Type.POLYGON); + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometry.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometry.java new file mode 100644 index 000000000..2f16e24c2 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometry.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 EdmGeometry extends AbstractEdmGeospatialType { + + private static final EdmGeometry INSTANCE = new EdmGeometry(); + + public static EdmGeometry getInstance() { + return INSTANCE; + } + + public EdmGeometry() { + super(Geospatial.class, Dimension.GEOMETRY, null); + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryCollection.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryCollection.java new file mode 100644 index 000000000..12c6c01d1 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryCollection.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 EdmGeometryCollection extends AbstractEdmGeospatialType { + + private static final EdmGeometryCollection INSTANCE = new EdmGeometryCollection(); + + public static EdmGeometryCollection getInstance() { + return INSTANCE; + } + + public EdmGeometryCollection() { + super(Point.class, Dimension.GEOMETRY, Type.GEOSPATIALCOLLECTION); + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryLineString.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryLineString.java new file mode 100644 index 000000000..db8cfb004 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryLineString.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 EdmGeometryLineString extends AbstractEdmGeospatialType { + + private static final EdmGeometryLineString INSTANCE = new EdmGeometryLineString(); + + public static EdmGeometryLineString getInstance() { + return INSTANCE; + } + + public EdmGeometryLineString() { + super(Point.class, Dimension.GEOMETRY, Type.LINESTRING); + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiLineString.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiLineString.java new file mode 100644 index 000000000..7bf89e6c7 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiLineString.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 EdmGeometryMultiLineString extends AbstractEdmGeospatialType { + + private static final EdmGeometryMultiLineString INSTANCE = new EdmGeometryMultiLineString(); + + public static EdmGeometryMultiLineString getInstance() { + return INSTANCE; + } + + public EdmGeometryMultiLineString() { + super(Point.class, Dimension.GEOMETRY, Type.MULTILINESTRING); + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiPoint.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiPoint.java new file mode 100644 index 000000000..9311d8de8 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiPoint.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 EdmGeometryMultiPoint extends AbstractEdmGeospatialType { + + private static final EdmGeometryMultiPoint INSTANCE = new EdmGeometryMultiPoint(); + + public static EdmGeometryMultiPoint getInstance() { + return INSTANCE; + } + + public EdmGeometryMultiPoint() { + super(Point.class, Dimension.GEOMETRY, Type.MULTIPOINT); + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiPolygon.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiPolygon.java new file mode 100644 index 000000000..f64ed8705 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiPolygon.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 EdmGeometryMultiPolygon extends AbstractEdmGeospatialType { + + private static final EdmGeometryMultiPolygon INSTANCE = new EdmGeometryMultiPolygon(); + + public static EdmGeometryMultiPolygon getInstance() { + return INSTANCE; + } + + public EdmGeometryMultiPolygon() { + super(Point.class, Dimension.GEOMETRY, Type.MULTIPOLYGON); + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryPoint.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryPoint.java new file mode 100644 index 000000000..ba8e5d287 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryPoint.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 EdmGeometryPoint extends AbstractEdmGeospatialType { + + private static final EdmGeometryPoint INSTANCE = new EdmGeometryPoint(); + + public static EdmGeometryPoint getInstance() { + return INSTANCE; + } + + public EdmGeometryPoint() { + super(Point.class, Dimension.GEOMETRY, Type.POINT); + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryPolygon.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryPolygon.java new file mode 100644 index 000000000..12f8cf118 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryPolygon.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 EdmGeometryPolygon extends AbstractEdmGeospatialType { + + private static final EdmGeometryPolygon INSTANCE = new EdmGeometryPolygon(); + + public static EdmGeometryPolygon getInstance() { + return INSTANCE; + } + + public EdmGeometryPolygon() { + super(Point.class, Dimension.GEOMETRY, Type.POLYGON); + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmPrimitiveTypeFactory.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmPrimitiveTypeFactory.java new file mode 100644 index 000000000..83a257dbe --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmPrimitiveTypeFactory.java @@ -0,0 +1,138 @@ +/* + * 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.EdmPrimitiveType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmType; + +public final class EdmPrimitiveTypeFactory { + + public static EdmType getInstance(final EdmPrimitiveTypeKind kind) { + return kind.isGeospatial() + ? getGeoInstance(kind) + : getNonGeoInstance(kind); + } + + /** + * Returns an instance for the provided {@link EdmPrimitiveTypeKind} in the form of {@link EdmPrimitiveType} (for + * non-geospatial types). + * + * @param kind EdmPrimitiveTypeKind + * @return {@link EdmPrimitiveType} instance + */ + public static EdmPrimitiveType getNonGeoInstance(final EdmPrimitiveTypeKind kind) { + switch (kind) { + case Binary: + return EdmBinary.getInstance(); + case Boolean: + return EdmBoolean.getInstance(); + case Byte: + return EdmByte.getInstance(); + case SByte: + return EdmSByte.getInstance(); + case Date: + return EdmDate.getInstance(); + case DateTime: + return EdmDateTime.getInstance(); + case DateTimeOffset: + return EdmDateTimeOffset.getInstance(); + case Time: + return EdmTime.getInstance(); + case TimeOfDay: + return EdmTimeOfDay.getInstance(); + case Duration: + return EdmDuration.getInstance(); + case Decimal: + return EdmDecimal.getInstance(); + case Single: + return EdmSingle.getInstance(); + case Double: + return EdmDouble.getInstance(); + case Guid: + return EdmGuid.getInstance(); + case Int16: + return EdmInt16.getInstance(); + case Int32: + return EdmInt32.getInstance(); + case Int64: + return EdmInt64.getInstance(); + case String: + return EdmString.getInstance(); + case Stream: + return EdmStream.getInstance(); + + default: + throw new IllegalArgumentException("Wrong type: " + kind); + } + } + + /** + * Returns an instance for the provided {@link EdmPrimitiveTypeKind} in the form of {@link EdmGeospatialType}. + * + * @param kind EdmPrimitiveTypeKind + * @return {@link EdmGeospatialType} instance + */ + public static EdmGeospatialType getGeoInstance(final EdmPrimitiveTypeKind kind) { + switch (kind) { + case Geography: + return EdmGeography.getInstance(); + case GeographyPoint: + return EdmGeographyPoint.getInstance(); + case GeographyLineString: + return EdmGeographyLineString.getInstance(); + case GeographyPolygon: + return EdmGeographyPolygon.getInstance(); + case GeographyMultiPoint: + return EdmGeographyMultiPoint.getInstance(); + case GeographyMultiLineString: + return EdmGeographyMultiLineString.getInstance(); + case GeographyMultiPolygon: + return EdmGeographyMultiPolygon.getInstance(); + case GeographyCollection: + return EdmGeographyCollection.getInstance(); + case Geometry: + return EdmGeometry.getInstance(); + case GeometryPoint: + return EdmGeometry.getInstance(); + case GeometryLineString: + return EdmGeometryLineString.getInstance(); + case GeometryPolygon: + return EdmGeometryPolygon.getInstance(); + case GeometryMultiPoint: + return EdmGeometryMultiPoint.getInstance(); + case GeometryMultiLineString: + return EdmGeographyMultiLineString.getInstance(); + case GeometryMultiPolygon: + return EdmGeometryMultiPolygon.getInstance(); + case GeometryCollection: + return EdmGeometryCollection.getInstance(); + + default: + throw new IllegalArgumentException("Wrong type: " + kind); + + } + } + + private EdmPrimitiveTypeFactory() { + // empty constructor for static utility class + } + +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmPrimitiveTypeKind.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmPrimitiveTypeKind.java deleted file mode 100644 index e36860758..000000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmPrimitiveTypeKind.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.edm.primitivetype; - -import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.api.edm.FullQualifiedName; - -//TODO: Should we delete this typekind and use a facade? -public enum EdmPrimitiveTypeKind { - - Binary, Boolean, Byte, Date, DateTimeOffset, Decimal, Double, Duration, Guid, - Int16, Int32, Int64, SByte, Single, String, TimeOfDay; - - /** - * Returns the {@link FullQualifiedName} for this type kind. - * - * @return {@link FullQualifiedName} - */ - public FullQualifiedName getFullQualifiedName() { - return new FullQualifiedName(EdmPrimitiveType.EDM_NAMESPACE, toString()); - } - - /** - * Returns an instance for this {@link EdmPrimitiveTypeKind} in the form of {@link EdmPrimitiveType}. - * - * @return {@link EdmPrimitiveType} instance - */ - public EdmPrimitiveType getEdmPrimitiveTypeInstance() { - switch (this) { - case Binary: - return EdmBinary.getInstance(); - case Boolean: - return EdmBoolean.getInstance(); - case Byte: - return EdmByte.getInstance(); - case Date: - return EdmDate.getInstance(); - case DateTimeOffset: - return EdmDateTimeOffset.getInstance(); - case Decimal: - return EdmDecimal.getInstance(); - case Double: - return EdmDouble.getInstance(); - case Duration: - return EdmDuration.getInstance(); - case Guid: - return EdmGuid.getInstance(); - case Int16: - return EdmInt16.getInstance(); - case Int32: - return EdmInt32.getInstance(); - case Int64: - return EdmInt64.getInstance(); - case SByte: - return EdmSByte.getInstance(); - case Single: - return EdmSingle.getInstance(); - case String: - return EdmString.getInstance(); - case TimeOfDay: - return EdmTimeOfDay.getInstance(); - default: - throw new RuntimeException("Wrong type:" + this); - } - } - - /** - * Gets EdmPrimitiveTypeKind from a full string (e.g. 'Edm.Int32'). - * - * @param value string value type. - * @return EdmPrimitiveTypeKind object. - */ - public static EdmPrimitiveTypeKind valueOfFQN(final String value) { - if (!value.startsWith(EdmPrimitiveType.EDM_NAMESPACE + ".")) { - throw new IllegalArgumentException(value + " does not look like an Edm primitive type"); - } - return valueOf(value.substring(4)); - } -} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStream.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStream.java new file mode 100644 index 000000000..75b629187 --- /dev/null +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStream.java @@ -0,0 +1,88 @@ +/* + * 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.net.URI; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; + +/** + * Implementation of the EDM primitive type Stream as URI. + */ +public final class EdmStream extends SingletonPrimitiveType { + + private static final EdmStream INSTANCE = new EdmStream(); + + public static EdmStream getInstance() { + return INSTANCE; + } + + @Override + public Class getDefaultType() { + return URI.class; + } + + @Override + public boolean validate(final String value, final Boolean isNullable, final Integer maxLength, + final Integer precision, final Integer scale, final Boolean isUnicode) { + + if (value == null) { + return isNullable == null || isNullable; + } + + try { + new URI(value); + return true; + } catch (Exception e) { + return false; + } + } + + @Override + protected T internalValueOfString(final String value, + final Boolean isNullable, final Integer maxLength, final Integer precision, + final Integer scale, final Boolean isUnicode, final Class returnType) throws EdmPrimitiveTypeException { + + URI stream = null; + try { + stream = new URI(value); + } catch (Exception e) { + throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e); + } + + if (returnType.isAssignableFrom(URI.class)) { + return returnType.cast(stream); + } else { + throw new EdmPrimitiveTypeException( + "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)"); + } + } + + @Override + protected 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 URI) { + return ((URI) value).toASCIIString(); + } else { + throw new EdmPrimitiveTypeException( + "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())"); + } + } +} diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmNull.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTime.java similarity index 57% rename from lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmNull.java rename to lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTime.java index 57b1218b3..75e80cfb8 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmNull.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTime.java @@ -18,33 +18,25 @@ */ package org.apache.olingo.commons.core.edm.primitivetype; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.Duration; + import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; -//TODO: Is this class still necessary? /** - * Implementation of the simple type Null. + * Implementation of the EDM primitive type Time. */ -public final class EdmNull extends SingletonPrimitiveType { +public final class EdmTime extends SingletonPrimitiveType { - private static final EdmNull INSTANCE = new EdmNull(); + private static final EdmTime INSTANCE = new EdmTime(); - public static EdmNull getInstance() { + public static EdmTime getInstance() { return INSTANCE; } - @Override - public boolean equals(final Object obj) { - return this == obj || obj == null; - } - - @Override - public int hashCode() { - return 0; - } - @Override public Class getDefaultType() { - return null; + return Duration.class; } @Override @@ -52,7 +44,20 @@ public final class EdmNull extends SingletonPrimitiveType { final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode, final Class returnType) throws EdmPrimitiveTypeException { - return null; + Duration duration = null; + try { + final DatatypeFactory dtFactory = DatatypeFactory.newInstance(); + duration = dtFactory.newDuration(value); + } catch (Exception e) { + throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e); + } + + if (returnType.isAssignableFrom(Duration.class)) { + return returnType.cast(duration); + } else { + throw new EdmPrimitiveTypeException( + "EdmPrimitiveTypeException.LITERAL_UNCONVERTIBLE_TO_VALUE_TYPE.addContent(value, returnType)"); + } } @Override @@ -60,16 +65,13 @@ public final class EdmNull extends SingletonPrimitiveType { final Boolean isNullable, final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException { - return null; - } + if (value instanceof Duration) { + final Duration duration = (Duration) value; + return duration.toString(); + } else { + throw new EdmPrimitiveTypeException( + "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())"); + } - @Override - public String toUriLiteral(final String literal) { - return "null"; - } - - @Override - public String fromUriLiteral(final String literal) throws EdmPrimitiveTypeException { - return null; } } diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/CommonPrimitiveTypeTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/CommonPrimitiveTypeTest.java index 18b0dc6cf..dba916b36 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/CommonPrimitiveTypeTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/CommonPrimitiveTypeTest.java @@ -28,10 +28,9 @@ import java.util.Calendar; import java.util.UUID; 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.constants.EdmTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.EdmNull; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.Uint7; import org.junit.Test; public class CommonPrimitiveTypeTest extends PrimitiveTypeBaseTest { @@ -40,9 +39,11 @@ public class CommonPrimitiveTypeTest extends PrimitiveTypeBaseTest { public void nameSpace() throws Exception { assertEquals(EdmPrimitiveType.SYSTEM_NAMESPACE, Uint7.getInstance().getNamespace()); - assertEquals(EdmPrimitiveType.EDM_NAMESPACE, EdmNull.getInstance().getNamespace()); + assertEquals(EdmPrimitiveType.EDM_NAMESPACE, EdmInt32.getInstance().getNamespace()); for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) { - final EdmPrimitiveType instance = kind.getEdmPrimitiveTypeInstance(); + final EdmType instance = kind.isGeospatial() + ? EdmPrimitiveTypeFactory.getGeoInstance(kind) + : EdmPrimitiveTypeFactory.getNonGeoInstance(kind); assertEquals(EdmPrimitiveType.EDM_NAMESPACE, instance.getNamespace()); } } @@ -51,29 +52,33 @@ public class CommonPrimitiveTypeTest extends PrimitiveTypeBaseTest { public void names() throws Exception { assertEquals("Uint7", Uint7.getInstance().getName()); - assertEquals("Null", EdmNull.getInstance().getName()); - assertEquals("Binary", EdmPrimitiveTypeKind.Binary.getEdmPrimitiveTypeInstance().getName()); - assertEquals("Boolean", EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance().getName()); - assertEquals("Byte", EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance().getName()); - assertEquals("Date", EdmPrimitiveTypeKind.Date.getEdmPrimitiveTypeInstance().getName()); - assertEquals("DateTimeOffset", EdmPrimitiveTypeKind.DateTimeOffset.getEdmPrimitiveTypeInstance().getName()); - assertEquals("Decimal", EdmPrimitiveTypeKind.Decimal.getEdmPrimitiveTypeInstance().getName()); - assertEquals("Double", EdmPrimitiveTypeKind.Double.getEdmPrimitiveTypeInstance().getName()); - assertEquals("Duration", EdmPrimitiveTypeKind.Duration.getEdmPrimitiveTypeInstance().getName()); - assertEquals("Guid", EdmPrimitiveTypeKind.Guid.getEdmPrimitiveTypeInstance().getName()); - assertEquals("Int16", EdmPrimitiveTypeKind.Int16.getEdmPrimitiveTypeInstance().getName()); - assertEquals("Int32", EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance().getName()); - assertEquals("Int64", EdmPrimitiveTypeKind.Int64.getEdmPrimitiveTypeInstance().getName()); - assertEquals("SByte", EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance().getName()); - assertEquals("Single", EdmPrimitiveTypeKind.Single.getEdmPrimitiveTypeInstance().getName()); - assertEquals("String", EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance().getName()); - assertEquals("TimeOfDay", EdmPrimitiveTypeKind.TimeOfDay.getEdmPrimitiveTypeInstance().getName()); + assertEquals("Binary", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Binary).getName()); + assertEquals("Boolean", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Boolean).getName()); + assertEquals("Byte", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Byte).getName()); + assertEquals("Date", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Date).getName()); + assertEquals("DateTimeOffset", + EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.DateTimeOffset).getName()); + assertEquals("Decimal", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Decimal).getName()); + assertEquals("Double", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Double).getName()); + assertEquals("Duration", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Duration).getName()); + assertEquals("Guid", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Guid).getName()); + assertEquals("Int16", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int16).getName()); + assertEquals("Int32", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int32).getName()); + assertEquals("Int64", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int64).getName()); + assertEquals("SByte", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.SByte).getName()); + assertEquals("Single", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Single).getName()); + assertEquals("String", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.String).getName()); + assertEquals("TimeOfDay", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.TimeOfDay).getName()); } @Test public void kind() throws Exception { for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) { - assertEquals(EdmTypeKind.PRIMITIVE, kind.getEdmPrimitiveTypeInstance().getKind()); + if (kind.isGeospatial()) { + assertEquals(EdmTypeKind.PRIMITIVE, EdmPrimitiveTypeFactory.getGeoInstance(kind).getKind()); + } else { + assertEquals(EdmTypeKind.PRIMITIVE, EdmPrimitiveTypeFactory.getNonGeoInstance(kind).getKind()); + } } } @@ -81,95 +86,113 @@ public class CommonPrimitiveTypeTest extends PrimitiveTypeBaseTest { public void toStringAll() throws Exception { assertEquals("System.Uint7", Uint7.getInstance().toString()); - assertEquals("Edm.Null", EdmNull.getInstance().toString()); - assertEquals("Edm.Binary", EdmPrimitiveTypeKind.Binary.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.Boolean", EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.Byte", EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.Date", EdmPrimitiveTypeKind.Date.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.DateTimeOffset", EdmPrimitiveTypeKind.DateTimeOffset.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.Decimal", EdmPrimitiveTypeKind.Decimal.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.Double", EdmPrimitiveTypeKind.Double.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.Duration", EdmPrimitiveTypeKind.Duration.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.Guid", EdmPrimitiveTypeKind.Guid.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.Int16", EdmPrimitiveTypeKind.Int16.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.Int32", EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.Int64", EdmPrimitiveTypeKind.Int64.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.SByte", EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.Single", EdmPrimitiveTypeKind.Single.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.String", EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance().toString()); - assertEquals("Edm.TimeOfDay", EdmPrimitiveTypeKind.TimeOfDay.getEdmPrimitiveTypeInstance().toString()); + assertEquals("Edm.Binary", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Binary).toString()); + assertEquals("Edm.Boolean", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Boolean).toString()); + assertEquals("Edm.Byte", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Byte).toString()); + assertEquals("Edm.Date", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Date).toString()); + assertEquals("Edm.DateTimeOffset", + EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.DateTimeOffset).toString()); + assertEquals("Edm.Decimal", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Decimal).toString()); + assertEquals("Edm.Double", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Double).toString()); + assertEquals("Edm.Duration", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Duration).toString()); + assertEquals("Edm.Guid", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Guid).toString()); + assertEquals("Edm.Int16", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int16).toString()); + assertEquals("Edm.Int32", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int32).toString()); + assertEquals("Edm.Int64", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int64).toString()); + assertEquals("Edm.SByte", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.SByte).toString()); + assertEquals("Edm.Single", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Single).toString()); + assertEquals("Edm.String", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.String).toString()); + assertEquals("Edm.TimeOfDay", EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.TimeOfDay).toString()); for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) { - final EdmPrimitiveType instance = kind.getEdmPrimitiveTypeInstance(); - assertEquals(instance.toString(), kind.getFullQualifiedName().toString()); + if (!kind.isGeospatial()) { + final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(kind); + assertEquals(instance.toString(), kind.getFullQualifiedName().toString()); + } } } @Test public void compatibility() { for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) { - final EdmPrimitiveType instance = kind.getEdmPrimitiveTypeInstance(); - assertTrue(instance.isCompatible(instance)); - assertFalse(instance.isCompatible( - (kind == EdmPrimitiveTypeKind.String ? EdmPrimitiveTypeKind.Binary : EdmPrimitiveTypeKind.String) - .getEdmPrimitiveTypeInstance())); + if (!kind.isGeospatial()) { + final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(kind); + assertTrue(instance.isCompatible(instance)); + assertFalse(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance( + (kind == EdmPrimitiveTypeKind.String ? EdmPrimitiveTypeKind.Binary : EdmPrimitiveTypeKind.String)))); + } } } @Test public void defaultType() throws Exception { assertEquals(Byte.class, Uint7.getInstance().getDefaultType()); - assertNull(EdmNull.getInstance().getDefaultType()); - assertEquals(byte[].class, EdmPrimitiveTypeKind.Binary.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(Boolean.class, EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(Short.class, EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(Calendar.class, EdmPrimitiveTypeKind.Date.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(Calendar.class, EdmPrimitiveTypeKind.DateTimeOffset.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(BigDecimal.class, EdmPrimitiveTypeKind.Decimal.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(Double.class, EdmPrimitiveTypeKind.Double.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(BigDecimal.class, EdmPrimitiveTypeKind.Duration.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(UUID.class, EdmPrimitiveTypeKind.Guid.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(Short.class, EdmPrimitiveTypeKind.Int16.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(Integer.class, EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(Long.class, EdmPrimitiveTypeKind.Int64.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(Byte.class, EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(Float.class, EdmPrimitiveTypeKind.Single.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(String.class, EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance().getDefaultType()); - assertEquals(Calendar.class, EdmPrimitiveTypeKind.TimeOfDay.getEdmPrimitiveTypeInstance().getDefaultType()); + assertEquals(byte[].class, EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Binary).getDefaultType()); + assertEquals(Boolean.class, + EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Boolean).getDefaultType()); + assertEquals(Short.class, EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Byte).getDefaultType()); + assertEquals(Calendar.class, EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Date).getDefaultType()); + assertEquals(Calendar.class, + EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.DateTimeOffset).getDefaultType()); + assertEquals(BigDecimal.class, + EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Decimal).getDefaultType()); + assertEquals(Double.class, EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Double).getDefaultType()); + assertEquals(BigDecimal.class, + EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Duration).getDefaultType()); + assertEquals(UUID.class, EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Guid).getDefaultType()); + assertEquals(Short.class, EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int16).getDefaultType()); + assertEquals(Integer.class, EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int32).getDefaultType()); + assertEquals(Long.class, EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int64).getDefaultType()); + assertEquals(Byte.class, EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.SByte).getDefaultType()); + assertEquals(Float.class, EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Single).getDefaultType()); + assertEquals(String.class, EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.String).getDefaultType()); + assertEquals(Calendar.class, + EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.TimeOfDay).getDefaultType()); } @Test public void validate() throws Exception { for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) { - final EdmPrimitiveType instance = kind.getEdmPrimitiveTypeInstance(); - assertTrue(instance.validate(null, null, null, null, null, null)); - assertTrue(instance.validate(null, true, null, null, null, null)); - assertFalse(instance.validate(null, false, null, null, null, null)); - assertFalse(instance.validate("ä", null, null, null, null, false)); - if (kind != EdmPrimitiveTypeKind.String && kind != EdmPrimitiveTypeKind.Binary) { - assertFalse(instance.validate("", null, null, null, null, null)); - } - if (kind != EdmPrimitiveTypeKind.String) { - assertFalse(instance.validate("ä", null, null, null, null, null)); + if (!kind.isGeospatial()) { + final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(kind); + assertTrue(instance.validate(null, null, null, null, null, null)); + assertTrue(instance.validate(null, true, null, null, null, null)); + assertFalse(instance.validate(null, false, null, null, null, null)); + if (kind != EdmPrimitiveTypeKind.Stream) { + assertFalse(instance.validate("ä", null, null, null, null, false)); + } + if (kind != EdmPrimitiveTypeKind.String && kind != EdmPrimitiveTypeKind.Binary + && kind != EdmPrimitiveTypeKind.Stream) { + + assertFalse(instance.validate("", null, null, null, null, null)); + } + if (kind != EdmPrimitiveTypeKind.String && kind != EdmPrimitiveTypeKind.Stream) { + assertFalse(instance.validate("ä", null, null, null, null, null)); + } } } - assertTrue(EdmPrimitiveTypeKind.Binary.getEdmPrimitiveTypeInstance().validate("abcd", null, 3, null, null, null)); - assertFalse(EdmPrimitiveTypeKind.Binary.getEdmPrimitiveTypeInstance().validate("abcd", null, 2, null, null, null)); + assertTrue(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Binary). + validate("abcd", null, 3, null, null, null)); + assertFalse(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Binary). + validate("abcd", null, 2, null, null, null)); - assertTrue(EdmPrimitiveTypeKind.Decimal.getEdmPrimitiveTypeInstance().validate("1", null, null, null, null, - null)); - assertFalse(EdmPrimitiveTypeKind.Decimal.getEdmPrimitiveTypeInstance().validate("1.2", null, null, null, 0, null)); + assertTrue(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Decimal). + validate("1", null, null, null, null, null)); + assertFalse(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Decimal). + validate("1.2", null, null, null, 0, null)); } @Test public void uriLiteral() throws Exception { for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) { - final EdmPrimitiveType instance = kind.getEdmPrimitiveTypeInstance(); - assertEquals("test", instance.fromUriLiteral(instance.toUriLiteral("test"))); - assertNull(instance.toUriLiteral(null)); - assertNull(instance.fromUriLiteral(null)); + if (!kind.isGeospatial()) { + final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(kind); + assertEquals("test", instance.fromUriLiteral(instance.toUriLiteral("test"))); + assertNull(instance.toUriLiteral(null)); + assertNull(instance.fromUriLiteral(null)); + } } } } diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinaryTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinaryTest.java index 39fd38c31..c3ff01c34 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinaryTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBinaryTest.java @@ -25,12 +25,12 @@ import static org.junit.Assert.assertTrue; import java.util.Arrays; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmBinaryTest extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.Binary.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Binary); @Test public void validate() throws Exception { @@ -64,14 +64,14 @@ public class EdmBinaryTest extends PrimitiveTypeBaseTest { @Test public void valueToString() throws Exception { - final byte[] binary = new byte[] { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + final byte[] binary = new byte[]{(byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF}; assertEquals("qrvM3e7_", instance.valueToString(binary, null, null, null, null, null)); assertEquals("qrvM3e7_", instance.valueToString(binary, null, 6, null, null, null)); assertEquals("qrvM3e7_", instance.valueToString(binary, null, Integer.MAX_VALUE, null, null, null)); - assertEquals("qg", instance.valueToString(new Byte[] { new Byte((byte) 170) }, null, null, null, null, null)); + assertEquals("qg", instance.valueToString(new Byte[]{new Byte((byte) 170)}, null, null, null, null, null)); expectFacetsErrorInValueToString(instance, binary, null, 3, null, null, null); @@ -80,23 +80,23 @@ public class EdmBinaryTest extends PrimitiveTypeBaseTest { @Test public void valueOfString() throws Exception { - final byte[] binary = new byte[] { (byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF }; + final byte[] binary = new byte[]{(byte) 0xAA, (byte) 0xBB, (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF}; assertTrue(Arrays.equals(binary, instance.valueOfString("qrvM3e7_", null, null, null, null, null, byte[].class))); - assertTrue(Arrays.equals(new Byte[] { binary[0], binary[1], binary[2] }, instance.valueOfString("qrvM", null, null, - null, null, null, Byte[].class))); + assertTrue(Arrays.equals(new Byte[]{binary[0], binary[1], binary[2]}, instance.valueOfString("qrvM", null, null, + null, null, null, Byte[].class))); assertTrue(Arrays.equals(binary, instance.valueOfString("qrvM3e7_", null, 6, null, null, null, byte[].class))); - assertTrue(Arrays.equals(new byte[] { 42 }, instance.valueOfString("Kg==", null, 1, null, null, null, - byte[].class))); - assertTrue(Arrays.equals(new byte[] { 42 }, instance.valueOfString("Kg", null, 1, null, null, null, - byte[].class))); - assertTrue(Arrays.equals(new byte[] { 1, 2 }, instance.valueOfString("AQI=", null, 2, null, null, null, - byte[].class))); + assertTrue(Arrays.equals(new byte[]{42}, instance.valueOfString("Kg==", null, 1, null, null, null, + byte[].class))); + assertTrue(Arrays.equals(new byte[]{42}, instance.valueOfString("Kg", null, 1, null, null, null, + byte[].class))); + assertTrue(Arrays.equals(new byte[]{1, 2}, instance.valueOfString("AQI=", null, 2, null, null, null, + byte[].class))); assertTrue(Arrays.equals(binary, instance.valueOfString("qrvM3e7_", null, 6, null, null, null, - byte[].class))); + byte[].class))); assertTrue(Arrays.equals(binary, instance.valueOfString("qrvM3e7_", null, Integer.MAX_VALUE, null, null, null, - byte[].class))); + byte[].class))); expectFacetsErrorInValueOfString(instance, "qrvM3e7_", null, 3, null, null, null); expectContentErrorInValueOfString(instance, "@"); diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBooleanTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBooleanTest.java index 1abca669c..d1e6580ee 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBooleanTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmBooleanTest.java @@ -21,12 +21,12 @@ package org.apache.olingo.commons.core.edm.primitivetype; import static org.junit.Assert.assertEquals; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmBooleanTest extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Boolean); @Test public void toUriLiteral() throws Exception { diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmByteTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmByteTest.java index ddf819ff4..c560c39da 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmByteTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmByteTest.java @@ -24,13 +24,12 @@ import static org.junit.Assert.assertTrue; import java.math.BigInteger; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.Uint7; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmByteTest extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Byte); @Test public void compatibility() { diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTest.java index 3d966bce4..6cc3d1924 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTest.java @@ -25,12 +25,12 @@ import java.util.Date; import java.util.TimeZone; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmDateTest extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.Date.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Date); @Test public void toUriLiteral() throws Exception { diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffsetTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffsetTest.java index f92fbecda..bcc01232d 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffsetTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffsetTest.java @@ -26,12 +26,12 @@ import java.util.Date; import java.util.TimeZone; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmDateTimeOffsetTest extends PrimitiveTypeBaseTest { - final EdmPrimitiveType instance = EdmPrimitiveTypeKind.DateTimeOffset.getEdmPrimitiveTypeInstance(); + final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.DateTimeOffset); @Test public void toUriLiteral() throws Exception { diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimalTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimalTest.java index 9f987a7e9..35917af01 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimalTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDecimalTest.java @@ -25,24 +25,23 @@ import java.math.BigDecimal; import java.math.BigInteger; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.Uint7; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmDecimalTest extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.Decimal.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Decimal); @Test public void compatibility() { assertTrue(instance.isCompatible(Uint7.getInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int16.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int64.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Single.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Double.getEdmPrimitiveTypeInstance())); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Byte))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.SByte))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int16))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int32))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int64))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Single))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Double))); } @Test diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDoubleTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDoubleTest.java index abb3a6bf2..57403ced3 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDoubleTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDoubleTest.java @@ -25,23 +25,22 @@ import java.math.BigDecimal; import java.math.BigInteger; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.Uint7; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmDoubleTest extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.Double.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Double); @Test public void compatibility() { assertTrue(instance.isCompatible(Uint7.getInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int16.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int64.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Single.getEdmPrimitiveTypeInstance())); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Byte))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.SByte))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int16))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int32))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int64))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Single))); } @Test diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDurationTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDurationTest.java index 7b97f7eba..85745b4ae 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDurationTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDurationTest.java @@ -24,12 +24,12 @@ import java.math.BigDecimal; import java.math.BigInteger; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmDurationTest extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.Duration.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Duration); @Test public void toUriLiteral() throws Exception { diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGuidTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGuidTest.java index c6d73ca42..f69eddc18 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGuidTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGuidTest.java @@ -23,12 +23,12 @@ import static org.junit.Assert.assertEquals; import java.util.UUID; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmGuidTest extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.Guid.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Guid); @Test public void toUriLiteral() { diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt16Test.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt16Test.java index 458e1d49b..55c12bba0 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt16Test.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt16Test.java @@ -24,19 +24,18 @@ import static org.junit.Assert.assertTrue; import java.math.BigInteger; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.Uint7; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmInt16Test extends PrimitiveTypeBaseTest { - final EdmPrimitiveType instance = EdmPrimitiveTypeKind.Int16.getEdmPrimitiveTypeInstance(); + final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int16); @Test public void testInt16Compatibility() { assertTrue(instance.isCompatible(Uint7.getInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance())); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Byte))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.SByte))); } @Test diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt32Test.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt32Test.java index f0ada7e35..e3410d742 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt32Test.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt32Test.java @@ -24,20 +24,19 @@ import static org.junit.Assert.assertTrue; import java.math.BigInteger; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.Uint7; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmInt32Test extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int32); @Test public void compatibility() { assertTrue(instance.isCompatible(Uint7.getInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int16.getEdmPrimitiveTypeInstance())); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Byte))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.SByte))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int16))); } @Test diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt64Test.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt64Test.java index d7047701d..f45ab4949 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt64Test.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmInt64Test.java @@ -24,21 +24,20 @@ import static org.junit.Assert.assertTrue; import java.math.BigInteger; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.Uint7; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmInt64Test extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.Int64.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int64); @Test public void compatibility() { assertTrue(instance.isCompatible(Uint7.getInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int16.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance())); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Byte))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.SByte))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int16))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int32))); } @Test diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmNullTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmNullTest.java index 3a9daafba..5450be841 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmNullTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmNullTest.java @@ -21,7 +21,7 @@ package org.apache.olingo.commons.core.edm.primitivetype; import static org.junit.Assert.assertNull; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmNullTest extends PrimitiveTypeBaseTest { @@ -29,22 +29,26 @@ public class EdmNullTest extends PrimitiveTypeBaseTest { @Test public void checkNull() throws Exception { for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) { - final EdmPrimitiveType instance = kind.getEdmPrimitiveTypeInstance(); - assertNull(instance.valueToString(null, null, null, null, null, null)); - assertNull(instance.valueToString(null, true, null, null, null, null)); + if (!kind.isGeospatial()) { + final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(kind); + assertNull(instance.valueToString(null, null, null, null, null, null)); + assertNull(instance.valueToString(null, true, null, null, null, null)); - expectNullErrorInValueToString(instance); + expectNullErrorInValueToString(instance); + } } } @Test public void checkValueOfNull() throws Exception { for (EdmPrimitiveTypeKind kind : EdmPrimitiveTypeKind.values()) { - final EdmPrimitiveType instance = kind.getEdmPrimitiveTypeInstance(); - assertNull(instance.valueOfString(null, null, null, null, null, null, instance.getDefaultType())); - assertNull(instance.valueOfString(null, true, null, null, null, null, instance.getDefaultType())); + if (!kind.isGeospatial()) { + final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(kind); + assertNull(instance.valueOfString(null, null, null, null, null, null, instance.getDefaultType())); + assertNull(instance.valueOfString(null, true, null, null, null, null, instance.getDefaultType())); - expectNullErrorInValueOfString(instance); + expectNullErrorInValueOfString(instance); + } } } -} \ No newline at end of file +} diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSByteTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSByteTest.java index 0ebb34226..88835e928 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSByteTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSByteTest.java @@ -24,13 +24,12 @@ import static org.junit.Assert.assertTrue; import java.math.BigInteger; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.Uint7; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmSByteTest extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.SByte); @Test public void compatibility() { diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSingleTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSingleTest.java index 67847c772..9e90f22ab 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSingleTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmSingleTest.java @@ -25,22 +25,21 @@ import java.math.BigDecimal; import java.math.BigInteger; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.Uint7; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmSingleTest extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.Single.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Single); @Test public void compatibility() { assertTrue(instance.isCompatible(Uint7.getInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Byte.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int16.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance())); - assertTrue(instance.isCompatible(EdmPrimitiveTypeKind.Int64.getEdmPrimitiveTypeInstance())); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Byte))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.SByte))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int16))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int32))); + assertTrue(instance.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int64))); } @Test diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStringTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStringTest.java index 993c94325..bba0f910c 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStringTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmStringTest.java @@ -21,12 +21,12 @@ package org.apache.olingo.commons.core.edm.primitivetype; import static org.junit.Assert.assertEquals; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmStringTest extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.String); @Test public void toUriLiteral() throws Exception { diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDayTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDayTest.java index 8979df9d3..ee9b2b882 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDayTest.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmTimeOfDayTest.java @@ -24,12 +24,12 @@ import java.util.Calendar; import java.util.TimeZone; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.junit.Test; public class EdmTimeOfDayTest extends PrimitiveTypeBaseTest { - private final EdmPrimitiveType instance = EdmPrimitiveTypeKind.TimeOfDay.getEdmPrimitiveTypeInstance(); + private final EdmPrimitiveType instance = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.TimeOfDay); @Test public void toUriLiteral() throws Exception { diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/UInt7Test.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/UInt7Test.java index 05807ee0e..c956789b3 100644 --- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/UInt7Test.java +++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/UInt7Test.java @@ -18,11 +18,10 @@ */ package org.apache.olingo.commons.core.edm.primitivetype; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.Uint7; import org.junit.Test; public class UInt7Test extends PrimitiveTypeBaseTest { @@ -30,6 +29,7 @@ public class UInt7Test extends PrimitiveTypeBaseTest { @Test public void compatibility() { assertTrue(Uint7.getInstance().isCompatible(Uint7.getInstance())); - assertFalse(Uint7.getInstance().isCompatible(EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance())); + assertFalse(Uint7.getInstance().isCompatible( + EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.String))); } } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEnumTypeImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEnumTypeImpl.java index faceb0edb..9645d93f3 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEnumTypeImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmEnumTypeImpl.java @@ -24,9 +24,10 @@ import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmMember; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.AbstractEdmEnumType; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.apache.olingo.server.api.edm.provider.EnumType; public class EdmEnumTypeImpl extends AbstractEdmEnumType implements EdmEnumType { @@ -39,10 +40,10 @@ public class EdmEnumTypeImpl extends AbstractEdmEnumType implements EdmEnumType super(edm, enumName, enumType.isFlags()); if (enumType.getUnderlyingType() == null) { - this.underlyingType = EdmPrimitiveTypeKind.Int32.getEdmPrimitiveTypeInstance(); + this.underlyingType = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Int32); } else { - this.underlyingType = EdmPrimitiveTypeKind.valueOf( - enumType.getUnderlyingType().getName()).getEdmPrimitiveTypeInstance(); + this.underlyingType = EdmPrimitiveTypeFactory.getNonGeoInstance( + EdmPrimitiveTypeKind.valueOf(enumType.getUnderlyingType().getName())); // TODO: Should we validate that the underlying type is of byte, sbyte, in16, int32 or int64? } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImpl.java index 1c6fb0b87..91b0cde14 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImpl.java @@ -21,10 +21,11 @@ package org.apache.olingo.server.core.edm.provider; 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.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.core.edm.AbstractEdmTypeDefinition; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.apache.olingo.server.api.edm.provider.TypeDefinition; public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements EdmTypeDefinition { @@ -34,7 +35,7 @@ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements private EdmPrimitiveType edmPrimitiveTypeInstance; public EdmTypeDefinitionImpl(final Edm edm, final FullQualifiedName typeDefinitionName, - final TypeDefinition typeDefinition) { + final TypeDefinition typeDefinition) { super(edm, typeDefinitionName); this.typeDefinition = typeDefinition; @@ -44,8 +45,8 @@ public class EdmTypeDefinitionImpl extends AbstractEdmTypeDefinition implements public EdmPrimitiveType getUnderlyingType() { if (edmPrimitiveTypeInstance == null) { try { - edmPrimitiveTypeInstance = EdmPrimitiveTypeKind.valueOf( - typeDefinition.getUnderlyingType().getName()).getEdmPrimitiveTypeInstance(); + edmPrimitiveTypeInstance = EdmPrimitiveTypeFactory.getNonGeoInstance( + EdmPrimitiveTypeKind.valueOf(typeDefinition.getUnderlyingType().getName())); } catch (IllegalArgumentException e) { throw new EdmException("Invalid underlying type: " + typeDefinition.getUnderlyingType(), e); } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAllImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAllImpl.java index a5b81af42..bb24c64de 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAllImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAllImpl.java @@ -18,17 +18,21 @@ */ package org.apache.olingo.server.core.uri; +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.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.apache.olingo.server.api.uri.UriResourceKind; import org.apache.olingo.server.api.uri.UriResourceLambdaAll; import org.apache.olingo.server.api.uri.queryoption.expression.Expression; import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl; public class UriResourceLambdaAllImpl extends UriResourceTypedImpl implements UriResourceLambdaAll { + protected EdmProperty property; + private String lambdaVariable; + private ExpressionImpl expression; public UriResourceLambdaAllImpl() { @@ -37,7 +41,7 @@ public class UriResourceLambdaAllImpl extends UriResourceTypedImpl implements Ur @Override public EdmType getType() { - return EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance(); + return EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean); } @Override @@ -53,7 +57,9 @@ public class UriResourceLambdaAllImpl extends UriResourceTypedImpl implements Ur public UriResourceLambdaAllImpl setLamdaVariable(final String lambdaVariable) { this.lambdaVariable = lambdaVariable; return this; - }; + } + + ; @Override public Expression getExpression() { @@ -63,7 +69,9 @@ public class UriResourceLambdaAllImpl extends UriResourceTypedImpl implements Ur public UriResourceLambdaAllImpl setExpression(final ExpressionImpl expression) { this.expression = expression; return this; - }; + } + + ; @Override public String toString() { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java index 65b6a698d..1e3143c1b 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/UriResourceLambdaAnyImpl.java @@ -18,17 +18,21 @@ */ package org.apache.olingo.server.core.uri; +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.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.apache.olingo.server.api.uri.UriResourceKind; import org.apache.olingo.server.api.uri.UriResourceLambdaAny; import org.apache.olingo.server.api.uri.queryoption.expression.Expression; import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl; public class UriResourceLambdaAnyImpl extends UriResourceTypedImpl implements UriResourceLambdaAny { + protected EdmProperty property; + private String lambdaVariable; + private ExpressionImpl expression; public UriResourceLambdaAnyImpl() { @@ -37,7 +41,7 @@ public class UriResourceLambdaAnyImpl extends UriResourceTypedImpl implements Ur @Override public EdmType getType() { - return EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance(); + return EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean); } @Override @@ -53,7 +57,9 @@ public class UriResourceLambdaAnyImpl extends UriResourceTypedImpl implements Ur public UriResourceLambdaAnyImpl setLamdaVariable(final String lambdaVariable) { this.lambdaVariable = lambdaVariable; return this; - }; + } + + ; @Override public Expression getExpression() { @@ -68,5 +74,6 @@ public class UriResourceLambdaAnyImpl extends UriResourceTypedImpl implements Ur @Override public String toString() { return "any"; - }; + } +; } diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java index e6a22569e..7d9b0d183 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/Parser.java @@ -54,7 +54,6 @@ import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl; import org.apache.olingo.server.core.uri.queryoption.FilterOptionImpl; import org.apache.olingo.server.core.uri.queryoption.FormatOptionImpl; import org.apache.olingo.server.core.uri.queryoption.IdOptionImpl; -import org.apache.olingo.server.core.uri.queryoption.LevelsOptionImpl; import org.apache.olingo.server.core.uri.queryoption.OrderByOptionImpl; import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl; import org.apache.olingo.server.core.uri.queryoption.SkipOptionImpl; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriContext.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriContext.java index 44607603c..c7d13cdb5 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriContext.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriContext.java @@ -22,10 +22,6 @@ import java.util.Stack; import org.apache.olingo.commons.api.edm.EdmType; import org.apache.olingo.server.core.uri.UriInfoImpl; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.ExpandPathContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.ExpandPathExtensionContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.SelectItemContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.SelectSegmentContext; import org.apache.olingo.server.core.uri.parser.UriParseTreeVisitor.TypeInformation; import org.apache.olingo.server.core.uri.queryoption.ExpandItemImpl; import org.apache.olingo.server.core.uri.queryoption.SelectItemImpl; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java index b3e5d694d..47f5ccee5 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java @@ -23,7 +23,6 @@ import java.util.List; import org.antlr.v4.runtime.misc.ParseCancellationException; import org.antlr.v4.runtime.tree.ParseTree; -import org.antlr.v4.runtime.tree.TerminalNodeImpl; import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.EdmAction; import org.apache.olingo.commons.api.edm.EdmActionImport; @@ -36,12 +35,14 @@ 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.EdmNavigationProperty; +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.EdmSingleton; import org.apache.olingo.commons.api.edm.EdmStructuredType; 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; import org.apache.olingo.server.api.uri.UriInfoKind; import org.apache.olingo.server.api.uri.UriResource; import org.apache.olingo.server.api.uri.UriResourcePartTyped; @@ -70,7 +71,6 @@ import org.apache.olingo.server.core.uri.UriResourceValueImpl; import org.apache.olingo.server.core.uri.UriResourceWithKeysImpl; import org.apache.olingo.server.core.uri.antlr.UriLexer; import org.apache.olingo.server.core.uri.antlr.UriParserBaseVisitor; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.AliasAndValueContext; import org.apache.olingo.server.core.uri.antlr.UriParserParser.AllEOFContext; import org.apache.olingo.server.core.uri.antlr.UriParserParser.AllExprContext; import org.apache.olingo.server.core.uri.antlr.UriParserParser.AltAddContext; @@ -128,7 +128,6 @@ import org.apache.olingo.server.core.uri.antlr.UriParserParser.NamespaceContext; import org.apache.olingo.server.core.uri.antlr.UriParserParser.NaninfinityContext; import org.apache.olingo.server.core.uri.antlr.UriParserParser.NowMethodCallExprContext; import org.apache.olingo.server.core.uri.antlr.UriParserParser.NullruleContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.Number_in_jsonContext; import org.apache.olingo.server.core.uri.antlr.UriParserParser.OdataIdentifierContext; import org.apache.olingo.server.core.uri.antlr.UriParserParser.OrderByContext; import org.apache.olingo.server.core.uri.antlr.UriParserParser.OrderByEOFContext; @@ -157,14 +156,11 @@ import org.apache.olingo.server.core.uri.antlr.UriParserParser.TopContext; import org.apache.olingo.server.core.uri.antlr.UriParserParser.TotalOffsetMinutesMethodCallExprContext; import org.apache.olingo.server.core.uri.antlr.UriParserParser.TotalsecondsMethodCallExprContext; import org.apache.olingo.server.core.uri.antlr.UriParserParser.TrimMethodCallExprContext; -import org.apache.olingo.server.core.uri.antlr.UriParserParser.UnaryContext; import org.apache.olingo.server.core.uri.antlr.UriParserParser.YearMethodCallExprContext; -import org.apache.olingo.server.core.uri.queryoption.AliasQueryOptionImpl; import org.apache.olingo.server.core.uri.queryoption.CountOptionImpl; import org.apache.olingo.server.core.uri.queryoption.ExpandItemImpl; import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl; import org.apache.olingo.server.core.uri.queryoption.FilterOptionImpl; -import org.apache.olingo.server.core.uri.queryoption.FormatOptionImpl; import org.apache.olingo.server.core.uri.queryoption.LevelsOptionImpl; import org.apache.olingo.server.core.uri.queryoption.OrderByItemImpl; import org.apache.olingo.server.core.uri.queryoption.OrderByOptionImpl; @@ -185,22 +181,22 @@ import org.apache.olingo.server.core.uri.queryoption.expression.TypeLiteralImpl; /** * UriVisitor - * - * Converts the URI parse tree the generated by ANTLR into an internal representation - * which maybe is given to the application. - * While converting the tree is only validated against the EDM if necessary. - * + * + * Converts the URI parse tree the generated by ANTLR into an internal representation which maybe is given to the + * application. While converting the tree is only validated against the EDM if necessary. + * * Attention: *
  • This UriVisitor is at somes point more lax than the original ABNF - *
  • It is more tolerable against additional white spaces - * Currently not supported + *
  • It is more tolerable against additional white spaces Currently not supported *
  • Parsing the context of $metadata
  • *
  • Parsing $search
  • */ public class UriParseTreeVisitor extends UriParserBaseVisitor { public class TypeInformation { + boolean isCollection; + EdmType type; TypeInformation(final EdmType type, final boolean isCollection) { @@ -213,11 +209,12 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } public UriContext context = null; + public Edm edm; + public EdmEntityContainer edmEntityContainer; // --- class --- - public UriParseTreeVisitor(final Edm edm, final UriContext context) { this.edm = edm; this.context = context; @@ -281,8 +278,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { public UriResourceTypedImpl readResourcePathSegment(final PathSegmentContext ctx) { boolean checkFirst = false; - if (context.contextUriInfo.getLastResourcePart() == null || - context.contextUriInfo.getLastResourcePart() instanceof UriResourceRootImpl) { + if (context.contextUriInfo.getLastResourcePart() == null + || context.contextUriInfo.getLastResourcePart() instanceof UriResourceRootImpl) { checkFirst = true; } @@ -294,7 +291,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { EdmEntitySet edmEntitySet = edmEntityContainer.getEntitySet(odi); if (edmEntitySet != null) { UriResourceEntitySetImpl uriResource = new UriResourceEntitySetImpl() - .setEntitSet(edmEntitySet); + .setEntitSet(edmEntitySet); context.contextUriInfo.addResourcePart(uriResource); return null; } @@ -303,7 +300,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { EdmSingleton edmSingleton = edmEntityContainer.getSingleton(odi); if (edmSingleton != null) { UriResourceSingletonImpl uriResource = new UriResourceSingletonImpl() - .setSingleton(edmSingleton); + .setSingleton(edmSingleton); context.contextUriInfo.addResourcePart(uriResource); return null; } @@ -312,7 +309,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { EdmActionImport edmActionImport = edmEntityContainer.getActionImport(odi); if (edmActionImport != null) { UriResourceActionImpl uriResource = new UriResourceActionImpl() - .setActionImport(edmActionImport); + .setActionImport(edmActionImport); context.contextUriInfo.addResourcePart(uriResource); return null; } @@ -331,7 +328,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { ctx.vlNVO.remove(0); UriResourceFunctionImpl uriResource = new UriResourceFunctionImpl() - .setFunctionImport(edmFunctionImport, parameters); + .setFunctionImport(edmFunctionImport, parameters); // collect parameter names List names = new ArrayList(); @@ -347,7 +344,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { tmp += (tmp.length() != 0 ? "," : "") + name; } throw wrap(new UriParserSemanticException("Function of functionimport '" + edmFunctionImport.getName() - + "' with parameters [" + tmp + "] not found")); + + "' with parameters [" + tmp + "] not found")); } uriResource.setFunction(edmFunctionImport.getFunction(names)); @@ -362,7 +359,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (lastResourcePart == null) { if (context.contextTypes.size() == 0) { throw wrap(new UriParserSemanticException("Resource part '" + odi + "' can only applied on typed " - + "resource parts")); + + "resource parts")); } source = context.contextTypes.peek(); } else { @@ -370,7 +367,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (source.type == null) { throw wrap(new UriParserSemanticException("Resource part '" + odi + "' can only applied on typed " - + "resource parts")); + + "resource parts")); } } @@ -389,7 +386,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (!(source.type instanceof EdmStructuredType)) { throw wrap(new UriParserSemanticException("Can not parse'" + odi - + "'Previous path segment not a structural type.")); + + "'Previous path segment not a structural type.")); } EdmStructuredType structType = (EdmStructuredType) source.type; @@ -397,27 +394,27 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { EdmElement property = structType.getProperty(odi); if (property == null) { throw wrap(new UriParserSemanticException("Property '" + odi + "' not found in type '" - + structType.getNamespace() + "." + structType.getName() + "'")); + + structType.getNamespace() + "." + structType.getName() + "'")); } if (property instanceof EdmProperty) { if (((EdmProperty) property).isPrimitive() == true) { // create simple property UriResourcePrimitivePropertyImpl simpleResource = new UriResourcePrimitivePropertyImpl() - .setProperty((EdmProperty) property); + .setProperty((EdmProperty) property); context.contextUriInfo.addResourcePart(simpleResource); return null; } else { // create complex property UriResourceComplexPropertyImpl complexResource = new UriResourceComplexPropertyImpl() - .setProperty((EdmProperty) property); + .setProperty((EdmProperty) property); context.contextUriInfo.addResourcePart(complexResource); return null; } } else if (property instanceof EdmNavigationProperty) { // create navigation property UriResourceNavigationPropertyImpl navigationResource = new UriResourceNavigationPropertyImpl() - .setNavigationProperty((EdmNavigationProperty) property); + .setNavigationProperty((EdmNavigationProperty) property); context.contextUriInfo.addResourcePart(navigationResource); return null; } else { @@ -429,7 +426,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { FullQualifiedName fullFilterName = getFullNameFromContext(ctx.vNS, odi); // EdmType lastType = getLastType(lastTyped); - if (source.type instanceof EdmEntityType) { EdmEntityType filterEntityType = edm.getEntityType(fullFilterName); @@ -437,14 +433,14 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { // is entity type cast if (!(filterEntityType.compatibleTo(source.type))) { throw wrap(new UriParserSemanticException( - "Entity typefilter not compatible to previous path segment: " + fullFilterName.toString())); + "Entity typefilter not compatible to previous path segment: " + fullFilterName.toString())); } if (lastResourcePart == null) { // this may be the case if a member expression within a filter starts with a typeCast UriResourceStartingTypeFilterImpl uriResource = new UriResourceStartingTypeFilterImpl() - .setType(filterEntityType) - .setCollection(source.isCollection); + .setType(filterEntityType) + .setCollection(source.isCollection); if (source.isCollection) { uriResource.setCollectionTypeFilter(filterEntityType); } else { @@ -460,17 +456,17 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (lastPartWithKeys.isCollection() == false) { if (lastPartWithKeys.getTypeFilterOnEntry() != null) { - throw wrap(new UriParserSemanticException("Entry typefilters are not chainable, used '" + - getName(filterEntityType) + "' behind '" + - getName(lastPartWithKeys.getTypeFilterOnEntry()) + "'")); + throw wrap(new UriParserSemanticException("Entry typefilters are not chainable, used '" + + getName(filterEntityType) + "' behind '" + + getName(lastPartWithKeys.getTypeFilterOnEntry()) + "'")); } lastPartWithKeys.setEntryTypeFilter(filterEntityType); return null; } else { if (lastPartWithKeys.getTypeFilterOnCollection() != null) { - throw wrap(new UriParserSemanticException("Collection typefilters are not chainable, used '" + - getName(filterEntityType) + "' behind '" + - getName(lastPartWithKeys.getTypeFilterOnCollection()) + "'")); + throw wrap(new UriParserSemanticException("Collection typefilters are not chainable, used '" + + getName(filterEntityType) + "' behind '" + + getName(lastPartWithKeys.getTypeFilterOnCollection()) + "'")); } lastPartWithKeys.setCollectionTypeFilter(filterEntityType); return null; @@ -478,16 +474,16 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } else if (lastResourcePart instanceof UriResourceTypedImpl) { UriResourceTypedImpl lastPartTyped = (UriResourceTypedImpl) lastResourcePart; if (lastPartTyped.getTypeFilter() != null) { - throw wrap(new UriParserSemanticException("Typefilters are not chainable, used '" + - getName(filterEntityType) + "' behind '" + - getName(lastPartTyped.getTypeFilter()) + "'")); + throw wrap(new UriParserSemanticException("Typefilters are not chainable, used '" + + getName(filterEntityType) + "' behind '" + + getName(lastPartTyped.getTypeFilter()) + "'")); } lastPartTyped.setTypeFilter(filterEntityType); return null; } else { throw wrap(new UriParserSemanticException("Path segment before '" + getName(filterEntityType) - + "' not typed")); + + "' not typed")); } } } @@ -501,7 +497,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { // is complex type cast if (!(filterComplexType.compatibleTo(source.type))) { throw wrap(new UriParserSemanticException( - "Complex typefilter '" + getName(source.type) + "'not compatible type of previous path segment '" + "Complex typefilter '" + getName(source.type) + "'not compatible type of previous path segment '" + getName(filterComplexType) + "'")); } @@ -509,8 +505,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (lastResourcePart == null) { // this may be the case if a member expression within a filter starts with a typeCast UriResourceStartingTypeFilterImpl uriResource = new UriResourceStartingTypeFilterImpl() - .setType(filterComplexType) - .setCollection(source.isCollection); + .setType(filterComplexType) + .setCollection(source.isCollection); if (source.isCollection) { uriResource.setCollectionTypeFilter(filterComplexType); @@ -526,17 +522,17 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (lastPartWithKeys.isCollection() == false) { if (lastPartWithKeys.getTypeFilterOnEntry() != null) { - throw wrap(new UriParserSemanticException("Entry typefilters are not chainable, used '" + - getName(filterComplexType) + "' behind '" + - getName(lastPartWithKeys.getTypeFilterOnEntry()) + "'")); + throw wrap(new UriParserSemanticException("Entry typefilters are not chainable, used '" + + getName(filterComplexType) + "' behind '" + + getName(lastPartWithKeys.getTypeFilterOnEntry()) + "'")); } lastPartWithKeys.setEntryTypeFilter(filterComplexType); return null; } else { if (lastPartWithKeys.getTypeFilterOnCollection() != null) { - throw wrap(new UriParserSemanticException("Collection typefilters are not chainable, used '" + - getName(filterComplexType) + "' behind '" + - getName(lastPartWithKeys.getTypeFilterOnCollection()) + "'")); + throw wrap(new UriParserSemanticException("Collection typefilters are not chainable, used '" + + getName(filterComplexType) + "' behind '" + + getName(lastPartWithKeys.getTypeFilterOnCollection()) + "'")); } lastPartWithKeys.setCollectionTypeFilter(filterComplexType); return null; @@ -545,16 +541,16 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } else if (lastResourcePart instanceof UriResourceTypedImpl) { UriResourceTypedImpl lastPartTyped = (UriResourceTypedImpl) lastResourcePart; if (lastPartTyped.getTypeFilter() != null) { - throw wrap(new UriParserSemanticException("Typefilters are not chainable, used '" + - getName(filterComplexType) + "' behind '" + - getName(lastPartTyped.getTypeFilter()) + "'")); + throw wrap(new UriParserSemanticException("Typefilters are not chainable, used '" + + getName(filterComplexType) + "' behind '" + + getName(lastPartTyped.getTypeFilter()) + "'")); } lastPartTyped.setTypeFilter(filterComplexType); return null; } else { throw wrap(new UriParserSemanticException("Path segment before '" + getName(filterComplexType) - + "' not typed")); + + "' not typed")); } } } @@ -574,7 +570,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { // do a check for bound functions (which requires a parameter list) if (ctx.vlNVO.size() == 0) { throw wrap(new UriParserSemanticException("Expected function parameters for '" + fullBindingTypeName.toString() - + "'")); + + "'")); } context.contextReadingFunctionParameters = true; @@ -592,8 +588,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (function != null) { UriResourceFunctionImpl pathInfoFunction = new UriResourceFunctionImpl() - .setFunction(function) - .setParameters(parameters); + .setFunction(function) + .setParameters(parameters); context.contextUriInfo.addResourcePart(pathInfoFunction); // mark parameters as consumed @@ -606,8 +602,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (function != null) { UriResourceFunctionImpl pathInfoFunction = new UriResourceFunctionImpl() - .setFunction(function) - .setParameters(parameters); + .setFunction(function) + .setParameters(parameters); context.contextUriInfo.addResourcePart(pathInfoFunction); // mark parameters as consumed @@ -693,20 +689,20 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (segments.size() == 0) { return null; } - + UriResource segment = segments.get(0); if (segment instanceof UriResourceStartingTypeFilterImpl) { UriResourceStartingTypeFilterImpl startingTypeFilter = (UriResourceStartingTypeFilterImpl) segment; - + EdmType type = null; - if (startingTypeFilter.getTypeFilterOnEntry()!= null) { - type =startingTypeFilter.getTypeFilterOnEntry(); - } else if (startingTypeFilter.getTypeFilterOnCollection()!= null) { - type =startingTypeFilter.getTypeFilterOnCollection(); + if (startingTypeFilter.getTypeFilterOnEntry() != null) { + type = startingTypeFilter.getTypeFilterOnEntry(); + } else if (startingTypeFilter.getTypeFilterOnCollection() != null) { + type = startingTypeFilter.getTypeFilterOnCollection(); } else { - type =startingTypeFilter.getType(); + type = startingTypeFilter.getType(); } - + uriInfoImplpath.removeResourcePart(0); return type; } @@ -785,7 +781,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { // @SuppressWarnings("unchecked") // List list = (List) ctx.vEO.accept(this); // uriInfo.setQueryOptions(list); - return null; } @@ -882,9 +877,11 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { String text = ctx.getText().toLowerCase(); if (text.equals("false")) { - return new LiteralImpl().setText("false").setType(EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance()); + return new LiteralImpl().setText("false").setType( + EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Boolean)); } - return new LiteralImpl().setText("true").setType(EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance()); + return new LiteralImpl().setText("true").setType( + EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Boolean)); } @Override @@ -924,9 +921,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { return type; } - if (fullName.getNamespace().equals("Edm")) { - EdmPrimitiveTypeKind typeKind = EdmPrimitiveTypeKind.valueOf(fullName.getName()); - type = typeKind.getEdmPrimitiveTypeInstance(); + if (fullName.getNamespace().equals(EdmPrimitiveType.EDM_NAMESPACE)) { + final EdmPrimitiveTypeKind typeKind = EdmPrimitiveTypeKind.valueOf(fullName.getName()); + type = EdmPrimitiveTypeFactory.getInstance(typeKind); if (type != null) { return type; } @@ -939,16 +936,16 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitCeilingMethodCallExpr(final CeilingMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.CEILING) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.CEILING) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitConcatMethodCallExpr(final ConcatMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.CONCAT) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)) - .addParameter((ExpressionImpl) ctx.vE2.accept(this)); + .setMethod(MethodKind.CONCAT) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)) + .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @Override @@ -1001,9 +998,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitContainsMethodCallExpr(final ContainsMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.CONTAINS) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)) - .addParameter((ExpressionImpl) ctx.vE2.accept(this)); + .setMethod(MethodKind.CONTAINS) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)) + .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @Override @@ -1021,31 +1018,31 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public Object visitDateMethodCallExpr(final DateMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.DATE) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.DATE) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitDayMethodCallExpr(final DayMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.DAY) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.DAY) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitGeoDistanceMethodCallExpr(final GeoDistanceMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.GEODISTANCE) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)) - .addParameter((ExpressionImpl) ctx.vE2.accept(this)); + .setMethod(MethodKind.GEODISTANCE) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)) + .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @Override public Object visitEndsWithMethodCallExpr(final EndsWithMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.ENDSWITH) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)) - .addParameter((ExpressionImpl) ctx.vE2.accept(this)); + .setMethod(MethodKind.ENDSWITH) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)) + .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @Override @@ -1127,7 +1124,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { ExpandItemImpl expandItem = new ExpandItemImpl(); // UriResourceItImpl pathInfoIT = new UriResourceItImpl(); - context.contextUriInfo.getLastResourcePart(); // save context @@ -1143,7 +1139,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { EdmType startType = this.removeUriResourceStartingTypeFilterImpl(context.contextUriInfo); expandItem.setResourcePath(context.contextUriInfo); - if ( startType != null) { + if (startType != null) { expandItem.setTypeFilter(startType); } @@ -1223,37 +1219,37 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitFloorMethodCallExpr(final FloorMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.FLOOR) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.FLOOR) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitFractionalsecondsMethodCallExpr(final FractionalsecondsMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.FRACTIONALSECONDS) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.FRACTIONALSECONDS) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitGeoLengthMethodCallExpr(final GeoLengthMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.GEOLENGTH) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.GEOLENGTH) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitHourMethodCallExpr(final HourMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.HOUR) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.HOUR) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitIndexOfMethodCallExpr(final IndexOfMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.INDEXOF) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)) - .addParameter((ExpressionImpl) ctx.vE2.accept(this)); + .setMethod(MethodKind.INDEXOF) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)) + .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @Override @@ -1268,9 +1264,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitGeoIntersectsMethodCallExpr(final GeoIntersectsMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.GEOINTERSECTS) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)) - .addParameter((ExpressionImpl) ctx.vE2.accept(this)); + .setMethod(MethodKind.GEOINTERSECTS) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)) + .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @Override @@ -1295,8 +1291,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitLengthMethodCallExpr(final LengthMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.LENGTH) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.LENGTH) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override @@ -1308,11 +1304,10 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { if (text.equals("max")) { levels.setMax(); - } else { + } else { levels.setValue(Integer.parseInt(text)); } levels.setText(text); - return levels; @@ -1321,7 +1316,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitMaxDateTimeMethodCallExpr(final MaxDateTimeMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.MAXDATETIME); + .setMethod(MethodKind.MAXDATETIME); } @Override @@ -1372,21 +1367,21 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitMinDateTimeMethodCallExpr(final MinDateTimeMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.MINDATETIME); + .setMethod(MethodKind.MINDATETIME); } @Override public ExpressionImpl visitMinuteMethodCallExpr(final MinuteMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.MINUTE) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.MINUTE) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitMonthMethodCallExpr(final MonthMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.MONTH) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.MONTH) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override @@ -1424,7 +1419,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { // There are more keys defined in the EDM, but only one is written in the URI. This is allowed only if // referential constrains are defined on this navigation property which can be used to will up all required // key. - // for using referential constrains the last resource part must be a navigation property if (!(context.contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) { throw wrap(new UriParserSemanticException("Not enougth keyproperties defined")); @@ -1499,7 +1493,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } // if not, check if the missing key predicates can be satisfied with help of the defined referential constrains - // for using referential constrains the last resource part must be a navigation property if (!(context.contextUriInfo.getLastResourcePart() instanceof UriResourceNavigationPropertyImpl)) { throw wrap(new UriParserSemanticException("Not enougth keyproperties defined")); @@ -1557,14 +1550,15 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } @Override - public Object visitNaninfinity(NaninfinityContext ctx) { - return new LiteralImpl().setType(EdmPrimitiveTypeKind.Decimal.getEdmPrimitiveTypeInstance()).setText(ctx.getText()); + public Object visitNaninfinity(final NaninfinityContext ctx) { + return new LiteralImpl().setType(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Decimal)). + setText(ctx.getText()); } @Override public ExpressionImpl visitNowMethodCallExpr(final NowMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.NOW); + .setMethod(MethodKind.NOW); } @Override @@ -1636,7 +1630,7 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @SuppressWarnings("unchecked") List list = (List) ctx.vlNVO.get(0).accept(this); ((UriResourceWithKeysImpl) pathInfoSegment) - .setKeyPredicates(list); + .setKeyPredicates(list); } else { throw wrap(new UriParserSemanticException("Key properties not allowed")); // throw UriSemanticError.addKrepredicatesNotAllowed(); @@ -1664,10 +1658,10 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { public Object visitPrimitiveLiteral(final PrimitiveLiteralContext ctx) { ParseTree child1 = ctx.children.get(0); - if (child1 instanceof EnumLitContext || - child1 instanceof BooleanNonCaseContext || - child1 instanceof NullruleContext || - child1 instanceof NaninfinityContext) { + if (child1 instanceof EnumLitContext + || child1 instanceof BooleanNonCaseContext + || child1 instanceof NullruleContext + || child1 instanceof NaninfinityContext) { return child1.accept(this); } return new LiteralImpl().setText(ctx.getText()); @@ -1699,7 +1693,6 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { * return contextUriInfo; * } */ - @Override public Object visitRootExpr(final RootExprContext ctx) { @@ -1731,22 +1724,22 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } return new MemberImpl() - .setResourcePath(uriInfoImplpath); + .setResourcePath(uriInfoImplpath); } @Override public ExpressionImpl visitRoundMethodCallExpr(final RoundMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.ROUND) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.ROUND) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitSecondMethodCallExpr(final SecondMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.SECOND) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.SECOND) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override @@ -1808,8 +1801,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { } else { UriInfoImpl uriInfo = (UriInfoImpl) context.contextSelectItem.getResourcePath(); UriResource last = uriInfo.getLastResourcePart(); - - prevType = getTypeInformation( last).type; + + prevType = getTypeInformation(last).type; if (prevType == null) { throw wrap(new UriParserSemanticException("prev segement not typed")); } @@ -2025,9 +2018,9 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitStartsWithMethodCallExpr(final StartsWithMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.STARTSWITH) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)) - .addParameter((ExpressionImpl) ctx.vE2.accept(this)); + .setMethod(MethodKind.STARTSWITH) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)) + .addParameter((ExpressionImpl) ctx.vE2.accept(this)); } @Override @@ -2048,8 +2041,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitTimeMethodCallExpr(final TimeMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.TIME) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.TIME) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override @@ -2064,44 +2057,43 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { @Override public ExpressionImpl visitToLowerMethodCallExpr(final ToLowerMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.TOLOWER) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.TOLOWER) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitTotalOffsetMinutesMethodCallExpr(final TotalOffsetMinutesMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.TOTALOFFSETMINUTES) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.TOTALOFFSETMINUTES) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitTotalsecondsMethodCallExpr(final TotalsecondsMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.TOTALSECONDS) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.TOTALSECONDS) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitToUpperMethodCallExpr(final ToUpperMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.TOUPPER) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.TOUPPER) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } @Override public ExpressionImpl visitTrimMethodCallExpr(final TrimMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.TRIM) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.TRIM) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } - @Override public ExpressionImpl visitYearMethodCallExpr(final YearMethodCallExprContext ctx) { return new MethodImpl() - .setMethod(MethodKind.YEAR) - .addParameter((ExpressionImpl) ctx.vE1.accept(this)); + .setMethod(MethodKind.YEAR) + .addParameter((ExpressionImpl) ctx.vE1.accept(this)); } private ParseCancellationException wrap(final UriParserException uriParserException) { diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandItemImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandItemImpl.java index 0fa3314e7..cd4d18d79 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandItemImpl.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandItemImpl.java @@ -33,7 +33,6 @@ import org.apache.olingo.server.api.uri.queryoption.SelectOption; import org.apache.olingo.server.api.uri.queryoption.SkipOption; import org.apache.olingo.server.api.uri.queryoption.SystemQueryOptionKind; import org.apache.olingo.server.api.uri.queryoption.TopOption; -import org.apache.olingo.server.core.uri.queryoption.expression.MemberImpl; public class ExpandItemImpl implements ExpandItem { private LevelsExpandOption levelsExpandOption; diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmComplexTypeImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmComplexTypeImplTest.java index 11e610eba..366b73c7f 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmComplexTypeImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmComplexTypeImplTest.java @@ -32,20 +32,19 @@ import java.util.List; import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmElement; import org.apache.olingo.commons.api.edm.EdmException; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; import org.apache.olingo.server.api.edm.provider.ComplexType; import org.apache.olingo.server.api.edm.provider.EdmProvider; import org.apache.olingo.server.api.edm.provider.NavigationProperty; import org.apache.olingo.server.api.edm.provider.Property; -import org.apache.olingo.server.core.edm.provider.EdmComplexTypeImpl; -import org.apache.olingo.server.core.edm.provider.EdmProviderImpl; import org.junit.Before; import org.junit.Test; public class EdmComplexTypeImplTest { private EdmComplexType baseType; + private EdmComplexType type; @Before @@ -60,7 +59,7 @@ public class EdmComplexTypeImplTest { List baseNavigationProperties = new ArrayList(); baseNavigationProperties.add(new NavigationProperty().setName("nav1")); baseComplexType.setName("BaseTypeName").setAbstract(false).setOpenType(false).setProperties(baseProperties) - .setNavigationProperties(baseNavigationProperties); + .setNavigationProperties(baseNavigationProperties); when(provider.getComplexType(baseName)).thenReturn(baseComplexType); baseType = EdmComplexTypeImpl.getInstance(edm, baseName, baseComplexType); @@ -72,7 +71,7 @@ public class EdmComplexTypeImplTest { List navigationProperties = new ArrayList(); navigationProperties.add(new NavigationProperty().setName("nav2")); complexType.setName("BaseTypeName").setAbstract(false).setOpenType(false).setProperties(properties) - .setNavigationProperties(navigationProperties); + .setNavigationProperties(navigationProperties); when(provider.getComplexType(name)).thenReturn(complexType); type = EdmComplexTypeImpl.getInstance(edm, name, complexType); @@ -156,8 +155,8 @@ public class EdmComplexTypeImplTest { EdmProvider provider = mock(EdmProvider.class); EdmProviderImpl edm = new EdmProviderImpl(provider); FullQualifiedName typeWithNonexistingBaseTypeName = new FullQualifiedName("namespace", "typeName"); - ComplexType complexTypeForNonexistingBaseType = - new ComplexType().setBaseType(new FullQualifiedName("wrong", "wrong")); + ComplexType complexTypeForNonexistingBaseType + = new ComplexType().setBaseType(new FullQualifiedName("wrong", "wrong")); complexTypeForNonexistingBaseType.setName("typeName"); when(provider.getComplexType(typeWithNonexistingBaseTypeName)).thenReturn(complexTypeForNonexistingBaseType); EdmComplexTypeImpl.getInstance(edm, typeWithNonexistingBaseTypeName, complexTypeForNonexistingBaseType); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntityTypeImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntityTypeImplTest.java index 6bcc6bd68..9e4a947d9 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntityTypeImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEntityTypeImplTest.java @@ -34,24 +34,24 @@ import org.apache.olingo.commons.api.edm.EdmElement; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmException; import org.apache.olingo.commons.api.edm.EdmKeyPropertyRef; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.EdmProperty; import org.apache.olingo.commons.api.edm.FullQualifiedName; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; import org.apache.olingo.server.api.edm.provider.ComplexType; import org.apache.olingo.server.api.edm.provider.EdmProvider; import org.apache.olingo.server.api.edm.provider.EntityType; import org.apache.olingo.server.api.edm.provider.NavigationProperty; import org.apache.olingo.server.api.edm.provider.Property; import org.apache.olingo.server.api.edm.provider.PropertyRef; -import org.apache.olingo.server.core.edm.provider.EdmEntityTypeImpl; -import org.apache.olingo.server.core.edm.provider.EdmProviderImpl; import org.junit.Before; import org.junit.Test; public class EdmEntityTypeImplTest { private EdmEntityType baseType; + private EdmEntityType typeWithBaseType; + private EdmEntityType typeWithComplexKey; @Before @@ -96,21 +96,21 @@ public class EdmEntityTypeImplTest { typeWithComplexKeyProvider.setName(typeWithComplexKeyName.getName()); List typeWithComplexKeyProperties = new ArrayList(); typeWithComplexKeyProperties.add(new Property().setName("Id").setType( - EdmPrimitiveTypeKind.String.getFullQualifiedName())); + EdmPrimitiveTypeKind.String.getFullQualifiedName())); List complexTypeProperties = new ArrayList(); complexTypeProperties.add(new Property().setName("ComplexPropName").setType( - EdmPrimitiveTypeKind.String.getFullQualifiedName())); + EdmPrimitiveTypeKind.String.getFullQualifiedName())); FullQualifiedName complexTypeName = new FullQualifiedName("namespace", "complexTypeName"); when(provider.getComplexType(complexTypeName)).thenReturn( - new ComplexType().setName("complexTypeName").setProperties(complexTypeProperties)); + new ComplexType().setName("complexTypeName").setProperties(complexTypeProperties)); typeWithComplexKeyProperties.add(new Property().setName("Comp").setType(complexTypeName)); typeWithComplexKeyProvider.setProperties(typeWithComplexKeyProperties); List keyForTypeWithComplexKey = new ArrayList(); keyForTypeWithComplexKey.add(new PropertyRef().setPropertyName("Id")); keyForTypeWithComplexKey.add(new PropertyRef().setPropertyName("ComplexPropName").setAlias("alias").setPath( - "Comp/ComplexPropName")); + "Comp/ComplexPropName")); typeWithComplexKeyProvider.setKey(keyForTypeWithComplexKey); when(provider.getEntityType(typeWithComplexKeyName)).thenReturn(typeWithComplexKeyProvider); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java index 748bbc28e..e58edb7e1 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmEnumTest.java @@ -29,13 +29,12 @@ import java.util.ArrayList; import java.util.List; import org.apache.olingo.commons.api.edm.EdmEnumType; +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.apache.olingo.server.api.edm.provider.EnumMember; import org.apache.olingo.server.api.edm.provider.EnumType; -import org.apache.olingo.server.core.edm.provider.EdmEnumTypeImpl; -import org.apache.olingo.server.core.edm.provider.EdmProviderImpl; import org.junit.Test; public class EdmEnumTest extends PrimitiveTypeBaseTest { @@ -66,7 +65,7 @@ public class EdmEnumTest extends PrimitiveTypeBaseTest { // when(member2.getName()).thenReturn("second"); // when(member2.getValue()).thenReturn("64"); // instance = new EdmEnumImpl("namespace", "name", -// EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance(), +// EdmPrimitiveTypeKind.SByte), // Arrays.asList(member1, member2), // true); } @@ -106,7 +105,7 @@ public class EdmEnumTest extends PrimitiveTypeBaseTest { @Test public void underlyingType() throws Exception { - assertEquals(EdmPrimitiveTypeKind.SByte.getEdmPrimitiveTypeInstance(), instance.getUnderlyingType()); + assertEquals(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.SByte), instance.getUnderlyingType()); } @Test diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmFunctionImportImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmFunctionImportImplTest.java index 4f4b3024b..b77f7e9a9 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmFunctionImportImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmFunctionImportImplTest.java @@ -30,17 +30,15 @@ import java.util.Collections; import org.apache.olingo.commons.api.edm.EdmEntityContainer; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmFunctionImport; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; 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; import org.apache.olingo.server.api.edm.provider.EdmProvider; import org.apache.olingo.server.api.edm.provider.EntityContainerInfo; import org.apache.olingo.server.api.edm.provider.Function; import org.apache.olingo.server.api.edm.provider.FunctionImport; import org.apache.olingo.server.api.edm.provider.Parameter; import org.apache.olingo.server.api.edm.provider.ReturnType; -import org.apache.olingo.server.core.edm.provider.EdmEntityContainerImpl; -import org.apache.olingo.server.core.edm.provider.EdmFunctionImportImpl; -import org.apache.olingo.server.core.edm.provider.EdmProviderImpl; import org.junit.Test; public class EdmFunctionImportImplTest { @@ -52,11 +50,11 @@ public class EdmFunctionImportImplTest { final FullQualifiedName functionName = new FullQualifiedName("ns", "function"); final Function functionProvider = new Function() - .setName(functionName.getName()) - .setParameters(Collections. emptyList()) - .setBound(false) - .setComposable(false) - .setReturnType(new ReturnType().setType(EdmPrimitiveTypeKind.Boolean.getFullQualifiedName())); + .setName(functionName.getName()) + .setParameters(Collections.emptyList()) + .setBound(false) + .setComposable(false) + .setReturnType(new ReturnType().setType(EdmPrimitiveTypeKind.Boolean.getFullQualifiedName())); when(provider.getFunctions(functionName)).thenReturn(Arrays.asList(functionProvider)); final FullQualifiedName containerName = new FullQualifiedName("ns", "container"); @@ -66,21 +64,22 @@ public class EdmFunctionImportImplTest { final String functionImportName = "functionImport"; final FunctionImport functionImportProvider = new FunctionImport() - .setName(functionImportName) - .setFunction(functionName) - .setIncludeInServiceDocument(true); + .setName(functionImportName) + .setFunction(functionName) + .setIncludeInServiceDocument(true); when(provider.getFunctionImport(containerName, functionImportName)).thenReturn(functionImportProvider); - final EdmFunctionImport functionImport = - new EdmFunctionImportImpl(edm, entityContainer, functionImportProvider); + final EdmFunctionImport functionImport + = new EdmFunctionImportImpl(edm, entityContainer, functionImportProvider); assertEquals(functionImportName, entityContainer.getFunctionImport(functionImportName).getName()); assertEquals("functionImport", functionImport.getName()); - final EdmFunction function = functionImport.getFunction(Collections. emptyList()); + final EdmFunction function = functionImport.getFunction(Collections.emptyList()); assertEquals(functionName.getNamespace(), function.getNamespace()); assertEquals(functionName.getName(), function.getName()); assertFalse(function.isBound()); assertFalse(function.isComposable()); - assertEquals(EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance(), function.getReturnType().getType()); + assertEquals(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Boolean), + function.getReturnType().getType()); assertEquals(entityContainer, functionImport.getEntityContainer()); assertNull(functionImport.getReturnedEntitySet()); } diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmParameterImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmParameterImplTest.java index d44614579..52a377e23 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmParameterImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmParameterImplTest.java @@ -27,17 +27,15 @@ import static org.mockito.Mockito.when; import org.apache.olingo.commons.api.edm.EdmException; 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.api.edm.constants.EdmTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; import org.apache.olingo.server.api.edm.provider.ComplexType; import org.apache.olingo.server.api.edm.provider.EdmProvider; import org.apache.olingo.server.api.edm.provider.EnumType; import org.apache.olingo.server.api.edm.provider.Parameter; import org.apache.olingo.server.api.edm.provider.TypeDefinition; -import org.apache.olingo.server.core.edm.provider.EdmParameterImpl; -import org.apache.olingo.server.core.edm.provider.EdmProviderImpl; import org.junit.Test; public class EdmParameterImplTest { @@ -139,4 +137,4 @@ public class EdmParameterImplTest { parameter.getType(); } -} \ No newline at end of file +} diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImplTest.java index fca16d8ce..11d2d093b 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmPropertyImplTest.java @@ -28,18 +28,16 @@ import static org.mockito.Mockito.when; 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.api.edm.constants.EdmTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; import org.apache.olingo.server.api.edm.provider.ComplexType; import org.apache.olingo.server.api.edm.provider.EdmProvider; import org.apache.olingo.server.api.edm.provider.EnumType; import org.apache.olingo.server.api.edm.provider.Property; import org.apache.olingo.server.api.edm.provider.TypeDefinition; -import org.apache.olingo.server.core.edm.provider.EdmPropertyImpl; -import org.apache.olingo.server.core.edm.provider.EdmProviderImpl; import org.junit.Test; public class EdmPropertyImplTest { diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmReturnTypeImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmReturnTypeImplTest.java index 5cb9a67cf..bd028ba2e 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmReturnTypeImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmReturnTypeImplTest.java @@ -29,14 +29,13 @@ import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmEnumType; import org.apache.olingo.commons.api.edm.EdmException; +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.EdmTypeDefinition; 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; import org.apache.olingo.server.api.edm.provider.ReturnType; -import org.apache.olingo.server.core.edm.provider.EdmProviderImpl; -import org.apache.olingo.server.core.edm.provider.EdmReturnTypeImpl; import org.junit.Test; public class EdmReturnTypeImplTest { @@ -47,7 +46,7 @@ public class EdmReturnTypeImplTest { EdmReturnType typeImpl = new EdmReturnTypeImpl(mock(EdmProviderImpl.class), providerType); - assertEquals(EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance(), typeImpl.getType()); + assertEquals(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.String), typeImpl.getType()); assertFalse(typeImpl.isCollection()); assertNull(typeImpl.getPrecision()); @@ -62,7 +61,7 @@ public class EdmReturnTypeImplTest { EdmReturnType typeImpl = new EdmReturnTypeImpl(mock(EdmProviderImpl.class), providerType); - assertEquals(EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance(), typeImpl.getType()); + assertEquals(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.String), typeImpl.getType()); assertTrue(typeImpl.isCollection()); } diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImplTest.java index 9b57bdb7a..260e77a2d 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/edm/provider/EdmTypeDefinitionImplTest.java @@ -24,31 +24,30 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import org.apache.olingo.commons.api.edm.EdmException; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.EdmTypeDefinition; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.apache.olingo.server.api.edm.provider.TypeDefinition; -import org.apache.olingo.server.core.edm.provider.EdmProviderImpl; -import org.apache.olingo.server.core.edm.provider.EdmTypeDefinitionImpl; import org.junit.Test; public class EdmTypeDefinitionImplTest { @Test public void typeDefOnStringNoFacets() throws Exception { - FullQualifiedName typeDefName = new FullQualifiedName("namespace", "name"); - TypeDefinition providerTypeDef = - new TypeDefinition().setName("typeDef").setUnderlyingType(new FullQualifiedName("Edm", "String")); - EdmTypeDefinition typeDefImpl = - new EdmTypeDefinitionImpl(mock(EdmProviderImpl.class), typeDefName, providerTypeDef); + final FullQualifiedName typeDefName = new FullQualifiedName("namespace", "name"); + final TypeDefinition providerTypeDef= + new TypeDefinition().setName("typeDef").setUnderlyingType(new FullQualifiedName("Edm", "String")); + final EdmTypeDefinition typeDefImpl = + new EdmTypeDefinitionImpl(mock(EdmProviderImpl.class), typeDefName, providerTypeDef); assertEquals("name", typeDefImpl.getName()); assertEquals("namespace", typeDefImpl.getNamespace()); assertEquals(String.class, typeDefImpl.getDefaultType()); assertEquals(EdmTypeKind.DEFINITION, typeDefImpl.getKind()); - assertEquals(EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance(), typeDefImpl.getUnderlyingType()); - assertTrue(typeDefImpl.isCompatible(EdmPrimitiveTypeKind.String.getEdmPrimitiveTypeInstance())); + assertEquals(EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.String), typeDefImpl.getUnderlyingType()); + assertTrue(typeDefImpl.isCompatible(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.String))); // String validation assertEquals("'StringValue'", typeDefImpl.toUriLiteral("StringValue")); @@ -67,8 +66,8 @@ public class EdmTypeDefinitionImplTest { @Test(expected = EdmException.class) public void invalidTypeResultsInEdmException() throws Exception { FullQualifiedName typeDefName = new FullQualifiedName("namespace", "name"); - TypeDefinition providerTypeDef = - new TypeDefinition().setName("typeDef").setUnderlyingType(new FullQualifiedName("wrong", "wrong")); + TypeDefinition providerTypeDef + = new TypeDefinition().setName("typeDef").setUnderlyingType(new FullQualifiedName("wrong", "wrong")); EdmTypeDefinitionImpl def = new EdmTypeDefinitionImpl(mock(EdmProviderImpl.class), typeDefName, providerTypeDef); def.getUnderlyingType(); } diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/testutil/EdmTechProvider.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/testutil/EdmTechProvider.java index 741ca3cfe..7590e710c 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/testutil/EdmTechProvider.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/testutil/EdmTechProvider.java @@ -23,9 +23,9 @@ import java.util.Arrays; import java.util.List; import org.apache.olingo.commons.api.ODataException; +import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.edm.Target; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeKind; import org.apache.olingo.server.api.edm.provider.Action; import org.apache.olingo.server.api.edm.provider.ActionImport; import org.apache.olingo.server.api.edm.provider.AliasInfo; diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java index d03345e9d..f2408ff5c 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/UriResourceImplTest.java @@ -32,9 +32,10 @@ import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmFunction; import org.apache.olingo.commons.api.edm.EdmFunctionImport; import org.apache.olingo.commons.api.edm.EdmNavigationProperty; +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.core.edm.primitivetype.EdmPrimitiveTypeKind; +import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; import org.apache.olingo.server.api.uri.UriResourceKind; import org.apache.olingo.server.core.edm.provider.EdmComplexTypeImpl; import org.apache.olingo.server.core.edm.provider.EdmEntitySetImpl; @@ -42,30 +43,12 @@ import org.apache.olingo.server.core.edm.provider.EdmProviderImpl; import org.apache.olingo.server.core.edm.provider.EdmSingletonImpl; import org.apache.olingo.server.core.testutil.EdmTechProvider; import org.apache.olingo.server.core.testutil.EdmTechTestProvider; -import org.apache.olingo.server.core.uri.UriParameterImpl; -import org.apache.olingo.server.core.uri.UriResourceActionImpl; -import org.apache.olingo.server.core.uri.UriResourceComplexPropertyImpl; -import org.apache.olingo.server.core.uri.UriResourceCountImpl; -import org.apache.olingo.server.core.uri.UriResourceEntitySetImpl; -import org.apache.olingo.server.core.uri.UriResourceFunctionImpl; -import org.apache.olingo.server.core.uri.UriResourceItImpl; -import org.apache.olingo.server.core.uri.UriResourceLambdaAllImpl; -import org.apache.olingo.server.core.uri.UriResourceLambdaAnyImpl; -import org.apache.olingo.server.core.uri.UriResourceLambdaVarImpl; -import org.apache.olingo.server.core.uri.UriResourceNavigationPropertyImpl; -import org.apache.olingo.server.core.uri.UriResourcePrimitivePropertyImpl; -import org.apache.olingo.server.core.uri.UriResourceRefImpl; -import org.apache.olingo.server.core.uri.UriResourceRootImpl; -import org.apache.olingo.server.core.uri.UriResourceSingletonImpl; -import org.apache.olingo.server.core.uri.UriResourceStartingTypeFilterImpl; -import org.apache.olingo.server.core.uri.UriResourceTypedImpl; -import org.apache.olingo.server.core.uri.UriResourceValueImpl; -import org.apache.olingo.server.core.uri.UriResourceWithKeysImpl; import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl; import org.apache.olingo.server.core.uri.queryoption.expression.LiteralImpl; import org.junit.Test; public class UriResourceImplTest { + Edm edm = new EdmProviderImpl(new EdmTechTestProvider()); @Test @@ -119,7 +102,7 @@ public class UriResourceImplTest { assertEquals(false, impl.isCollection()); assertEquals(expression, impl.getExpression()); assertEquals("A", impl.getLambdaVariable()); - assertEquals(EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance(), impl.getType()); + assertEquals(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Boolean), impl.getType()); assertEquals("all", impl.toString()); } @@ -135,7 +118,7 @@ public class UriResourceImplTest { assertEquals(false, impl.isCollection()); assertEquals(expression, impl.getExpression()); assertEquals("A", impl.getLamdaVariable()); - assertEquals(EdmPrimitiveTypeKind.Boolean.getEdmPrimitiveTypeInstance(), impl.getType()); + assertEquals(EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.Boolean), impl.getType()); assertEquals("any", impl.toString()); } @@ -155,8 +138,8 @@ public class UriResourceImplTest { assertEquals(property.getType(), impl.getComplexType()); impl.getComplexType(); - EdmComplexTypeImpl complexTypeImplType = - (EdmComplexTypeImpl) edm.getComplexType(EdmTechProvider.nameCTBasePrimCompNav); + EdmComplexTypeImpl complexTypeImplType + = (EdmComplexTypeImpl) edm.getComplexType(EdmTechProvider.nameCTBasePrimCompNav); impl.setTypeFilter(complexTypeImplType); assertEquals(complexTypeImplType, impl.getTypeFilter()); @@ -216,15 +199,14 @@ public class UriResourceImplTest { // function EdmFunction function = (EdmFunction) edm.getEntityContainer(null).getFunctionImport("FINRTInt16") - .getFunction(new ArrayList()); + .getFunction(new ArrayList()); assertNotNull(function); impl.setFunction(function); - assertEquals(function, impl.getFunction()); assertEquals("UFNRTInt16", impl.toString()); assertEquals(function.getReturnType().getType(), impl.getType()); - assertEquals(false,impl.isParameterListFilled()); + assertEquals(false, impl.isParameterListFilled()); // function import impl = new UriResourceFunctionImpl(); @@ -247,12 +229,13 @@ public class UriResourceImplTest { assertEquals(false, impl.isCollection()); assertEquals(parameter, impl.getParameters().get(0)); - assertEquals(true,impl.isParameterListFilled()); + assertEquals(true, impl.isParameterListFilled()); } @Test public void testUriResourceImplKeyPred() { class Mock extends UriResourceWithKeysImpl { + EdmType type; public Mock() { @@ -299,7 +282,7 @@ public class UriResourceImplTest { assertEquals(entityTypeBaseEntry, impl.getTypeFilterOnEntry()); assertEquals("mock", impl.toString(false)); assertEquals("mock/com.sap.odata.test1.ETBaseTwoKeyNav/()com.sap.odata.test1.ETTwoBaseTwoKeyNav", - impl.toString(true)); + impl.toString(true)); // set entry impl = new Mock(); @@ -330,6 +313,7 @@ public class UriResourceImplTest { @Test public void testUriResourceImplTyped() { class Mock extends UriResourceTypedImpl { + EdmType type; public Mock() { @@ -498,7 +482,6 @@ public class UriResourceImplTest { assertEquals(true, impl.isCollection()); } - @Test public void testUriResourceStartingTypeFilterImpl() { UriResourceStartingTypeFilterImpl impl = new UriResourceStartingTypeFilterImpl(); diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java index 21df8bbce..2062c86ff 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/testutil/ExpandValidator.java @@ -35,7 +35,6 @@ import org.apache.olingo.server.core.uri.queryoption.FilterOptionImpl; import org.apache.olingo.server.core.uri.queryoption.OrderByOptionImpl; import org.apache.olingo.server.core.uri.queryoption.QueryOptionImpl; import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl; -import org.apache.olingo.server.core.uri.queryoption.expression.MemberImpl; public class ExpandValidator implements Validator { private Edm edm; diff --git a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java index 31392d2f0..483fc5c56 100644 --- a/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java +++ b/lib/server-core/src/test/java/org/apache/olingo/server/core/uri/testutil/ResourceValidator.java @@ -54,7 +54,6 @@ import org.apache.olingo.server.core.uri.queryoption.CustomQueryOptionImpl; import org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl; import org.apache.olingo.server.core.uri.queryoption.SelectOptionImpl; import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl; -import org.apache.olingo.server.core.uri.queryoption.expression.MemberImpl; public class ResourceValidator implements Validator { private Edm edm;