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