From 6c4fde1fd6dcf484d2c567d3fabf0496ed8b30e0 Mon Sep 17 00:00:00 2001 From: Fei Tang Date: Tue, 27 Mar 2018 16:26:39 +0800 Subject: add alarm synchronization related operation Issue-ID: HOLMES-106 Change-Id: I9020c29b69eb0e8bd5a0a33901c671fd02b9f0d1 Signed-off-by: FeiTang --- .../onap/holmes/common/api/entity/AlarmInfo.java | 49 ++++++++++++++++++++++ .../common/exception/AlarmInfoException.java | 23 ++++++++++ .../onap/holmes/common/utils/AlarmInfoMapper.java | 39 +++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 holmes-actions/src/main/java/org/onap/holmes/common/api/entity/AlarmInfo.java create mode 100644 holmes-actions/src/main/java/org/onap/holmes/common/exception/AlarmInfoException.java create mode 100644 holmes-actions/src/main/java/org/onap/holmes/common/utils/AlarmInfoMapper.java (limited to 'holmes-actions/src/main/java') 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 { + @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; + } +} -- cgit 1.2.3-korg