Search in sources :

Example 96 with TypeReference

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;
}
Also used : Action(com.hortonworks.streamline.streams.layout.component.rule.action.Action) TypeReference(com.fasterxml.jackson.core.type.TypeReference) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException)

Example 97 with TypeReference

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>>() {
    });
}
Also used : TypeReference(com.fasterxml.jackson.core.type.TypeReference) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 98 with TypeReference

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>>() {
    });
}
Also used : TypeReference(com.fasterxml.jackson.core.type.TypeReference) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 99 with TypeReference

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;
}
Also used : Window(com.hortonworks.streamline.streams.layout.component.rule.expression.Window) Action(com.hortonworks.streamline.streams.layout.component.rule.action.Action) ArrayList(java.util.ArrayList) List(java.util.List) TypeReference(com.fasterxml.jackson.core.type.TypeReference) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 100 with TypeReference

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>>() {
    });
}
Also used : Field(com.hortonworks.registries.common.Schema.Field) TypeReference(com.fasterxml.jackson.core.type.TypeReference) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Aggregations

TypeReference (com.fasterxml.jackson.core.type.TypeReference)316 IOException (java.io.IOException)130 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)113 Test (org.junit.Test)95 ArrayList (java.util.ArrayList)74 Map (java.util.Map)74 List (java.util.List)60 HashMap (java.util.HashMap)58 File (java.io.File)34 TextPageLink (org.thingsboard.server.common.data.page.TextPageLink)27 Collectors (java.util.stream.Collectors)25 InputStream (java.io.InputStream)23 JsonNode (com.fasterxml.jackson.databind.JsonNode)19 ImmutableMap (com.google.common.collect.ImmutableMap)19 lombok.val (lombok.val)18 Matchers.containsString (org.hamcrest.Matchers.containsString)17 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)14 Collections (java.util.Collections)13 ISE (org.apache.druid.java.util.common.ISE)12 URL (java.net.URL)10