1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
40
41
42
43
44
45 @Entity(name="org.kuali.rice.kew.notes.Attachment")
46 @Table(name="KREW_ATT_T")
47
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 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 return attachmentId;
80 }
81 public void setAttachmentId(String attachmentId) {
82 this.attachmentId = attachmentId;
83 }
84 public String getFileLoc() {
85 return fileLoc;
86 }
87 public void setFileLoc(String fileLoc) {
88 this.fileLoc = fileLoc;
89 }
90 public String getFileName() {
91 return fileName;
92 }
93 public void setFileName(String fileName) {
94 this.fileName = fileName;
95 }
96 public Integer getLockVerNbr() {
97 return lockVerNbr;
98 }
99 public void setLockVerNbr(Integer lockVerNbr) {
100 this.lockVerNbr = lockVerNbr;
101 }
102 public String getMimeType() {
103 return mimeType;
104 }
105 public void setMimeType(String mimeType) {
106 this.mimeType = mimeType;
107 }
108 public String getNoteId() {
109
110 if (noteId == null && note != null){
111 return note.getNoteId();
112 }
113 return noteId;
114 }
115 public void setNoteId(String noteId) {
116 this.noteId = noteId;
117 }
118 public Note getNote() {
119 return note;
120 }
121 public void setNote(Note note) {
122 this.note = note;
123 }
124 public InputStream getAttachedObject() {
125 return attachedObject;
126 }
127 public void setAttachedObject(InputStream attachedObject) {
128 this.attachedObject = attachedObject;
129 }
130
131
132 public void beforeInsert(){
133 OrmUtils.populateAutoIncValue(this, KRADServiceLocator.getEntityManagerFactory().createEntityManager());
134 }
135
136 }
137