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