You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2013/12/05 13:31:29 UTC
[36/52] git commit: Removed dependcy from 'api-annotations' to 'api'
Removed dependcy from 'api-annotations' to 'api'
Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/commit/09344a5b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/09344a5b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/09344a5b
Branch: refs/heads/master
Commit: 09344a5bc0f2c370a44aec218c1d9ea0bfae10a9
Parents: 7030c24
Author: Michael Bolz <mi...@apache.org>
Authored: Tue Dec 3 14:18:12 2013 +0100
Committer: Michael Bolz <mi...@apache.org>
Committed: Tue Dec 3 14:18:12 2013 +0100
----------------------------------------------------------------------
.../annotation/edm/AnnotationEdmProvider.java | 71 ++++++++++++++------
.../core/annotation/edm/AnnotationHelper.java | 31 ++++++++-
.../processor/json/EdmAnnotationSerializer.java | 12 ++--
.../odata2/core/annotation/model/Building.java | 6 +-
.../odata2/core/annotation/model/Employee.java | 7 +-
.../odata2/core/annotation/model/Photo.java | 4 +-
.../odata2/core/annotation/model/RefBase.java | 4 +-
.../odata2/core/annotation/model/Team.java | 4 +-
.../odata2/ref/annotation/model/Building.java | 7 +-
.../odata2/ref/annotation/model/Employee.java | 7 +-
.../odata2/ref/annotation/model/Photo.java | 5 +-
.../odata2/ref/annotation/model/RefBase.java | 6 +-
.../odata2/ref/annotation/model/Team.java | 4 +-
.../edm/EdmFunctionImportParameter.java | 12 ++--
.../odata2/api/annotation/edm/EdmProperty.java | 13 ++--
.../odata2/api/annotation/edm/EdmType.java | 31 +++++++++
16 files changed, 163 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/edm/AnnotationEdmProvider.java
----------------------------------------------------------------------
diff --git a/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/edm/AnnotationEdmProvider.java b/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/edm/AnnotationEdmProvider.java
index 7dfbd0e..1b53d58 100644
--- a/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/edm/AnnotationEdmProvider.java
+++ b/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/edm/AnnotationEdmProvider.java
@@ -39,8 +39,8 @@ import org.apache.olingo.odata2.api.annotation.edm.EdmKey;
import org.apache.olingo.odata2.api.annotation.edm.EdmMediaResourceContent;
import org.apache.olingo.odata2.api.annotation.edm.EdmNavigationProperty;
import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
+import org.apache.olingo.odata2.api.annotation.edm.EdmType;
import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
import org.apache.olingo.odata2.api.edm.FullQualifiedName;
import org.apache.olingo.odata2.api.edm.provider.AnnotationAttribute;
import org.apache.olingo.odata2.api.edm.provider.AnnotationElement;
@@ -453,11 +453,11 @@ public class AnnotationEdmProvider extends EdmProvider {
String entityName = ANNOTATION_HELPER.getPropertyName(field);
sp.setName(entityName);
//
- EdmSimpleTypeKind type = ep.type();
- if (type == EdmSimpleTypeKind.Null) {
- type = getEdmSimpleType(field.getType());
+ EdmType type = ep.type();
+ if (type == EdmType.NULL) {
+ type = getEdmType(field.getType());
}
- sp.setType(type);
+ sp.setType(ANNOTATION_HELPER.mapTypeKind(type));
return sp;
}
@@ -494,38 +494,71 @@ public class AnnotationEdmProvider extends EdmProvider {
return navProp;
}
- private EdmSimpleTypeKind getEdmSimpleType(Class<?> type) {
+// private EdmSimpleTypeKind getEdmSimpleType(Class<?> type) {
+// if (type == String.class) {
+// return EdmType.String;
+// } else if (type == boolean.class || type == Boolean.class) {
+// return EdmType.Boolean;
+// } else if (type == byte.class || type == Byte.class) {
+// return EdmType.SByte;
+// } else if (type == short.class || type == Short.class) {
+// return EdmType.Int16;
+// } else if (type == int.class || type == Integer.class) {
+// return EdmType.Int32;
+// } else if (type == long.class || type == Long.class) {
+// return EdmType.Int64;
+// } else if (type == double.class || type == Double.class) {
+// return EdmType.Double;
+// } else if (type == float.class || type == Float.class) {
+// return EdmType.Single;
+// } else if (type == BigInteger.class || type == BigDecimal.class) {
+// return EdmType.Decimal;
+// } else if (type == Byte[].class || type == byte[].class) {
+// return EdmType.Binary;
+// } else if (type == Date.class) {
+// return EdmType.DateTime;
+// } else if (type == Calendar.class) {
+// return EdmType.DateTimeOffset;
+// } else if (type == UUID.class) {
+// return EdmType.Guid;
+// } else {
+// throw new UnsupportedOperationException("Not yet supported type '" + type + "'.");
+// }
+// }
+
+ private EdmType getEdmType(Class<?> type) {
if (type == String.class) {
- return EdmSimpleTypeKind.String;
+ return EdmType.STRING;
} else if (type == boolean.class || type == Boolean.class) {
- return EdmSimpleTypeKind.Boolean;
+ return EdmType.BOOLEAN;
} else if (type == byte.class || type == Byte.class) {
- return EdmSimpleTypeKind.SByte;
+ return EdmType.SBYTE;
} else if (type == short.class || type == Short.class) {
- return EdmSimpleTypeKind.Int16;
+ return EdmType.INT16;
} else if (type == int.class || type == Integer.class) {
- return EdmSimpleTypeKind.Int32;
+ return EdmType.INT32;
} else if (type == long.class || type == Long.class) {
- return EdmSimpleTypeKind.Int64;
+ return EdmType.INT64;
} else if (type == double.class || type == Double.class) {
- return EdmSimpleTypeKind.Double;
+ return EdmType.DOUBLE;
} else if (type == float.class || type == Float.class) {
- return EdmSimpleTypeKind.Single;
+ return EdmType.SINGLE;
} else if (type == BigInteger.class || type == BigDecimal.class) {
- return EdmSimpleTypeKind.Decimal;
+ return EdmType.DECIMAL;
} else if (type == Byte[].class || type == byte[].class) {
- return EdmSimpleTypeKind.Binary;
+ return EdmType.BINARY;
} else if (type == Date.class) {
- return EdmSimpleTypeKind.DateTime;
+ return EdmType.DATE_TIME;
} else if (type == Calendar.class) {
- return EdmSimpleTypeKind.DateTimeOffset;
+ return EdmType.DATE_TIME_OFFSET;
} else if (type == UUID.class) {
- return EdmSimpleTypeKind.Guid;
+ return EdmType.GUID;
} else {
throw new UnsupportedOperationException("Not yet supported type '" + type + "'.");
}
}
+
private Class<?> checkForBaseEntityClass(Class<?> aClass) {
Class<?> superClass = aClass.getSuperclass();
if (superClass == Object.class) {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/edm/AnnotationHelper.java
----------------------------------------------------------------------
diff --git a/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/edm/AnnotationHelper.java b/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/edm/AnnotationHelper.java
index f25d9b9..94edb0a 100644
--- a/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/edm/AnnotationHelper.java
+++ b/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/edm/AnnotationHelper.java
@@ -615,7 +615,7 @@ public class AnnotationHelper {
Class<?> fieldClass = field.getType();
try {
EdmProperty property = field.getAnnotation(EdmProperty.class);
- EdmSimpleTypeKind type = property.type();
+ EdmSimpleTypeKind type = mapTypeKind(property.type());
return type.getEdmSimpleTypeInstance().valueOfString(propertyValue,
EdmLiteralKind.DEFAULT, null, fieldClass);
} catch (EdmSimpleTypeException ex) {
@@ -663,8 +663,37 @@ public class AnnotationHelper {
return content.substring(0, 1).toUpperCase(Locale.ENGLISH) + content.substring(1);
}
+ public EdmSimpleTypeKind mapTypeKind(org.apache.olingo.odata2.api.annotation.edm.EdmType type) {
+ switch (type) {
+ case BINARY: return EdmSimpleTypeKind.Binary;
+ case BOOLEAN: return EdmSimpleTypeKind.Boolean;
+ case BYTE: return EdmSimpleTypeKind.Byte;
+ case COMPLEX: return EdmSimpleTypeKind.Null;
+ case DATE_TIME: return EdmSimpleTypeKind.DateTime;
+ case DATE_TIME_OFFSET: return EdmSimpleTypeKind.DateTimeOffset;
+ case DECIMAL: return EdmSimpleTypeKind.Decimal;
+ case DOUBLE: return EdmSimpleTypeKind.Double;
+ case GUID: return EdmSimpleTypeKind.Guid;
+ case INT16: return EdmSimpleTypeKind.Int16;
+ case INT32: return EdmSimpleTypeKind.Int32;
+ case INT64: return EdmSimpleTypeKind.Int64;
+ case NULL: return EdmSimpleTypeKind.Null;
+ case SBYTE: return EdmSimpleTypeKind.SByte;
+ case SINGLE: return EdmSimpleTypeKind.Single;
+ case STRING: return EdmSimpleTypeKind.String;
+ case TIME: return EdmSimpleTypeKind.Time;
+ default: throw new ODataRuntimeException("Unknown type '" + type
+ + "' for mapping to EdmSimpleTypeKind.");
+ }
+ }
+
+ /**
+ *
+ */
private static class EdmAnnotationException extends RuntimeException {
+ private static final long serialVersionUID = 42L;
+
public EdmAnnotationException(String message) {
super(message);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/processor/json/EdmAnnotationSerializer.java
----------------------------------------------------------------------
diff --git a/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/processor/json/EdmAnnotationSerializer.java b/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/processor/json/EdmAnnotationSerializer.java
index 6e1d8ea..7ae9971 100644
--- a/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/processor/json/EdmAnnotationSerializer.java
+++ b/odata2-edm-annotation/edm-annotation-core/src/main/java/org/apache/olingo/odata2/core/annotation/processor/json/EdmAnnotationSerializer.java
@@ -25,11 +25,12 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-import org.apache.olingo.odata2.api.annotation.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.annotation.edm.EdmEntitySet;
import org.apache.olingo.odata2.api.annotation.edm.EdmKey;
import org.apache.olingo.odata2.api.annotation.edm.EdmNavigationProperty;
import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
+import org.apache.olingo.odata2.api.annotation.edm.EdmType;
import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
import org.apache.olingo.odata2.api.edm.EdmSimpleTypeException;
import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
@@ -178,8 +179,8 @@ public class EdmAnnotationSerializer {
}
private EdmSimpleTypeKind getDefaultSimpleTypeKind(Field field, EdmProperty property) {
- final EdmSimpleTypeKind type = property.type();
- if (type == EdmSimpleTypeKind.Null) {
+ final EdmType type = property.type();
+ if (type == EdmType.NULL) {
Class<?> fieldType = field.getType();
if (fieldType == String.class) {
return EdmSimpleTypeKind.String;
@@ -189,11 +190,12 @@ public class EdmAnnotationSerializer {
return EdmSimpleTypeKind.Int32;
}
}
- return type;
+ return ANNOTATION_HELPER.mapTypeKind(type);
}
private Class<?> getType(EdmProperty property) {
- Class<?> defaultType = property.type().getEdmSimpleTypeInstance().getDefaultType();
+ EdmSimpleTypeKind type = ANNOTATION_HELPER.mapTypeKind(property.type());
+ Class<?> defaultType = type.getEdmSimpleTypeInstance().getDefaultType();
return defaultType;
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Building.java
----------------------------------------------------------------------
diff --git a/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Building.java b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Building.java
index 15cd3ae..bf43580 100644
--- a/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Building.java
+++ b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Building.java
@@ -27,8 +27,8 @@ import org.apache.olingo.odata2.api.annotation.edm.EdmEntityType;
import org.apache.olingo.odata2.api.annotation.edm.EdmKey;
import org.apache.olingo.odata2.api.annotation.edm.EdmNavigationProperty;
import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
+import org.apache.olingo.odata2.api.annotation.edm.EdmType;
import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
/**
*
@@ -37,11 +37,11 @@ import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
@EdmEntitySet(name = "Buildings")
public class Building {
@EdmKey
- @EdmProperty(type = EdmSimpleTypeKind.Int32)
+ @EdmProperty(type = EdmType.INT32)
private String id;
@EdmProperty
private String name;
- @EdmProperty(name = "Image", type = EdmSimpleTypeKind.Binary)
+ @EdmProperty(name = "Image", type = EdmType.BINARY)
private byte[] image;
@EdmNavigationProperty(name = "nb_Rooms", toType = Room.class,
association = "BuildingRooms", toMultiplicity = EdmMultiplicity.MANY)
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Employee.java
----------------------------------------------------------------------
diff --git a/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Employee.java b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Employee.java
index dc97c68..63b8a76 100644
--- a/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Employee.java
+++ b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Employee.java
@@ -28,7 +28,7 @@ import org.apache.olingo.odata2.api.annotation.edm.EdmMediaResourceContent;
import org.apache.olingo.odata2.api.annotation.edm.EdmMediaResourceMimeType;
import org.apache.olingo.odata2.api.annotation.edm.EdmNavigationProperty;
import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.annotation.edm.EdmType;
/**
*
@@ -36,9 +36,8 @@ import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
@EdmEntityType(name = "Employee", namespace = ModelSharedConstants.NAMESPACE_1)
@EdmEntitySet(name = "Employees")
public class Employee {
- private static int counter = 1;
@EdmKey
- @EdmProperty(name = "EmployeeId", type = EdmSimpleTypeKind.String)
+ @EdmProperty(name = "EmployeeId", type = EdmType.STRING)
private String employeeId;
@EdmProperty(name = "EmployeeName")
private String employeeName;
@@ -56,7 +55,7 @@ public class Employee {
private byte[] image;
@EdmProperty(name = "ImageUrl")
private String imageUrl;
- @EdmProperty(name = "EntryDate", type = EdmSimpleTypeKind.DateTime)
+ @EdmProperty(name = "EntryDate", type = EdmType.DATE_TIME)
private Calendar entryDate;
@EdmProperty(name = "Location")
private Location location;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Photo.java
----------------------------------------------------------------------
diff --git a/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Photo.java b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Photo.java
index df7d687..520216a 100644
--- a/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Photo.java
+++ b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Photo.java
@@ -27,7 +27,7 @@ import org.apache.olingo.odata2.api.annotation.edm.EdmMediaResourceContent;
import org.apache.olingo.odata2.api.annotation.edm.EdmMediaResourceMimeType;
import org.apache.olingo.odata2.api.annotation.edm.EdmMediaResourceSource;
import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.annotation.edm.EdmType;
/**
*
@@ -47,7 +47,7 @@ public class Photo {
@EdmProperty
@EdmMediaResourceSource
private String imageUrl = "http://localhost/someResource.png";
- @EdmProperty(type = EdmSimpleTypeKind.Binary)
+ @EdmProperty(type = EdmType.BINARY)
@EdmMediaResourceContent
private byte[] image = ResourceHelper.generateImage();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/RefBase.java
----------------------------------------------------------------------
diff --git a/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/RefBase.java b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/RefBase.java
index c38a506..6f3002f 100644
--- a/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/RefBase.java
+++ b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/RefBase.java
@@ -19,7 +19,7 @@ package org.apache.olingo.odata2.core.annotation.model;
import org.apache.olingo.odata2.api.annotation.edm.EdmEntityType;
import org.apache.olingo.odata2.api.annotation.edm.EdmKey;
import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.annotation.edm.EdmType;
/**
*
@@ -28,7 +28,7 @@ import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
public abstract class RefBase {
@EdmProperty(name="Name")
protected String name;
- @EdmProperty(name="Id", type = EdmSimpleTypeKind.String)
+ @EdmProperty(name="Id", type = EdmType.STRING)
@EdmKey
protected int id;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Team.java
----------------------------------------------------------------------
diff --git a/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Team.java b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Team.java
index 6e3463b..23ad181 100644
--- a/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Team.java
+++ b/odata2-edm-annotation/edm-annotation-core/src/test/java/org/apache/olingo/odata2/core/annotation/model/Team.java
@@ -25,8 +25,8 @@ import org.apache.olingo.odata2.api.annotation.edm.EdmEntitySet;
import org.apache.olingo.odata2.api.annotation.edm.EdmEntityType;
import org.apache.olingo.odata2.api.annotation.edm.EdmNavigationProperty;
import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
+import org.apache.olingo.odata2.api.annotation.edm.EdmType;
import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
/**
*
@@ -34,7 +34,7 @@ import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
@EdmEntityType(name = "Team", namespace = ModelSharedConstants.NAMESPACE_1)
@EdmEntitySet(name = "Teams")
public class Team extends RefBase {
- @EdmProperty(type = EdmSimpleTypeKind.Boolean)
+ @EdmProperty(type = EdmType.BOOLEAN)
private Boolean isScrumTeam;
@EdmNavigationProperty(name = "nt_Employees", association = "TeamEmployees", toMultiplicity = EdmMultiplicity.MANY)
private List<Employee> employees = new ArrayList<Employee>();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Building.java
----------------------------------------------------------------------
diff --git a/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Building.java b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Building.java
index bb50759..503ccfd 100644
--- a/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Building.java
+++ b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Building.java
@@ -21,13 +21,14 @@ package org.apache.olingo.odata2.ref.annotation.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+
import org.apache.olingo.odata2.api.annotation.edm.EdmEntitySet;
import org.apache.olingo.odata2.api.annotation.edm.EdmEntityType;
import org.apache.olingo.odata2.api.annotation.edm.EdmKey;
import org.apache.olingo.odata2.api.annotation.edm.EdmNavigationProperty;
import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
+import org.apache.olingo.odata2.api.annotation.edm.EdmType;
import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
/**
*
@@ -36,11 +37,11 @@ import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
@EdmEntitySet(name = "Buildings")
public class Building {
@EdmKey
- @EdmProperty(type = EdmSimpleTypeKind.Int32)
+ @EdmProperty(type = EdmType.INT32)
private int id;
@EdmProperty
private String name;
- @EdmProperty(name = "Image", type = EdmSimpleTypeKind.Binary)
+ @EdmProperty(name = "Image", type = EdmType.BINARY)
private byte[] image;
@EdmNavigationProperty(name = "nb_Rooms", toType = Room.class,
association = "BuildingRooms", toMultiplicity = EdmMultiplicity.MANY)
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Employee.java
----------------------------------------------------------------------
diff --git a/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Employee.java b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Employee.java
index 2975d1b..2204ee8 100644
--- a/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Employee.java
+++ b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Employee.java
@@ -29,7 +29,7 @@ import org.apache.olingo.odata2.api.annotation.edm.EdmMediaResourceContent;
import org.apache.olingo.odata2.api.annotation.edm.EdmMediaResourceMimeType;
import org.apache.olingo.odata2.api.annotation.edm.EdmNavigationProperty;
import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.annotation.edm.EdmType;
/**
*
@@ -37,9 +37,8 @@ import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
@EdmEntityType(name = "Employee", namespace = ModelSharedConstants.NAMESPACE_1)
@EdmEntitySet(name = "Employees")
public class Employee {
- private static int counter = 1;
@EdmKey
- @EdmProperty(name = "EmployeeId", type = EdmSimpleTypeKind.String)
+ @EdmProperty(name = "EmployeeId", type = EdmType.STRING)
private String employeeId;
@EdmProperty(name = "EmployeeName")
private String employeeName;
@@ -57,7 +56,7 @@ public class Employee {
private byte[] image;
@EdmProperty(name = "ImageUrl")
private String imageUrl;
- @EdmProperty(name = "EntryDate", type = EdmSimpleTypeKind.DateTime,
+ @EdmProperty(name = "EntryDate", type = EdmType.DATE_TIME,
facets = @EdmFacets(nullable = true))
private Calendar entryDate;
@EdmProperty(name = "Location", facets = @EdmFacets(nullable = false))
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Photo.java
----------------------------------------------------------------------
diff --git a/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Photo.java b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Photo.java
index eafee7b..52971cd 100644
--- a/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Photo.java
+++ b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Photo.java
@@ -19,6 +19,7 @@
package org.apache.olingo.odata2.ref.annotation.model;
import java.util.Arrays;
+
import org.apache.olingo.odata2.api.annotation.edm.EdmEntitySet;
import org.apache.olingo.odata2.api.annotation.edm.EdmEntityType;
import org.apache.olingo.odata2.api.annotation.edm.EdmKey;
@@ -26,7 +27,7 @@ import org.apache.olingo.odata2.api.annotation.edm.EdmMediaResourceContent;
import org.apache.olingo.odata2.api.annotation.edm.EdmMediaResourceMimeType;
import org.apache.olingo.odata2.api.annotation.edm.EdmMediaResourceSource;
import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.annotation.edm.EdmType;
/**
*
@@ -46,7 +47,7 @@ public class Photo {
@EdmProperty
@EdmMediaResourceSource
private String imageUrl = "http://localhost/someResource.png";
- @EdmProperty(type = EdmSimpleTypeKind.Binary)
+ @EdmProperty(type = EdmType.BINARY)
@EdmMediaResourceContent
private byte[] image = ResourceHelper.generateImage();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/RefBase.java
----------------------------------------------------------------------
diff --git a/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/RefBase.java b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/RefBase.java
index 5f40d1e..727b8c3 100644
--- a/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/RefBase.java
+++ b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/RefBase.java
@@ -19,9 +19,9 @@
package org.apache.olingo.odata2.ref.annotation.model;
import org.apache.olingo.odata2.api.annotation.edm.EdmEntityType;
-import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
import org.apache.olingo.odata2.api.annotation.edm.EdmKey;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
+import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
+import org.apache.olingo.odata2.api.annotation.edm.EdmType;
/**
*
@@ -30,7 +30,7 @@ import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
public abstract class RefBase {
@EdmProperty(name="Name")
protected String name;
- @EdmProperty(name="Id", type = EdmSimpleTypeKind.String)
+ @EdmProperty(name="Id", type = EdmType.STRING)
@EdmKey
protected String id;
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Team.java
----------------------------------------------------------------------
diff --git a/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Team.java b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Team.java
index 7cbe321..8320c54 100644
--- a/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Team.java
+++ b/odata2-edm-annotation/edm-annotation-webref/src/main/java/org/apache/olingo/odata2/ref/annotation/model/Team.java
@@ -25,8 +25,8 @@ import org.apache.olingo.odata2.api.annotation.edm.EdmEntitySet;
import org.apache.olingo.odata2.api.annotation.edm.EdmEntityType;
import org.apache.olingo.odata2.api.annotation.edm.EdmNavigationProperty;
import org.apache.olingo.odata2.api.annotation.edm.EdmProperty;
+import org.apache.olingo.odata2.api.annotation.edm.EdmType;
import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
/**
*
@@ -34,7 +34,7 @@ import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
@EdmEntityType(name = "Team", namespace = ModelSharedConstants.NAMESPACE_1)
@EdmEntitySet(name = "Teams")
public class Team extends RefBase {
- @EdmProperty(type = EdmSimpleTypeKind.Boolean)
+ @EdmProperty(type = EdmType.BOOLEAN)
private Boolean isScrumTeam;
@EdmNavigationProperty(name = "nt_Employees", association = "TeamEmployees", toMultiplicity = EdmMultiplicity.MANY)
private List<Employee> employees = new ArrayList<Employee>();
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmFunctionImportParameter.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmFunctionImportParameter.java b/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmFunctionImportParameter.java
index 74d1072..dca3d44 100644
--- a/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmFunctionImportParameter.java
+++ b/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmFunctionImportParameter.java
@@ -23,8 +23,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-
/**
* <p>Annotation for definition of an {@link EdmFunctionImportParameter} for an {@link EdmFunctionImport}
* which contains the {@link EdmFunctionImportParameter} as a parameter.</p>
@@ -42,12 +40,18 @@ public @interface EdmFunctionImportParameter {
String name();
/**
* Define the EdmSimpleType which is used for the Function Import Parameter in the EDM.
- * If not set a default value has to be generated by the EDM provider (which should be compatible to the
+ * <p>
+ * If not explicit set a default value has to be generated by the EDM provider (which should be compatible to the
* java type of the annotated field).
+ * <p>
+ * If the property is a simple property a EdmSimpleType must be used which can be mapped to the
+ * java type of the annotated field. Which mappings are available depends on the used implementation.
+ * <p>
+ * If the property is a EdmComplexType (and no EdmSimpleType) the type <code>COMPLEX</code> must be used.
*
* @return type for the Function Import Parameter as used in the EDM
*/
- EdmSimpleTypeKind type() default EdmSimpleTypeKind.Null;
+ EdmType type() default EdmType.NULL;
/**
* Define the EdmFacets for the Function Import Parameter in the EDM.
* If not set the default EdmFacet values are used (see {@link EdmFacets}).
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmProperty.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmProperty.java b/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmProperty.java
index 6e45598..cc6fbba 100644
--- a/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmProperty.java
+++ b/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmProperty.java
@@ -23,8 +23,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
-
/**
* <p>Annotation for definition of an EdmProperty for an EdmEntityType or EdmComplexType
* which contains the EdmProperty as a field.</p>
@@ -35,13 +33,18 @@ import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind;
public @interface EdmProperty {
/**
* Define the EdmSimpleType which is used for the Property in the EDM.
- * If not set a default value has to be generated by the EDM provider (which should be compatible to the
+ * <p>
+ * If not explicit set a default value has to be generated by the EDM provider (which should be compatible to the
* java type of the annotated field).
- * If the property is a EdmComplexType (and no EdmSimpleType) the default value has to be used.
+ * <p>
+ * If the property is a simple property a EdmSimpleType must be used which can be mapped to the
+ * java type of the annotated field. Which mappings are available depends on the used implementation.
+ * <p>
+ * If the property is a EdmComplexType (and no EdmSimpleType) the type <code>COMPLEX</code> must be used.
*
* @return type for the Property as used in the EDM
*/
- EdmSimpleTypeKind type() default EdmSimpleTypeKind.Null;
+ EdmType type() default EdmType.NULL;
/**
* Define the name for the Property.
* If not set a default value has to be generated by the EDM provider.
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/09344a5b/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmType.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmType.java b/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmType.java
new file mode 100644
index 0000000..1b7b4a3
--- /dev/null
+++ b/odata2-lib/odata-annotation/src/main/java/org/apache/olingo/odata2/api/annotation/edm/EdmType.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ******************************************************************************/
+package org.apache.olingo.odata2.api.annotation.edm;
+
+/**
+ * <p>The EdmTypes which can be used for property definition in the EDM.</p>
+ * The available values are based on <code>EdmSimpleTypeKind</code> values with the additional type
+ * <code>COMPLEX</code> which can be used to explicit define a EdmProperty as complex.
+ */
+public enum EdmType {
+ BINARY, BOOLEAN, BYTE, DATE_TIME, DATE_TIME_OFFSET, DECIMAL, DOUBLE,
+ GUID, INT16, INT32, INT64, SBYTE, SINGLE, STRING, TIME, NULL,
+ /** Only for explicit definition of a complex property. Not mappable to <code>EdmSimpleTypeKind</code> */
+ COMPLEX;
+}