Switched from Dropwizard to Springboot
[holmes/engine-management.git] / engine-d / src / main / java / org / onap / holmes / engine / db / jdbi / AlarmInfoDao.java
1 /**\r
2  * Copyright 2017-2022 ZTE Corporation.\r
3  * <p>\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
7  * <p>\r
8  * http://www.apache.org/licenses/LICENSE-2.0\r
9  * <p>\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
15  */\r
16 package org.onap.holmes.engine.db.jdbi;\r
17 \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.AlarmInfo;\r
25 import org.onap.holmes.common.utils.AlarmInfoMapper;\r
26 \r
27 import java.util.List;\r
28 \r
29 @RegisterRowMapper(AlarmInfoMapper.class)\r
30 public interface AlarmInfoDao {\r
31 \r
32     @GetGeneratedKeys\r
33     @SqlUpdate("INSERT INTO ALARM_INFO  (EVENTID,EVENTNAME,STARTEPOCHMICROSEC,SOURCEID,SOURCENAME,SEQUENCE,ALARMISCLEARED,ROOTFLAG,LASTEPOCHMICROSEC) VALUES (:eventId,:eventName,:startEpochMicroSec,:sourceId,:sourceName,:sequence,:alarmIsCleared,:rootFlag,:lastEpochMicroSec)")\r
34     String addAlarm(@BindBean AlarmInfo alarmInfo);\r
35 \r
36     @SqlQuery("SELECT * FROM ALARM_INFO")\r
37     List<AlarmInfo> queryAlarm();\r
38 \r
39     @SqlUpdate("DELETE FROM ALARM_INFO WHERE EVENTNAME=:eventName AND SOURCEID=:sourceId AND SOURCENAME=:sourceName")\r
40     int deleteAlarmByAlarmIsCleared(@Bind("eventName") String eventName,\r
41                                     @Bind("sourceId") String sourceId,\r
42                                     @Bind("sourceName") String sourceName);\r
43 }\r