1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.labs;
17
18
19 import org.kuali.rice.krad.bo.DataObjectBase;
20 import org.kuali.rice.krad.bo.PersistableAttachment;
21 import org.kuali.rice.krad.data.provider.annotation.Description;
22 import org.kuali.rice.krad.data.provider.annotation.Label;
23 import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViewType;
24 import org.kuali.rice.krad.data.provider.annotation.UifAutoCreateViews;
25 import org.kuali.rice.krad.data.provider.annotation.UifDisplayHint;
26 import org.kuali.rice.krad.data.provider.annotation.UifDisplayHintType;
27 import org.kuali.rice.krad.data.provider.annotation.UifDisplayHints;
28 import org.kuali.rice.krad.data.provider.annotation.UifValidCharactersConstraintBeanName;
29 import org.kuali.rice.krad.uif.util.SessionTransient;
30 import org.springframework.web.multipart.MultipartFile;
31 import javax.persistence.Column;
32 import javax.persistence.Entity;
33 import javax.persistence.Id;
34 import javax.persistence.JoinColumn;
35 import javax.persistence.ManyToOne;
36 import javax.persistence.Table;
37 import javax.validation.constraints.NotNull;
38 import java.io.Serializable;
39
40
41
42
43 @Entity
44 @Table(name="trv_att_sample")
45 @UifAutoCreateViews({UifAutoCreateViewType.INQUIRY,UifAutoCreateViewType.LOOKUP})
46 public class LabsTravelAttachment extends DataObjectBase implements PersistableAttachment, Serializable {
47
48 @Id
49 @Column(name="ATTACHMENT_ID",length=30)
50 @Label("Id")
51 @Description("Unique identifier for the attachment")
52 @UifValidCharactersConstraintBeanName("AlphaNumericPatternConstraint")
53 private String id;
54
55 @ManyToOne
56 @JoinColumn(name = "ATT_GRP_NUM" ,insertable=false, updatable=false)
57 LabsTravelAttachmentGroup labsTravelAttachmentGroup;
58
59 @Id
60 @Column(name = "ATT_GRP_NUM",length = 10)
61 @Label("Travel Attachment Group Number")
62 @NotNull
63 private String travelAttachmentGroupNumber;
64
65 @Column(name="DESCRIPTION",length=100)
66 @Label("Description")
67 @Description("Descriptor for the attachment")
68 @UifDisplayHints({
69 @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_CRITERIA)})
70 private String description;
71
72 @Column(name="ATTACHMENT_FILENAME",length=300)
73 @Label("File Name")
74 @Description("File name of the attachment")
75 @UifDisplayHints({
76 @UifDisplayHint(UifDisplayHintType.NO_INQUIRY),
77 @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_CRITERIA),
78 @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_RESULT)})
79 private String fileName;
80
81 @Column(name="ATTACHMENT_FILE_CONTENT_TYPE",length=255)
82 @Label("Content Type")
83 @Description("Content Type of the attachment")
84 @UifDisplayHints({
85 @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_RESULT)})
86 private String contentType;
87
88 @Column(name="ATTACHMENT_FILE")
89 @Label("Attachment Content")
90 @Description("Content of the attachment")
91 @UifDisplayHints({
92 @UifDisplayHint(UifDisplayHintType.NO_INQUIRY),
93 @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_CRITERIA),
94 @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_RESULT)})
95 private byte[] attachmentContent;
96
97 @Label("Attachment File")
98 @Description("File of the attachment")
99 @SessionTransient
100 private transient MultipartFile attachmentFile;
101
102 public String getId() {
103 return id;
104 }
105
106 public void setId(String id) {
107 this.id = id;
108 }
109
110 public String getDescription() {
111 return description;
112 }
113
114 public void setDescription(String description) {
115 this.description = description;
116 }
117
118 public String getFileName() {
119 return fileName;
120 }
121
122 public void setFileName(String fileName) {
123 this.fileName = fileName;
124 }
125
126 public String getContentType() {
127 return contentType;
128 }
129
130 public void setContentType(String contentType) {
131 this.contentType = contentType;
132 }
133
134 public byte[] getAttachmentContent() {
135 return attachmentContent;
136 }
137
138 public void setAttachmentContent(byte[] attachmentContent) {
139 this.attachmentContent = attachmentContent;
140 }
141
142 public MultipartFile getAttachmentFile() {
143 return attachmentFile;
144 }
145
146 public void setAttachmentFile(MultipartFile attachmentFile) {
147
148 if(attachmentFile != null) {
149 setContentType(attachmentFile.getContentType());
150 setFileName(attachmentFile.getOriginalFilename());
151 try {
152 setAttachmentContent(attachmentFile.getBytes());
153
154 }catch (Exception e) {
155 throw new RuntimeException(e);
156 }
157 }
158 }
159
160 public LabsTravelAttachmentGroup getLabsTravelAttachmentGroup() {
161 return labsTravelAttachmentGroup;
162 }
163
164 public void setLabsTravelAttachmentGroup(LabsTravelAttachmentGroup labsTravelAttachmentGroup) {
165 this.labsTravelAttachmentGroup = labsTravelAttachmentGroup;
166 }
167
168 public String getTravelAttachmentGroupNumber() {
169 return travelAttachmentGroupNumber;
170 }
171
172 public void setTravelAttachmentGroupNumber(String travelAttachmentGroupNumber) {
173 this.travelAttachmentGroupNumber = travelAttachmentGroupNumber;
174 }
175 }