package processors;

import com.fasterxml.jackson.databind.JsonNode;
import datamodel.EventHubMessage;
import datamodel.Job;
import datamodel.Measurement;

import java.util.Date;

public class EventHubAdapter {

    public static EventHubMessage createEventHubMessage(JsonNode data, Job job, Measurement measurement) {
        String command = measurement.getCommand();
        String usedTool = command.substring(0, command.indexOf(' '));

        EventHubMessage eventHubMessage = new EventHubMessage();
        eventHubMessage.setComponent(null);
        eventHubMessage.setObject(usedTool);
        eventHubMessage.setLabels(new String[]{"userId-" + measurement.getClientId()});
        eventHubMessage.setType(null);
        eventHubMessage.setData(data);
        eventHubMessage.setTimestamp(Long.toString((new Date().getTime()) / 1000));
        return eventHubMessage;
    }
}

@@ -62,16 +62,101 @@
 onNode;%0A
+import com.fasterxml.jackson.databind.ObjectMapper;%0Aimport converters.JsonConverter;%0A
 import d
@@ -181,16 +181,16 @@
 essage;%0A
-
 import d
@@ -234,16 +234,44 @@
 ement;%0A%0A
+import java.io.IOException;%0A
 import j
@@ -336,31 +336,22 @@
  static 
-EventHubMessage
+String
  createE
@@ -369,21 +369,27 @@
 age(
-JsonNode data
+String filteredJson
 , Jo
@@ -419,16 +419,35 @@
 urement)
+ throws IOException
  %7B%0A     
@@ -563,16 +563,122 @@
 ' '));%0A%0A
+        ObjectMapper mapper = new ObjectMapper();%0A        JsonNode data = mapper.readTree(filteredJson);%0A%0A
         
@@ -1088,16 +1088,49 @@
  return 
+JsonConverter.objectToJsonString(
 eventHub
@@ -1136,16 +1136,17 @@
 bMessage
+)
 ;%0A    %7D%0A

Change interface.