[PORTAL-16 PORTAL-18] Widget ms; staging
[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         
93         @OneToMany(fetch = FetchType.LAZY, cascade = {CascadeType.ALL}, orphanRemoval = true)
94         @JoinColumn(name="notification_ID")
95         private Set<EpRoleNotificationItem> roles;
96         
97         @Transient
98         private List<Long> roleIds;
99         
100         public Long getNotificationId() {
101                 return notificationId;
102         }
103
104         public void setNotificationId(Long notificationId) {
105                 this.notificationId = notificationId;
106         }
107
108         public String getIsForOnlineUsers() {
109                 return isForOnlineUsers;
110         }
111
112         public void setIsForOnlineUsers(String isForOnlineUsers) {
113                 this.isForOnlineUsers = isForOnlineUsers;
114         }
115
116         public String getIsForAllRoles() {
117                 return isForAllRoles;
118         }
119
120         public void setIsForAllRoles(String isForAllRoles) {
121                 this.isForAllRoles = isForAllRoles;
122         }
123         
124         public String getActiveYn() {
125                 return activeYn;
126         }
127
128         public void setActiveYn(String activeYn) {
129                 this.activeYn = activeYn;
130         }
131
132         public String getMsgHeader() {
133                 return msgHeader;
134         }
135
136         public void setMsgHeader(String msgHeader) {
137                 this.msgHeader = msgHeader;
138         }
139
140         public String getMsgDescription() {
141                 return msgDescription;
142         }
143
144         public void setMsgDescription(String msgDescription) {
145                 this.msgDescription = msgDescription;
146         }
147
148         public Date getStartTime() {
149                 return startTime;
150         }
151
152         public void setStartTime(Date startTime) {
153                 this.startTime = startTime;
154         }
155
156         public Date getEndTime() {
157                 return endTime;
158         }
159
160         public void setEndTime(Date endTime) {
161                 this.endTime = endTime;
162         }
163
164         public Long getPriority() {
165                 return priority;
166         }
167
168         public void setPriority(Long priority) {
169                 this.priority = priority;
170         }
171
172         public Long getCreatorId() {
173                 return creatorId;
174         }
175
176         public void setCreatorId(Long creatorId) {
177                 this.creatorId = creatorId;
178         }
179
180         public Date getCreatedDate() {
181                 return createdDate;
182         }
183
184         public void setCreatedDate(Date createdDate) {
185                 this.createdDate = createdDate;
186         }
187
188         public static long getSerialversionuid() {
189                 return serialVersionUID;
190         }
191
192         public Set<EpRoleNotificationItem> getRoles() {
193                 return roles;
194         }
195
196         public void setRoles(Set<EpRoleNotificationItem> roles) {
197                 this.roles = roles;
198         }
199
200         public List<Long> getRoleIds() {
201                 return roleIds;
202         }
203
204         public void setRoleIds(List<Long> roleIds) {
205                 this.roleIds = roleIds;
206         }
207         
208         public String getMsgSource() {
209                 return msgSource;
210         }
211
212         public void setMsgSource(String msgSource) {
213                 this.msgSource = msgSource;
214         }
215
216         @Override
217         public int hashCode() {
218                 final int prime = 31;
219                 int result = 1;
220                 result = prime * result + ((activeYn == null) ? 0 : activeYn.hashCode());
221                 result = prime * result + ((createdDate == null) ? 0 : createdDate.hashCode());
222                 result = prime * result + ((creatorId == null) ? 0 : creatorId.hashCode());
223                 result = prime * result + ((endTime == null) ? 0 : endTime.hashCode());
224                 result = prime * result + ((isForAllRoles == null) ? 0 : isForAllRoles.hashCode());
225                 result = prime * result + ((isForOnlineUsers == null) ? 0 : isForOnlineUsers.hashCode());
226                 result = prime * result + ((msgDescription == null) ? 0 : msgDescription.hashCode());
227                 result = prime * result + ((msgHeader == null) ? 0 : msgHeader.hashCode());
228                 result = prime * result + ((msgSource == null) ? 0 : msgSource.hashCode());
229                 result = prime * result + ((notificationId == null) ? 0 : notificationId.hashCode());
230                 result = prime * result + ((priority == null) ? 0 : priority.hashCode());
231                 result = prime * result + ((roleIds == null) ? 0 : roleIds.hashCode());
232                 result = prime * result + ((roles == null) ? 0 : roles.hashCode());
233                 result = prime * result + ((startTime == null) ? 0 : startTime.hashCode());
234                 return result;
235         }
236
237         @Override
238         public boolean equals(Object obj) {
239                 if (this == obj)
240                         return true;
241                 if (obj == null)
242                         return false;
243                 if (getClass() != obj.getClass())
244                         return false;
245                 EpNotificationItem other = (EpNotificationItem) obj;
246                 if (activeYn == null) {
247                         if (other.activeYn != null)
248                                 return false;
249                 } else if (!activeYn.equals(other.activeYn))
250                         return false;
251                 if (createdDate == null) {
252                         if (other.createdDate != null)
253                                 return false;
254                 } else if (!createdDate.equals(other.createdDate))
255                         return false;
256                 if (creatorId == null) {
257                         if (other.creatorId != null)
258                                 return false;
259                 } else if (!creatorId.equals(other.creatorId))
260                         return false;
261                 if (endTime == null) {
262                         if (other.endTime != null)
263                                 return false;
264                 } else if (!endTime.equals(other.endTime))
265                         return false;
266                 if (isForAllRoles == null) {
267                         if (other.isForAllRoles != null)
268                                 return false;
269                 } else if (!isForAllRoles.equals(other.isForAllRoles))
270                         return false;
271                 if (isForOnlineUsers == null) {
272                         if (other.isForOnlineUsers != null)
273                                 return false;
274                 } else if (!isForOnlineUsers.equals(other.isForOnlineUsers))
275                         return false;
276                 if (msgDescription == null) {
277                         if (other.msgDescription != null)
278                                 return false;
279                 } else if (!msgDescription.equals(other.msgDescription))
280                         return false;
281                 if (msgHeader == null) {
282                         if (other.msgHeader != null)
283                                 return false;
284                 } else if (!msgHeader.equals(other.msgHeader))
285                         return false;
286                 if (msgSource == null) {
287                         if (other.msgSource != null)
288                                 return false;
289                 } else if (!msgSource.equals(other.msgSource))
290                         return false;
291                 if (notificationId == null) {
292                         if (other.notificationId != null)
293                                 return false;
294                 } else if (!notificationId.equals(other.notificationId))
295                         return false;
296                 if (priority == null) {
297                         if (other.priority != null)
298                                 return false;
299                 } else if (!priority.equals(other.priority))
300                         return false;
301                 if (roleIds == null) {
302                         if (other.roleIds != null)
303                                 return false;
304                 } else if (!roleIds.equals(other.roleIds))
305                         return false;
306                 if (roles == null) {
307                         if (other.roles != null)
308                                 return false;
309                 } else if (!roles.equals(other.roles))
310                         return false;
311                 if (startTime == null) {
312                         if (other.startTime != null)
313                                 return false;
314                 } else if (!startTime.equals(other.startTime))
315                         return false;
316                 return true;
317         }
318
319         @Override
320         public String toString() {
321                 return "EpNotificationItem [notificationId=" + notificationId + ", isForOnlineUsers=" + isForOnlineUsers
322                                 + ", isForAllRoles=" + isForAllRoles + ", activeYn=" + activeYn + ", msgHeader=" + msgHeader
323                                 + ", msgDescription=" + msgDescription + ", msgSource=" + msgSource + ", startTime=" + startTime
324                                 + ", endTime=" + endTime + ", priority=" + priority + ", creatorId=" + creatorId + ", createdDate="
325                                 + createdDate + ", roles=" + roles + ", roleIds=" + roleIds + "]";
326         }
327         
328 }