2 * Copyright 2017-2020 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
17 package org.onap.holmes.common.api.stat;
\r
19 import com.alibaba.fastjson.JSONObject;
\r
20 import lombok.Getter;
\r
21 import lombok.Setter;
\r
23 import java.io.Serializable;
\r
29 public class Alarm implements AplusData, Cloneable, Serializable {
\r
31 public static final byte EVENT_CLEARED_ALARM = 3;
\r
33 public static final byte EVENT_CHANGED = 2;
\r
35 public static final byte EVENT_CLEARED = 1;
\r
37 public static final byte EVENT_RAISED = 0;
\r
39 private static final long serialVersionUID = 4520003737132012000L;
\r
40 private static final Date clearedServerTime = null;
\r
41 private final Map<Integer, Integer> linkIdNodeIdxMap = new HashMap<>();
\r
42 private byte eventType = EVENT_RAISED;
\r
43 private long id = 0L;
\r
44 private String alarmKey = "";
\r
45 private String network = "";
\r
46 private String neType = "";
\r
47 private String equipType = "";
\r
48 private String position1 = "";
\r
49 private String subPosition1 = null;
\r
50 private String position2 = null;
\r
51 private String subPosition2 = null;
\r
52 private byte severity = -1;
\r
53 private byte alarmType = -1;
\r
54 private long probableCause = -1;
\r
55 private String specificProblem = null;
\r
56 private String additionalText = null;
\r
57 private Date raisedTime = new Date();
\r
58 private Date raisedServerTime = new Date();
\r
59 private Date clearedTime = null;
\r
60 private String region = null;
\r
61 private String site = null;
\r
62 private String aid = null;
\r
63 private short systemType = -1;
\r
64 private boolean rootAlarmFlag = false;
\r
65 private int linkId = -1;
\r
66 private int nodeIdx = -1;
\r
67 private Set<Integer> linkIds = new HashSet<>();
\r
68 private HashMap<String, Integer> priorityMap = new HashMap<>();
\r
69 private HashMap<String, Integer> rootAlarmTypeMap = new HashMap<>();
\r
70 private int rootAlarmType = -1;
\r
71 private boolean keyAlarmFlag = false;
\r
72 private int keyAlarmType = -1;
\r
73 private int networkLevel = -1;
\r
74 private int linkType = -1;
\r
75 private int centerType;
\r
77 public void addLinkIdNodeIdx(int linkId, int index) {
\r
78 linkIdNodeIdxMap.put(linkId, index);
\r
81 public boolean containNode(int linkId, int index) {
\r
82 return linkIdNodeIdxMap.containsKey(linkId) && linkIdNodeIdxMap.get(linkId) == index;
\r
86 public byte getDataType() {
\r
91 public String toString() {
\r
93 return JSONObject.toJSONString(this);
\r
97 public int hashCode() {
\r
98 return this.getAlarmKey().hashCode();
\r
102 public boolean equals(Object arg0) {
\r
103 if (arg0 == null || !(arg0 instanceof Alarm)) {
\r
106 return this.alarmKey.equals(((Alarm) arg0).getAlarmKey());
\r
110 public Object clone() throws CloneNotSupportedException {
\r
113 Alarm alarm = new Alarm();
\r
115 alarm.setEventType(this.getEventType());
\r
117 alarm.setAid(this.getAid());
\r
118 alarm.setId(this.getId());
\r
119 alarm.setAlarmKey(this.getAlarmKey());
\r
121 alarm.setNetwork(this.getNetwork());
\r
122 alarm.setEquipType(this.getEquipType());
\r
123 alarm.setNeType(this.getNeType());
\r
124 alarm.setPosition1(this.getPosition1());
\r
125 alarm.setSubPosition1(this.getSubPosition1());
\r
126 alarm.setPosition2(this.getPosition2());
\r
127 alarm.setSubPosition2(this.getSubPosition2());
\r
128 alarm.setRegion(this.getRegion());
\r
129 alarm.setSite(this.getSite());
\r
131 alarm.setSeverity(this.getSeverity());
\r
132 alarm.setAlarmType(this.getAlarmType());
\r
133 alarm.setSystemType(this.getSystemType());
\r
134 alarm.setSpecificProblem(this.getSpecificProblem());
\r
135 alarm.setAdditionalText(this.getAdditionalText());
\r
136 alarm.setProbableCause(this.getProbableCause());
\r
138 alarm.setRaisedTime(this.getRaisedTime());
\r
139 alarm.setRaisedServerTime(this.getRaisedServerTime());
\r
140 alarm.setClearedTime(this.getClearedTime());
\r
146 public String getObjectId() {
\r
147 return String.valueOf(id);
\r
150 public void addLinkIds(int linkId) {
\r
151 linkIds.add(linkId);
\r
155 public boolean containsPriority(String ruleId) {
\r
156 return priorityMap.keySet().contains(ruleId);
\r
159 public int getPriority(String ruleId) {
\r
160 Integer priority = this.priorityMap.get(ruleId);
\r
161 if (priority == null) {
\r
167 public int getRootAlarmType(String ruleId) {
\r
168 Integer rootAlarmTypeVar = this.rootAlarmTypeMap.get(ruleId);
\r
169 return (rootAlarmTypeVar == null) ? -1 : rootAlarmTypeVar;
\r