summaryrefslogtreecommitdiffstats
path: root/musictrigger
diff options
context:
space:
mode:
authorNelson, Thomas (tn1381) <tn1381@att.com>2018-08-20 04:45:13 +0000
committerNelson, Thomas (tn1381) <tn1381@att.com>2018-08-20 04:45:13 +0000
commit0d2f003049e562354fda88729dbab70f46daa25f (patch)
tree886cceb97a030a13d6d5fe586cb80dca377443cf /musictrigger
parent1dbff4199663796788e5658c0eec33b2faade59d (diff)
Update swagger.json and other updates.
Change-Id: I84753300e64ba82072e65ef1bde2cb76771ee046 Issue-ID: MUSIC-97 Signed-off-by: Nelson, Thomas (tn1381) <tn1381@att.com>
Diffstat (limited to 'musictrigger')
-rwxr-xr-x[-rw-r--r--]musictrigger/src/MusicTrigger.java49
1 files changed, 29 insertions, 20 deletions
diff --git a/musictrigger/src/MusicTrigger.java b/musictrigger/src/MusicTrigger.java
index b3a54293..d70e41a0 100644..100755
--- a/musictrigger/src/MusicTrigger.java
+++ b/musictrigger/src/MusicTrigger.java
@@ -23,7 +23,9 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
@@ -74,7 +76,7 @@ public class MusicTrigger implements ITrigger {
operation = "insert";
else
operation = "update";
-
+ Map<String, String> changeMap = new HashMap<>();
obj.put("operation", operation);
obj.put("keyspace", ksName);
@@ -83,31 +85,38 @@ public class MusicTrigger implements ITrigger {
obj.put("primary_key", partition.metadata().getKeyValidator().getString(partition.partitionKey().getKey()));
//obj.put("message_id", partition.metadata().getKeyValidator().getString(partition.partitionKey().getKey()));
- try {
- UnfilteredRowIterator it = partition.unfilteredIterator();
- while (it.hasNext()) {
- Unfiltered un = it.next();
- Clustering clt = (Clustering) un.clustering();
- Iterator<Cell> cells = partition.getRow(clt).cells().iterator();
- Iterator<ColumnDefinition> columns = partition.getRow(clt).columns().iterator();
-
- while(columns.hasNext()){
- ColumnDefinition columnDef = columns.next();
- Cell cell = cells.next();
- String data = new String(cell.value().array()); // If cell type is text
- logger.info("Inside triggers loop: "+columnDef.toString()+" : "+data);
- obj.put(columnDef.toString(), data);
- }
- }
- } catch (Exception e) {
-
+ if("update".equals(operation)) {
+ try {
+ UnfilteredRowIterator it = partition.unfilteredIterator();
+ while (it.hasNext()) {
+ Unfiltered un = it.next();
+ Clustering clt = (Clustering) un.clustering();
+ Iterator<Cell> cells = partition.getRow(clt).cells().iterator();
+ Iterator<ColumnDefinition> columns = partition.getRow(clt).columns().iterator();
+
+ while(columns.hasNext()){
+ ColumnDefinition columnDef = columns.next();
+ Cell cell = cells.next();
+ String data = new String(cell.value().array()); // If cell type is text
+ logger.info("Inside triggers loop: "+columnDef.name+" : "+data);
+ changeMap.put(ksName+"."+tableName+"."+columnDef.name,data);
+ changeMap.put("field_value",ksName+"."+tableName+":"+columnDef.name+":"+data);
+ }
+ }
+ } catch (Exception e) {
+
+ }
+ } else {
+ changeMap.put("field_value", ksName+"."+tableName);
}
+
+ obj.put("changeValue", changeMap);
logger.info("Sending response: "+obj.toString());
try {
notifyMusic(obj.toString());
} catch(Exception e) {
e.printStackTrace();
- logger.error("Notification failed..."+e.getMessage()s);
+ logger.error("Notification failed..."+e.getMessage());
}
return Collections.emptyList();
}