c52569571943ef4ebecc4a8e13b41f097293c190
[portal.git] / ecomp-portal-BE-common / src / main / java / org / openecomp / portalapp / portal / transport / EpNotificationItem.java
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
8  * Unless otherwise specified, all software contained herein is licensed
9  * under the Apache License, Version 2.0 (the “License”);
10  * you may not use this software except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *             http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * Unless otherwise specified, all documentation contained herein is licensed
22  * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
23  * you may not use this documentation except in compliance with the License.
24  * You may obtain a copy of the License at
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
28  * Unless required by applicable law or agreed to in writing, documentation
29  * distributed under the License is distributed on an "AS IS" BASIS,
30  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31  * See the License for the specific language governing permissions and
32  * limitations under the License.
33  *
34  * ============LICENSE_END============================================
35  *
36  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
37  */
38 package org.openecomp.portalapp.portal.transport;
39
40 import java.util.Date;
41 import java.util.List;
42 import java.util.Set;
43
44 import javax.persistence.CascadeType;
45 import javax.persistence.Column;
46 import javax.persistence.Entity;
47 import javax.persistence.FetchType;
48 import javax.persistence.GeneratedValue;
49 import javax.persistence.GenerationType;
50 import javax.persistence.Id;
51 import javax.persistence.JoinColumn;
52 import javax.persistence.OneToMany;
53 import javax.persistence.Table;
54 import javax.persistence.Transient;
55
56 import org.openecomp.portalsdk.core.domain.support.DomainVo;
57
58
59 /**
60  * This is to handle notifications in notification PopUp
61  */
62
63
64 @Entity
65 @Table(name = "ep_notification")
66 public class EpNotificationItem extends DomainVo {
67         public EpNotificationItem() {
68         };
69
70         private static final long serialVersionUID = 1L;
71
72         @Id
73         @GeneratedValue(strategy = GenerationType.IDENTITY)
74         @Column(name = "notification_ID")
75         public Long notificationId;
76
77         @Column(name = "is_for_online_users")
78         public String isForOnlineUsers;
79
80         @Column(name = "is_for_all_roles")
81         public String isForAllRoles;
82
83         @Column(name = "active_YN")
84         public String activeYn;
85         
86         @Column(name = "msg_header")
87         public String msgHeader;
88
89         @Column(name = "msg_description")
90         public String msgDescription;
91         
92         @Column(name = "msg_source")
93         public String msgSource;
94
95         @Column(name = "start_time")
96         public Date startTime;
97         
98         @Column(name = "end_time")
99         public Date endTime;
100
101         @Column(name = "priority")
102         public Long priority;
103         
104         @Column(name = "creator_ID")
105         public Long creatorId;
106         
107         @Column(name = "created_date")
108         public Date createdDate;
109         
110         @Column(name = "notification_hyperlink")
111         public String notificationHyperlink;
112                 
113         
114         @OneToMany(fetch = FetchType.LAZY, cascade = {CascadeType.ALL}, orphanRemoval = true)
115         @JoinColumn(name="notification_ID")
116         private Set<EpRoleNotificationItem> roles;
117         
118         @Transient
119         private List<Long> roleIds;
120         
121         public Long getNotificationId() {
122                 return notificationId;
123         }
124
125         public void setNotificationId(Long notificationId) {
126                 this.notificationId = notificationId;
127         }
128
129         public String getIsForOnlineUsers() {
130                 return isForOnlineUsers;
131         }
132
133         public void setIsForOnlineUsers(String isForOnlineUsers) {
134                 this.isForOnlineUsers = isForOnlineUsers;
135         }
136
137         public String getIsForAllRoles() {
138                 return isForAllRoles;
139         }
140
141         public void setIsForAllRoles(String isForAllRoles) {
142                 this.isForAllRoles = isForAllRoles;
143         }
144         
145         public String getActiveYn() {
146                 return activeYn;
147         }
148
149         public void setActiveYn(String activeYn) {
150                 this.activeYn = activeYn;
151         }
152
153         public String getMsgHeader() {
154                 return msgHeader;
155         }
156
157         public void setMsgHeader(String msgHeader) {
158                 this.msgHeader = msgHeader;
159         }
160
161         public String getMsgDescription() {
162                 return msgDescription;
163         }
164
165         public void setMsgDescription(String msgDescription) {
166                 this.msgDescription = msgDescription;
167         }
168
169         public Date getStartTime() {
170                 return startTime;
171         }
172
173         public void setStartTime(Date startTime) {
174                 this.startTime = startTime;
175         }
176
177         public Date getEndTime() {
178                 return endTime;
179         }
180
181         public void setEndTime(Date endTime) {
182                 this.endTime = endTime;
183         }
184
185         public Long getPriority() {
186                 return priority;
187         }
188
189         public void setPriority(Long priority) {
190                 this.priority = priority;
191         }
192
193         public Long getCreatorId() {
194                 return creatorId;
195         }
196
197         public void setCreatorId(Long creatorId) {
198                 this.creatorId = creatorId;
199         }
200
201         public Date getCreatedDate() {
202                 return createdDate;
203         }
204
205         public void setCreatedDate(Date createdDate) {
206                 this.createdDate = createdDate;
207         }
208
209         public static long getSerialversionuid() {
210                 return serialVersionUID;
211         }
212
213         public Set<EpRoleNotificationItem> getRoles() {
214                 return roles;
215         }
216
217         public void setRoles(Set<EpRoleNotificationItem> roles) {
218                 this.roles = roles;
219         }
220
221         public List<Long> getRoleIds() {
222                 return roleIds;
223         }
224
225         public void setRoleIds(List<Long> roleIds) {
226                 this.roleIds = roleIds;
227         }
228         
229         public String getMsgSource() {
230                 return msgSource;
231         }
232
233         public void setMsgSource(String msgSource) {
234                 this.msgSource = msgSource;
235         }
236         
237         public String getNotificationHyperlink() {
238                 return notificationHyperlink;
239         }
240
241         public void setNotificationHyperlink(String notificationHyperlink) {
242                 this.notificationHyperlink = notificationHyperlink;
243         }
244
245         @Override
246         public int hashCode() {
247                 final int prime = 31;
248                 int result = 1;
249                 result = prime * result + ((activeYn == null) ? 0 : activeYn.hashCode());
250                 result = prime * result + ((createdDate == null) ? 0 : createdDate.hashCode());
251                 result = prime * result + ((creatorId == null) ? 0 : creatorId.hashCode());
252                 result = prime * result + ((endTime == null) ? 0 : endTime.hashCode());
253                 result = prime * result + ((isForAllRoles == null) ? 0 : isForAllRoles.hashCode());
254                 result = prime * result + ((isForOnlineUsers == null) ? 0 : isForOnlineUsers.hashCode());
255                 result = prime * result + ((msgDescription == null) ? 0 : msgDescription.hashCode());
256                 result = prime * result + ((msgHeader == null) ? 0 : msgHeader.hashCode());
257                 result = prime * result + ((msgSource == null) ? 0 : msgSource.hashCode());
258                 result = prime * result + ((notificationId == null) ? 0 : notificationId.hashCode());
259                 result = prime * result + ((priority == null) ? 0 : priority.hashCode());
260                 result = prime * result + ((roleIds == null) ? 0 : roleIds.hashCode());
261                 result = prime * result + ((roles == null) ? 0 : roles.hashCode());
262                 result = prime * result + ((startTime == null) ? 0 : startTime.hashCode());
263                 return result;
264         }
265
266         @Override
267         public boolean equals(Object obj) {
268                 if (this == obj)
269                         return true;
270                 if (obj == null)
271                         return false;
272                 if (getClass() != obj.getClass())
273                         return false;
274                 EpNotificationItem other = (EpNotificationItem) obj;
275                 if (activeYn == null) {
276                         if (other.activeYn != null)
277                                 return false;
278                 } else if (!activeYn.equals(other.activeYn))
279                         return false;
280                 if (createdDate == null) {
281                         if (other.createdDate != null)
282                                 return false;
283                 } else if (!createdDate.equals(other.createdDate))
284                         return false;
285                 if (creatorId == null) {
286                         if (other.creatorId != null)
287                                 return false;
288                 } else if (!creatorId.equals(other.creatorId))
289                         return false;
290                 if (endTime == null) {
291                         if (other.endTime != null)
292                                 return false;
293                 } else if (!endTime.equals(other.endTime))
294                         return false;
295                 if (isForAllRoles == null) {
296                         if (other.isForAllRoles != null)
297                                 return false;
298                 } else if (!isForAllRoles.equals(other.isForAllRoles))
299                         return false;
300                 if (isForOnlineUsers == null) {
301                         if (other.isForOnlineUsers != null)
302                                 return false;
303                 } else if (!isForOnlineUsers.equals(other.isForOnlineUsers))
304                         return false;
305                 if (msgDescription == null) {
306                         if (other.msgDescription != null)
307                                 return false;
308                 } else if (!msgDescription.equals(other.msgDescription))
309                         return false;
310                 if (msgHeader == null) {
311                         if (other.msgHeader != null)
312                                 return false;
313                 } else if (!msgHeader.equals(other.msgHeader))
314                         return false;
315                 if (msgSource == null) {
316                         if (other.msgSource != null)
317                                 return false;
318                 } else if (!msgSource.equals(other.msgSource))
319                         return false;
320                 if (notificationId == null) {
321                         if (other.notificationId != null)
322                                 return false;
323                 } else if (!notificationId.equals(other.notificationId))
324                         return false;
325                 if (priority == null) {
326                         if (other.priority != null)
327                                 return false;
328                 } else if (!priority.equals(other.priority))
329                         return false;
330                 if (roleIds == null) {
331                         if (other.roleIds != null)
332                                 return false;
333                 } else if (!roleIds.equals(other.roleIds))
334                         return false;
335                 if (roles == null) {
336                         if (other.roles != null)
337                                 return false;
338                 } else if (!roles.equals(other.roles))
339                         return false;
340                 if (startTime == null) {
341                         if (other.startTime != null)
342                                 return false;
343                 } else if (!startTime.equals(other.startTime))
344                         return false;
345                 return true;
346         }
347
348         @Override
349         public String toString() {
350                 return "EpNotificationItem [notificationId=" + notificationId + ", isForOnlineUsers=" + isForOnlineUsers
351                                 + ", isForAllRoles=" + isForAllRoles + ", activeYn=" + activeYn + ", msgHeader=" + msgHeader
352                                 + ", msgDescription=" + msgDescription + ", msgSource=" + msgSource + ", startTime=" + startTime
353                                 + ", endTime=" + endTime + ", priority=" + priority + ", creatorId=" + creatorId + ", createdDate="
354                                 + createdDate + ", roles=" + roles + ", roleIds=" + roleIds + "]";
355         }
356         
357 }