olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject git commit: Minor changes for OLINGO-30
Date Tue, 15 Oct 2013 17:04:25 GMT
Updated Branches:
  refs/heads/master 95eb8f189 -> 5c3319b32


Minor changes for OLINGO-30


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/5c3319b3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/5c3319b3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/5c3319b3

Branch: refs/heads/master
Commit: 5c3319b32f17a049d5b38cbe6d1538223cef5c62
Parents: 95eb8f1
Author: Michael Bolz <mibo@apache.org>
Authored: Tue Oct 15 11:04:38 2013 +0200
Committer: Michael Bolz <mibo@apache.org>
Committed: Tue Oct 15 11:04:38 2013 +0200

----------------------------------------------------------------------
 .../olingo/odata2/api/edm/EdmMapping.java       |  1 +
 .../olingo/odata2/api/edm/provider/Mapping.java |  9 ++++++--
 .../api/ep/EntityProviderWriteProperties.java   |  6 ++++-
 .../odata2/ref/edm/ScenarioEdmProvider.java     |  4 ++--
 .../odata2/ref/processor/ListsProcessor.java    | 24 ++++++++++++++++----
 5 files changed, 34 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/5c3319b3/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/EdmMapping.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/EdmMapping.java
b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/EdmMapping.java
index c810fca..2c1116d 100644
--- a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/EdmMapping.java
+++ b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/EdmMapping.java
@@ -36,6 +36,7 @@ public interface EdmMapping {
    * Get the mapping name for mime type lookup
    * 
    * @return mapping name as String
+   * @deprecated use instead functionality of {@link #getMediaResourceMimeTypeKey()} method
    */
   @Deprecated
   String getMimeType();

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/5c3319b3/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/Mapping.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/Mapping.java
b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/Mapping.java
index 4cdb6de..12a6166 100644
--- a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/Mapping.java
+++ b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/provider/Mapping.java
@@ -71,6 +71,7 @@ public class Mapping implements EdmMapping {
    * Sets the mime type for this {@link Mapping}.
    * @param mimeType
    * @return {@link Mapping} for method chaining
+   * @deprecated use instead functionality of {@link #setMediaResourceMimeTypeKey(String)}
method
    */
   @Deprecated
   public Mapping setMimeType(final String mimeType) {
@@ -91,17 +92,21 @@ public class Mapping implements EdmMapping {
   /**
    * Sets the key for the resource source key which is used for the lookup in the data map
    * @param mediaResourceSourceKey under which the source can be found in the data map
+   * @return {@link Mapping} for method chaining
    */
-  public void setMediaResourceSourceKey(String mediaResourceSourceKey) {
+  public Mapping setMediaResourceSourceKey(String mediaResourceSourceKey) {
     this.mediaResourceSourceKey = mediaResourceSourceKey;
+    return this;
   }
 
   /**
    * Sets the key for the resource mime type key which is used for the lookup in the data
map
    * @param mediaResourceMimeTypeKey under which the mime type can be found in the data map
+   * @return {@link Mapping} for method chaining
    */
-  public void setMediaResourceMimeTypeKey(String mediaResourceMimeTypeKey) {
+  public Mapping setMediaResourceMimeTypeKey(String mediaResourceMimeTypeKey) {
     this.mediaResourceMimeTypeKey = mediaResourceMimeTypeKey;
+    return this;
   }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/5c3319b3/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderWriteProperties.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderWriteProperties.java
b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderWriteProperties.java
index 2a7e978..f212810 100644
--- a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderWriteProperties.java
+++ b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/ep/EntityProviderWriteProperties.java
@@ -64,6 +64,8 @@ public class EntityProviderWriteProperties {
   /**
    * Gets the MIME type of the media resource.
    * @return the MIME type of the media resource
+   * @deprecated use instead the functionality of 'EdmMapping -> mediaResourceMimeTypeKey'
to reference via a key
+   * to the 'mime type' of the media resource provided in the entity data map
    */
   @Deprecated
   public final String getMediaResourceMimeType() {
@@ -84,7 +86,7 @@ public class EntityProviderWriteProperties {
 
   /**
    * Gets the expand select tree data structure resulting from $expand and $select query
options.
-   * @return a paresed tree structure representing the $expand and $select
+   * @return a parsed tree structure representing the $expand and $select
    */
   public final ExpandSelectTreeNode getExpandSelectTree() {
     return expandSelectTree;
@@ -117,6 +119,8 @@ public class EntityProviderWriteProperties {
 
     /**
      * @param mediaResourceMimeType the mediaResourceMimeType to set
+     * @deprecated use instead the functionality of 'EdmMapping -> mediaResourceMimeTypeKey'
to reference via a key
+     * to the 'mime type' of the media resource provided in the entity data map
      */
     @Deprecated
     public final ODataEntityProviderPropertiesBuilder mediaResourceMimeType(final String
mediaResourceMimeType) {

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/5c3319b3/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/edm/ScenarioEdmProvider.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/edm/ScenarioEdmProvider.java
b/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/edm/ScenarioEdmProvider.java
index b3cf662..c57b06c 100644
--- a/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/edm/ScenarioEdmProvider.java
+++ b/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/edm/ScenarioEdmProvider.java
@@ -215,7 +215,7 @@ public class ScenarioEdmProvider extends EdmProvider {
             .setHasStream(true)
             .setKey(getKey("EmployeeId"))
             .setNavigationProperties(navigationProperties)
-            .setMapping(new Mapping().setMimeType("getImageType"));
+            .setMapping(new Mapping().setMimeType("getImageType").setMediaResourceMimeTypeKey("~mrmtk"));
 
       } else if (ENTITY_TYPE_1_BASE.getName().equals(edmFQName.getName())) {
         List<Property> properties = new ArrayList<Property>();
@@ -315,7 +315,7 @@ public class ScenarioEdmProvider extends EdmProvider {
             .setProperties(properties)
             .setHasStream(true)
             .setKey(getKey("Id", "Type"))
-            .setMapping(new Mapping().setMimeType("getType"));
+            .setMapping(new Mapping().setMimeType("getType").setMediaResourceMimeTypeKey("~MediaResourceMimeTypeKey"));
       }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/5c3319b3/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/processor/ListsProcessor.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/processor/ListsProcessor.java
b/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/processor/ListsProcessor.java
index 901fe59..58009d9 100644
--- a/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/processor/ListsProcessor.java
+++ b/odata2-lib/odata-ref/src/main/java/org/apache/olingo/odata2/ref/processor/ListsProcessor.java
@@ -46,6 +46,7 @@ import org.apache.olingo.odata2.api.edm.EdmException;
 import org.apache.olingo.odata2.api.edm.EdmFunctionImport;
 import org.apache.olingo.odata2.api.edm.EdmLiteral;
 import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
+import org.apache.olingo.odata2.api.edm.EdmMapping;
 import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
 import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
 import org.apache.olingo.odata2.api.edm.EdmProperty;
@@ -1518,13 +1519,26 @@ public class ListsProcessor extends ODataSingleProcessor {
         null : getterMethodName.replaceFirst("^is", "set").replaceFirst("^get", "set");
   }
 
+  private static void handleMimeType(Object data, EdmMapping mapping, Map<String, Object>
valueMap) 
+      throws ODataNotFoundException {
+    final String methodName = mapping.getMimeType();
+    if (mapping.getMimeType() != null) {
+      Object value = getValue(data, methodName);
+      valueMap.put(methodName, value);
+      if(mapping.getMediaResourceMimeTypeKey() != null) {
+        valueMap.put(mapping.getMediaResourceMimeTypeKey(), value);
+      }
+    }
+  }
+  
   private static <T> Map<String, Object> getSimpleTypeValueMap(final T data,
final List<EdmProperty> propertyPath)
       throws ODataException {
     final EdmProperty property = propertyPath.get(propertyPath.size() - 1);
     Map<String, Object> valueWithMimeType = new HashMap<String, Object>();
     valueWithMimeType.put(property.getName(), getPropertyValue(data, propertyPath));
-    final String mimeTypeMappingName = property.getMapping().getMimeType();
-    valueWithMimeType.put(mimeTypeMappingName, getValue(data, mimeTypeMappingName));
+
+    handleMimeType(data, property.getMapping(), valueWithMimeType);
+    
     return valueWithMimeType;
   }
 
@@ -1535,9 +1549,9 @@ public class ListsProcessor extends ODataSingleProcessor {
 
     Map<String, Object> valueMap = new HashMap<String, Object>();
 
-    if (type.getMapping() != null && type.getMapping().getMimeType() != null) {
-      final String methodName = type.getMapping().getMimeType();
-      valueMap.put(methodName, getValue(data, methodName));
+    EdmMapping mapping = type.getMapping();
+    if (mapping != null) {
+      handleMimeType(data, mapping, valueMap);
     }
 
     for (final String propertyName : type.getPropertyNames()) {


Mime
View raw message