Coverage Report - org.kuali.rice.kew.notes.Note
 
Classes in this File Line Coverage Branch Coverage Complexity
Note
0%
0/62
N/A
1
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.notes;
 18  
 
 19  
 import java.sql.Timestamp;
 20  
 import java.text.DateFormat;
 21  
 import java.text.SimpleDateFormat;
 22  
 import java.util.ArrayList;
 23  
 import java.util.Calendar;
 24  
 import java.util.Date;
 25  
 import java.util.List;
 26  
 
 27  
 import javax.persistence.CascadeType;
 28  
 import javax.persistence.Column;
 29  
 import javax.persistence.Entity;
 30  
 import javax.persistence.FetchType;
 31  
 import javax.persistence.Id;
 32  
 import javax.persistence.NamedQueries;
 33  
 import javax.persistence.NamedQuery;
 34  
 import javax.persistence.OneToMany;
 35  
 import javax.persistence.PrePersist;
 36  
 import javax.persistence.Table;
 37  
 import javax.persistence.Transient;
 38  
 import javax.persistence.Version;
 39  
 
 40  
 import org.kuali.rice.core.jpa.annotations.Sequence;
 41  
 import org.kuali.rice.core.util.OrmUtils;
 42  
 import org.kuali.rice.core.util.RiceConstants;
 43  
 import org.kuali.rice.kew.bo.WorkflowPersistable;
 44  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 45  
 import org.kuali.rice.kew.util.KEWConstants;
 46  
 
 47  
 
 48  
 /**
 49  
  * A note attached to a document.  May also contain a List of attachments.
 50  
  * 
 51  
  * @see Attachment
 52  
  *
 53  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 54  
  */
 55  
 @Entity
 56  
 @Table(name="KREW_DOC_NTE_T")
 57  
 @Sequence(name="KREW_DOC_NTE_S",property="noteId")
 58  
 @NamedQueries({
 59  
         @NamedQuery(name="KewNote.FindNoteByNoteId",query="select n from Note as n where n.noteId = :noteId"),
 60  
         @NamedQuery(name="KewNote.FindNoteByRouteHeaderId", query="select n from Note as n where n.routeHeaderId = :routeHeaderId order by n.noteId")
 61  
 })
 62  0
 public class Note implements WorkflowPersistable {
 63  
 
 64  
         private static final long serialVersionUID = -6136544551121011531L;
 65  
         @Id
 66  
         @Column(name="DOC_NTE_ID")
 67  
         private Long noteId;
 68  
     @Column(name="DOC_HDR_ID")
 69  
         private Long routeHeaderId;
 70  
     @Column(name="AUTH_PRNCPL_ID")
 71  
         private String noteAuthorWorkflowId;
 72  
         @Column(name="CRT_DT")
 73  
         private Timestamp noteCreateDate;
 74  
     @Column(name="TXT")
 75  
         private String noteText;
 76  
     @Version
 77  
         @Column(name="VER_NBR")
 78  
         private Integer lockVerNbr;
 79  
         
 80  0
     @OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST},
 81  
             targetEntity=org.kuali.rice.kew.notes.Attachment.class, mappedBy="note")
 82  
     private List<Attachment> attachments = new ArrayList<Attachment>();
 83  
 
 84  
     //additional data not in database
 85  
     @Transient
 86  
     private String noteAuthorEmailAddress;
 87  
     @Transient
 88  
     private String noteAuthorNetworkId;
 89  
     @Transient
 90  
     private String noteAuthorFullName;
 91  
     @Transient
 92  
     private Long noteCreateLongDate;
 93  
     @Transient
 94  
     private Boolean authorizedToEdit; 
 95  
     @Transient
 96  
     private Boolean editingNote;
 97  
     
 98  
     public Integer getLockVerNbr() {
 99  0
         return lockVerNbr;
 100  
     }
 101  
 
 102  
     public void setLockVerNbr(Integer lockVerNbr) {
 103  0
         this.lockVerNbr = lockVerNbr;
 104  0
     }
 105  
 
 106  
     public String getNoteAuthorWorkflowId() {
 107  0
         return noteAuthorWorkflowId;
 108  
     }
 109  
 
 110  
     public void setNoteAuthorWorkflowId(String noteAuthorWorkflowId) {
 111  0
         this.noteAuthorWorkflowId = noteAuthorWorkflowId;
 112  0
     }
 113  
 
 114  
     public Timestamp getNoteCreateDate() {
 115  0
         return noteCreateDate;
 116  
     }
 117  
 
 118  
     public void setNoteCreateDate(Timestamp noteCreateDate) {
 119  0
         this.noteCreateDate = noteCreateDate;
 120  0
     }
 121  
 
 122  
     public Long getNoteId() {
 123  0
         return noteId;
 124  
     }
 125  
  
 126  
     public void setNoteId(Long noteId) {
 127  0
         this.noteId = noteId;
 128  0
     }
 129  
  
 130  
     public String getNoteText() {
 131  0
         return noteText;
 132  
     }
 133  
 
 134  
     public void setNoteText(String noteText) {
 135  0
         this.noteText = noteText;
 136  0
     }
 137  
 
 138  
     public Long getRouteHeaderId() {
 139  0
         return routeHeaderId;
 140  
     }
 141  
 
 142  
     public void setRouteHeaderId(Long routeHeaderId) {
 143  0
         this.routeHeaderId = routeHeaderId;
 144  0
     }
 145  
 
 146  
     public String getNoteAuthorEmailAddress() {
 147  0
         return noteAuthorEmailAddress;
 148  
     }
 149  
  
 150  
     public void setNoteAuthorEmailAddress(String noteAuthorEmailAddress) {
 151  0
         this.noteAuthorEmailAddress = noteAuthorEmailAddress;
 152  0
     }
 153  
 
 154  
     public String getNoteAuthorFullName() {
 155  0
         return noteAuthorFullName;
 156  
     }
 157  
 
 158  
     public void setNoteAuthorFullName(String noteAuthorFullName) {
 159  0
         this.noteAuthorFullName = noteAuthorFullName;
 160  0
     }
 161  
 
 162  
     public String getNoteAuthorNetworkId() {
 163  0
         return noteAuthorNetworkId;
 164  
     }
 165  
 
 166  
     public void setNoteAuthorNetworkId(String noteAuthorNetworkId) {
 167  0
         this.noteAuthorNetworkId = noteAuthorNetworkId;
 168  0
     }
 169  
 
 170  
     public Long getNoteCreateLongDate() {
 171  0
         return noteCreateLongDate;
 172  
     }
 173  
 
 174  
     public void setNoteCreateLongDate(Long noteCreateLongDate) {
 175  0
         this.noteCreateLongDate = noteCreateLongDate;
 176  0
     }
 177  
 
 178  
     public Boolean getAuthorizedToEdit() {
 179  0
         return authorizedToEdit;
 180  
     }
 181  
 
 182  
     public void setAuthorizedToEdit(Boolean authorizedToEdit) {
 183  0
         this.authorizedToEdit = authorizedToEdit;
 184  0
     }
 185  
 
 186  
     public Boolean getEditingNote() {
 187  0
         return editingNote;
 188  
     }
 189  
 
 190  
     public void setEditingNote(Boolean editingNote) {
 191  0
         this.editingNote = editingNote;
 192  0
     }
 193  
 
 194  
     public String getFormattedCreateDateTime() {
 195  0
         long time = getNoteCreateDate().getTime();
 196  0
         Calendar calendar = Calendar.getInstance();
 197  0
         calendar.setTimeInMillis(time);
 198  0
         Date date = calendar.getTime();
 199  0
         DateFormat dateFormat = new SimpleDateFormat(KEWConstants.TIMESTAMP_DATE_FORMAT_PATTERN2);
 200  0
         return dateFormat.format(date);
 201  
     }
 202  
 
 203  
     public String getFormattedCreateDate() {
 204  0
         long time = getNoteCreateDate().getTime();
 205  0
         Calendar calendar = Calendar.getInstance();
 206  0
         calendar.setTimeInMillis(time);
 207  0
         Date date = calendar.getTime();
 208  0
         DateFormat dateFormat = RiceConstants.getDefaultDateFormat();
 209  0
         return dateFormat.format(date);
 210  
     }
 211  
     
 212  
     public String getFormattedCreateTime() {
 213  0
         long time = getNoteCreateDate().getTime();
 214  0
         Calendar calendar = Calendar.getInstance();
 215  0
         calendar.setTimeInMillis(time);
 216  0
         Date date = calendar.getTime();
 217  0
         DateFormat dateFormat = RiceConstants.getDefaultTimeFormat();
 218  0
         return dateFormat.format(date);
 219  
     }
 220  
     
 221  
     public Object copy(boolean preserveKeys) {
 222  0
         return null;
 223  
     }
 224  
 
 225  
         public List<Attachment> getAttachments() {
 226  0
                 return attachments;
 227  
         }
 228  
 
 229  
         public void setAttachments(List<Attachment> attachments) {
 230  0
                 this.attachments = attachments;
 231  0
         }
 232  
         
 233  
         @PrePersist
 234  
         public void beforeInsert(){
 235  0
                 OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager());                
 236  0
         }
 237  
         
 238  
 
 239  
 }
 240