private String parseAndSerialize(TopologyBranchRule ruleInfo) throws JsonProcessingException { Rule rule = new Rule(); rule.setId(ruleInfo.getId()); rule.setName(ruleInfo.getName()); rule.setDescription(ruleInfo.getDescription()); rule.setActions(ruleInfo.getActions()); String sql = getSqlString(Collections.singletonList(ruleInfo.getStream()), null, ruleInfo.getCondition(), null); updateRuleWithSql(rule, sql, ruleInfo.getTopologyId(), ruleInfo.getVersionId()); ObjectMapper mapper = new ObjectMapper(); return mapper.writeValueAsString(rule); }
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()); } }
removeBranchRule(topologyId, topologyBranchRule.getId(), versionId);