1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.travel.bo;
17
18 import java.util.ArrayList;
19 import java.util.LinkedHashMap;
20 import java.util.List;
21
22 import javax.persistence.CascadeType;
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.FetchType;
26 import javax.persistence.Id;
27 import javax.persistence.JoinColumn;
28 import javax.persistence.ManyToOne;
29 import javax.persistence.Table;
30
31 import org.apache.struts.upload.FormFile;
32 import org.kuali.rice.kns.bo.PersistableAttachment;
33 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
34
35 @Entity
36 @Table(name="TRV_ATTACH_SAMPLE_T")
37 public class AttachmentSample extends PersistableBusinessObjectBase implements PersistableAttachment {
38
39 @Id
40 @Column(name="attachment_id")
41 private String id;
42 @Column(name="description")
43 private String description;
44 @Column(name="attachment_filename")
45 private String fileName;
46 @Column(name="attachment_file_content_type")
47 private String contentType;
48 @Column(name="attachment_file")
49 private byte[] attachmentContent;
50
51 private transient FormFile attachmentFile;
52
53
54 @ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST, CascadeType.MERGE})
55 @JoinColumn(name="attachment_id", insertable=false, updatable=false)
56 private List<MultiAttachmentSample> multiAttachment;
57
58 public AttachmentSample() {
59 this.multiAttachment = new ArrayList<MultiAttachmentSample>();
60 }
61 public String getId() {
62 return this.id;
63 }
64
65 public void setId(String id) {
66 this.id = id;
67 }
68
69 public String getDescription() {
70 return this.description;
71 }
72
73 public void setDescription(String description) {
74 this.description = description;
75 }
76
77 public String getFileName() {
78 return this.fileName;
79 }
80
81 public void setFileName(String fileName) {
82 this.fileName = fileName;
83 }
84
85 public String getContentType() {
86 return this.contentType;
87 }
88
89 public void setContentType(String contentType) {
90 this.contentType = contentType;
91 }
92
93 public byte[] getAttachmentContent() {
94 return this.attachmentContent;
95 }
96
97 public void setAttachmentContent(byte[] attachmentContent) {
98 this.attachmentContent = attachmentContent;
99 }
100
101 public FormFile getAttachmentFile() {
102 return getAttachmentFile();
103 }
104
105 public void setAttachmentFile(FormFile attachmentFile) {
106 this.attachmentFile = attachmentFile;
107 }
108
109 public List<MultiAttachmentSample> getMultiAttachment() {
110 return this.multiAttachment;
111 }
112 public void setMultiAttachment(List<MultiAttachmentSample> multiAttachment) {
113 this.multiAttachment = multiAttachment;
114 }
115
116 @Override
117 protected LinkedHashMap toStringMapper() {
118 LinkedHashMap<String, Object> toStringMap = new LinkedHashMap<String, Object>();
119 toStringMap.put("id", id);
120 return toStringMap;
121 }
122
123 @Override
124 public List buildListOfDeletionAwareLists() {
125 List managedLists = super.buildListOfDeletionAwareLists();
126 managedLists.add(this.multiAttachment);
127 return managedLists;
128 }
129
130 }