/**\r
* Copyright 2017 ZTE Corporation.\r
- *\r
+ * <p>\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
+ * <p>\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * <p>\r
* Unless required by applicable law or agreed to in writing, software\r
* distributed under the License is distributed on an "AS IS" BASIS,\r
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
@SqlQuery("SELECT * FROM ALARM_INFO")\r
protected abstract List<AlarmInfo> queryAlarm();\r
\r
- @SqlUpdate("DELETE FROM ALARM_INFO WHERE ALARMISCLEARED=:alarmiscleared")\r
- protected abstract int deleteAlarmByAlarmIsCleared(@Bind("alarmiscleared") int alarmIsCleared);\r
+ @SqlUpdate("DELETE FROM ALARM_INFO WHERE EVENTNAME=:eventName AND SOURCEID=:sourceId AND SOURCENAME=:sourceName")\r
+ protected abstract int deleteAlarmByAlarmIsCleared(@Bind("eventName") String eventName,\r
+ @Bind("sourceId") String sourceId,\r
+ @Bind("sourceName") String sourceName);\r
\r
public AlarmInfo saveAlarm(AlarmInfo alarmInfo) throws AlarmInfoException {\r
try {\r
addAlarm(alarmInfo);\r
return alarmInfo;\r
- } catch(Exception e) {\r
+ } catch (Exception e) {\r
throw new AlarmInfoException("Can not access the database. Please contact the administrator for help.", e);\r
}\r
}\r
public List<AlarmInfo> queryAllAlarm() throws AlarmInfoException {\r
try {\r
return queryAlarm();\r
- } catch(Exception e) {\r
+ } catch (Exception e) {\r
throw new AlarmInfoException("Can not access the database. Please contact the administrator for help.", e);\r
}\r
}\r
\r
- public void deleteClearedAlarm(AlarmInfo alarmInfo) {\r
- int alarmIsCleared = alarmInfo.getAlarmIsCleared();\r
- if(alarmIsCleared == 1) {\r
- deleteAlarmByAlarmIsCleared(alarmIsCleared);\r
- }\r
+ public void deleteAlarm(AlarmInfo alarmInfo) {\r
+ if (alarmInfo.getAlarmIsCleared() != 1) {\r
+ return;\r
+ }\r
+\r
+ String sourceId = alarmInfo.getSourceId();\r
+ String sourceName = alarmInfo.getSourceName();\r
+ String eventName = alarmInfo.getEventName();\r
+ eventName = eventName.substring(0, eventName.lastIndexOf("Cleared"));\r
+\r
+ deleteAlarmByAlarmIsCleared(eventName, sourceId, sourceName);\r
}\r
}\r