ead8464f730ab7a2664981e7243295ada6fb2fc5
[holmes/common.git] / holmes-actions / src / main / java / org / onap / holmes / common / api / stat / VesAlarm.java
1 /*
2  * Copyright 2017 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.holmes.common.api.stat;
18
19 import java.io.Serializable;
20 import java.util.ArrayList;
21 import java.util.List;
22 import lombok.Getter;
23 import lombok.Setter;
24
25 @Getter
26 @Setter
27 public class VesAlarm implements Cloneable, Serializable{
28     private String domain;
29     private String eventId;
30     private String eventName;
31     private String eventType;
32     private Object internalHeaderFields;
33     private Long lastEpochMicrosec;
34     private String nfcNamingCode;
35     private String nfNamingCode;
36     private String priority;
37     private String reportingEntityId;
38     private String reportingEntityName;
39     private Integer sequence;
40     private String sourceId;
41     private String sourceName;
42     private Long startEpochMicrosec;
43     private Long version;
44
45     private List<AlarmAdditionalField> alarmAdditionalInformation;
46     private String alarmCondition;
47     private String alarmInterfaceA;
48     private String eventCategory;
49     private String eventSeverity;
50     private String eventSourceType;
51     private Long faultFieldsVersion;
52     private String specificProblem;
53     private String vfStatus;
54     private String parentId;
55     private int alarmIsCleared = 0;  //mark as 1 when alarm type is cleared, else mark as 0
56     private int rootFlag = 0;        // mark as 1 when alarm is a root alarm , else mark as 0
57
58     @Override
59     public int hashCode() {
60         return (this.getSourceId() + this.eventName.replace("Cleared", "")).hashCode();
61     }
62
63     @Override
64     public boolean equals(Object object) {
65         if (object == null || !(object instanceof VesAlarm)) {
66             return false;
67         }
68         return this.eventName.replace("Cleared", "")
69                 .equals(((VesAlarm) object).getEventName().replace("Cleared", ""))
70                 && this.getSourceId().equals(((VesAlarm) object).getSourceId());
71     }
72
73     @Override
74     public Object clone() throws CloneNotSupportedException {
75         VesAlarm vesAlarm = new VesAlarm();
76
77         vesAlarm.setDomain(this.domain);
78         vesAlarm.setEventId(this.getEventId());
79         vesAlarm.setEventName(this.getEventName());
80         vesAlarm.setEventType(this.getEventType());
81         vesAlarm.setInternalHeaderFields(this.getInternalHeaderFields());
82         vesAlarm.setLastEpochMicrosec(this.getLastEpochMicrosec());
83         vesAlarm.setNfcNamingCode(this.nfcNamingCode);
84         vesAlarm.setNfNamingCode(this.getNfNamingCode());
85         vesAlarm.setPriority(this.getPriority());
86         vesAlarm.setReportingEntityId(this.getReportingEntityId());
87         vesAlarm.setReportingEntityName(this.reportingEntityName);
88         vesAlarm.setSequence(this.getSequence());
89         vesAlarm.setSourceId(this.getSourceId());
90         vesAlarm.setSourceName(this.getSourceName());
91         vesAlarm.setStartEpochMicrosec(this.getStartEpochMicrosec());
92         vesAlarm.setVersion(this.getVersion());
93
94         if (alarmAdditionalInformation != null) {
95             List<AlarmAdditionalField> alarmAdditionalFields = new ArrayList<>();
96             alarmAdditionalInformation.forEach(alarmAdditionalField -> {
97                 AlarmAdditionalField alarmAdditionalField1 = new AlarmAdditionalField();
98                 alarmAdditionalField1.setName(alarmAdditionalField.getName());
99                 alarmAdditionalField1.setName(alarmAdditionalField.getValue());
100                 alarmAdditionalFields.add(alarmAdditionalField1);
101             });
102             vesAlarm.setAlarmAdditionalInformation(alarmAdditionalFields);
103         }
104
105         vesAlarm.setAlarmCondition(this.getAlarmCondition());
106         vesAlarm.setAlarmInterfaceA(this.getAlarmInterfaceA());
107         vesAlarm.setEventCategory(this.getEventCategory());
108         vesAlarm.setEventSeverity(this.getEventSeverity());
109         vesAlarm.setEventSourceType(this.getEventSourceType());
110         vesAlarm.setFaultFieldsVersion(this.getFaultFieldsVersion());
111         vesAlarm.setSpecificProblem(this.getSpecificProblem());
112         vesAlarm.setVfStatus(this.vfStatus);
113         vesAlarm.setAlarmIsCleared(this.alarmIsCleared);
114         vesAlarm.setRootFlag(this.rootFlag);
115
116         return vesAlarm;
117     }
118 }