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.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 @UifDisplayHints({
101 @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_CRITERIA),
102 @UifDisplayHint(UifDisplayHintType.NO_LOOKUP_RESULT)})
103 private transient MultipartFile attachmentFile;
104
105 public String getId() {
106 return id;
107 }
108
109 public void setId(String id) {
110 this.id = id;
111 }
112
113 public String getDescription() {
114 return description;
115 }
116
117 public void setDescription(String description) {
118 this.description = description;
119 }
120
121 public String getFileName() {
122 return fileName;
123 }
124
125 public void setFileName(String fileName) {
126 this.fileName = fileName;
127 }
128
129 public String getContentType() {
130 return contentType;
131 }
132
133 public void setContentType(String contentType) {
134 this.contentType = contentType;
135 }
136
137 public byte[] getAttachmentContent() {
138 return attachmentContent;
139 }
140
141 public void setAttachmentContent(byte[] attachmentContent) {
142 this.attachmentContent = attachmentContent;
143 }
144
145 public MultipartFile getAttachmentFile() {
146 return attachmentFile;
147 }
148
149 public void setAttachmentFile(MultipartFile attachmentFile) {
150
151 if(attachmentFile != null) {
152 setContentType(attachmentFile.getContentType());
153 setFileName(attachmentFile.getOriginalFilename());
154 try {
155 setAttachmentContent(attachmentFile.getBytes());
156
157 }catch (Exception e) {
158 throw new RuntimeException(e);
159 }
160 }
161 }
162
163 public LabsTravelAttachmentGroup getLabsTravelAttachmentGroup() {
164 return labsTravelAttachmentGroup;
165 }
166
167 public void setLabsTravelAttachmentGroup(LabsTravelAttachmentGroup labsTravelAttachmentGroup) {
168 this.labsTravelAttachmentGroup = labsTravelAttachmentGroup;
169 }
170
171 public String getTravelAttachmentGroupNumber() {
172 return travelAttachmentGroupNumber;
173 }
174
175 public void setTravelAttachmentGroupNumber(String travelAttachmentGroupNumber) {
176 this.travelAttachmentGroupNumber = travelAttachmentGroupNumber;
177 }
178 }