@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 addOrUpdateBranchRule(Long topologyId, Long ruleId, TopologyBranchRule topologyBranchRule) throws Exception { Long currentTopologyVersionId = getCurrentVersionId(topologyId); topologyBranchRule.setId(ruleId); topologyBranchRule.setVersionId(currentTopologyVersionId); topologyBranchRule.setTopologyId(topologyId); String parsedRuleStr = parseAndSerialize(topologyBranchRule); LOG.debug("ParsedRuleStr {}", parsedRuleStr); topologyBranchRule.setParsedRuleStr(parsedRuleStr); topologyBranchRule.setReconfigure(false); dao.addOrUpdate(topologyBranchRule); topologyBranchRule.setVersionTimestamp(updateVersionTimestamp(currentTopologyVersionId).getTimestamp()); return topologyBranchRule; }
public TopologyBranchRule addBranchRule(Long topologyId, Long versionId, TopologyBranchRule topologyBranchRule) throws Exception { if (topologyBranchRule.getId() == null) { topologyBranchRule.setId(dao.nextId(TOPOLOGY_BRANCHRULEINFO_NAMESPACE)); } topologyBranchRule.setTopologyId(topologyId); topologyBranchRule.setVersionId(versionId); String parsedRuleStr = parseAndSerialize(topologyBranchRule); LOG.debug("ParsedRuleStr {}", parsedRuleStr); topologyBranchRule.setParsedRuleStr(parsedRuleStr); dao.add(topologyBranchRule); topologyBranchRule.setVersionTimestamp(updateVersionTimestamp(versionId).getTimestamp()); return topologyBranchRule; }
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()); } }