Implement DMaaP message handling from policy
[dcaegen2/services/son-handler.git] / src / main / java / org / onap / dcaegen2 / services / sonhms / model / PolicyNotification.java
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  son-handler
4  *  ================================================================================
5  *   Copyright (C) 2019 Wipro Limited.
6  *   ==============================================================================
7  *     Licensed under the Apache License, Version 2.0 (the "License");
8  *     you may not use this file except in compliance with the License.
9  *     You may obtain a copy of the License at
10  *  
11  *          http://www.apache.org/licenses/LICENSE-2.0
12  *  
13  *     Unless required by applicable law or agreed to in writing, software
14  *     distributed under the License is distributed on an "AS IS" BASIS,
15  *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *     See the License for the specific language governing permissions and
17  *     limitations under the License.
18  *     ============LICENSE_END=========================================================
19  *  
20  *******************************************************************************/
21
22 package org.onap.dcaegen2.services.sonhms.model;
23
24 import com.fasterxml.jackson.annotation.JsonProperty;
25
26 import java.util.HashMap;
27 import java.util.Map;
28
29 public class PolicyNotification {
30
31     private String closedLoopControlName;
32     private long closedLoopAlarmStart;
33     private String closedLoopEventClient;
34     private String closedLoopEventStatus;
35     
36     @JsonProperty("target_type")
37     private String targetType;
38
39     private String target;
40
41     @JsonProperty("requestID")
42     private String requestId;
43
44     @JsonProperty("AAI")
45     private Map<String, String> aai;
46
47     private String from;
48     private String version;
49     
50     private String policyName;
51     private String policyVersion;
52
53     @JsonProperty("Action")
54     private String action;
55     private String payload;
56
57     /**
58      * constructor.
59      */
60     public PolicyNotification() {
61
62     }
63
64     /**
65      * Constructor.
66      */
67     public PolicyNotification(String closedLoopControlName, String requestId, Long alarmStartTime, String pnfName,
68             String action) {
69         this.closedLoopControlName = closedLoopControlName;
70         this.requestId = requestId;
71         this.closedLoopEventClient = "microservice.PCI";
72         this.closedLoopEventStatus = "ONSET";
73         this.closedLoopAlarmStart = alarmStartTime;
74         this.from = "PCIMS";
75         this.version = "1.0.2";
76         this.action = action;
77         this.target = "generic-vnf.vnf-id";
78         this.targetType = "VNF";
79         this.aai = new HashMap<>();
80         aai.put("generic-vnf.is-closed-loop-disabled", "false");
81         aai.put("generic-vnf.prov-status", "ACTIVE");
82         aai.put("generic-vnf.vnf-id", pnfName);
83     }
84
85     public long getClosedLoopAlarmStart() {
86         return closedLoopAlarmStart;
87     }
88
89     public void setClosedLoopAlarmStart(long closedLoopAlarmStart) {
90         this.closedLoopAlarmStart = closedLoopAlarmStart;
91     }
92
93     public String getClosedLoopEventClient() {
94         return closedLoopEventClient;
95     }
96
97     public void setClosedLoopEventClient(String closedLoopEventClient) {
98         this.closedLoopEventClient = closedLoopEventClient;
99     }
100
101     public String getClosedLoopEventStatus() {
102         return closedLoopEventStatus;
103     }
104
105     public void setClosedLoopEventStatus(String closedLoopEventStatus) {
106         this.closedLoopEventStatus = closedLoopEventStatus;
107     }
108
109     public String getRequestId() {
110         return requestId;
111     }
112
113     public void setRequestId(String requestId) {
114         this.requestId = requestId;
115     }
116
117     public String getFrom() {
118         return from;
119     }
120
121     public void setFrom(String from) {
122         this.from = from;
123     }
124
125     public String getVersion() {
126         return version;
127     }
128
129     public void setVersion(String version) {
130         this.version = version;
131     }
132
133     public String getAction() {
134         return action;
135     }
136
137     public void setAction(String action) {
138         this.action = action;
139     }
140
141     public String getClosedLoopControlName() {
142         return closedLoopControlName;
143     }
144
145     public void setClosedLoopControlName(String closedLoopControlName) {
146         this.closedLoopControlName = closedLoopControlName;
147     }
148
149     public String getPayload() {
150         return payload;
151     }
152
153     public void setPayload(String payload) {
154         this.payload = payload;
155     }
156
157     public String getTargetType() {
158         return targetType;
159     }
160
161     public void setTargetType(String targetType) {
162         this.targetType = targetType;
163     }
164
165     public String getTarget() {
166         return target;
167     }
168
169     public void setTarget(String target) {
170         this.target = target;
171     }
172
173     public Map<String, String> getAai() {
174         return aai;
175     }
176
177     public void setAai(Map<String, String> aai) {
178         this.aai = aai;
179     }
180
181     @Override
182     public String toString() {
183         return "PolicyNotification [closedLoopControlName=" + closedLoopControlName + ", closedLoopAlarmStart="
184                 + closedLoopAlarmStart + ", closedLoopEventClient=" + closedLoopEventClient + ", closedLoopEventStatus="
185                 + closedLoopEventStatus + ", targetType=" + targetType + ", target=" + target + ", requestId="
186                 + requestId + ", aai=" + aai + ", from=" + from + ", version=" + version + ", action=" + action
187                 + ", payload=" + payload + "]";
188     }
189
190     @Override
191     public int hashCode() {
192         final int prime = 31;
193         int result = 1;
194         result = prime * result + ((aai == null) ? 0 : aai.hashCode());
195         result = prime * result + ((action == null) ? 0 : action.hashCode());
196         result = prime * result + (int) (closedLoopAlarmStart ^ (closedLoopAlarmStart >>> 32));
197         result = prime * result + ((closedLoopControlName == null) ? 0 : closedLoopControlName.hashCode());
198         result = prime * result + ((closedLoopEventClient == null) ? 0 : closedLoopEventClient.hashCode());
199         result = prime * result + ((closedLoopEventStatus == null) ? 0 : closedLoopEventStatus.hashCode());
200         result = prime * result + ((from == null) ? 0 : from.hashCode());
201         result = prime * result + ((payload == null) ? 0 : payload.hashCode());
202         result = prime * result + ((requestId == null) ? 0 : requestId.hashCode());
203         result = prime * result + ((target == null) ? 0 : target.hashCode());
204         result = prime * result + ((targetType == null) ? 0 : targetType.hashCode());
205         result = prime * result + ((version == null) ? 0 : version.hashCode());
206         return result;
207     }
208
209     @Override
210     public boolean equals(Object obj) {
211         if (obj == null) {
212             return false;
213         }
214         return (this.hashCode() == obj.hashCode());
215     }
216
217     public String getPolicyName() {
218         return policyName;
219     }
220
221     public void setPolicyName(String policyName) {
222         this.policyName = policyName;
223     }
224
225     public String getPolicyVersion() {
226         return policyVersion;
227     }
228
229     public void setPolicyVersion(String policyVersion) {
230         this.policyVersion = policyVersion;
231     }
232     
233     
234
235 }