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 java.sql.Timestamp;
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import javax.persistence.Basic;
23 import javax.persistence.CascadeType;
24 import javax.persistence.Column;
25 import javax.persistence.Entity;
26 import javax.persistence.FetchType;
27 import javax.persistence.Id;
28 import javax.persistence.JoinColumn;
29 import javax.persistence.Lob;
30 import javax.persistence.OneToMany;
31 import javax.persistence.OneToOne;
32 import javax.persistence.Table;
33 import javax.persistence.Version;
34
35 import org.apache.commons.lang.StringUtils;
36 import org.apache.commons.lang.builder.ToStringBuilder;
37 import org.kuali.rice.ken.util.NotificationConstants;
38
39
40
41
42
43
44 @Entity
45 @Table(name="KREN_NTFCTN_T")
46 public class Notification implements Lockable {
47 @Id
48 @Column(name="NTFCTN_ID")
49 private Long id;
50 @Column(name="DELIV_TYP", nullable=false)
51 private String deliveryType;
52 @Column(name="CRTE_DTTM", nullable=false)
53 private Timestamp creationDateTime;
54 @Column(name="SND_DTTM", nullable=true)
55 private Timestamp sendDateTime;
56 @Column(name="AUTO_RMV_DTTM", nullable=true)
57 private Timestamp autoRemoveDateTime;
58 @Column(name="TTL", nullable=true)
59 private String title;
60 @Lob
61 @Basic(fetch=FetchType.LAZY)
62 @Column(name="CNTNT", nullable=false)
63 private String content;
64 @Column(name="PROCESSING_FLAG", nullable=false)
65 private String processingFlag;
66 @Column(name="LOCKD_DTTM", nullable=true)
67 private Timestamp lockedDate;
68
69
70
71 @Version
72 @Column(name="VER_NBR")
73 private Integer lockVerNbr;
74
75
76 @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
77 @JoinColumn(name="PRIO_ID")
78 private NotificationPriority priority;
79 @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
80 @JoinColumn(name="CNTNT_TYP_ID")
81 private NotificationContentType contentType;
82 @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
83 @JoinColumn(name="CHNL_ID")
84 private NotificationChannel channel;
85 @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
86 @JoinColumn(name="PRODCR_ID")
87 private NotificationProducer producer;
88
89
90 @OneToMany(cascade={CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE},
91 targetEntity=org.kuali.rice.ken.bo.NotificationRecipient.class, mappedBy="notification")
92 private List<NotificationRecipient> recipients;
93 @OneToMany(cascade={CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE},
94 targetEntity=org.kuali.rice.ken.bo.NotificationSender.class, mappedBy="notification")
95 private List<NotificationSender> senders;
96
97
98
99
100 public Notification() {
101 recipients = new ArrayList<NotificationRecipient>();
102 senders = new ArrayList<NotificationSender>();
103 processingFlag = NotificationConstants.PROCESSING_FLAGS.UNRESOLVED;
104 }
105
106
107
108
109
110 public Timestamp getCreationDateTime() {
111 return creationDateTime;
112 }
113
114
115
116
117
118 public void setCreationDateTime(Timestamp created) {
119 this.creationDateTime = created;
120 }
121
122
123
124
125
126 public Integer getLockVerNbr() {
127 return lockVerNbr;
128 }
129
130
131
132
133
134 public void setLockVerNbr(Integer lockVerNbr) {
135 this.lockVerNbr = lockVerNbr;
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
404
405
406
407 public String toString() {
408 return new ToStringBuilder(this)
409 .append("id", id)
410 .append("deliveryType", deliveryType)
411 .append("sendDateTime", sendDateTime)
412 .append("autoRemoveDateTime", autoRemoveDateTime)
413 .append("content", StringUtils.abbreviate(content, 100))
414 .append("processingFlag", processingFlag)
415 .append("lockedDate", lockedDate)
416 .append("lockVerNbr", lockVerNbr)
417 .append("priority", priority)
418 .append("contentType", contentType)
419 .append("channel", channel)
420 .append("producer", producer)
421 .append("recipients", recipients == null ? null : "" + recipients.size())
422 .append("senders", senders == null ? null : "" + senders.size()).toString();
423 }
424 }