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