Coverage Report - org.kuali.rice.kew.notes.Attachment
 
Classes in this File Line Coverage Branch Coverage Complexity
Attachment
0%
0/29
0%
0/4
1.176
 
 1  
 /*
 2  
  * Copyright 2005-2008 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.io.InputStream;
 20  
 
 21  
 import javax.persistence.CascadeType;
 22  
 import javax.persistence.Column;
 23  
 import javax.persistence.Entity;
 24  
 import javax.persistence.FetchType;
 25  
 import javax.persistence.Id;
 26  
 import javax.persistence.JoinColumn;
 27  
 import javax.persistence.ManyToOne;
 28  
 import javax.persistence.NamedQueries;
 29  
 import javax.persistence.NamedQuery;
 30  
 import javax.persistence.PrePersist;
 31  
 import javax.persistence.Table;
 32  
 import javax.persistence.Transient;
 33  
 import javax.persistence.Version;
 34  
 
 35  
 import org.kuali.rice.core.jpa.annotations.Sequence;
 36  
 import org.kuali.rice.core.util.OrmUtils;
 37  
 import org.kuali.rice.kns.service.KNSServiceLocator;
 38  
 
 39  
 /**
 40  
  * An attachment which is attached to a {@link Note}.
 41  
  * 
 42  
  * @see Note
 43  
  *
 44  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 45  
  */
 46  
 @Entity
 47  
 @Table(name="KREW_ATT_T")
 48  
 @Sequence(name="KREW_DOC_NTE_S",property="attachmentId")
 49  
 @NamedQueries({
 50  
         @NamedQuery(name="Attachment.FindAttachmentById",query="select a from Attachment as a where a.attachmentId = :attachmentId")
 51  
 })
 52  0
 public class Attachment {
 53  
 
 54  
         @Id
 55  
         @Column(name="ATTACHMENT_ID")
 56  
         private Long attachmentId;
 57  
         @Transient
 58  
         private Long noteId;
 59  
         @Column(name="FILE_NM")
 60  
         private String fileName;
 61  
         @Column(name="FILE_LOC")
 62  
         private String fileLoc;
 63  
         @Column(name="MIME_TYP")
 64  
         private String mimeType;
 65  
         @Version
 66  
         @Column(name="VER_NBR")
 67  
         private Integer lockVerNbr;
 68  
     @Transient
 69  
         private InputStream attachedObject;
 70  
         @ManyToOne(fetch=FetchType.EAGER)
 71  
         @JoinColumn(name="NTE_ID")
 72  
         private Note note;
 73  
         
 74  
         public Long getAttachmentId() {
 75  0
                 return attachmentId;
 76  
         }
 77  
         public void setAttachmentId(Long attachmentId) {
 78  0
                 this.attachmentId = attachmentId;
 79  0
         }
 80  
         public String getFileLoc() {
 81  0
                 return fileLoc;
 82  
         }
 83  
         public void setFileLoc(String fileLoc) {
 84  0
                 this.fileLoc = fileLoc;
 85  0
         }
 86  
         public String getFileName() {
 87  0
                 return fileName;
 88  
         }
 89  
         public void setFileName(String fileName) {
 90  0
                 this.fileName = fileName;
 91  0
         }
 92  
         public Integer getLockVerNbr() {
 93  0
                 return lockVerNbr;
 94  
         }
 95  
         public void setLockVerNbr(Integer lockVerNbr) {
 96  0
                 this.lockVerNbr = lockVerNbr;
 97  0
         }
 98  
         public String getMimeType() {
 99  0
                 return mimeType;
 100  
         }
 101  
         public void setMimeType(String mimeType) {
 102  0
                 this.mimeType = mimeType;
 103  0
         }
 104  
         public Long getNoteId() {
 105  
                 //noteId field not mapped in JPA 
 106  0
                 if (noteId == null && note != null){
 107  0
                         return note.getNoteId();
 108  
                 }
 109  0
                 return noteId;
 110  
         }
 111  
         public void setNoteId(Long noteId) {
 112  0
                 this.noteId = noteId;
 113  0
         }
 114  
         public Note getNote() {
 115  0
                 return note;
 116  
         }
 117  
         public void setNote(Note note) {
 118  0
                 this.note = note;
 119  0
         }
 120  
         public InputStream getAttachedObject() {
 121  0
                 return attachedObject;
 122  
         }
 123  
         public void setAttachedObject(InputStream attachedObject) {
 124  0
                 this.attachedObject = attachedObject;
 125  0
         }
 126  
         
 127  
         @PrePersist
 128  
         public void beforeInsert(){
 129  0
                 OrmUtils.populateAutoIncValue(this, KNSServiceLocator.getEntityManagerFactory().createEntityManager());                
 130  0
         }
 131  
 
 132  
 }
 133