streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblack...@apache.org
Subject [37/41] git commit: STREAMS-157 | Modified the way that IDs are set so that we are more tolerant to null values, which can be necessary
Date Thu, 04 Sep 2014 17:12:25 GMT
STREAMS-157 | Modified the way that IDs are set so that we are more tolerant to null values,
which can be necessary


Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/873c232e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/873c232e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/873c232e

Branch: refs/heads/pp
Commit: 873c232eca7ee81761092988d072b0ec6505501f
Parents: 493f43a
Author: Robert Douglas <rdouglas@w2odigital.com>
Authored: Mon Aug 25 16:26:19 2014 -0500
Committer: Robert Douglas <rdouglas@w2odigital.com>
Committed: Mon Aug 25 16:26:19 2014 -0500

----------------------------------------------------------------------
 .../elasticsearch/ElasticsearchPersistWriter.java    | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/873c232e/streams-contrib/streams-persist-elasticsearch/src/main/java/org/apache/streams/elasticsearch/ElasticsearchPersistWriter.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-persist-elasticsearch/src/main/java/org/apache/streams/elasticsearch/ElasticsearchPersistWriter.java
b/streams-contrib/streams-persist-elasticsearch/src/main/java/org/apache/streams/elasticsearch/ElasticsearchPersistWriter.java
index 4edc60f..664dd24 100644
--- a/streams-contrib/streams-persist-elasticsearch/src/main/java/org/apache/streams/elasticsearch/ElasticsearchPersistWriter.java
+++ b/streams-contrib/streams-persist-elasticsearch/src/main/java/org/apache/streams/elasticsearch/ElasticsearchPersistWriter.java
@@ -146,9 +146,7 @@ public class ElasticsearchPersistWriter implements StreamsPersistWriter,
DatumSt
 
         String index = (String) streamsDatum.getMetadata().get("index");
         String type = (String) streamsDatum.getMetadata().get("type");
-        String id = Optional.fromNullable(
-                (String) streamsDatum.getMetadata().get("id"))
-                .or(streamsDatum.getId());
+        String id = setId(streamsDatum);
 
         if(index == null || (config.getForceUseConfig() != null && config.getForceUseConfig()))
{
             index = config.getIndex();
@@ -166,6 +164,17 @@ public class ElasticsearchPersistWriter implements StreamsPersistWriter,
DatumSt
         }
     }
 
+    private String setId(StreamsDatum streamsDatum) {
+        String id = Optional.fromNullable(
+                (String) streamsDatum.getMetadata().get("id"))
+                .orNull();
+
+        if(id == null)
+            id = Optional.fromNullable(streamsDatum.getId())
+                    .orNull();
+
+        return id;
+    }
 
     private String convertAndAppendMetadata(StreamsDatum streamsDatum) throws IOException
{
         Object object = streamsDatum.getDocument();


Mime
View raw message