2 * Copyright 2017-2021 ZTE Corporation.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
16 package org.onap.holmes.rulemgt.db.jdbi;
\r
18 import org.jdbi.v3.sqlobject.config.RegisterRowMapper;
\r
19 import org.jdbi.v3.sqlobject.customizer.Bind;
\r
20 import org.jdbi.v3.sqlobject.customizer.BindBean;
\r
21 import org.jdbi.v3.sqlobject.statement.GetGeneratedKeys;
\r
22 import org.jdbi.v3.sqlobject.statement.SqlQuery;
\r
23 import org.jdbi.v3.sqlobject.statement.SqlUpdate;
\r
24 import org.onap.holmes.common.api.entity.CorrelationRule;
\r
25 import org.onap.holmes.common.utils.CorrelationRuleMapper;
\r
26 import org.springframework.stereotype.Service;
\r
28 import java.util.List;
\r
31 @RegisterRowMapper(CorrelationRuleMapper.class)
\r
32 public interface CorrelationRuleDao {
\r
35 @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)")
\r
36 String addRule(@BindBean CorrelationRule correlationRule);
\r
38 @SqlUpdate("UPDATE APLUS_RULE SET CTRLLOOP=:closedControlLoopName,DESCRIPTION=:description,ENABLE=:enabled,CONTENT=:content,UPDATOR=:modifier,UPDATETIME=:updateTime, PACKAGE=:packageName, ENGINEINSTANCE=:engineInstance WHERE RID=:rid")
\r
39 int updateRuleByRid(@BindBean CorrelationRule correlationRule);
\r
41 @SqlUpdate("DELETE FROM APLUS_RULE WHERE RID=:rid")
\r
42 int deleteRuleByRid(@Bind("rid") String rid);
\r
44 @SqlUpdate("DELETE FROM APLUS_RULE WHERE RID=:rid AND NAME=:name")
\r
45 int deleteRuleByRidAndName(@Bind("rid") String rid, @Bind("name") String name);
\r
47 @SqlQuery("SELECT * FROM APLUS_RULE")
\r
48 List<CorrelationRule> queryAllRules();
\r
50 @SqlQuery("SELECT * FROM APLUS_RULE WHERE RID=:rid")
\r
51 CorrelationRule queryRuleById(@Bind("rid") String rid);
\r
53 @SqlQuery("SELECT * FROM APLUS_RULE WHERE NAME=:name")
\r
54 CorrelationRule queryRuleByName(@Bind("name") String name);
\r
56 @SqlQuery("SELECT * FROM APLUS_RULE WHERE enable=:enable")
\r
57 List<CorrelationRule> queryRuleByEnable(@Bind("enable") int enable);
\r
59 @SqlQuery("SELECT * FROM APLUS_RULE WHERE engineinstance=:engineinstance")
\r
60 List<CorrelationRule> queryRuleByEngineInstance(@Bind("engineinstance") String engineinstance);
\r