You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/04/04 19:05:46 UTC

[40/50] [abbrv] olingo-odata4 git commit: [OLINGO-603] Delete unnecessary deserializer constants

[OLINGO-603] Delete unnecessary deserializer constants


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/5855c6b6
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/5855c6b6
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/5855c6b6

Branch: refs/heads/OLINGO-549-ODataV4-JPA
Commit: 5855c6b6241842cfc984f3a739f1ab9f55488fc4
Parents: d067037
Author: Christian Amend <ch...@apache.org>
Authored: Wed Apr 1 15:19:41 2015 +0200
Committer: Christian Amend <ch...@apache.org>
Committed: Wed Apr 1 15:19:41 2015 +0200

----------------------------------------------------------------------
 .../olingo/commons/api/edm/EdmOperation.java    |  4 +-
 .../serialization/JsonDeltaDeserializer.java    | 12 ++--
 .../core/serialization/JsonDeserializer.java    | 50 +++-----------
 .../serialization/JsonEntityDeserializer.java   | 70 ++++++++++----------
 .../JsonEntitySetDeserializer.java              | 18 ++---
 .../JsonODataErrorDeserializer.java             |  4 +-
 .../serialization/JsonPropertyDeserializer.java |  7 +-
 7 files changed, 70 insertions(+), 95 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5855c6b6/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java
index d6101b3..c90316d 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/EdmOperation.java
@@ -32,6 +32,8 @@ public interface EdmOperation extends EdmType, EdmAnnotatable {
   EdmParameter getParameter(String name);
 
   /**
+   * A list of all parameter names. If this is a bound action or function the first parameter name in the list is the
+   * binding parameter
    * @return a list of all parameter names
    */
   List<String> getParameterNames();
@@ -63,7 +65,7 @@ public interface EdmOperation extends EdmType, EdmAnnotatable {
    * @return true if binding parameter is of type collection.
    */
   Boolean isBindingParameterTypeCollection();
-  
+
   /**
    * @return the entity set path as a String or null if not present
    */

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5855c6b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
index 5cb2076..de79cf7 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeltaDeserializer.java
@@ -56,14 +56,14 @@ public class JsonDeltaDeserializer extends JsonDeserializer {
       delta.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA));
     }
 
-    if (tree.hasNonNull(jsonCount)) {
-      delta.setCount(tree.get(jsonCount).asInt());
+    if (tree.hasNonNull(Constants.JSON_COUNT)) {
+      delta.setCount(tree.get(Constants.JSON_COUNT).asInt());
     }
-    if (tree.hasNonNull(jsonNextLink)) {
-      delta.setNext(URI.create(tree.get(jsonNextLink).textValue()));
+    if (tree.hasNonNull(Constants.JSON_NEXT_LINK)) {
+      delta.setNext(URI.create(tree.get(Constants.JSON_NEXT_LINK).textValue()));
     }
-    if (tree.hasNonNull(jsonDeltaLink)) {
-      delta.setDeltaLink(URI.create(tree.get(jsonDeltaLink).textValue()));
+    if (tree.hasNonNull(Constants.JSON_DELTA_LINK)) {
+      delta.setDeltaLink(URI.create(tree.get(Constants.JSON_DELTA_LINK).textValue()));
     }
 
     if (tree.hasNonNull(Constants.VALUE)) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5855c6b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
index fc7e4f8..9641623 100755
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonDeserializer.java
@@ -72,36 +72,6 @@ public class JsonDeserializer implements ODataDeserializer {
 
   protected final boolean serverMode;
 
-  protected String jsonType = Constants.JSON_TYPE;
-
-  protected String jsonId = Constants.JSON_ID;
-
-  protected String jsonETag = Constants.JSON_ETAG;
-
-  protected String jsonReadLink = Constants.JSON_READ_LINK;
-
-  protected String jsonEditLink = Constants.JSON_EDIT_LINK;
-
-  protected String jsonMediaEditLink = Constants.JSON_MEDIA_EDIT_LINK;
-
-  protected String jsonMediaReadLink = Constants.JSON_MEDIA_READ_LINK;
-
-  protected String jsonMediaContentType = Constants.JSON_MEDIA_CONTENT_TYPE;
-
-  protected String jsonMediaETag = Constants.JSON_MEDIA_ETAG;
-
-  protected String jsonAssociationLink = Constants.JSON_ASSOCIATION_LINK;
-
-  protected String jsonNavigationLink = Constants.JSON_NAVIGATION_LINK;
-
-  protected String jsonCount = Constants.JSON_COUNT;
-
-  protected String jsonNextLink = Constants.JSON_NEXT_LINK;
-
-  protected String jsonDeltaLink = Constants.JSON_DELTA_LINK;
-
-  protected String jsonError = Constants.JSON_ERROR;
-
   private JsonGeoValueDeserializer geoDeserializer;
 
   private JsonParser parser;
@@ -163,7 +133,7 @@ public class JsonDeserializer implements ODataDeserializer {
   private void clientLinks(final Map.Entry<String, JsonNode> field, final Linked linked, final Set<String> toRemove,
       final JsonNode tree, final ObjectCodec codec) throws IOException {
 
-    if (field.getKey().endsWith(jsonNavigationLink)) {
+    if (field.getKey().endsWith(Constants.JSON_NAVIGATION_LINK)) {
       final LinkImpl link = new LinkImpl();
       link.setTitle(getTitle(field));
       link.setRel(Constants.NS_NAVIGATION_LINK_REL + getTitle(field));
@@ -176,8 +146,8 @@ public class JsonDeserializer implements ODataDeserializer {
       linked.getNavigationLinks().add(link);
 
       toRemove.add(field.getKey());
-      toRemove.add(setInline(field.getKey(), jsonNavigationLink, tree, codec, link));
-    } else if (field.getKey().endsWith(jsonAssociationLink)) {
+      toRemove.add(setInline(field.getKey(), Constants.JSON_NAVIGATION_LINK, tree, codec, link));
+    } else if (field.getKey().endsWith(Constants.JSON_ASSOCIATION_LINK)) {
       final LinkImpl link = new LinkImpl();
       link.setTitle(getTitle(field));
       link.setRel(Constants.NS_ASSOCIATION_LINK_REL + getTitle(field));
@@ -193,7 +163,7 @@ public class JsonDeserializer implements ODataDeserializer {
       final JsonNode tree, final ObjectCodec codec) throws IOException {
 
     if (field.getKey().endsWith(Constants.JSON_BIND_LINK_SUFFIX)
-        || field.getKey().endsWith(jsonNavigationLink)) {
+        || field.getKey().endsWith(Constants.JSON_NAVIGATION_LINK)) {
 
       if (field.getValue().isValueNode()) {
         final String suffix = field.getKey().replaceAll("^.*@", "@");
@@ -280,7 +250,7 @@ public class JsonDeserializer implements ODataDeserializer {
         if (annotatable != null) {
           annotatable.getAnnotations().add(entityAnnot);
         }
-      } else if (type == null && field.getKey().endsWith(getJSONAnnotation(jsonType))) {
+      } else if (type == null && field.getKey().endsWith(getJSONAnnotation(Constants.JSON_TYPE))) {
         type = field.getValue().asText();
       } else if (annotation == null && customAnnotation.matches() && !"odata".equals(customAnnotation.group(2))) {
         annotation = new AnnotationImpl();
@@ -354,8 +324,8 @@ public class JsonDeserializer implements ODataDeserializer {
           values.add(child.asText());
         }
       } else if (child.isContainerNode()) {
-        if (child.has(jsonType)) {
-          ((ObjectNode) child).remove(jsonType);
+        if (child.has(Constants.JSON_TYPE)) {
+          ((ObjectNode) child).remove(Constants.JSON_TYPE);
         }
         final Object value = fromComplex((ObjectNode) child, codec);
         valueType = ValueType.COLLECTION_COMPLEX;
@@ -387,9 +357,9 @@ public class JsonDeserializer implements ODataDeserializer {
       break;
 
     case COMPLEX:
-      if (node.has(jsonType)) {
-        valuable.setType(node.get(jsonType).asText());
-        ((ObjectNode) node).remove(jsonType);
+      if (node.has(Constants.JSON_TYPE)) {
+        valuable.setType(node.get(Constants.JSON_TYPE).asText());
+        ((ObjectNode) node).remove(Constants.JSON_TYPE);
       }
       final Object value = fromComplex((ObjectNode) node, codec);
       valuable.setValue(ValueType.COMPLEX, value);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5855c6b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
index b63950b..228ac06 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntityDeserializer.java
@@ -82,7 +82,7 @@ public class JsonEntityDeserializer extends JsonDeserializer {
     if (contextURL != null) {
       entity.setBaseURI(StringUtils.substringBefore(contextURL.toASCIIString(), Constants.METADATA));
     }
-    
+
     final String metadataETag;
     if (tree.hasNonNull(Constants.JSON_METADATA_ETAG)) {
       metadataETag = tree.get(Constants.JSON_METADATA_ETAG).textValue();
@@ -91,56 +91,57 @@ public class JsonEntityDeserializer extends JsonDeserializer {
       metadataETag = null;
     }
 
-    if (tree.hasNonNull(jsonETag)) {
-      entity.setETag(tree.get(jsonETag).textValue());
-      tree.remove(jsonETag);
+    if (tree.hasNonNull(Constants.JSON_ETAG)) {
+      entity.setETag(tree.get(Constants.JSON_ETAG).textValue());
+      tree.remove(Constants.JSON_ETAG);
     }
 
-    if (tree.hasNonNull(jsonType)) {
-      entity.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(jsonType).textValue()).build().internal());
-      tree.remove(jsonType);
+    if (tree.hasNonNull(Constants.JSON_TYPE)) {
+      entity.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(Constants.JSON_TYPE).textValue()).build()
+          .internal());
+      tree.remove(Constants.JSON_TYPE);
     }
 
-    if (tree.hasNonNull(jsonId)) {
-      entity.setId(URI.create(tree.get(jsonId).textValue()));
-      tree.remove(jsonId);
+    if (tree.hasNonNull(Constants.JSON_ID)) {
+      entity.setId(URI.create(tree.get(Constants.JSON_ID).textValue()));
+      tree.remove(Constants.JSON_ID);
     }
 
-    if (tree.hasNonNull(jsonReadLink)) {
+    if (tree.hasNonNull(Constants.JSON_READ_LINK)) {
       final LinkImpl link = new LinkImpl();
       link.setRel(Constants.SELF_LINK_REL);
-      link.setHref(tree.get(jsonReadLink).textValue());
+      link.setHref(tree.get(Constants.JSON_READ_LINK).textValue());
       entity.setSelfLink(link);
 
-      tree.remove(jsonReadLink);
+      tree.remove(Constants.JSON_READ_LINK);
     }
 
-    if (tree.hasNonNull(jsonEditLink)) {
+    if (tree.hasNonNull(Constants.JSON_EDIT_LINK)) {
       final LinkImpl link = new LinkImpl();
       if (serverMode) {
         link.setRel(Constants.EDIT_LINK_REL);
       }
-      link.setHref(tree.get(jsonEditLink).textValue());
+      link.setHref(tree.get(Constants.JSON_EDIT_LINK).textValue());
       entity.setEditLink(link);
 
-      tree.remove(jsonEditLink);
+      tree.remove(Constants.JSON_EDIT_LINK);
     }
 
-    if (tree.hasNonNull(jsonMediaReadLink)) {
-      entity.setMediaContentSource(URI.create(tree.get(jsonMediaReadLink).textValue()));
-      tree.remove(jsonMediaReadLink);
+    if (tree.hasNonNull(Constants.JSON_MEDIA_READ_LINK)) {
+      entity.setMediaContentSource(URI.create(tree.get(Constants.JSON_MEDIA_READ_LINK).textValue()));
+      tree.remove(Constants.JSON_MEDIA_READ_LINK);
     }
-    if (tree.hasNonNull(jsonMediaEditLink)) {
-      entity.setMediaContentSource(URI.create(tree.get(jsonMediaEditLink).textValue()));
-      tree.remove(jsonMediaEditLink);
+    if (tree.hasNonNull(Constants.JSON_MEDIA_EDIT_LINK)) {
+      entity.setMediaContentSource(URI.create(tree.get(Constants.JSON_MEDIA_EDIT_LINK).textValue()));
+      tree.remove(Constants.JSON_MEDIA_EDIT_LINK);
     }
-    if (tree.hasNonNull(jsonMediaContentType)) {
-      entity.setMediaContentType(tree.get(jsonMediaContentType).textValue());
-      tree.remove(jsonMediaContentType);
+    if (tree.hasNonNull(Constants.JSON_MEDIA_CONTENT_TYPE)) {
+      entity.setMediaContentType(tree.get(Constants.JSON_MEDIA_CONTENT_TYPE).textValue());
+      tree.remove(Constants.JSON_MEDIA_CONTENT_TYPE);
     }
-    if (tree.hasNonNull(jsonMediaETag)) {
-      entity.setMediaETag(tree.get(jsonMediaETag).textValue());
-      tree.remove(jsonMediaETag);
+    if (tree.hasNonNull(Constants.JSON_MEDIA_ETAG)) {
+      entity.setMediaETag(tree.get(Constants.JSON_MEDIA_ETAG).textValue());
+      tree.remove(Constants.JSON_MEDIA_ETAG);
     }
 
     final Set<String> toRemove = new HashSet<String>();
@@ -151,7 +152,7 @@ public class JsonEntityDeserializer extends JsonDeserializer {
       final Matcher customAnnotation = CUSTOM_ANNOTATION.matcher(field.getKey());
 
       links(field, entity, toRemove, tree, parser.getCodec());
-      if (field.getKey().endsWith(getJSONAnnotation(jsonMediaEditLink))) {
+      if (field.getKey().endsWith(getJSONAnnotation(Constants.JSON_MEDIA_EDIT_LINK))) {
         final LinkImpl link = new LinkImpl();
         link.setTitle(getTitle(field));
         link.setRel(Constants.NS_MEDIA_EDIT_LINK_REL + getTitle(field));
@@ -159,14 +160,15 @@ public class JsonEntityDeserializer extends JsonDeserializer {
         link.setType(ODataLinkType.MEDIA_EDIT.toString());
         entity.getMediaEditLinks().add(link);
 
-        if (tree.has(link.getTitle() + getJSONAnnotation(jsonMediaETag))) {
-          link.setMediaETag(tree.get(link.getTitle() + getJSONAnnotation(jsonMediaETag)).asText());
-          toRemove.add(link.getTitle() + getJSONAnnotation(jsonMediaETag));
+        if (tree.has(link.getTitle() + getJSONAnnotation(Constants.JSON_MEDIA_ETAG))) {
+          link.setMediaETag(tree.get(link.getTitle() + getJSONAnnotation(Constants.JSON_MEDIA_ETAG)).asText());
+          toRemove.add(link.getTitle() + getJSONAnnotation(Constants.JSON_MEDIA_ETAG));
         }
 
         toRemove.add(field.getKey());
-        toRemove.add(setInline(field.getKey(), getJSONAnnotation(jsonMediaEditLink), tree, parser.getCodec(), link));
-      } else if (field.getKey().endsWith(getJSONAnnotation(jsonMediaContentType))) {
+        toRemove.add(setInline(field.getKey(), getJSONAnnotation(Constants.JSON_MEDIA_EDIT_LINK), tree, parser
+            .getCodec(), link));
+      } else if (field.getKey().endsWith(getJSONAnnotation(Constants.JSON_MEDIA_CONTENT_TYPE))) {
         final String linkTitle = getTitle(field);
         for (Link link : entity.getMediaEditLinks()) {
           if (linkTitle.equals(link.getTitle())) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5855c6b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
index 00b807e..1e844b5 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonEntitySetDeserializer.java
@@ -79,17 +79,17 @@ public class JsonEntitySetDeserializer extends JsonDeserializer {
       metadataETag = null;
     }
 
-    if (tree.hasNonNull(jsonCount)) {
-      entitySet.setCount(tree.get(jsonCount).asInt());
-      tree.remove(jsonCount);
+    if (tree.hasNonNull(Constants.JSON_COUNT)) {
+      entitySet.setCount(tree.get(Constants.JSON_COUNT).asInt());
+      tree.remove(Constants.JSON_COUNT);
     }
-    if (tree.hasNonNull(jsonNextLink)) {
-      entitySet.setNext(URI.create(tree.get(jsonNextLink).textValue()));
-      tree.remove(jsonNextLink);
+    if (tree.hasNonNull(Constants.JSON_NEXT_LINK)) {
+      entitySet.setNext(URI.create(tree.get(Constants.JSON_NEXT_LINK).textValue()));
+      tree.remove(Constants.JSON_NEXT_LINK);
     }
-    if (tree.hasNonNull(jsonDeltaLink)) {
-      entitySet.setDeltaLink(URI.create(tree.get(jsonDeltaLink).textValue()));
-      tree.remove(jsonDeltaLink);
+    if (tree.hasNonNull(Constants.JSON_DELTA_LINK)) {
+      entitySet.setDeltaLink(URI.create(tree.get(Constants.JSON_DELTA_LINK).textValue()));
+      tree.remove(Constants.JSON_DELTA_LINK);
     }
 
     if (tree.hasNonNull(Constants.VALUE)) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5855c6b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java
index 8e49a28..89252dc 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonODataErrorDeserializer.java
@@ -43,8 +43,8 @@ public class JsonODataErrorDeserializer extends JsonDeserializer {
     final ODataError error = new ODataError();
 
     final ObjectNode tree = parser.getCodec().readTree(parser);
-    if (tree.has(jsonError)) {
-      final JsonNode errorNode = tree.get(jsonError);
+    if (tree.has(Constants.JSON_ERROR)) {
+      final JsonNode errorNode = tree.get(Constants.JSON_ERROR);
 
       if (errorNode.has(Constants.ERROR_CODE)) {
         error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/5855c6b6/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
index 9a9498e..e0732d5 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/JsonPropertyDeserializer.java
@@ -75,9 +75,10 @@ public class JsonPropertyDeserializer extends JsonDeserializer {
       contextURL = null;
     }
 
-    if (tree.has(jsonType)) {
-      property.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(jsonType).textValue()).build().internal());
-      tree.remove(jsonType);
+    if (tree.has(Constants.JSON_TYPE)) {
+      property.setType(new EdmTypeInfo.Builder().setTypeExpression(tree.get(Constants.JSON_TYPE).textValue()).build()
+          .internal());
+      tree.remove(Constants.JSON_TYPE);
     }
 
     if (tree.has(Constants.JSON_NULL) && tree.get(Constants.JSON_NULL).asBoolean()) {