X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=rulemgt%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Frulemgt%2Fdb%2FCorrelationRuleDao.java;h=a9be49fe74c964764b50d60d67fab75a3f2d53cb;hb=348ce6e112876f552a939e58d74376704537344e;hp=6b55d98ccaff42e6c42b95308ddee2aa5e92981b;hpb=99db451cbc9ddabc1085e4734ce3ea8ed0d83b61;p=holmes%2Frule-management.git 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..a9be49f 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 @@ -16,9 +16,11 @@ package org.onap.holmes.rulemgt.db; import java.util.List; + +import org.jvnet.hk2.annotations.Service; import org.onap.holmes.common.api.entity.CorrelationRule; import org.onap.holmes.common.exception.CorrelationException; -import org.onap.holmes.rulemgt.db.mapper.CorrelationRuleMapper; +import org.onap.holmes.common.utils.CorrelationRuleMapper; import org.skife.jdbi.v2.sqlobject.Bind; import org.skife.jdbi.v2.sqlobject.BindBean; import org.skife.jdbi.v2.sqlobject.GetGeneratedKeys; @@ -26,14 +28,15 @@ import org.skife.jdbi.v2.sqlobject.SqlQuery; import org.skife.jdbi.v2.sqlobject.SqlUpdate; import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper; +@Service @RegisterMapper(CorrelationRuleMapper.class) 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, ENGINEINSTANCE) VALUES (:name,:closedControlLoopName,:description,:enabled,:templateID,:engineType,:creator,:modifier,:params,:content,:vendor,:createTime,:updateTime,:engineID,:packageName,:rid,:engineInstance)") 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, ENGINEINSTANCE=:engineInstance WHERE RID=:rid") protected abstract int updateRuleByRid(@BindBean CorrelationRule correlationRule); @SqlUpdate("DELETE FROM APLUS_RULE WHERE RID=:rid") @@ -51,6 +54,21 @@ public abstract class CorrelationRuleDao { @SqlQuery("SELECT * FROM APLUS_RULE WHERE NAME=:name") protected abstract CorrelationRule queryRuleByName(@Bind("name") String name); + @SqlQuery("SELECT * FROM APLUS_RULE WHERE enable=:enable") + public abstract List queryRuleByEnable(@Bind("enable") int enable); + + @SqlQuery("SELECT * FROM APLUS_RULE WHERE engineinstance=:engineinstance") + public abstract List queryRuleByEngineInstance(@Bind("engineinstance") String engineinstance); + + public List queryRuleByRuleEngineInstance(String enginetype) { + return queryRuleByEngineInstance(enginetype); + } + + public List queryRuleByRuleEnable(int enable) { + return queryRuleByEnable(enable); + } + + private void deleteRule2DbInner(CorrelationRule correlationRule) { String name = correlationRule.getName() != null ? correlationRule.getName().trim() : ""; String rid = correlationRule.getRid() != null ? correlationRule.getRid().trim() : "";