Coverage Report - org.kuali.rice.kns.bo.Note
 
Classes in this File Line Coverage Branch Coverage Complexity
Note
0%
0/56
N/A
1
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  * 
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  * 
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.kuali.rice.kns.bo;
 18  
 
 19  
 import org.hibernate.annotations.GenericGenerator;
 20  
 import org.hibernate.annotations.Parameter;
 21  
 import org.kuali.rice.kim.bo.Person;
 22  
 import org.kuali.rice.kim.service.KIMServiceLocator;
 23  
 import org.kuali.rice.kns.service.KNSServiceLocator;
 24  
 import org.kuali.rice.kns.util.KNSConstants;
 25  
 
 26  
 import javax.persistence.*;
 27  
 import java.sql.Timestamp;
 28  
 
 29  
 /**
 30  
  * Represents a user note in the system.
 31  
  */
 32  
 @Entity
 33  
 @Table(name="KRNS_NTE_T")
 34  
 public class Note extends PersistableBusinessObjectBase {
 35  
     private static final long serialVersionUID = -7647166354016356770L;
 36  
 
 37  
     @Id
 38  
     @GeneratedValue(generator="KRNS_NTE_S")
 39  
         @GenericGenerator(name="KRNS_NTE_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
 40  
                         @Parameter(name="sequence_name",value="KRNS_NTE_S"),
 41  
                         @Parameter(name="value_column",value="id")
 42  
         })
 43  
         @Column(name="NTE_ID")
 44  
         private Long noteIdentifier;
 45  
     @Column(name="RMT_OBJ_ID")
 46  
         private String remoteObjectIdentifier;
 47  
     @Column(name="AUTH_PRNCPL_ID")
 48  
         private String authorUniversalIdentifier;
 49  
         @Column(name="POST_TS")
 50  
         private Timestamp notePostedTimestamp;
 51  
     @Column(name="NTE_TYP_CD")
 52  
         private String noteTypeCode;
 53  
     @Column(name="TXT")
 54  
         private String noteText;
 55  
     @Column(name="TPC_TXT")
 56  
         private String noteTopicText;
 57  
     @Column(name="PRG_CD")
 58  
         private String notePurgeCode;
 59  
     @Transient
 60  
     private String attachmentIdentifier;
 61  
 
 62  
     @OneToOne(fetch=FetchType.EAGER)
 63  
         @JoinColumn(name="NTE_TYP_CD", insertable=false, updatable=false)
 64  
         private NoteType noteType;
 65  
     @Transient
 66  
     private Person authorUniversal;
 67  
     @OneToOne(fetch = FetchType.EAGER, cascade = { CascadeType.ALL })
 68  
         @JoinColumn(name = "NTE_ID", insertable = false, updatable = false)
 69  
         private Attachment attachment;
 70  
     @Transient
 71  
     private AdHocRouteRecipient adHocRouteRecipient;
 72  
 
 73  
     /**
 74  
      * Default constructor.
 75  
      */
 76  
     public Note() {
 77  0
         super();
 78  
 
 79  
         //this.setNotePostedTimestampToCurrent();
 80  0
         this.setNoteText(KNSConstants.EMPTY_STRING);
 81  
         // for now just do this
 82  0
         this.setNoteTypeCode("DH");
 83  
 
 84  0
         this.setAdHocRouteRecipient(new AdHocRoutePerson());
 85  0
     }
 86  
     
 87  
     /**
 88  
      * Sets the {@link #setNotePostedTimestamp(Timestamp)} to the current time.
 89  
      */
 90  
     public void setNotePostedTimestampToCurrent() {
 91  0
             final Timestamp now = KNSServiceLocator.getDateTimeService().getCurrentTimestamp();
 92  0
             this.setNotePostedTimestamp(now);
 93  0
     }
 94  
 
 95  
     /**
 96  
      * Gets the noteIdentifier attribute.
 97  
      * 
 98  
      * @return Returns the noteIdentifier.
 99  
      */
 100  
     public Long getNoteIdentifier() {
 101  0
         return noteIdentifier;
 102  
     }
 103  
 
 104  
     /**
 105  
      * Sets the noteIdentifier attribute value.
 106  
      * 
 107  
      * @param noteIdentifier The noteIdentifier to set.
 108  
      */
 109  
     public void setNoteIdentifier(Long noteIdentifier) {
 110  0
         this.noteIdentifier = noteIdentifier;
 111  0
     }
 112  
 
 113  
     /**
 114  
      * Gets the remoteObjectIdentifier attribute.
 115  
      * 
 116  
      * @return Returns the remoteObjectIdentifier
 117  
      */
 118  
     public String getRemoteObjectIdentifier() {
 119  0
         return remoteObjectIdentifier;
 120  
     }
 121  
 
 122  
     /**
 123  
      * Sets the remoteObjectIdentifier attribute.
 124  
      * 
 125  
      * @param remoteObjectIdentifier The remoteObjectIdentifier to set.
 126  
      */
 127  
     public void setRemoteObjectIdentifier(String remoteObjectIdentifier) {
 128  0
         this.remoteObjectIdentifier = remoteObjectIdentifier;
 129  0
     }
 130  
 
 131  
 
 132  
     /**
 133  
      * Gets the authorUniversalIdentifier attribute.
 134  
      * 
 135  
      * @return Returns the authorUniversalIdentifier
 136  
      */
 137  
     public String getAuthorUniversalIdentifier() {
 138  0
         return authorUniversalIdentifier;
 139  
     }
 140  
 
 141  
     /**
 142  
      * Sets the authorUniversalIdentifier attribute.
 143  
      * 
 144  
      * @param noteAuthorIdentifier The author ID to be set as the AuthorUniversalIdentifier
 145  
      */
 146  
     public void setAuthorUniversalIdentifier(String noteAuthorIdentifier) {
 147  0
         this.authorUniversalIdentifier = noteAuthorIdentifier;
 148  0
     }
 149  
 
 150  
 
 151  
     /**
 152  
      * Gets the notePostedTimestamp attribute.
 153  
      * 
 154  
      * @return Returns the notePostedTimestamp
 155  
      */
 156  
     public Timestamp getNotePostedTimestamp() {
 157  0
         return notePostedTimestamp;
 158  
     }
 159  
 
 160  
     /**
 161  
      * Sets the notePostedTimestamp attribute.
 162  
      * 
 163  
      * @param notePostedTimestamp The notePostedTimestamp to set.
 164  
      */
 165  
     public void setNotePostedTimestamp(Timestamp notePostedTimestamp) {
 166  0
         this.notePostedTimestamp = notePostedTimestamp;
 167  0
     }
 168  
 
 169  
 
 170  
     /**
 171  
      * Gets the noteTypeCode attribute.
 172  
      * 
 173  
      * @return Returns the noteTypeCode
 174  
      */
 175  
     public String getNoteTypeCode() {
 176  0
         return noteTypeCode;
 177  
     }
 178  
 
 179  
     /**
 180  
      * Sets the noteTypeCode attribute.
 181  
      * 
 182  
      * @param noteTypeCode The noteTypeCode to set.
 183  
      */
 184  
     public void setNoteTypeCode(String noteTypeCode) {
 185  0
         this.noteTypeCode = noteTypeCode;
 186  0
     }
 187  
 
 188  
 
 189  
     /**
 190  
      * Gets the noteText attribute.
 191  
      * 
 192  
      * @return Returns the noteText
 193  
      */
 194  
     public String getNoteText() {
 195  0
         return noteText;
 196  
     }
 197  
 
 198  
     /**
 199  
      * Sets the noteText attribute.
 200  
      * 
 201  
      * @param noteText The noteText to set.
 202  
      */
 203  
     public void setNoteText(String noteText) {
 204  0
         this.noteText = noteText;
 205  0
     }
 206  
 
 207  
 
 208  
     /**
 209  
      * Gets the noteTopicText attribute.
 210  
      * 
 211  
      * @return Returns the noteTopicText.
 212  
      */
 213  
     public String getNoteTopicText() {
 214  0
         return noteTopicText;
 215  
     }
 216  
 
 217  
     /**
 218  
      * Sets the noteTopicText attribute value.
 219  
      * 
 220  
      * @param noteTopicText The noteTopicText to set.
 221  
      */
 222  
     public void setNoteTopicText(String noteTopicText) {
 223  0
         this.noteTopicText = noteTopicText;
 224  0
     }
 225  
 
 226  
     /**
 227  
      * Gets the notePurgeCode attribute.
 228  
      * 
 229  
      * @return Returns the notePurgeCode
 230  
      */
 231  
     public String getNotePurgeCode() {
 232  0
         return notePurgeCode;
 233  
     }
 234  
 
 235  
     /**
 236  
      * Sets the notePurgeCode attribute.
 237  
      * 
 238  
      * @param notePurgeCode The notePurgeCode to set.
 239  
      */
 240  
     public void setNotePurgeCode(String notePurgeCode) {
 241  0
         this.notePurgeCode = notePurgeCode;
 242  0
     }
 243  
 
 244  
     /**
 245  
      * Gets the noteType attribute.
 246  
      * 
 247  
      * @return Returns the noteType.
 248  
      */
 249  
     public NoteType getNoteType() {
 250  0
         return noteType;
 251  
     }
 252  
 
 253  
     /**
 254  
      * Sets the noteType attribute value.
 255  
      * 
 256  
      * @param noteType The noteType to set.
 257  
      * @deprecated
 258  
      */
 259  
     public void setNoteType(NoteType noteType) {
 260  0
         this.noteType = noteType;
 261  0
     }
 262  
 
 263  
     /**
 264  
      * Gets the authorUniversal attribute.
 265  
      * 
 266  
      * @return Returns the authorUniversal.
 267  
      */
 268  
     public Person getAuthorUniversal() {
 269  0
         authorUniversal = KIMServiceLocator.getPersonService().updatePersonIfNecessary(authorUniversalIdentifier, authorUniversal);
 270  0
         return authorUniversal;
 271  
     }
 272  
 
 273  
     /**
 274  
      * Sets the authorUniversal attribute value.
 275  
      * 
 276  
      * @param authorUniversal The authorUniversal to set.
 277  
      * @deprecated
 278  
      */
 279  
     public void setAuthorUniversal(Person authorUniversal) {
 280  0
         this.authorUniversal = authorUniversal;
 281  0
     }
 282  
 
 283  
     /**
 284  
      * Gets the attachment attribute.
 285  
      * 
 286  
      * @return Returns the attachment.
 287  
      */
 288  
     public Attachment getAttachment() {
 289  0
         return attachment;
 290  
     }
 291  
 
 292  
     /**
 293  
      * Sets the attachment attribute value.
 294  
      * 
 295  
      * @param attachment The attachment to set.
 296  
      */
 297  
     public void setAttachment(Attachment attachment) {
 298  0
         this.attachment = attachment;
 299  0
     }
 300  
 
 301  
     /**
 302  
      * Gets the attachmentIdentifier attribute.
 303  
      * 
 304  
      * @return Returns the attachmentIdentifier.
 305  
      */
 306  
     public String getAttachmentIdentifier() {
 307  0
         return attachmentIdentifier;
 308  
     }
 309  
 
 310  
     /**
 311  
      * Sets the attachmentIdentifier attribute value.
 312  
      * 
 313  
      * @param attachmentIdentifier The attachmentIdentifier to set.
 314  
      */
 315  
     public void setAttachmentIdentifier(String attachmentIdentifier) {
 316  0
         this.attachmentIdentifier = attachmentIdentifier;
 317  0
     }
 318  
 
 319  
     /**
 320  
      * Adds the given attachment to this note. More specifically, sets both the attachmentIdentifier and the attachment reference,
 321  
      * since they both need to be done separately now that we aren't using anonymous keys.
 322  
      * 
 323  
      * @param attachment
 324  
      */
 325  
     public void addAttachment(Attachment attachment) {
 326  0
         setAttachmentIdentifier(attachment.getAttachmentIdentifier());
 327  0
         setAttachment(attachment);
 328  
 
 329  
         // copy foreign key and redundant values into attachment
 330  0
         attachment.setNoteIdentifier(noteIdentifier);
 331  
         // we'll need this note reference if the attachment is deleted
 332  
         // before the note is saved
 333  0
         attachment.setNote(this);
 334  0
     }
 335  
 
 336  
     /**
 337  
      * Removes the current attachment, if any. More specifically, clears both the attachmentIdentifier and the attachment reference,
 338  
      * since they both need to be done separately now that we aren't using anonymous keys.
 339  
      */
 340  
     public void removeAttachment() {
 341  0
         setAttachment(null);
 342  0
         setAttachmentIdentifier(null);
 343  0
     }
 344  
 
 345  
     /**
 346  
      * @return the adHocRouteRecipient
 347  
      */
 348  
     public AdHocRouteRecipient getAdHocRouteRecipient() {
 349  0
         return adHocRouteRecipient;
 350  
     }
 351  
 
 352  
     /**
 353  
      * @param adHocRouteRecipient the adHocRouteRecipient to set
 354  
      */
 355  
     public void setAdHocRouteRecipient(AdHocRouteRecipient adHocRouteRecipient) {
 356  0
         this.adHocRouteRecipient = adHocRouteRecipient;
 357  0
     }
 358  
 
 359  
 }
 360  
 
 361