@Override public Rule getRule(Long topologyId, Long ruleId, Long versionId) throws Exception { TopologyBranchRule topologyBranchRule = catalogService.getBranchRule(topologyId, ruleId, versionId); if (topologyBranchRule == null) { throw new IllegalArgumentException("Cannot find branch rule with id " + ruleId); } else if (topologyBranchRule.getReconfigure()) { throw new IllegalStateException("Rule " + topologyBranchRule.getName() + " must be reconfigured"); } return topologyBranchRule.getRule(); } }));
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(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()); } }