001 /*
002 * Copyright 2007-2011 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package edu.sampleu.travel.bo;
017
018 import java.util.ArrayList;
019 import java.util.LinkedHashMap;
020 import java.util.List;
021
022 import javax.persistence.CascadeType;
023 import javax.persistence.Column;
024 import javax.persistence.Entity;
025 import javax.persistence.FetchType;
026 import javax.persistence.Id;
027 import javax.persistence.JoinColumn;
028 import javax.persistence.ManyToOne;
029 import javax.persistence.Table;
030
031 import org.apache.struts.upload.FormFile;
032 import org.kuali.rice.kns.bo.PersistableAttachment;
033 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
034
035 @Entity
036 @Table(name="TRV_ATTACH_SAMPLE_T")
037 public class AttachmentSample extends PersistableBusinessObjectBase implements PersistableAttachment {
038
039 @Id
040 @Column(name="attachment_id")
041 private String id;
042 @Column(name="description")
043 private String description;
044 @Column(name="attachment_filename")
045 private String fileName;
046 @Column(name="attachment_file_content_type")
047 private String contentType;
048 @Column(name="attachment_file")
049 private byte[] attachmentContent;
050
051 private transient FormFile attachmentFile;
052
053
054 @ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST, CascadeType.MERGE})
055 @JoinColumn(name="attachment_id", insertable=false, updatable=false)
056 private List<MultiAttachmentSample> multiAttachment;
057
058 public AttachmentSample() {
059 this.multiAttachment = new ArrayList<MultiAttachmentSample>();
060 }
061 public String getId() {
062 return this.id;
063 }
064
065 public void setId(String id) {
066 this.id = id;
067 }
068
069 public String getDescription() {
070 return this.description;
071 }
072
073 public void setDescription(String description) {
074 this.description = description;
075 }
076
077 public String getFileName() {
078 return this.fileName;
079 }
080
081 public void setFileName(String fileName) {
082 this.fileName = fileName;
083 }
084
085 public String getContentType() {
086 return this.contentType;
087 }
088
089 public void setContentType(String contentType) {
090 this.contentType = contentType;
091 }
092
093 public byte[] getAttachmentContent() {
094 return this.attachmentContent;
095 }
096
097 public void setAttachmentContent(byte[] attachmentContent) {
098 this.attachmentContent = attachmentContent;
099 }
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 }