Coverage Report - org.kuali.rice.krad.bo.Note
 
Classes in this File Line Coverage Branch Coverage Complexity
Note
0%
0/56
N/A
1
 
 1  
 /**
 2  
  * Copyright 2005-2011 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  
 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  
  * Represents a user note in the system.
 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  
      * Default constructor.
 83  
      */
 84  
     public Note() {
 85  0
         super();
 86  
 
 87  
         //this.setNotePostedTimestampToCurrent();
 88  0
         this.setNoteText(KRADConstants.EMPTY_STRING);
 89  
         // for now just do this
 90  0
         this.setNoteTypeCode("DH");
 91  
 
 92  0
         this.setAdHocRouteRecipient(new AdHocRoutePerson());
 93  0
     }
 94  
     
 95  
     /**
 96  
      * Sets the {@link #setNotePostedTimestamp(Timestamp)} to the current time.
 97  
      */
 98  
     public void setNotePostedTimestampToCurrent() {
 99  0
             final Timestamp now = CoreApiServiceLocator.getDateTimeService().getCurrentTimestamp();
 100  0
             this.setNotePostedTimestamp(now);
 101  0
     }
 102  
 
 103  
     /**
 104  
      * Gets the noteIdentifier attribute.
 105  
      * 
 106  
      * @return Returns the noteIdentifier.
 107  
      */
 108  
     public Long getNoteIdentifier() {
 109  0
         return noteIdentifier;
 110  
     }
 111  
 
 112  
     /**
 113  
      * Sets the noteIdentifier attribute value.
 114  
      * 
 115  
      * @param noteIdentifier The noteIdentifier to set.
 116  
      */
 117  
     public void setNoteIdentifier(Long noteIdentifier) {
 118  0
         this.noteIdentifier = noteIdentifier;
 119  0
     }
 120  
 
 121  
     /**
 122  
      * Gets the remoteObjectIdentifier attribute.
 123  
      * 
 124  
      * @return Returns the remoteObjectIdentifier
 125  
      */
 126  
     public String getRemoteObjectIdentifier() {
 127  0
         return remoteObjectIdentifier;
 128  
     }
 129  
 
 130  
     /**
 131  
      * Sets the remoteObjectIdentifier attribute.
 132  
      * 
 133  
      * @param remoteObjectIdentifier The remoteObjectIdentifier to set.
 134  
      */
 135  
     public void setRemoteObjectIdentifier(String remoteObjectIdentifier) {
 136  0
         this.remoteObjectIdentifier = remoteObjectIdentifier;
 137  0
     }
 138  
 
 139  
 
 140  
     /**
 141  
      * Gets the authorUniversalIdentifier attribute.
 142  
      * 
 143  
      * @return Returns the authorUniversalIdentifier
 144  
      */
 145  
     public String getAuthorUniversalIdentifier() {
 146  0
         return authorUniversalIdentifier;
 147  
     }
 148  
 
 149  
     /**
 150  
      * Sets the authorUniversalIdentifier attribute.
 151  
      * 
 152  
      * @param noteAuthorIdentifier The author ID to be set as the AuthorUniversalIdentifier
 153  
      */
 154  
     public void setAuthorUniversalIdentifier(String noteAuthorIdentifier) {
 155  0
         this.authorUniversalIdentifier = noteAuthorIdentifier;
 156  0
     }
 157  
 
 158  
 
 159  
     /**
 160  
      * Gets the notePostedTimestamp attribute.
 161  
      * 
 162  
      * @return Returns the notePostedTimestamp
 163  
      */
 164  
     public Timestamp getNotePostedTimestamp() {
 165  0
         return notePostedTimestamp;
 166  
     }
 167  
 
 168  
     /**
 169  
      * Sets the notePostedTimestamp attribute.
 170  
      * 
 171  
      * @param notePostedTimestamp The notePostedTimestamp to set.
 172  
      */
 173  
     public void setNotePostedTimestamp(Timestamp notePostedTimestamp) {
 174  0
         this.notePostedTimestamp = notePostedTimestamp;
 175  0
     }
 176  
 
 177  
 
 178  
     /**
 179  
      * Gets the noteTypeCode attribute.
 180  
      * 
 181  
      * @return Returns the noteTypeCode
 182  
      */
 183  
     public String getNoteTypeCode() {
 184  0
         return noteTypeCode;
 185  
     }
 186  
 
 187  
     /**
 188  
      * Sets the noteTypeCode attribute.
 189  
      * 
 190  
      * @param noteTypeCode The noteTypeCode to set.
 191  
      */
 192  
     public void setNoteTypeCode(String noteTypeCode) {
 193  0
         this.noteTypeCode = noteTypeCode;
 194  0
     }
 195  
 
 196  
 
 197  
     /**
 198  
      * Gets the noteText attribute.
 199  
      * 
 200  
      * @return Returns the noteText
 201  
      */
 202  
     public String getNoteText() {
 203  0
         return noteText;
 204  
     }
 205  
 
 206  
     /**
 207  
      * Sets the noteText attribute.
 208  
      * 
 209  
      * @param noteText The noteText to set.
 210  
      */
 211  
     public void setNoteText(String noteText) {
 212  0
         this.noteText = noteText;
 213  0
     }
 214  
 
 215  
 
 216  
     /**
 217  
      * Gets the noteTopicText attribute.
 218  
      * 
 219  
      * @return Returns the noteTopicText.
 220  
      */
 221  
     public String getNoteTopicText() {
 222  0
         return noteTopicText;
 223  
     }
 224  
 
 225  
     /**
 226  
      * Sets the noteTopicText attribute value.
 227  
      * 
 228  
      * @param noteTopicText The noteTopicText to set.
 229  
      */
 230  
     public void setNoteTopicText(String noteTopicText) {
 231  0
         this.noteTopicText = noteTopicText;
 232  0
     }
 233  
 
 234  
     /**
 235  
      * Gets the notePurgeCode attribute.
 236  
      * 
 237  
      * @return Returns the notePurgeCode
 238  
      */
 239  
     public String getNotePurgeCode() {
 240  0
         return notePurgeCode;
 241  
     }
 242  
 
 243  
     /**
 244  
      * Sets the notePurgeCode attribute.
 245  
      * 
 246  
      * @param notePurgeCode The notePurgeCode to set.
 247  
      */
 248  
     public void setNotePurgeCode(String notePurgeCode) {
 249  0
         this.notePurgeCode = notePurgeCode;
 250  0
     }
 251  
 
 252  
     /**
 253  
      * Gets the noteType attribute.
 254  
      * 
 255  
      * @return Returns the noteType.
 256  
      */
 257  
     public NoteType getNoteType() {
 258  0
         return noteType;
 259  
     }
 260  
 
 261  
     /**
 262  
      * Sets the noteType attribute value.
 263  
      * 
 264  
      * @param noteType The noteType to set.
 265  
      * @deprecated
 266  
      */
 267  
     public void setNoteType(NoteType noteType) {
 268  0
         this.noteType = noteType;
 269  0
     }
 270  
 
 271  
     /**
 272  
      * Gets the authorUniversal attribute.
 273  
      * 
 274  
      * @return Returns the authorUniversal.
 275  
      */
 276  
     public Person getAuthorUniversal() {
 277  0
         authorUniversal = KimApiServiceLocator.getPersonService().updatePersonIfNecessary(authorUniversalIdentifier, authorUniversal);
 278  0
         return authorUniversal;
 279  
     }
 280  
 
 281  
     /**
 282  
      * Sets the authorUniversal attribute value.
 283  
      * 
 284  
      * @param authorUniversal The authorUniversal to set.
 285  
      * @deprecated
 286  
      */
 287  
     public void setAuthorUniversal(Person authorUniversal) {
 288  0
         this.authorUniversal = authorUniversal;
 289  0
     }
 290  
 
 291  
     /**
 292  
      * Gets the attachment attribute.
 293  
      * 
 294  
      * @return Returns the attachment.
 295  
      */
 296  
     public Attachment getAttachment() {
 297  0
         return attachment;
 298  
     }
 299  
 
 300  
     /**
 301  
      * Sets the attachment attribute value.
 302  
      * 
 303  
      * @param attachment The attachment to set.
 304  
      */
 305  
     public void setAttachment(Attachment attachment) {
 306  0
         this.attachment = attachment;
 307  0
     }
 308  
 
 309  
     /**
 310  
      * Gets the attachmentIdentifier attribute.
 311  
      * 
 312  
      * @return Returns the attachmentIdentifier.
 313  
      */
 314  
     public String getAttachmentIdentifier() {
 315  0
         return attachmentIdentifier;
 316  
     }
 317  
 
 318  
     /**
 319  
      * Sets the attachmentIdentifier attribute value.
 320  
      * 
 321  
      * @param attachmentIdentifier The attachmentIdentifier to set.
 322  
      */
 323  
     public void setAttachmentIdentifier(String attachmentIdentifier) {
 324  0
         this.attachmentIdentifier = attachmentIdentifier;
 325  0
     }
 326  
 
 327  
     /**
 328  
      * Adds the given attachment to this note. More specifically, sets both the attachmentIdentifier and the attachment reference,
 329  
      * since they both need to be done separately now that we aren't using anonymous keys.
 330  
      * 
 331  
      * @param attachment
 332  
      */
 333  
     public void addAttachment(Attachment attachment) {
 334  0
         setAttachmentIdentifier(attachment.getAttachmentIdentifier());
 335  0
         setAttachment(attachment);
 336  
 
 337  
         // copy foreign key and redundant values into attachment
 338  0
         attachment.setNoteIdentifier(noteIdentifier);
 339  
         // we'll need this note reference if the attachment is deleted
 340  
         // before the note is saved
 341  0
         attachment.setNote(this);
 342  0
     }
 343  
 
 344  
     /**
 345  
      * Removes the current attachment, if any. More specifically, clears both the attachmentIdentifier and the attachment reference,
 346  
      * since they both need to be done separately now that we aren't using anonymous keys.
 347  
      */
 348  
     public void removeAttachment() {
 349  0
         setAttachment(null);
 350  0
         setAttachmentIdentifier(null);
 351  0
     }
 352  
 
 353  
     /**
 354  
      * @return the adHocRouteRecipient
 355  
      */
 356  
     public AdHocRouteRecipient getAdHocRouteRecipient() {
 357  0
         return adHocRouteRecipient;
 358  
     }
 359  
 
 360  
     /**
 361  
      * @param adHocRouteRecipient the adHocRouteRecipient to set
 362  
      */
 363  
     public void setAdHocRouteRecipient(AdHocRouteRecipient adHocRouteRecipient) {
 364  0
         this.adHocRouteRecipient = adHocRouteRecipient;
 365  0
     }
 366  
 
 367  
 }
 368  
 
 369