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