public TopologyBranchRule getBranchRule(Long topologyId, Long ruleId, Long versionId) { TopologyBranchRule topologyBranchRule = new TopologyBranchRule(); topologyBranchRule.setId(ruleId); topologyBranchRule.setVersionId(versionId); topologyBranchRule = dao.get(new StorableKey(TOPOLOGY_BRANCHRULEINFO_NAMESPACE, topologyBranchRule.getPrimaryKey())); if (topologyBranchRule == null || !topologyBranchRule.getTopologyId().equals(topologyId)) { return null; } topologyBranchRule.setVersionTimestamp(getVersionTimestamp(versionId)); return topologyBranchRule; }
public TopologyBranchRule removeBranchRule(Long topologyId, Long id, Long versionId) throws Exception { TopologyBranchRule topologyBranchRule = getBranchRule(topologyId, id, versionId); if (topologyBranchRule != null) { topologyBranchRule = dao.remove(new StorableKey(TOPOLOGY_BRANCHRULEINFO_NAMESPACE, topologyBranchRule.getPrimaryKey())); topologyBranchRule.setVersionTimestamp(updateVersionTimestamp(versionId).getTimestamp()); } return topologyBranchRule; }
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()); } }