use of com.fasterxml.jackson.core.type.TypeReference in project streamline by hortonworks.
the class TopologyWindow method toMap.
@Override
public Map<String, Object> toMap() {
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> map = super.toMap();
try {
map.put(STREAMS, streams != null ? mapper.writeValueAsString(streams) : "");
map.put(OUTPUT_STREAMS, outputStreams != null ? mapper.writeValueAsString(outputStreams) : "");
map.put(WINDOW, window != null ? mapper.writeValueAsString(window) : "");
map.put(ACTIONS, actions != null ? mapper.writerFor(new TypeReference<List<Action>>() {
}).writeValueAsString(actions) : "");
map.put(PROJECTIONS, projections != null ? mapper.writeValueAsString(projections) : "");
map.put(GROUPBYKEYS, groupbykeys != null ? mapper.writeValueAsString(groupbykeys) : "");
} catch (Exception e) {
throw new RuntimeException(e);
}
return map;
}
use of com.fasterxml.jackson.core.type.TypeReference in project streamline by hortonworks.
the class Notifier method setPropertiesData.
public void setPropertiesData(String propertiesData) throws Exception {
ObjectMapper mapper = new ObjectMapper();
this.properties = mapper.readValue(propertiesData, new TypeReference<Map<String, String>>() {
});
}
use of com.fasterxml.jackson.core.type.TypeReference in project streamline by hortonworks.
the class Notifier method setFieldValuesData.
public void setFieldValuesData(String fieldValuesData) throws Exception {
if (fieldValuesData == null || fieldValuesData.isEmpty()) {
return;
}
ObjectMapper mapper = new ObjectMapper();
fieldValues = mapper.readValue(fieldValuesData, new TypeReference<Map<String, String>>() {
});
}
use of com.fasterxml.jackson.core.type.TypeReference in project streamline by hortonworks.
the class TopologyRule method fromMap.
@Override
public Storable fromMap(Map<String, Object> map) {
super.fromMap(map);
setId((Long) map.get(ID));
setVersionId((Long) map.get(VERSIONID));
setTopologyId((Long) map.get(TOPOLOGY_ID));
setName((String) map.get(NAME));
setDescription((String) map.get(DESCRIPTION));
setCondition((String) map.get(CONDITION));
setSql((String) map.get(SQL));
setParsedRuleStr((String) map.get(PARSED_RULE_STR));
try {
ObjectMapper mapper = new ObjectMapper();
String streamsStr = (String) map.get(STREAMS);
if (!StringUtils.isEmpty(streamsStr)) {
List<String> streams = mapper.readValue(streamsStr, new TypeReference<List<String>>() {
});
setStreams(streams);
}
String outputStreamsStr = (String) map.get(OUTPUT_STREAMS);
if (!StringUtils.isEmpty(outputStreamsStr)) {
List<String> outputStreams = mapper.readValue(outputStreamsStr, new TypeReference<List<String>>() {
});
setOutputStreams(outputStreams);
}
String windowStr = (String) map.get(WINDOW);
if (!StringUtils.isEmpty(windowStr)) {
Window window = mapper.readValue(windowStr, Window.class);
setWindow(window);
}
String projectionsStr = (String) map.get(PROJECTIONS);
if (!StringUtils.isEmpty(projectionsStr)) {
setProjections(mapper.readValue(projectionsStr, new TypeReference<List<Projection>>() {
}));
}
String actionsStr = (String) map.get(ACTIONS);
if (!StringUtils.isEmpty(actionsStr)) {
setActions(mapper.readValue(actionsStr, new TypeReference<List<Action>>() {
}));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return this;
}
use of com.fasterxml.jackson.core.type.TypeReference in project streamline by hortonworks.
the class TopologyStream method setFieldsData.
// for internal storage, not part of JSON
@JsonIgnore
public void setFieldsData(String fieldsData) throws Exception {
if (fieldsData == null || fieldsData.isEmpty()) {
return;
}
ObjectMapper mapper = new ObjectMapper();
fields = mapper.readValue(fieldsData, new TypeReference<List<Field>>() {
});
}
Aggregations