@Override public Storable fromMap(Map<String, Object> map) { super.fromMap(map); setId((Long) map.get(ID)); setVersionId((Long) map.get(VERSION_ID)); setTopologyId((Long) map.get(TOPOLOGY_ID)); setName((String) map.get(NAME)); setDescription((String) map.get(DESCRIPTION)); setCondition((String) map.get(CONDITION)); setParsedRuleStr((String) map.get(PARSED_RULE_STR)); setStream((String) map.get(STREAM)); try { ObjectMapper mapper = new ObjectMapper(); String outputStreamsStr = (String) map.get(OUTPUT_STREAMS); if (!StringUtils.isEmpty(outputStreamsStr)) { List<String> outputStreams = mapper.readValue(outputStreamsStr, new TypeReference<List<String>>() { }); setOutputStreams(outputStreams); } String actionsStr = (String) map.get(ACTIONS); if (!StringUtils.isEmpty(actionsStr)) { List<Action> actions = mapper.readValue(actionsStr, new TypeReference<List<Action>>() { }); setActions(actions); } } catch (IOException e) { throw new RuntimeException(e); } return this; }
public TopologyBranchRule(TopologyBranchRule other) { if (other != null) { setId(other.getId()); setTopologyId(other.getTopologyId()); setVersionId(other.getVersionId()); setName(other.getName()); setDescription(other.getDescription()); setStream(other.getStream()); setCondition(other.getCondition()); setParsedRuleStr(other.getParsedRuleStr()); if (other.getActions() != null) { setActions(other.getActions().stream().map(Action::copy).collect(Collectors.toList())); } if (other.getOutputStreams() != null) { setOutputStreams(new ArrayList<>(other.getOutputStreams())); } setVersionTimestamp(other.getVersionTimestamp()); } }