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