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