1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ken.bo;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.hibernate.annotations.GenericGenerator;
20 import org.hibernate.annotations.Parameter;
21 import org.kuali.rice.ken.util.NotificationConstants;
22 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
23
24 import javax.persistence.*;
25 import java.sql.Timestamp;
26 import java.util.ArrayList;
27 import java.util.List;
28
29
30
31
32
33
34 @Entity
35 @Table(name="KREN_NTFCTN_T")
36 public class Notification extends PersistableBusinessObjectBase implements Lockable {
37
38 @Id
39 @GeneratedValue(generator="KREN_NTFCTN_S")
40 @GenericGenerator(name="KREN_NTFCTN_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
41 @Parameter(name="sequence_name",value="KREN_NTFCTN_S"),
42 @Parameter(name="value_column",value="id")
43 })
44 @Column(name="NTFCTN_ID")
45 private Long id;
46 @Column(name="DELIV_TYP", nullable=false)
47 private String deliveryType;
48 @Column(name="CRTE_DTTM", nullable=false)
49 private Timestamp creationDateTime;
50 @Column(name="SND_DTTM", nullable=true)
51 private Timestamp sendDateTime;
52 @Column(name="AUTO_RMV_DTTM", nullable=true)
53 private Timestamp autoRemoveDateTime;
54 @Column(name="TTL", nullable=true)
55 private String title;
56 @Lob
57 @Basic(fetch=FetchType.LAZY)
58 @Column(name="CNTNT", nullable=false)
59 private String content;
60 @Column(name="PROCESSING_FLAG", nullable=false)
61 private String processingFlag;
62 @Column(name="LOCKD_DTTM", nullable=true)
63 private Timestamp lockedDate;
64
65
66
67
68
69
70
71
72 @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH, CascadeType.DETACH})
73 @JoinColumn(name="PRIO_ID")
74 private NotificationPriority priority;
75 @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH, CascadeType.DETACH})
76 @JoinColumn(name="CNTNT_TYP_ID")
77 private NotificationContentType contentType;
78 @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH, CascadeType.DETACH})
79 @JoinColumn(name="CHNL_ID")
80 private NotificationChannel channel;
81 @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH, CascadeType.DETACH})
82 @JoinColumn(name="PRODCR_ID")
83 private NotificationProducer producer;
84
85
86 @OneToMany(cascade={CascadeType.ALL},
87 targetEntity=org.kuali.rice.ken.bo.NotificationRecipient.class, mappedBy="notification")
88 @OrderBy("id ASC")
89 private List<NotificationRecipient> recipients;
90 @OneToMany(cascade={CascadeType.ALL},
91 targetEntity=org.kuali.rice.ken.bo.NotificationSender.class, mappedBy="notification")
92 @OrderBy("id ASC")
93 private List<NotificationSender> senders;
94
95
96
97
98 public Notification() {
99 recipients = new ArrayList<NotificationRecipient>();
100 senders = new ArrayList<NotificationSender>();
101 processingFlag = NotificationConstants.PROCESSING_FLAGS.UNRESOLVED;
102 }
103
104
105
106
107
108 public Timestamp getCreationDateTime() {
109 return creationDateTime;
110 }
111
112
113
114
115
116 public void setCreationDateTime(Timestamp created) {
117 this.creationDateTime = created;
118 }
119
120
121
122
123
124
125 public Integer getLockVerNbr() {
126 return Integer.valueOf(super.getVersionNumber().intValue());
127 }
128
129
130
131
132
133
134 public void setLockVerNbr(Integer lockVerNbr) {
135 super.setVersionNumber(lockVerNbr.longValue());
136 }
137
138
139
140
141
142 public List<NotificationRecipient> getRecipients() {
143 return recipients;
144 }
145
146
147
148
149
150 public void setRecipients(List<NotificationRecipient> recipients) {
151 this.recipients = recipients;
152 }
153
154
155
156
157
158
159 public NotificationRecipient getRecipient(int index) {
160 return (NotificationRecipient) recipients.get(index);
161 }
162
163
164
165
166
167 public void addRecipient(NotificationRecipient recipient) {
168 recipients.add(recipient);
169 }
170
171
172
173
174
175 public List<NotificationSender> getSenders() {
176 return senders;
177 }
178
179
180
181
182
183 public void setSenders(List<NotificationSender> senders) {
184 this.senders = senders;
185 }
186
187
188
189
190
191
192 public NotificationSender getSender(int index) {
193 return (NotificationSender) senders.get(index);
194 }
195
196
197
198
199 public void addSender(NotificationSender sender) {
200 senders.add(sender);
201 }
202
203
204
205
206
207 public Timestamp getAutoRemoveDateTime() {
208 return autoRemoveDateTime;
209 }
210
211
212
213
214
215 public void setAutoRemoveDateTime(Timestamp autoRemoveDateTime) {
216 this.autoRemoveDateTime = autoRemoveDateTime;
217 }
218
219
220
221
222
223 public NotificationChannel getChannel() {
224 return channel;
225 }
226
227
228
229
230
231 public void setChannel(NotificationChannel channel) {
232 this.channel = channel;
233 }
234
235
236
237
238
239 public String getContent() {
240 return content;
241 }
242
243
244
245
246
247 public void setContent(String content) {
248 this.content = content;
249 }
250
251
252
253
254
255 public NotificationContentType getContentType() {
256 return contentType;
257 }
258
259
260
261
262
263 public void setContentType(NotificationContentType contentType) {
264 this.contentType = contentType;
265 }
266
267
268
269
270
271 public String getDeliveryType() {
272 return deliveryType;
273 }
274
275
276
277
278
279 public void setDeliveryType(String deliveryType) {
280 this.deliveryType = deliveryType.toUpperCase();
281 }
282
283
284
285
286
287 public Long getId() {
288 return id;
289 }
290
291
292
293
294
295 public void setId(Long id) {
296 this.id = id;
297 }
298
299
300
301
302
303 public NotificationPriority getPriority() {
304 return priority;
305 }
306
307
308
309
310
311 public void setPriority(NotificationPriority priority) {
312 this.priority = priority;
313 }
314
315
316
317
318
319 public NotificationProducer getProducer() {
320 return producer;
321 }
322
323
324
325
326
327 public void setProducer(NotificationProducer producer) {
328 this.producer = producer;
329 }
330
331
332
333
334
335 public Timestamp getSendDateTime() {
336 return sendDateTime;
337 }
338
339
340
341
342
343 public void setSendDateTime(Timestamp sendDateTime) {
344 this.sendDateTime = sendDateTime;
345 }
346
347
348
349
350
351 public String getProcessingFlag() {
352 return processingFlag;
353 }
354
355
356
357
358
359 public void setProcessingFlag(String processingFlag) {
360 this.processingFlag = processingFlag;
361 }
362
363
364
365
366
367 public Timestamp getLockedDate() {
368 return lockedDate;
369 }
370
371
372
373
374
375 public void setLockedDate(Timestamp lockedDate) {
376 this.lockedDate = lockedDate;
377 }
378
379
380
381
382
383 public String getTitle() {
384 return title;
385 }
386
387
388
389
390
391 public void setTitle(String title) {
392 this.title = title;
393 }
394
395
396
397
398
399
400 public String getContentMessage() {
401 return StringUtils.substringBetween(content, NotificationConstants.XML_MESSAGE_CONSTANTS.MESSAGE_OPEN, NotificationConstants.XML_MESSAGE_CONSTANTS.MESSAGE_CLOSE);
402 }
403 }