[OLINGO-65] Geospatial types implemented, EdmStream mock implemented with URI as backend, V3 pruned types implemented, EdmSimpleTypeKind adapted, EdmSimpleTypeFactory introduces
This commit is contained in:
parent
bab0362401
commit
559698d4db
|
@ -45,10 +45,6 @@
|
|||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
|
|
|
@ -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;
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 <tt>EdmSimpleType</tt> from object instance.
|
||||
*
|
||||
* @param workingVersion OData version.
|
||||
* @param obj object.
|
||||
* @return <tt>EdmSimpleType</tt> object.
|
||||
*/
|
||||
public static ODataJClientEdmPrimitiveType fromObject(final ODataServiceVersion workingVersion, final Object obj) {
|
||||
for (ODataJClientEdmPrimitiveType edmSimpleType : ODataJClientEdmPrimitiveType.values()) {
|
||||
if (edmSimpleType.javaType().equals(obj.getClass())) {
|
||||
return edmSimpleType == DateTimeOffset || edmSimpleType == DateTime || edmSimpleType == Date
|
||||
? ((ODataTimestamp) obj).isOffset()
|
||||
? DateTimeOffset : workingVersion == ODataServiceVersion.V30 ? DateTime : Date
|
||||
: edmSimpleType;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException(obj.getClass().getSimpleName() + " is not a simple type");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets namespace.
|
||||
*
|
||||
|
|
|
@ -28,9 +28,8 @@ import java.util.UUID;
|
|||
import javax.xml.datatype.Duration;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
|
||||
/**
|
||||
* OData primitive property value.
|
||||
|
@ -50,8 +49,8 @@ public class ODataPrimitiveValue extends ODataValue {
|
|||
this.client = client;
|
||||
}
|
||||
|
||||
public AbstractBuilder isSupported(final ODataJClientEdmPrimitiveType type) {
|
||||
if (type != null && !ArrayUtils.contains(type.getSupportedVersions(), client.getServiceVersion())) {
|
||||
public AbstractBuilder isSupported(final EdmPrimitiveTypeKind type) {
|
||||
if (type != null && !type.getSupportedVersions().contains(client.getServiceVersion())) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Type %s not supported by the current OData working version", type.toString()));
|
||||
}
|
||||
|
@ -103,12 +102,12 @@ public class ODataPrimitiveValue extends ODataValue {
|
|||
* @param type type.
|
||||
* @return the current builder.
|
||||
*/
|
||||
public Builder setType(final ODataJClientEdmPrimitiveType type) {
|
||||
public Builder setType(final EdmPrimitiveTypeKind type) {
|
||||
isSupported(type);
|
||||
|
||||
if (type == ODataJClientEdmPrimitiveType.Stream) {
|
||||
if (type == EdmPrimitiveTypeKind.Stream) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Cannot build a primitive value for %s", ODataJClientEdmPrimitiveType.Stream.toString()));
|
||||
"Cannot build a primitive value for %s", EdmPrimitiveTypeKind.Stream.toString()));
|
||||
}
|
||||
|
||||
this.opv.type = type;
|
||||
|
@ -129,7 +128,7 @@ public class ODataPrimitiveValue extends ODataValue {
|
|||
}
|
||||
|
||||
if (this.opv.type == null) {
|
||||
this.opv.type = ODataJClientEdmPrimitiveType.String;
|
||||
this.opv.type = EdmPrimitiveTypeKind.String;
|
||||
}
|
||||
|
||||
if (this.opv.type.isGeospatial()) {
|
||||
|
@ -147,7 +146,7 @@ public class ODataPrimitiveValue extends ODataValue {
|
|||
this.opv.value = new ODataDuration((Duration) this.opv.value);
|
||||
}
|
||||
|
||||
if (this.opv.value != null && !this.opv.type.javaType().isAssignableFrom(this.opv.value.getClass())) {
|
||||
if (this.opv.value != null && !this.opv.getJavaType().isAssignableFrom(this.opv.value.getClass())) {
|
||||
throw new IllegalArgumentException("Provided value is not compatible with " + this.opv.type.toString());
|
||||
}
|
||||
|
||||
|
@ -177,7 +176,7 @@ public class ODataPrimitiveValue extends ODataValue {
|
|||
/**
|
||||
* Value type.
|
||||
*/
|
||||
protected ODataJClientEdmPrimitiveType type;
|
||||
protected EdmPrimitiveTypeKind type;
|
||||
|
||||
/**
|
||||
* Protected constructor, need to use the builder to instantiate this class.
|
||||
|
@ -189,15 +188,82 @@ public class ODataPrimitiveValue extends ODataValue {
|
|||
this.client = client;
|
||||
}
|
||||
|
||||
private Class<?> getJavaType() {
|
||||
Class<?> javaType = null;
|
||||
|
||||
switch (this.type) {
|
||||
case Binary:
|
||||
javaType = byte[].class;
|
||||
break;
|
||||
|
||||
case SByte:
|
||||
javaType = Byte.class;
|
||||
break;
|
||||
|
||||
case Boolean:
|
||||
javaType = Boolean.class;
|
||||
break;
|
||||
|
||||
case Date:
|
||||
case DateTime:
|
||||
case DateTimeOffset:
|
||||
javaType = ODataTimestamp.class;
|
||||
break;
|
||||
|
||||
case Time:
|
||||
case TimeOfDay:
|
||||
javaType = ODataDuration.class;
|
||||
break;
|
||||
|
||||
case Decimal:
|
||||
javaType = BigDecimal.class;
|
||||
break;
|
||||
|
||||
case Single:
|
||||
javaType = Float.class;
|
||||
break;
|
||||
|
||||
case Double:
|
||||
javaType = Double.class;
|
||||
break;
|
||||
|
||||
case Guid:
|
||||
javaType = UUID.class;
|
||||
break;
|
||||
|
||||
case Int16:
|
||||
javaType = Short.class;
|
||||
break;
|
||||
|
||||
case Byte:
|
||||
case Int32:
|
||||
javaType = Integer.class;
|
||||
break;
|
||||
|
||||
case Int64:
|
||||
javaType = Long.class;
|
||||
break;
|
||||
|
||||
case Stream:
|
||||
javaType = URI.class;
|
||||
break;
|
||||
|
||||
case String:
|
||||
javaType = String.class;
|
||||
break;
|
||||
|
||||
default:
|
||||
javaType = this.value.getClass();
|
||||
}
|
||||
|
||||
return javaType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses given text as object value.
|
||||
*/
|
||||
private void parseText() {
|
||||
switch (this.type) {
|
||||
case Null:
|
||||
this.value = null;
|
||||
break;
|
||||
|
||||
case Binary:
|
||||
this.value = Base64.decodeBase64(this.toString());
|
||||
break;
|
||||
|
@ -267,10 +333,6 @@ public class ODataPrimitiveValue extends ODataValue {
|
|||
*/
|
||||
private void formatValue() {
|
||||
switch (this.type) {
|
||||
case Null:
|
||||
this.text = StringUtils.EMPTY;
|
||||
break;
|
||||
|
||||
case Binary:
|
||||
this.text = Base64.encodeBase64String(this.<byte[]>toCastValue());
|
||||
break;
|
||||
|
@ -295,15 +357,15 @@ public class ODataPrimitiveValue extends ODataValue {
|
|||
break;
|
||||
|
||||
case Decimal:
|
||||
this.text = new DecimalFormat(this.type.pattern()).format(this.<BigDecimal>toCastValue());
|
||||
this.text = new DecimalFormat("#.#######################").format(this.<BigDecimal>toCastValue());
|
||||
break;
|
||||
|
||||
case Single:
|
||||
this.text = new DecimalFormat(this.type.pattern()).format(this.<Float>toCastValue());
|
||||
this.text = new DecimalFormat("#.#######E0").format(this.<Float>toCastValue());
|
||||
break;
|
||||
|
||||
case Double:
|
||||
this.text = new DecimalFormat(this.type.pattern()).format(this.<Double>toCastValue());
|
||||
this.text = new DecimalFormat("#.#######################E0").format(this.<Double>toCastValue());
|
||||
break;
|
||||
|
||||
case Guid:
|
||||
|
@ -341,7 +403,7 @@ public class ODataPrimitiveValue extends ODataValue {
|
|||
* @return type name.
|
||||
*/
|
||||
public String getTypeName() {
|
||||
return type.toString();
|
||||
return type.getFullQualifiedName().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -369,6 +431,6 @@ public class ODataPrimitiveValue extends ODataValue {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T toCastValue() {
|
||||
return (T) type.javaType().cast(toValue());
|
||||
return (T) getJavaType().cast(toValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.apache.olingo.client.api.CommonODataClient;
|
|||
import org.apache.olingo.client.api.communication.request.ODataBatchableRequest;
|
||||
import org.apache.olingo.client.api.communication.request.cud.ODataValueUpdateRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataValueUpdateResponse;
|
||||
import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
|
||||
import org.apache.olingo.client.api.domain.ODataPrimitiveValue;
|
||||
import org.apache.olingo.client.api.domain.ODataValue;
|
||||
import org.apache.olingo.client.api.format.ODataValueFormat;
|
||||
|
@ -38,6 +37,7 @@ import org.apache.olingo.client.api.http.HttpMethod;
|
|||
import org.apache.olingo.client.api.utils.URIUtils;
|
||||
import org.apache.olingo.client.core.communication.request.AbstractODataBasicRequest;
|
||||
import org.apache.olingo.client.core.communication.response.AbstractODataResponse;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
|
||||
/**
|
||||
* This class implements an OData update entity property value request.
|
||||
|
@ -125,7 +125,7 @@ public class ODataValueUpdateRequestImpl extends AbstractODataBasicRequest<OData
|
|||
try {
|
||||
value = new ODataPrimitiveValue.Builder(odataClient).
|
||||
setType(format == ODataValueFormat.TEXT
|
||||
? ODataJClientEdmPrimitiveType.String : ODataJClientEdmPrimitiveType.Stream).
|
||||
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
|
||||
setText(IOUtils.toString(getRawResponse())).
|
||||
build();
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -26,11 +26,11 @@ import org.apache.http.client.HttpClient;
|
|||
import org.apache.olingo.client.api.CommonODataClient;
|
||||
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
|
||||
import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
|
||||
import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
|
||||
import org.apache.olingo.client.api.domain.ODataPrimitiveValue;
|
||||
import org.apache.olingo.client.api.domain.ODataValue;
|
||||
import org.apache.olingo.client.api.format.ODataValueFormat;
|
||||
import org.apache.olingo.client.api.http.HttpClientException;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
|
||||
/**
|
||||
* This class implements an OData entity property value query request.
|
||||
|
@ -93,7 +93,7 @@ public class ODataValueRequestImpl extends AbstractODataRetrieveRequest<ODataVal
|
|||
try {
|
||||
value = new ODataPrimitiveValue.Builder(odataClient).
|
||||
setType(format == ODataValueFormat.TEXT
|
||||
? ODataJClientEdmPrimitiveType.String : ODataJClientEdmPrimitiveType.Stream).
|
||||
? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
|
||||
setText(IOUtils.toString(getRawResponse())).
|
||||
build();
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -27,23 +27,30 @@ import org.apache.olingo.client.api.Constants;
|
|||
import org.apache.olingo.client.api.data.CollectionValue;
|
||||
import org.apache.olingo.client.api.data.ComplexValue;
|
||||
import org.apache.olingo.client.api.data.Value;
|
||||
import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
|
||||
import org.apache.olingo.client.api.domain.ODataJClientEdmType;
|
||||
import org.apache.olingo.client.api.domain.ODataPropertyType;
|
||||
import org.apache.olingo.client.core.edm.EdmTypeInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
|
||||
abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
|
||||
|
||||
private final JSONGeoValueDeserializer geoDeserializer = new JSONGeoValueDeserializer();
|
||||
private JSONGeoValueDeserializer geoDeserializer;
|
||||
|
||||
protected ODataJClientEdmPrimitiveType getPrimitiveType(final JsonNode node) {
|
||||
ODataJClientEdmPrimitiveType result = ODataJClientEdmPrimitiveType.String;
|
||||
private JSONGeoValueDeserializer getGeoDeserializer() {
|
||||
if (geoDeserializer == null) {
|
||||
geoDeserializer = new JSONGeoValueDeserializer(client.getServiceVersion());
|
||||
}
|
||||
return geoDeserializer;
|
||||
}
|
||||
|
||||
protected EdmPrimitiveTypeKind getPrimitiveType(final JsonNode node) {
|
||||
EdmPrimitiveTypeKind result = EdmPrimitiveTypeKind.String;
|
||||
|
||||
if (node.isIntegralNumber()) {
|
||||
result = ODataJClientEdmPrimitiveType.Int32;
|
||||
result = EdmPrimitiveTypeKind.Int32;
|
||||
} else if (node.isBoolean()) {
|
||||
result = ODataJClientEdmPrimitiveType.Boolean;
|
||||
result = EdmPrimitiveTypeKind.Boolean;
|
||||
} else if (node.isFloatingPointNumber()) {
|
||||
result = ODataJClientEdmPrimitiveType.Double;
|
||||
result = EdmPrimitiveTypeKind.Double;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -65,16 +72,14 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
|
|||
return type;
|
||||
}
|
||||
|
||||
private Value fromPrimitive(final JsonNode node, final ODataJClientEdmType typeInfo) {
|
||||
private Value fromPrimitive(final JsonNode node, final EdmTypeInfo typeInfo) {
|
||||
Value value = null;
|
||||
|
||||
if (node.isNull()) {
|
||||
value = new NullValueImpl();
|
||||
} else {
|
||||
if (typeInfo != null && typeInfo.isGeospatialType()) {
|
||||
final ODataJClientEdmPrimitiveType geoType = ODataJClientEdmPrimitiveType.fromValue(typeInfo.getBaseType());
|
||||
|
||||
value = new GeospatialValueImpl(this.geoDeserializer.deserialize(node, geoType));
|
||||
if (typeInfo != null && typeInfo.getPrimitiveTypeKind().isGeospatial()) {
|
||||
value = new GeospatialValueImpl(getGeoDeserializer().deserialize(node, typeInfo));
|
||||
} else {
|
||||
value = new PrimitiveValueImpl(node.asText());
|
||||
}
|
||||
|
@ -106,12 +111,12 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
|
|||
return value;
|
||||
}
|
||||
|
||||
private CollectionValue fromCollection(final Iterator<JsonNode> nodeItor, final ODataJClientEdmType typeInfo) {
|
||||
private CollectionValue fromCollection(final Iterator<JsonNode> nodeItor, final EdmTypeInfo typeInfo) {
|
||||
final CollectionValueImpl value = new CollectionValueImpl();
|
||||
|
||||
final ODataJClientEdmType type = typeInfo == null
|
||||
final EdmTypeInfo type = typeInfo == null
|
||||
? null
|
||||
: new ODataJClientEdmType(typeInfo.getBaseType());
|
||||
: new EdmTypeInfo.Builder().setTypeExpression(typeInfo.getFullQualifiedName().toString()).build();
|
||||
|
||||
while (nodeItor.hasNext()) {
|
||||
final JsonNode child = nodeItor.next();
|
||||
|
@ -130,9 +135,9 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
|
|||
}
|
||||
|
||||
protected void value(final JSONPropertyImpl property, final JsonNode node) {
|
||||
final ODataJClientEdmType typeInfo = StringUtils.isBlank(property.getType())
|
||||
final EdmTypeInfo typeInfo = StringUtils.isBlank(property.getType())
|
||||
? null
|
||||
: new ODataJClientEdmType(property.getType());
|
||||
: new EdmTypeInfo.Builder().setTypeExpression(property.getType()).build();
|
||||
|
||||
final ODataPropertyType propType = typeInfo == null
|
||||
? guessPropertyType(node)
|
||||
|
@ -157,7 +162,7 @@ abstract class AbstractJsonDeserializer<T> extends ODataJacksonDeserializer<T> {
|
|||
|
||||
case PRIMITIVE:
|
||||
if (property.getType() == null) {
|
||||
property.setType(getPrimitiveType(node).toString());
|
||||
property.setType(getPrimitiveType(node).getFullQualifiedName().toString());
|
||||
}
|
||||
property.setValue(fromPrimitive(node, typeInfo));
|
||||
break;
|
||||
|
|
|
@ -26,15 +26,15 @@ import org.apache.commons.lang3.math.NumberUtils;
|
|||
import org.apache.olingo.client.api.data.CollectionValue;
|
||||
import org.apache.olingo.client.api.data.Property;
|
||||
import org.apache.olingo.client.api.data.Value;
|
||||
import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
|
||||
import org.apache.olingo.client.api.domain.ODataJClientEdmType;
|
||||
import org.apache.olingo.client.core.edm.EdmTypeInfo;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
|
||||
abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
|
||||
|
||||
private static final ODataJClientEdmPrimitiveType[] NUMBER_TYPES = {
|
||||
ODataJClientEdmPrimitiveType.Byte, ODataJClientEdmPrimitiveType.SByte,
|
||||
ODataJClientEdmPrimitiveType.Single, ODataJClientEdmPrimitiveType.Double,
|
||||
ODataJClientEdmPrimitiveType.Int16, ODataJClientEdmPrimitiveType.Int32, ODataJClientEdmPrimitiveType.Int64
|
||||
private static final EdmPrimitiveTypeKind[] NUMBER_TYPES = {
|
||||
EdmPrimitiveTypeKind.Byte, EdmPrimitiveTypeKind.SByte,
|
||||
EdmPrimitiveTypeKind.Single, EdmPrimitiveTypeKind.Double,
|
||||
EdmPrimitiveTypeKind.Int16, EdmPrimitiveTypeKind.Int32, EdmPrimitiveTypeKind.Int64
|
||||
};
|
||||
|
||||
private final JSONGeoValueSerializer geoSerializer = new JSONGeoValueSerializer();
|
||||
|
@ -50,20 +50,20 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
|
|||
}
|
||||
|
||||
private void value(final JsonGenerator jgen, final String type, final Value value) throws IOException {
|
||||
final ODataJClientEdmType typeInfo = type == null
|
||||
final EdmTypeInfo typeInfo = type == null
|
||||
? null
|
||||
: new ODataJClientEdmType(type);
|
||||
: new EdmTypeInfo.Builder().setTypeExpression(type).build();
|
||||
|
||||
if (value.isNull()) {
|
||||
jgen.writeNull();
|
||||
} else if (value.isSimple()) {
|
||||
final boolean isNumber = typeInfo == null
|
||||
? NumberUtils.isNumber(value.asSimple().get())
|
||||
: ArrayUtils.contains(NUMBER_TYPES, typeInfo.getPrimitiveType());
|
||||
: ArrayUtils.contains(NUMBER_TYPES, typeInfo.getPrimitiveTypeKind());
|
||||
final boolean isBoolean = typeInfo == null
|
||||
? (value.asSimple().get().equalsIgnoreCase(Boolean.TRUE.toString())
|
||||
|| value.asSimple().get().equalsIgnoreCase(Boolean.FALSE.toString()))
|
||||
: typeInfo.getPrimitiveType() == ODataJClientEdmPrimitiveType.Boolean;
|
||||
: typeInfo.getPrimitiveTypeKind() == EdmPrimitiveTypeKind.Boolean;
|
||||
|
||||
if (isNumber) {
|
||||
jgen.writeNumber(value.asSimple().get());
|
||||
|
@ -77,7 +77,7 @@ abstract class AbstractJsonSerializer<T> extends ODataJacksonSerializer<T> {
|
|||
geoSerializer.serialize(jgen, value.asGeospatial().get());
|
||||
jgen.writeEndObject();
|
||||
} else if (value.isCollection()) {
|
||||
collection(jgen, typeInfo == null ? null : typeInfo.getBaseType(), value.asCollection());
|
||||
collection(jgen, typeInfo == null ? null : typeInfo.getFullQualifiedName().toString(), value.asCollection());
|
||||
} else if (value.isComplex()) {
|
||||
jgen.writeStartObject();
|
||||
for (Property property : value.asComplex().get()) {
|
||||
|
|
|
@ -28,20 +28,21 @@ import javax.xml.stream.events.StartElement;
|
|||
import javax.xml.stream.events.XMLEvent;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.olingo.client.api.Constants;
|
||||
import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
|
||||
import org.apache.olingo.client.api.domain.geospatial.Geospatial;
|
||||
import org.apache.olingo.client.api.domain.geospatial.GeospatialCollection;
|
||||
import org.apache.olingo.client.api.domain.geospatial.LineString;
|
||||
import org.apache.olingo.client.api.domain.geospatial.MultiLineString;
|
||||
import org.apache.olingo.client.api.domain.geospatial.MultiPoint;
|
||||
import org.apache.olingo.client.api.domain.geospatial.MultiPolygon;
|
||||
import org.apache.olingo.client.api.domain.geospatial.Point;
|
||||
import org.apache.olingo.client.api.domain.geospatial.Polygon;
|
||||
import org.apache.olingo.client.api.data.GeoUtils;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial;
|
||||
import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
|
||||
import org.apache.olingo.commons.api.edm.geo.LineString;
|
||||
import org.apache.olingo.commons.api.edm.geo.MultiLineString;
|
||||
import org.apache.olingo.commons.api.edm.geo.MultiPoint;
|
||||
import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
|
||||
import org.apache.olingo.commons.api.edm.geo.Point;
|
||||
import org.apache.olingo.commons.api.edm.geo.Polygon;
|
||||
|
||||
class AtomGeoValueDeserializer {
|
||||
|
||||
private List<Point> points(final XMLEventReader reader, final StartElement start,
|
||||
final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
|
||||
final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
|
||||
|
||||
final List<Point> result = new ArrayList<Point>();
|
||||
|
||||
|
@ -67,7 +68,7 @@ class AtomGeoValueDeserializer {
|
|||
}
|
||||
|
||||
private MultiPoint multipoint(final XMLEventReader reader, final StartElement start,
|
||||
final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
|
||||
final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
|
||||
|
||||
List<Point> points = Collections.<Point>emptyList();
|
||||
|
||||
|
@ -88,13 +89,13 @@ class AtomGeoValueDeserializer {
|
|||
}
|
||||
|
||||
private LineString lineString(final XMLEventReader reader, final StartElement start,
|
||||
final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
|
||||
final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
|
||||
|
||||
return new LineString(GeoUtils.getDimension(type), crs, points(reader, start, type, null));
|
||||
}
|
||||
|
||||
private Polygon polygon(final XMLEventReader reader, final StartElement start,
|
||||
final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
|
||||
final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
|
||||
|
||||
List<Point> extPoints = null;
|
||||
List<Point> intPoints = null;
|
||||
|
@ -121,7 +122,7 @@ class AtomGeoValueDeserializer {
|
|||
}
|
||||
|
||||
private MultiLineString multiLineString(final XMLEventReader reader, final StartElement start,
|
||||
final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
|
||||
final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
|
||||
|
||||
final List<LineString> lineStrings = new ArrayList<LineString>();
|
||||
|
||||
|
@ -142,7 +143,7 @@ class AtomGeoValueDeserializer {
|
|||
}
|
||||
|
||||
private MultiPolygon multiPolygon(final XMLEventReader reader, final StartElement start,
|
||||
final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
|
||||
final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
|
||||
|
||||
final List<Polygon> polygons = new ArrayList<Polygon>();
|
||||
|
||||
|
@ -163,7 +164,7 @@ class AtomGeoValueDeserializer {
|
|||
}
|
||||
|
||||
private GeospatialCollection collection(final XMLEventReader reader, final StartElement start,
|
||||
final ODataJClientEdmPrimitiveType type, final String crs) throws XMLStreamException {
|
||||
final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
|
||||
|
||||
final List<Geospatial> geospatials = new ArrayList<Geospatial>();
|
||||
|
||||
|
@ -196,7 +197,7 @@ class AtomGeoValueDeserializer {
|
|||
}
|
||||
|
||||
public Geospatial deserialize(final XMLEventReader reader, final StartElement start,
|
||||
final ODataJClientEdmPrimitiveType type) throws XMLStreamException {
|
||||
final EdmPrimitiveTypeKind type) throws XMLStreamException {
|
||||
|
||||
String crs = null;
|
||||
final Attribute srsName = start.getAttributeByName(Constants.QNAME_ATTR_SRSNAME);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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<JsonNode> itor, final ODataJClientEdmPrimitiveType type, final String crs) {
|
||||
private final ODataServiceVersion version;
|
||||
|
||||
public JSONGeoValueDeserializer(final ODataServiceVersion version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
private Point point(final Iterator<JsonNode> 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<JsonNode> itor, final ODataJClientEdmPrimitiveType type,
|
||||
private MultiPoint multipoint(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
|
||||
final String crs) {
|
||||
|
||||
MultiPoint multiPoint = null;
|
||||
|
@ -67,7 +76,7 @@ class JSONGeoValueDeserializer {
|
|||
return multiPoint;
|
||||
}
|
||||
|
||||
private LineString lineString(final Iterator<JsonNode> itor, final ODataJClientEdmPrimitiveType type,
|
||||
private LineString lineString(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
|
||||
final String crs) {
|
||||
|
||||
LineString lineString = null;
|
||||
|
@ -86,7 +95,7 @@ class JSONGeoValueDeserializer {
|
|||
return lineString;
|
||||
}
|
||||
|
||||
private MultiLineString multiLineString(final Iterator<JsonNode> itor, final ODataJClientEdmPrimitiveType type,
|
||||
private MultiLineString multiLineString(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
|
||||
final String crs) {
|
||||
|
||||
MultiLineString multiLineString = null;
|
||||
|
@ -105,7 +114,7 @@ class JSONGeoValueDeserializer {
|
|||
return multiLineString;
|
||||
}
|
||||
|
||||
private Polygon polygon(final Iterator<JsonNode> itor, final ODataJClientEdmPrimitiveType type,
|
||||
private Polygon polygon(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
|
||||
final String crs) {
|
||||
|
||||
List<Point> extPoints = null;
|
||||
|
@ -135,7 +144,7 @@ class JSONGeoValueDeserializer {
|
|||
return new Polygon(GeoUtils.getDimension(type), crs, intPoints, extPoints);
|
||||
}
|
||||
|
||||
private MultiPolygon multiPolygon(final Iterator<JsonNode> itor, final ODataJClientEdmPrimitiveType type,
|
||||
private MultiPolygon multiPolygon(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
|
||||
final String crs) {
|
||||
|
||||
MultiPolygon multiPolygon = null;
|
||||
|
@ -154,7 +163,7 @@ class JSONGeoValueDeserializer {
|
|||
return multiPolygon;
|
||||
}
|
||||
|
||||
private GeospatialCollection collection(final Iterator<JsonNode> itor, final ODataJClientEdmPrimitiveType type,
|
||||
private GeospatialCollection collection(final Iterator<JsonNode> 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<JsonNode> 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:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<EdmSchema> createSchemas() {
|
||||
final List<EdmSchema> schemas = new ArrayList<EdmSchema>();
|
||||
for (Schema schema : xmlMetadata.getSchemas()) {
|
||||
schemas.add(new EdmSchemaImpl(this, xmlMetadata, schema));
|
||||
schemas.add(new EdmSchemaImpl(version, this, xmlMetadata, schema));
|
||||
}
|
||||
return schemas;
|
||||
}
|
||||
|
|
|
@ -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<String, EdmMember> 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());
|
||||
}
|
||||
|
|
|
@ -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<EnumType> 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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.<Integer>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.<String>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.<BigDecimal>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.<ODataTimestamp>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.<UUID>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.<byte[]>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<Point> 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<Point> 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<List<Point>> 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<Point> checkInterior,
|
||||
final List<Point> 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<List<Point>> checkInterior,
|
||||
final List<List<Point>> 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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<Point> points = new ArrayList<Point>();
|
||||
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<LineString> lineStrings = new ArrayList<LineString>();
|
||||
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<Polygon> polygons = new ArrayList<Polygon>();
|
||||
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<Geospatial> geospatials = new ArrayList<Geospatial>();
|
||||
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()).
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<String> expectedAI = new HashSet<String>(Arrays.asList(new String[]{
|
||||
final Set<String> expectedAI = new HashSet<String>(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<String> expectedFI = new HashSet<String>(Arrays.asList(new String[]{
|
||||
final Set<String> expectedFI = new HashSet<String>(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());
|
||||
|
|
|
@ -29,21 +29,21 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.olingo.client.api.v3.ODataClient;
|
||||
import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
|
||||
import org.apache.olingo.client.api.domain.ODataDuration;
|
||||
import org.apache.olingo.client.api.domain.ODataPrimitiveValue;
|
||||
import org.apache.olingo.client.api.domain.ODataTimestamp;
|
||||
import org.apache.olingo.client.api.domain.ODataValue;
|
||||
import org.apache.olingo.client.api.domain.geospatial.Geospatial;
|
||||
import org.apache.olingo.client.api.domain.geospatial.GeospatialCollection;
|
||||
import org.apache.olingo.client.api.domain.geospatial.LineString;
|
||||
import org.apache.olingo.client.api.domain.geospatial.MultiLineString;
|
||||
import org.apache.olingo.client.api.domain.geospatial.MultiPoint;
|
||||
import org.apache.olingo.client.api.domain.geospatial.MultiPolygon;
|
||||
import org.apache.olingo.client.api.domain.geospatial.Point;
|
||||
import org.apache.olingo.client.api.domain.geospatial.Polygon;
|
||||
import org.apache.olingo.client.core.AbstractTest;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial;
|
||||
import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
|
||||
import org.apache.olingo.commons.api.edm.geo.LineString;
|
||||
import org.apache.olingo.commons.api.edm.geo.MultiLineString;
|
||||
import org.apache.olingo.commons.api.edm.geo.MultiPoint;
|
||||
import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
|
||||
import org.apache.olingo.commons.api.edm.geo.Point;
|
||||
import org.apache.olingo.commons.api.edm.geo.Polygon;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PrimitiveValueTest extends AbstractTest {
|
||||
|
@ -56,24 +56,24 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
@Test
|
||||
public void manageInt32() {
|
||||
final int primitive = -10;
|
||||
ODataValue value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Int32).
|
||||
ODataValue value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Int32).
|
||||
setValue(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.Int32.toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(EdmPrimitiveTypeKind.Int32.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(Integer.valueOf(primitive), value.asPrimitive().<Integer>toCastValue());
|
||||
|
||||
value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Int32).setText("9").build();
|
||||
value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Int32).setText("9").build();
|
||||
assertEquals("9", value.asPrimitive().<Integer>toCastValue().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void manageString() {
|
||||
final String primitive = UUID.randomUUID().toString();
|
||||
ODataValue value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.String).
|
||||
ODataValue value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.String).
|
||||
setText(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.String.toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(EdmPrimitiveTypeKind.String.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(primitive, value.toString());
|
||||
|
||||
value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.String).
|
||||
value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.String).
|
||||
setText("1126a28b-a4af-4bbd-bf0a-2b2c22635565").build();
|
||||
assertEquals("1126a28b-a4af-4bbd-bf0a-2b2c22635565", value.asPrimitive().<String>toCastValue().toString());
|
||||
}
|
||||
|
@ -81,12 +81,12 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
@Test
|
||||
public void manageDecimal() {
|
||||
final BigDecimal primitive = new BigDecimal("-79228162514264337593543950335");
|
||||
ODataValue value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Decimal).
|
||||
ODataValue value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Decimal).
|
||||
setValue(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.Decimal.toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(EdmPrimitiveTypeKind.Decimal.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(primitive, value.asPrimitive().<BigDecimal>toCastValue());
|
||||
|
||||
value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Decimal).
|
||||
value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Decimal).
|
||||
setText("-79228162514264337593543950335").build();
|
||||
assertEquals("-79228162514264337593543950335", value.asPrimitive().<BigDecimal>toCastValue().toString());
|
||||
}
|
||||
|
@ -97,15 +97,15 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
final String primitive = "2013-01-10T06:27:51.1667673";
|
||||
try {
|
||||
new ODataPrimitiveValue.Builder(ODataClientFactory.getV4()).
|
||||
setType(ODataJClientEdmPrimitiveType.DateTime).setText(primitive).build();
|
||||
setType(EdmPrimitiveTypeKind.DateTime).setText(primitive).build();
|
||||
fail();
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// ignore
|
||||
}
|
||||
final ODataValue value =
|
||||
getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.DateTime).
|
||||
getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.DateTime).
|
||||
setText(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.DateTime.toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(EdmPrimitiveTypeKind.DateTime.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
|
||||
// performed cast to improve the check
|
||||
assertEquals(primitive, value.asPrimitive().<ODataTimestamp>toCastValue().toString());
|
||||
}
|
||||
|
@ -116,16 +116,16 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
final String primitive = "-P9DT51M10.5063807S";
|
||||
try {
|
||||
new ODataPrimitiveValue.Builder(ODataClientFactory.getV4()).
|
||||
setType(ODataJClientEdmPrimitiveType.Time).setText(primitive).build();
|
||||
setType(EdmPrimitiveTypeKind.Time).setText(primitive).build();
|
||||
fail();
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
final ODataValue value =
|
||||
getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Time).
|
||||
getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Time).
|
||||
setText(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.Time.toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(EdmPrimitiveTypeKind.Time.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
|
||||
// performed cast to improve the check
|
||||
assertEquals(primitive, value.asPrimitive().<ODataDuration>toCastValue().toString());
|
||||
}
|
||||
|
@ -134,8 +134,9 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
public void manageDateTimeOffset() {
|
||||
final String primitive = "2013-01-10T02:00:00";
|
||||
final ODataValue value = getClient().getPrimitiveValueBuilder().
|
||||
setType(ODataJClientEdmPrimitiveType.DateTimeOffset).setText(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.DateTimeOffset.toString(), value.asPrimitive().getTypeName());
|
||||
setType(EdmPrimitiveTypeKind.DateTimeOffset).setText(primitive).build();
|
||||
assertEquals(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName().toString(),
|
||||
value.asPrimitive().getTypeName());
|
||||
// performed cast to improve the check
|
||||
assertEquals(primitive, value.asPrimitive().<ODataTimestamp>toCastValue().toString());
|
||||
}
|
||||
|
@ -143,12 +144,12 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
@Test
|
||||
public void manageGuid() {
|
||||
final UUID primitive = UUID.fromString("1126a28b-a4af-4bbd-bf0a-2b2c22635565");
|
||||
ODataValue value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Guid).
|
||||
ODataValue value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Guid).
|
||||
setValue(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.Guid.toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(EdmPrimitiveTypeKind.Guid.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(primitive, value.asPrimitive().<UUID>toCastValue());
|
||||
|
||||
value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Guid).
|
||||
value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Guid).
|
||||
setText("1126a28b-a4af-4bbd-bf0a-2b2c22635565").build();
|
||||
assertEquals("1126a28b-a4af-4bbd-bf0a-2b2c22635565", value.asPrimitive().<UUID>toCastValue().toString());
|
||||
}
|
||||
|
@ -156,14 +157,14 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
@Test
|
||||
public void manageBinary() {
|
||||
final byte[] primitive = UUID.randomUUID().toString().getBytes();
|
||||
ODataValue value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Binary).
|
||||
ODataValue value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Binary).
|
||||
setValue(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.Binary.toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(EdmPrimitiveTypeKind.Binary.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(
|
||||
Base64.encodeBase64String(primitive),
|
||||
Base64.encodeBase64String(value.asPrimitive().<byte[]>toCastValue()));
|
||||
|
||||
value = getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.Binary).
|
||||
value = getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.Binary).
|
||||
setText(Base64.encodeBase64String("primitive".getBytes())).build();
|
||||
assertEquals("primitive", new String(value.asPrimitive().<byte[]>toCastValue()));
|
||||
}
|
||||
|
@ -175,7 +176,7 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
primitive.setY(173.334);
|
||||
|
||||
try {
|
||||
getClient().getPrimitiveValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyPoint).
|
||||
getClient().getPrimitiveValueBuilder().setType(EdmPrimitiveTypeKind.GeographyPoint).
|
||||
setValue(primitive).build();
|
||||
fail();
|
||||
} catch (IllegalArgumentException iae) {
|
||||
|
@ -183,10 +184,11 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
}
|
||||
|
||||
final ODataValue value =
|
||||
getClient().getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyPoint).
|
||||
getClient().getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeographyPoint).
|
||||
setValue(primitive).
|
||||
build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.GeographyPoint.toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(EdmPrimitiveTypeKind.GeographyPoint.getFullQualifiedName().toString(),
|
||||
value.asPrimitive().getTypeName());
|
||||
assertEquals(Double.valueOf(primitive.getX()), Double.valueOf(value.asPrimitive().<Point>toCastValue().getX()));
|
||||
assertEquals(Double.valueOf(primitive.getY()), Double.valueOf(value.asPrimitive().<Point>toCastValue().getY()));
|
||||
}
|
||||
|
@ -217,8 +219,9 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
final LineString primitive = new LineString(Geospatial.Dimension.GEOGRAPHY, null, points);
|
||||
|
||||
final ODataValue value = getClient().getGeospatialValueBuilder().
|
||||
setType(ODataJClientEdmPrimitiveType.GeographyLineString).setValue(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.GeographyLineString.toString(), value.asPrimitive().getTypeName());
|
||||
setType(EdmPrimitiveTypeKind.GeographyLineString).setValue(primitive).build();
|
||||
assertEquals(EdmPrimitiveTypeKind.GeographyLineString.getFullQualifiedName().toString(),
|
||||
value.asPrimitive().getTypeName());
|
||||
|
||||
final Iterator<Point> iter = value.asPrimitive().<LineString>toCastValue().iterator();
|
||||
|
||||
|
@ -242,8 +245,9 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
final MultiPoint primitive = new MultiPoint(Geospatial.Dimension.GEOMETRY, null, points);
|
||||
|
||||
final ODataValue value = getClient().getGeospatialValueBuilder().
|
||||
setType(ODataJClientEdmPrimitiveType.GeometryMultiPoint).setValue(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.GeometryMultiPoint.toString(), value.asPrimitive().getTypeName());
|
||||
setType(EdmPrimitiveTypeKind.GeometryMultiPoint).setValue(primitive).build();
|
||||
assertEquals(EdmPrimitiveTypeKind.GeometryMultiPoint.getFullQualifiedName().toString(),
|
||||
value.asPrimitive().getTypeName());
|
||||
|
||||
final Iterator<Point> iter = value.asPrimitive().<MultiPoint>toCastValue().iterator();
|
||||
point = iter.next();
|
||||
|
@ -302,9 +306,10 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
final MultiLineString primitive = new MultiLineString(Geospatial.Dimension.GEOMETRY, null, lines);
|
||||
|
||||
final ODataValue value =
|
||||
getClient().getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeometryMultiLineString).
|
||||
getClient().getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeometryMultiLineString).
|
||||
setValue(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.GeometryMultiLineString.toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(EdmPrimitiveTypeKind.GeometryMultiLineString.getFullQualifiedName().toString(),
|
||||
value.asPrimitive().getTypeName());
|
||||
|
||||
final Iterator<LineString> lineIter = value.asPrimitive().<MultiLineString>toCastValue().iterator();
|
||||
|
||||
|
@ -355,9 +360,10 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
final Polygon primitive = new Polygon(Geospatial.Dimension.GEOGRAPHY, null, interior, exterior);
|
||||
|
||||
final ODataValue value =
|
||||
getClient().getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyPolygon).
|
||||
getClient().getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeographyPolygon).
|
||||
setValue(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.GeographyPolygon.toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(EdmPrimitiveTypeKind.GeographyPolygon.getFullQualifiedName().toString(),
|
||||
value.asPrimitive().getTypeName());
|
||||
|
||||
assertTrue(value.asPrimitive().<Polygon>toCastValue().getInterior().isEmpty());
|
||||
final Iterator<Point> iter = value.asPrimitive().<Polygon>toCastValue().getExterior().iterator();
|
||||
|
@ -461,9 +467,10 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
final MultiPolygon primitive = new MultiPolygon(Geospatial.Dimension.GEOMETRY, null, polygons);
|
||||
|
||||
final ODataValue value =
|
||||
getClient().getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeometryMultiPolygon).
|
||||
getClient().getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeometryMultiPolygon).
|
||||
setValue(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.GeometryMultiPolygon.toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(EdmPrimitiveTypeKind.GeometryMultiPolygon.getFullQualifiedName().toString(),
|
||||
value.asPrimitive().getTypeName());
|
||||
|
||||
final Iterator<Polygon> iter = value.asPrimitive().<MultiPolygon>toCastValue().iterator();
|
||||
|
||||
|
@ -507,9 +514,10 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
final GeospatialCollection primitive = new GeospatialCollection(Geospatial.Dimension.GEOMETRY, null, collection);
|
||||
|
||||
final ODataValue value =
|
||||
getClient().getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeometryCollection).
|
||||
getClient().getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeometryCollection).
|
||||
setValue(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.GeometryCollection.toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(EdmPrimitiveTypeKind.GeometryCollection.getFullQualifiedName().toString(),
|
||||
value.asPrimitive().getTypeName());
|
||||
|
||||
final Iterator<Geospatial> iter = value.asPrimitive().<GeospatialCollection>toCastValue().iterator();
|
||||
iter.next();
|
||||
|
@ -539,9 +547,10 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
final GeospatialCollection primitive = new GeospatialCollection(Geospatial.Dimension.GEOGRAPHY, null, collection);
|
||||
|
||||
final ODataValue value =
|
||||
getClient().getGeospatialValueBuilder().setType(ODataJClientEdmPrimitiveType.GeographyCollection).
|
||||
getClient().getGeospatialValueBuilder().setType(EdmPrimitiveTypeKind.GeographyCollection).
|
||||
setValue(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.GeographyCollection.toString(), value.asPrimitive().getTypeName());
|
||||
assertEquals(EdmPrimitiveTypeKind.GeographyCollection.getFullQualifiedName().toString(),
|
||||
value.asPrimitive().getTypeName());
|
||||
|
||||
final Iterator<Geospatial> iter = value.asPrimitive().<GeospatialCollection>toCastValue().iterator();
|
||||
iter.next();
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -22,13 +22,13 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.apache.olingo.client.api.v4.ODataClient;
|
||||
import org.apache.olingo.client.api.domain.ODataJClientEdmPrimitiveType;
|
||||
import org.apache.olingo.client.api.domain.ODataDuration;
|
||||
import org.apache.olingo.client.api.domain.ODataPrimitiveValue;
|
||||
import org.apache.olingo.client.api.domain.ODataTimestamp;
|
||||
import org.apache.olingo.client.api.domain.ODataValue;
|
||||
import org.apache.olingo.client.core.AbstractTest;
|
||||
import org.apache.olingo.client.core.ODataClientFactory;
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PrimitiveValueTest extends AbstractTest {
|
||||
|
@ -44,15 +44,15 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
final String primitive = "-P9DT51M12.5063807S";
|
||||
try {
|
||||
new ODataPrimitiveValue.Builder(ODataClientFactory.getV3()).
|
||||
setType(ODataJClientEdmPrimitiveType.TimeOfDay).setText(primitive).build();
|
||||
setType(EdmPrimitiveTypeKind.TimeOfDay).setText(primitive).build();
|
||||
fail();
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
final ODataValue value = getClient().getPrimitiveValueBuilder().
|
||||
setType(ODataJClientEdmPrimitiveType.TimeOfDay).setText(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.TimeOfDay.toString(), value.asPrimitive().getTypeName());
|
||||
setType(EdmPrimitiveTypeKind.TimeOfDay).setText(primitive).build();
|
||||
assertEquals(EdmPrimitiveTypeKind.TimeOfDay.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
|
||||
// performed cast to improve the check
|
||||
assertEquals(primitive, value.asPrimitive().<ODataDuration>toCastValue().toString());
|
||||
}
|
||||
|
@ -63,15 +63,15 @@ public class PrimitiveValueTest extends AbstractTest {
|
|||
final String primitive = "2013-01-10";
|
||||
try {
|
||||
new ODataPrimitiveValue.Builder(ODataClientFactory.getV3()).
|
||||
setType(ODataJClientEdmPrimitiveType.Date).setText(primitive).build();
|
||||
setType(EdmPrimitiveTypeKind.Date).setText(primitive).build();
|
||||
fail();
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
final ODataValue value = getClient().getPrimitiveValueBuilder().
|
||||
setType(ODataJClientEdmPrimitiveType.Date).setText(primitive).build();
|
||||
assertEquals(ODataJClientEdmPrimitiveType.Date.toString(), value.asPrimitive().getTypeName());
|
||||
setType(EdmPrimitiveTypeKind.Date).setText(primitive).build();
|
||||
assertEquals(EdmPrimitiveTypeKind.Date.getFullQualifiedName().toString(), value.asPrimitive().getTypeName());
|
||||
// performed cast to improve the check
|
||||
assertEquals(primitive, value.asPrimitive().<ODataTimestamp>toCastValue().toString());
|
||||
}
|
||||
|
|
|
@ -33,4 +33,12 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.api.edm;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial;
|
||||
|
||||
public interface EdmGeospatialType extends EdmType {
|
||||
|
||||
String EDM_NAMESPACE = EdmPrimitiveType.EDM_NAMESPACE;
|
||||
|
||||
/**
|
||||
* Returns the Java type for this EDM geospatial type.
|
||||
*
|
||||
* @return the geospatial Java type
|
||||
*/
|
||||
Class<? extends Geospatial> getJavaType();
|
||||
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.api.edm;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
|
||||
|
||||
public enum EdmPrimitiveTypeKind {
|
||||
|
||||
Binary,
|
||||
Boolean,
|
||||
Byte,
|
||||
SByte,
|
||||
Date(new ODataServiceVersion[] {ODataServiceVersion.V40}),
|
||||
DateTime(new ODataServiceVersion[] {ODataServiceVersion.V30}),
|
||||
DateTimeOffset,
|
||||
Time(new ODataServiceVersion[] {ODataServiceVersion.V30}),
|
||||
TimeOfDay(new ODataServiceVersion[] {ODataServiceVersion.V40}),
|
||||
Duration(new ODataServiceVersion[] {ODataServiceVersion.V40}),
|
||||
Decimal,
|
||||
Single,
|
||||
Double,
|
||||
Guid,
|
||||
Int16,
|
||||
Int32,
|
||||
Int64,
|
||||
String,
|
||||
Stream,
|
||||
Geography,
|
||||
GeographyPoint,
|
||||
GeographyLineString,
|
||||
GeographyPolygon,
|
||||
GeographyMultiPoint,
|
||||
GeographyMultiLineString,
|
||||
GeographyMultiPolygon,
|
||||
GeographyCollection,
|
||||
Geometry,
|
||||
GeometryPoint,
|
||||
GeometryLineString,
|
||||
GeometryPolygon,
|
||||
GeometryMultiPoint,
|
||||
GeometryMultiLineString,
|
||||
GeometryMultiPolygon,
|
||||
GeometryCollection;
|
||||
|
||||
private final List<ODataServiceVersion> versions;
|
||||
|
||||
EdmPrimitiveTypeKind() {
|
||||
this.versions = Collections.unmodifiableList(
|
||||
Arrays.asList(new ODataServiceVersion[] {ODataServiceVersion.V30, ODataServiceVersion.V40}));
|
||||
}
|
||||
|
||||
EdmPrimitiveTypeKind(final ODataServiceVersion[] versions) {
|
||||
this.versions = Collections.unmodifiableList(Arrays.asList(versions.clone()));
|
||||
}
|
||||
|
||||
public List<ODataServiceVersion> getSupportedVersions() {
|
||||
return this.versions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is a geospatial type.
|
||||
*
|
||||
* @return <tt>true</tt> if is geospatial type; <tt>false</tt> otherwise.
|
||||
*/
|
||||
public boolean isGeospatial() {
|
||||
return name().startsWith("Geo");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link FullQualifiedName} for this type kind.
|
||||
*
|
||||
* @return {@link FullQualifiedName}
|
||||
*/
|
||||
public FullQualifiedName getFullQualifiedName() {
|
||||
return new FullQualifiedName(EdmPrimitiveType.EDM_NAMESPACE, toString());
|
||||
}
|
||||
|
||||
public static EdmPrimitiveTypeKind valueOf(final ODataServiceVersion version, final String name) {
|
||||
final EdmPrimitiveTypeKind kind = valueOf(name);
|
||||
if (!kind.versions.contains(version)) {
|
||||
throw new IllegalArgumentException(kind + " not allowed in " + version);
|
||||
}
|
||||
return kind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets <tt>EdmPrimitiveTypeKind</tt> from a full-qualified type name, for the given OData protocol version.
|
||||
*
|
||||
* @param version OData protocol version.
|
||||
* @param fqn full-qualified type name.
|
||||
* @return <tt>EdmPrimitiveTypeKind</tt> object.
|
||||
*/
|
||||
public static EdmPrimitiveTypeKind valueOfFQN(final ODataServiceVersion version, final FullQualifiedName fqn) {
|
||||
return valueOfFQN(version, fqn.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets <tt>EdmPrimitiveTypeKind</tt> from a full type expression (as <tt>Edm.Int32</tt>), for the given OData
|
||||
* protocol version.
|
||||
*
|
||||
* @param version OData protocol version.
|
||||
* @param fqn string value type.
|
||||
* @return <tt>EdmPrimitiveTypeKind</tt> object.
|
||||
*/
|
||||
public static EdmPrimitiveTypeKind valueOfFQN(final ODataServiceVersion version, final String fqn) {
|
||||
if (version == null) {
|
||||
throw new IllegalArgumentException("No OData protocol version provided");
|
||||
}
|
||||
if (!fqn.startsWith(EdmPrimitiveType.EDM_NAMESPACE + ".")) {
|
||||
throw new IllegalArgumentException(fqn + " does not look like an Edm primitive type");
|
||||
}
|
||||
|
||||
final EdmPrimitiveTypeKind kind = valueOf(fqn.substring(4));
|
||||
if (!kind.versions.contains(version)) {
|
||||
throw new IllegalArgumentException(kind + " not allowed in " + version);
|
||||
}
|
||||
return kind;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
|
@ -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 }
|
|
@ -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<Geospatial> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataJClientEdmPrimitiveType getEdmSimpleType() {
|
||||
public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
|
||||
return dimension == Dimension.GEOGRAPHY
|
||||
? ODataJClientEdmPrimitiveType.GeographyCollection
|
||||
: ODataJClientEdmPrimitiveType.GeometryCollection;
|
||||
? EdmPrimitiveTypeKind.GeographyCollection
|
||||
: EdmPrimitiveTypeKind.GeometryCollection;
|
||||
}
|
||||
}
|
|
@ -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<Point> {
|
||||
|
||||
|
@ -31,9 +30,9 @@ public class LineString extends ComposedGeospatial<Point> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataJClientEdmPrimitiveType getEdmSimpleType() {
|
||||
public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
|
||||
return dimension == Dimension.GEOGRAPHY
|
||||
? ODataJClientEdmPrimitiveType.GeographyLineString
|
||||
: ODataJClientEdmPrimitiveType.GeometryLineString;
|
||||
? EdmPrimitiveTypeKind.GeographyLineString
|
||||
: EdmPrimitiveTypeKind.GeometryLineString;
|
||||
}
|
||||
}
|
|
@ -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<LineString> {
|
||||
|
||||
|
@ -31,9 +30,10 @@ public class MultiLineString extends ComposedGeospatial<LineString> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataJClientEdmPrimitiveType getEdmSimpleType() {
|
||||
public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
|
||||
return dimension == Dimension.GEOGRAPHY
|
||||
? ODataJClientEdmPrimitiveType.GeographyMultiLineString
|
||||
: ODataJClientEdmPrimitiveType.GeometryMultiLineString;
|
||||
? EdmPrimitiveTypeKind.GeographyMultiLineString
|
||||
: EdmPrimitiveTypeKind.GeometryMultiLineString;
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Point> {
|
||||
|
||||
|
@ -31,9 +30,10 @@ public class MultiPoint extends ComposedGeospatial<Point> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataJClientEdmPrimitiveType getEdmSimpleType() {
|
||||
public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
|
||||
return dimension == Dimension.GEOGRAPHY
|
||||
? ODataJClientEdmPrimitiveType.GeographyMultiPoint
|
||||
: ODataJClientEdmPrimitiveType.GeometryMultiPoint;
|
||||
? EdmPrimitiveTypeKind.GeographyMultiPoint
|
||||
: EdmPrimitiveTypeKind.GeometryMultiPoint;
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Polygon> {
|
||||
|
||||
|
@ -31,9 +30,9 @@ public class MultiPolygon extends ComposedGeospatial<Polygon> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ODataJClientEdmPrimitiveType getEdmSimpleType() {
|
||||
public EdmPrimitiveTypeKind getEdmPrimitiveTypeKind() {
|
||||
return dimension == Dimension.GEOGRAPHY
|
||||
? ODataJClientEdmPrimitiveType.GeographyMultiPolygon
|
||||
: ODataJClientEdmPrimitiveType.GeometryMultiPolygon;
|
||||
? EdmPrimitiveTypeKind.GeographyMultiPolygon
|
||||
: EdmPrimitiveTypeKind.GeometryMultiPolygon;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.core.edm.primitivetype;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.EdmGeospatialType;
|
||||
import org.apache.olingo.commons.api.edm.FullQualifiedName;
|
||||
import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
|
||||
|
||||
public abstract class AbstractEdmGeospatialType<T extends Geospatial> implements EdmGeospatialType {
|
||||
|
||||
private final Class<T> reference;
|
||||
|
||||
protected final Dimension dimension;
|
||||
|
||||
protected final Type type;
|
||||
|
||||
protected AbstractEdmGeospatialType(final Class<T> reference, final Dimension dimension, final Type type) {
|
||||
this.reference = reference;
|
||||
this.dimension = dimension;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Geospatial> getJavaType() {
|
||||
return reference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return EDM_NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getSimpleName().substring(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdmTypeKind getKind() {
|
||||
return EdmTypeKind.PRIMITIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
return this == obj || obj != null && getClass() == obj.getClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getClass().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new FullQualifiedName(getNamespace(), getName()).getFullQualifiedNameAsString();
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.core.edm.primitivetype;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
|
||||
|
||||
/**
|
||||
* Implementation of the EDM primitive type DateTime.
|
||||
*/
|
||||
public final class EdmDateTime extends SingletonPrimitiveType {
|
||||
|
||||
public static final ThreadLocal<SimpleDateFormat> DATE_FORMAT = new ThreadLocal<SimpleDateFormat>() {
|
||||
@Override
|
||||
protected SimpleDateFormat initialValue() {
|
||||
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||
}
|
||||
};
|
||||
|
||||
private static final EdmDateTime INSTANCE = new EdmDateTime();
|
||||
|
||||
public static EdmDateTime getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getDefaultType() {
|
||||
return Calendar.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> T internalValueOfString(final String value,
|
||||
final Boolean isNullable, final Integer maxLength, final Integer precision,
|
||||
final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
|
||||
|
||||
Calendar calendar = null;
|
||||
Timestamp timestamp = null;
|
||||
|
||||
final String[] dateParts = value.split("\\.");
|
||||
try {
|
||||
final Date date = DATE_FORMAT.get().parse(dateParts[0]);
|
||||
if (dateParts.length > 1) {
|
||||
int idx = dateParts[1].indexOf('+');
|
||||
if (idx == -1) {
|
||||
idx = dateParts[1].indexOf('-');
|
||||
}
|
||||
if (idx == -1) {
|
||||
calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
calendar.setTime(date);
|
||||
|
||||
timestamp = new Timestamp(calendar.getTimeInMillis());
|
||||
timestamp.setNanos(Integer.parseInt(dateParts[1]));
|
||||
} else {
|
||||
calendar = Calendar.getInstance(TimeZone.getTimeZone(dateParts[1].substring(idx)));
|
||||
calendar.setTime(date);
|
||||
|
||||
timestamp = new Timestamp(calendar.getTimeInMillis());
|
||||
timestamp.setNanos(Integer.parseInt(dateParts[1].substring(0, idx)));
|
||||
}
|
||||
} else {
|
||||
timestamp = new Timestamp(date.getTime());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e);
|
||||
}
|
||||
|
||||
if (returnType.isAssignableFrom(Calendar.class)) {
|
||||
return returnType.cast(calendar);
|
||||
} else if (returnType.isAssignableFrom(Timestamp.class)) {
|
||||
return returnType.cast(timestamp);
|
||||
} else {
|
||||
throw new EdmPrimitiveTypeException(
|
||||
"EdmPrimitiveTypeException.LITERAL_UNCONVERTIBLE_TO_VALUE_TYPE.addContent(value, returnType)");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T> String internalValueToString(final T value,
|
||||
final Boolean isNullable, final Integer maxLength, final Integer precision,
|
||||
final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
|
||||
|
||||
if (value instanceof Calendar) {
|
||||
final Calendar calendar = (Calendar) value;
|
||||
|
||||
final StringBuilder formatted = new StringBuilder().append(DATE_FORMAT.get().format(calendar.getTime()));
|
||||
formatted.append(calendar.getTimeZone());
|
||||
|
||||
return formatted.toString();
|
||||
} else if (value instanceof Timestamp) {
|
||||
final Timestamp timestamp = (Timestamp) value;
|
||||
|
||||
final StringBuilder formatted = new StringBuilder().append(DATE_FORMAT.get().format(timestamp));
|
||||
if (timestamp.getNanos() > 0) {
|
||||
formatted.append('.').append(String.valueOf(timestamp.getNanos()));
|
||||
}
|
||||
|
||||
return formatted.toString();
|
||||
} else {
|
||||
throw new EdmPrimitiveTypeException(
|
||||
"EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.core.edm.primitivetype;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
|
||||
|
||||
public final class EdmGeography extends AbstractEdmGeospatialType<Geospatial> {
|
||||
|
||||
private static final EdmGeography INSTANCE = new EdmGeography();
|
||||
|
||||
public static EdmGeography getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeography() {
|
||||
super(Geospatial.class, Dimension.GEOGRAPHY, null);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.core.edm.primitivetype;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
|
||||
import org.apache.olingo.commons.api.edm.geo.Point;
|
||||
|
||||
public final class EdmGeographyCollection extends AbstractEdmGeospatialType<Point> {
|
||||
|
||||
private static final EdmGeographyCollection INSTANCE = new EdmGeographyCollection();
|
||||
|
||||
public static EdmGeographyCollection getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeographyCollection() {
|
||||
super(Point.class, Dimension.GEOGRAPHY, Type.GEOSPATIALCOLLECTION);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.core.edm.primitivetype;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
|
||||
import org.apache.olingo.commons.api.edm.geo.Point;
|
||||
|
||||
public final class EdmGeographyLineString extends AbstractEdmGeospatialType<Point> {
|
||||
|
||||
private static final EdmGeographyLineString INSTANCE = new EdmGeographyLineString();
|
||||
|
||||
public static EdmGeographyLineString getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeographyLineString() {
|
||||
super(Point.class, Dimension.GEOGRAPHY, Type.LINESTRING);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.core.edm.primitivetype;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
|
||||
import org.apache.olingo.commons.api.edm.geo.Point;
|
||||
|
||||
public final class EdmGeographyMultiLineString extends AbstractEdmGeospatialType<Point> {
|
||||
|
||||
private static final EdmGeographyMultiLineString INSTANCE = new EdmGeographyMultiLineString();
|
||||
|
||||
public static EdmGeographyMultiLineString getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeographyMultiLineString() {
|
||||
super(Point.class, Dimension.GEOGRAPHY, Type.MULTILINESTRING);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.core.edm.primitivetype;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
|
||||
import org.apache.olingo.commons.api.edm.geo.Point;
|
||||
|
||||
public final class EdmGeographyMultiPoint extends AbstractEdmGeospatialType<Point> {
|
||||
|
||||
private static final EdmGeographyMultiPoint INSTANCE = new EdmGeographyMultiPoint();
|
||||
|
||||
public static EdmGeographyMultiPoint getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeographyMultiPoint() {
|
||||
super(Point.class, Dimension.GEOGRAPHY, Type.MULTIPOINT);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.core.edm.primitivetype;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
|
||||
import org.apache.olingo.commons.api.edm.geo.Point;
|
||||
|
||||
public final class EdmGeographyMultiPolygon extends AbstractEdmGeospatialType<Point> {
|
||||
|
||||
private static final EdmGeographyMultiPolygon INSTANCE = new EdmGeographyMultiPolygon();
|
||||
|
||||
public static EdmGeographyMultiPolygon getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeographyMultiPolygon() {
|
||||
super(Point.class, Dimension.GEOGRAPHY, Type.MULTIPOLYGON);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.core.edm.primitivetype;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
|
||||
import org.apache.olingo.commons.api.edm.geo.Point;
|
||||
|
||||
public final class EdmGeographyPoint extends AbstractEdmGeospatialType<Point> {
|
||||
|
||||
private static final EdmGeographyPoint INSTANCE = new EdmGeographyPoint();
|
||||
|
||||
public static EdmGeographyPoint getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeographyPoint() {
|
||||
super(Point.class, Dimension.GEOGRAPHY, Type.POINT);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.olingo.commons.core.edm.primitivetype;
|
||||
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
|
||||
import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
|
||||
import org.apache.olingo.commons.api.edm.geo.Point;
|
||||
|
||||
public final class EdmGeographyPolygon extends AbstractEdmGeospatialType<Point> {
|
||||
|
||||
private static final EdmGeographyPolygon INSTANCE = new EdmGeographyPolygon();
|
||||
|
||||
public static EdmGeographyPolygon getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeographyPolygon() {
|
||||
super(Point.class, Dimension.GEOGRAPHY, Type.POLYGON);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Geospatial> {
|
||||
|
||||
private static final EdmGeometry INSTANCE = new EdmGeometry();
|
||||
|
||||
public static EdmGeometry getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeometry() {
|
||||
super(Geospatial.class, Dimension.GEOMETRY, null);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Point> {
|
||||
|
||||
private static final EdmGeometryCollection INSTANCE = new EdmGeometryCollection();
|
||||
|
||||
public static EdmGeometryCollection getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeometryCollection() {
|
||||
super(Point.class, Dimension.GEOMETRY, Type.GEOSPATIALCOLLECTION);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Point> {
|
||||
|
||||
private static final EdmGeometryLineString INSTANCE = new EdmGeometryLineString();
|
||||
|
||||
public static EdmGeometryLineString getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeometryLineString() {
|
||||
super(Point.class, Dimension.GEOMETRY, Type.LINESTRING);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Point> {
|
||||
|
||||
private static final EdmGeometryMultiLineString INSTANCE = new EdmGeometryMultiLineString();
|
||||
|
||||
public static EdmGeometryMultiLineString getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeometryMultiLineString() {
|
||||
super(Point.class, Dimension.GEOMETRY, Type.MULTILINESTRING);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Point> {
|
||||
|
||||
private static final EdmGeometryMultiPoint INSTANCE = new EdmGeometryMultiPoint();
|
||||
|
||||
public static EdmGeometryMultiPoint getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeometryMultiPoint() {
|
||||
super(Point.class, Dimension.GEOMETRY, Type.MULTIPOINT);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Point> {
|
||||
|
||||
private static final EdmGeometryMultiPolygon INSTANCE = new EdmGeometryMultiPolygon();
|
||||
|
||||
public static EdmGeometryMultiPolygon getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeometryMultiPolygon() {
|
||||
super(Point.class, Dimension.GEOMETRY, Type.MULTIPOLYGON);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Point> {
|
||||
|
||||
private static final EdmGeometryPoint INSTANCE = new EdmGeometryPoint();
|
||||
|
||||
public static EdmGeometryPoint getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeometryPoint() {
|
||||
super(Point.class, Dimension.GEOMETRY, Type.POINT);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Point> {
|
||||
|
||||
private static final EdmGeometryPolygon INSTANCE = new EdmGeometryPolygon();
|
||||
|
||||
public static EdmGeometryPolygon getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public EdmGeometryPolygon() {
|
||||
super(Point.class, Dimension.GEOMETRY, Type.POLYGON);
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
|
@ -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 <tt>EdmPrimitiveTypeKind</tt> from a full string (e.g. 'Edm.Int32').
|
||||
*
|
||||
* @param value string value type.
|
||||
* @return <tt>EdmPrimitiveTypeKind</tt> 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));
|
||||
}
|
||||
}
|
|
@ -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> T internalValueOfString(final String value,
|
||||
final Boolean isNullable, final Integer maxLength, final Integer precision,
|
||||
final Integer scale, final Boolean isUnicode, final Class<T> returnType) throws EdmPrimitiveTypeException {
|
||||
|
||||
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 <T> String internalValueToString(final T value,
|
||||
final Boolean isNullable, final Integer maxLength, final Integer precision,
|
||||
final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
|
||||
|
||||
if (value instanceof URI) {
|
||||
return ((URI) value).toASCIIString();
|
||||
} else {
|
||||
throw new EdmPrimitiveTypeException(
|
||||
"EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<T> 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;
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, "@");
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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?
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue