summaryrefslogtreecommitdiffstats
path: root/rulemgt/src/main/java
diff options
context:
space:
mode:
authorGuangrong Fu <fu.guangrong@zte.com.cn>2017-10-14 16:41:35 +0800
committerGuangrong Fu <fu.guangrong@zte.com.cn>2017-10-14 16:41:35 +0800
commit8b2d0be73ab8dcbd573769ed89ad27ecd7c25f88 (patch)
treef1a9730298b9a5b22c0d8743957e00c0119c622a /rulemgt/src/main/java
parent049c1722681a7c0d564d625f2740cbc47c15a4be (diff)
Add DMaaP Configuration APIs for Testing
Change-Id: Iefc0f22da204f30fca8ef81effcd3497a347ebc0 Issue-ID: HOLMES-59 Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
Diffstat (limited to 'rulemgt/src/main/java')
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleUpdateRequest.java2
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleDao.java4
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java1
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java28
4 files changed, 13 insertions, 22 deletions
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleUpdateRequest.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleUpdateRequest.java
index e2811e3..99af585 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleUpdateRequest.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/bean/request/RuleUpdateRequest.java
@@ -30,4 +30,6 @@ public class RuleUpdateRequest {
private int enabled;
@JsonProperty(value="ruleid")
private String ruleId;
+ @JsonProperty(value = "loopcontrolname")
+ private String loopControlName;
}
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleDao.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleDao.java
index 6b55d98..98553c9 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleDao.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/CorrelationRuleDao.java
@@ -30,10 +30,10 @@ import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
public abstract class CorrelationRuleDao {
@GetGeneratedKeys
- @SqlUpdate("INSERT INTO APLUS_RULE (NAME,DESCRIPTION,ENABLE,TEMPLATEID,ENGINETYPE,CREATOR,UPDATOR,PARAMS,CONTENT ,VENDOR,CREATETIME,UPDATETIME,ENGINEID,PACKAGE,RID) VALUES (:name,:description,:enabled,:templateID,:engineType,:creator,:modifier,:params,:content,:vendor,:createTime,:updateTime,:engineID,:packageName,:rid)")
+ @SqlUpdate("INSERT INTO APLUS_RULE (NAME,CTRLLOOP,DESCRIPTION,ENABLE,TEMPLATEID,ENGINETYPE,CREATOR,UPDATOR,PARAMS,CONTENT ,VENDOR,CREATETIME,UPDATETIME,ENGINEID,PACKAGE,RID) VALUES (:name,:closedControlLoopName,:description,:enabled,:templateID,:engineType,:creator,:modifier,:params,:content,:vendor,:createTime,:updateTime,:engineID,:packageName,:rid)")
protected abstract String addRule(@BindBean CorrelationRule correlationRule);
- @SqlUpdate("UPDATE APLUS_RULE SET DESCRIPTION=:description,ENABLE=:enabled,CONTENT=:content,UPDATOR=:modifier,UPDATETIME=:updateTime, PACKAGE=:packageName WHERE RID=:rid")
+ @SqlUpdate("UPDATE APLUS_RULE SET CTRLLOOP=:closedControlLoopName,DESCRIPTION=:description,ENABLE=:enabled,CONTENT=:content,UPDATOR=:modifier,UPDATETIME=:updateTime, PACKAGE=:packageName WHERE RID=:rid")
protected abstract int updateRuleByRid(@BindBean CorrelationRule correlationRule);
@SqlUpdate("DELETE FROM APLUS_RULE WHERE RID=:rid")
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java
index d40253f..98d7d01 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java
@@ -42,6 +42,7 @@ public class CorrelationRuleMapper implements ResultSetMapper<CorrelationRule> {
correlationRule.setContent(resultSet.getString("content"));
correlationRule.setVendor(resultSet.getString("vendor"));
correlationRule.setPackageName(resultSet.getString("package"));
+ correlationRule.setClosedControlLoopName(resultSet.getString("ctrlloop"));
return correlationRule;
}
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java
index c1f1917..6ab7576 100644
--- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java
+++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java
@@ -73,7 +73,7 @@ public class RuleMgtWrapper {
if (ruleTemp != null) {
throw new CorrelationException("A rule with the same name already exists.");
}
- String packageName = deployRule2Engine(correlationRule, ruleCreateRequest.getLoopControlName());
+ String packageName = deployRule2Engine(correlationRule);
correlationRule.setPackageName(packageName);
CorrelationRule result = null;
try {
@@ -135,7 +135,10 @@ public class RuleMgtWrapper {
int oldEnabled = oldCorrelationRule.getEnabled();
String newDes = newCorrelationRule.getDescription();
String oldDes = oldCorrelationRule.getDescription();
- if (newContent.equals(oldContent) && newEnabled == oldEnabled && newDes.equals(oldDes)) {
+ String oldControlLoop = oldCorrelationRule.getClosedControlLoopName();
+ String newControlLoop = newCorrelationRule.getClosedControlLoopName();
+ if (newContent.equals(oldContent) && newEnabled == oldEnabled
+ && newDes.equals(oldDes) && newControlLoop.equals(oldControlLoop)) {
return false;
}
return true;
@@ -178,6 +181,7 @@ public class RuleMgtWrapper {
correlationRule.setCreator(userName);
correlationRule.setModifier(userName);
correlationRule.setEnabled(ruleCreateRequest.getEnabled());
+ correlationRule.setClosedControlLoopName(ruleCreateRequest.getLoopControlName());
return correlationRule;
}
@@ -192,6 +196,7 @@ public class RuleMgtWrapper {
correlationRule.setUpdateTime(new Date());
correlationRule.setModifier(modifier);
correlationRule.setName(ruleName);
+ correlationRule.setClosedControlLoopName(ruleUpdateRequest.getLoopControlName());
return correlationRule;
}
@@ -204,15 +209,6 @@ public class RuleMgtWrapper {
return "";
}
- private String deployRule2Engine(CorrelationRule correlationRule, String loopControlName)
- throws CorrelationException {
- if (engineWarpper.checkRuleFromEngine(correlationRules2CheckRule(correlationRule)) && (
- correlationRule.getEnabled() == RuleMgtConstant.STATUS_RULE_OPEN)) {
- return engineWarpper.deployEngine(correlationRules2DeployRule(correlationRule, loopControlName));
- }
- return "";
- }
-
public RuleQueryListResponse getCorrelationRuleByCondition(
RuleQueryCondition ruleQueryCondition) throws CorrelationException {
List<CorrelationRule> correlationRule = correlationRuleQueryDao
@@ -249,15 +245,7 @@ public class RuleMgtWrapper {
CorrelationDeployRule4Engine correlationDeployRule4Engine = new CorrelationDeployRule4Engine();
correlationDeployRule4Engine.setContent(correlationRule.getContent());
correlationDeployRule4Engine.setEngineId(correlationRule.getEngineID());
- return correlationDeployRule4Engine;
- }
-
- private CorrelationDeployRule4Engine correlationRules2DeployRule(
- CorrelationRule correlationRule, String loopControlName) {
- CorrelationDeployRule4Engine correlationDeployRule4Engine = new CorrelationDeployRule4Engine();
- correlationDeployRule4Engine.setContent(correlationRule.getContent());
- correlationDeployRule4Engine.setEngineId(correlationRule.getEngineID());
- correlationDeployRule4Engine.setLoopControlName(loopControlName);
+ correlationDeployRule4Engine.setLoopControlName(correlationRule.getClosedControlLoopName());
return correlationDeployRule4Engine;
}