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