1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.bo;
17
18 import org.hibernate.annotations.GenericGenerator;
19 import org.hibernate.annotations.Parameter;
20 import org.kuali.rice.core.api.CoreApiServiceLocator;
21 import org.kuali.rice.kim.api.identity.Person;
22 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
23 import org.kuali.rice.krad.service.KRADServiceLocator;
24 import org.kuali.rice.krad.util.KRADConstants;
25 import org.kuali.rice.krad.util.UrlFactory;
26
27 import javax.persistence.CascadeType;
28 import javax.persistence.Column;
29 import javax.persistence.Entity;
30 import javax.persistence.FetchType;
31 import javax.persistence.GeneratedValue;
32 import javax.persistence.Id;
33 import javax.persistence.JoinColumn;
34 import javax.persistence.OneToOne;
35 import javax.persistence.Table;
36 import javax.persistence.Transient;
37 import java.sql.Timestamp;
38 import java.util.Properties;
39
40
41
42
43 @Entity
44 @Table(name="KRNS_NTE_T")
45 public class Note extends PersistableBusinessObjectBase {
46 private static final long serialVersionUID = -7647166354016356770L;
47
48 @Id
49 @GeneratedValue(generator="KRNS_NTE_S")
50 @GenericGenerator(name="KRNS_NTE_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
51 @Parameter(name="sequence_name",value="KRNS_NTE_S"),
52 @Parameter(name="value_column",value="id")
53 })
54 @Column(name="NTE_ID")
55 private Long noteIdentifier;
56 @Column(name="RMT_OBJ_ID")
57 private String remoteObjectIdentifier;
58 @Column(name="AUTH_PRNCPL_ID")
59 private String authorUniversalIdentifier;
60 @Column(name="POST_TS")
61 private Timestamp notePostedTimestamp;
62 @Column(name="NTE_TYP_CD")
63 private String noteTypeCode;
64 @Column(name="TXT")
65 private String noteText;
66 @Column(name="TPC_TXT")
67 private String noteTopicText;
68 @Column(name="PRG_CD")
69 private String notePurgeCode;
70 @Transient
71 private String attachmentIdentifier;
72
73 @OneToOne(fetch=FetchType.EAGER)
74 @JoinColumn(name="NTE_TYP_CD", insertable=false, updatable=false)
75 private NoteType noteType;
76 @Transient
77 private transient Person authorUniversal;
78 @OneToOne(fetch = FetchType.EAGER, cascade = { CascadeType.ALL })
79 @JoinColumn(name = "NTE_ID", insertable = false, updatable = false)
80 private Attachment attachment;
81 @Transient
82 private AdHocRouteRecipient adHocRouteRecipient;
83
84
85
86
87 public Note() {
88 super();
89
90
91 this.setNoteText(KRADConstants.EMPTY_STRING);
92
93 this.setNoteTypeCode("DH");
94
95 this.setAdHocRouteRecipient(new AdHocRoutePerson());
96 }
97
98
99
100
101 public void setNotePostedTimestampToCurrent() {
102 final Timestamp now = CoreApiServiceLocator.getDateTimeService().getCurrentTimestamp();
103 this.setNotePostedTimestamp(now);
104 }
105
106
107
108
109
110
111 public Long getNoteIdentifier() {
112 return noteIdentifier;
113 }
114
115
116
117
118
119
120 public void setNoteIdentifier(Long noteIdentifier) {
121 this.noteIdentifier = noteIdentifier;
122 }
123
124
125
126
127
128
129 public String getRemoteObjectIdentifier() {
130 return remoteObjectIdentifier;
131 }
132
133
134
135
136
137
138 public void setRemoteObjectIdentifier(String remoteObjectIdentifier) {
139 this.remoteObjectIdentifier = remoteObjectIdentifier;
140 }
141
142
143
144
145
146
147
148 public String getAuthorUniversalIdentifier() {
149 return authorUniversalIdentifier;
150 }
151
152
153
154
155
156
157 public void setAuthorUniversalIdentifier(String noteAuthorIdentifier) {
158 this.authorUniversalIdentifier = noteAuthorIdentifier;
159 }
160
161
162
163
164
165
166
167 public Timestamp getNotePostedTimestamp() {
168 return notePostedTimestamp;
169 }
170
171
172
173
174
175
176 public void setNotePostedTimestamp(Timestamp notePostedTimestamp) {
177 this.notePostedTimestamp = notePostedTimestamp;
178 }
179
180
181
182
183
184
185
186 public String getNoteTypeCode() {
187 return noteTypeCode;
188 }
189
190
191
192
193
194
195 public void setNoteTypeCode(String noteTypeCode) {
196 this.noteTypeCode = noteTypeCode;
197 }
198
199
200
201
202
203
204
205 public String getNoteText() {
206 return noteText;
207 }
208
209
210
211
212
213
214 public void setNoteText(String noteText) {
215 this.noteText = noteText;
216 }
217
218
219
220
221
222
223
224 public String getNoteTopicText() {
225 return noteTopicText;
226 }
227
228
229
230
231
232
233 public void setNoteTopicText(String noteTopicText) {
234 this.noteTopicText = noteTopicText;
235 }
236
237
238
239
240
241
242 public String getNotePurgeCode() {
243 return notePurgeCode;
244 }
245
246
247
248
249
250
251 public void setNotePurgeCode(String notePurgeCode) {
252 this.notePurgeCode = notePurgeCode;
253 }
254
255
256
257
258
259
260 public NoteType getNoteType() {
261 return noteType;
262 }
263
264
265
266
267
268
269
270 public void setNoteType(NoteType noteType) {
271 this.noteType = noteType;
272 }
273
274
275
276
277
278
279 public Person getAuthorUniversal() {
280 authorUniversal = KimApiServiceLocator.getPersonService().updatePersonIfNecessary(authorUniversalIdentifier, authorUniversal);
281 return authorUniversal;
282 }
283
284
285
286
287
288
289
290 public void setAuthorUniversal(Person authorUniversal) {
291 this.authorUniversal = authorUniversal;
292 }
293
294
295
296
297
298
299 public Attachment getAttachment() {
300 return attachment;
301 }
302
303
304
305
306
307
308 public void setAttachment(Attachment attachment) {
309 this.attachment = attachment;
310 }
311
312
313
314
315
316
317 public String getAttachmentIdentifier() {
318 return attachmentIdentifier;
319 }
320
321
322
323
324
325
326 public void setAttachmentIdentifier(String attachmentIdentifier) {
327 this.attachmentIdentifier = attachmentIdentifier;
328 }
329
330
331
332
333
334
335
336 public void addAttachment(Attachment attachment) {
337 setAttachmentIdentifier(attachment.getAttachmentIdentifier());
338 setAttachment(attachment);
339
340
341 attachment.setNoteIdentifier(noteIdentifier);
342
343
344 attachment.setNote(this);
345 }
346
347
348
349
350
351 public void removeAttachment() {
352 setAttachment(null);
353 setAttachmentIdentifier(null);
354 }
355
356
357
358
359 public AdHocRouteRecipient getAdHocRouteRecipient() {
360 return adHocRouteRecipient;
361 }
362
363
364
365
366 public void setAdHocRouteRecipient(AdHocRouteRecipient adHocRouteRecipient) {
367 this.adHocRouteRecipient = adHocRouteRecipient;
368 }
369
370
371
372 public String getAttachmentLink() {
373
374 if(KRADServiceLocator.getAttachmentService().getAttachmentByNoteId(this.getNoteIdentifier()) == null){
375 return "";
376 }else{
377 Properties params = new Properties();
378 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.DOWNLOAD_BO_ATTACHMENT_METHOD);
379 params.put(KRADConstants.DOC_FORM_KEY, "88888888");
380 params.put(KRADConstants.NOTE_IDENTIFIER, this.getNoteIdentifier().toString());
381 return UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params);
382 }
383 }
384 }
385
386