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.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 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
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 | |
|
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 | |
|