summaryrefslogtreecommitdiffstats
path: root/holmes-actions/src/main/java
diff options
context:
space:
mode:
authorFei Tang <tang.fei4@zte.com.cn>2018-03-27 16:26:39 +0800
committerFei Tang <tang.fei4@zte.com.cn>2018-03-27 16:50:32 +0800
commit6c4fde1fd6dcf484d2c567d3fabf0496ed8b30e0 (patch)
tree0c357c36cfda707fa1ec6cd81d5f0f95f53f2bcd /holmes-actions/src/main/java
parent131be6f05c41acd5502d637d2d3326d8b20081ce (diff)
add alarm synchronization related operation
Issue-ID: HOLMES-106 Change-Id: I9020c29b69eb0e8bd5a0a33901c671fd02b9f0d1 Signed-off-by: FeiTang <tang.fei4@zte.com.cn>
Diffstat (limited to 'holmes-actions/src/main/java')
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/api/entity/AlarmInfo.java49
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/exception/AlarmInfoException.java23
-rw-r--r--holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java39
3 files changed, 111 insertions, 0 deletions
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/AlarmInfo.java b/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/AlarmInfo.java
new file mode 100644
index 0000000..fe1f677
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/AlarmInfo.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.api.entity;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+public class AlarmInfo {
+
+ @SerializedName(value = "eventid")
+ private String eventId;
+
+ @SerializedName(value = "eventname")
+ private String eventName;
+
+ @SerializedName(value = "startepochmicrosec")
+ private Long startEpochMicroSec;
+
+ @SerializedName(value = "lastepochmicrosec")
+ private Long lastEpochMicroSec;
+
+ @SerializedName(value = "sourceid")
+ private String sourceId;
+
+ @SerializedName(value = "sourcename")
+ private String sourceName;
+
+ @SerializedName(value = "alarmiscleared")
+ private int alarmIsCleared;
+
+ @SerializedName(value = "rootflag")
+ private int rootFlag;
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/exception/AlarmInfoException.java b/holmes-actions/src/main/java/org/onap/holmes/common/exception/AlarmInfoException.java
new file mode 100644
index 0000000..ab3eba7
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/exception/AlarmInfoException.java
@@ -0,0 +1,23 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.exception;
+
+public class AlarmInfoException extends Exception {
+
+ public AlarmInfoException(String msg, Exception e) { super(msg, e);}
+
+ public AlarmInfoException(String msg) { super(msg);}
+}
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java
new file mode 100644
index 0000000..0c7d756
--- /dev/null
+++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.utils;
+
+import org.onap.holmes.common.api.entity.AlarmInfo;
+import org.skife.jdbi.v2.StatementContext;
+import org.skife.jdbi.v2.tweak.ResultSetMapper;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class AlarmInfoMapper implements ResultSetMapper<AlarmInfo> {
+ @Override
+ public AlarmInfo map(int i, ResultSet resultSet, StatementContext statementContext) throws SQLException {
+ AlarmInfo alarmInfo = new AlarmInfo();
+ alarmInfo.setAlarmIsCleared(resultSet.getInt("alarmiscleared"));
+ alarmInfo.setRootFlag(resultSet.getInt("rootflag"));
+ alarmInfo.setEventId(resultSet.getString("eventid"));
+ alarmInfo.setEventName(resultSet.getString("eventname"));
+ alarmInfo.setSourceId(resultSet.getString("sourceid"));
+ alarmInfo.setSourceName(resultSet.getString("sourcename"));
+ alarmInfo.setStartEpochMicroSec(resultSet.getLong("startepochmicrosec"));
+ alarmInfo.setLastEpochMicroSec(resultSet.getLong("lastepochmicrosec"));
+ return alarmInfo;
+ }
+}