1 21 package com.jaspersoft.jasperserver.war.dto; 22 23 import java.io.Serializable ; 24 import java.util.LinkedHashMap ; 25 import java.util.List ; 26 import java.util.Map ; 27 28 import com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource; 29 import com.jaspersoft.jasperserver.api.metadata.common.domain.Resource; 30 import com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ResourceDescriptor; 31 import com.jaspersoft.jasperserver.war.common.JasperServerConst; 32 33 public class FileResourceWrapper extends BaseDTO implements Serializable { 34 private FileResource fileResource; 35 36 private Resource resource; 37 38 private byte[] newData; 39 40 private String newUri; 41 42 private Map allTypes; 43 44 private boolean suggested; 45 46 private List allResources; 47 48 private List existingResources; 49 50 private String source; 51 52 private String fileName; 53 54 private Object parentFlowObject; 55 56 private boolean located; 57 58 private List allFolders; 59 60 private String folder; 61 62 public boolean isLocated() { 63 return located; 64 } 65 66 public void setLocated(boolean located) { 67 this.located = located; 68 } 69 70 public Object getParentFlowObject() { 71 return parentFlowObject; 72 } 73 74 public void setParentFlowObject(Object parentFlowObject) { 75 this.parentFlowObject = parentFlowObject; 76 } 77 78 public String getFileName() { 79 return fileName; 80 } 81 82 public void setFileName(String fileName) { 83 this.fileName = fileName; 84 } 85 86 public String getSource() { 87 return source; 88 } 89 90 public void setSource(String source) { 91 this.source = source; 92 } 93 94 public List getAllResources() { 95 return allResources; 96 } 97 98 public void setAllResources(List allResources) { 99 this.allResources = allResources; 100 } 101 102 public boolean isSuggested() { 103 return suggested; 104 } 105 106 public void setSuggested(boolean suggested) { 107 this.suggested = suggested; 108 } 109 110 public Map getAllTypes() { 111 if (allTypes == null) { 112 allTypes = new LinkedHashMap (); 113 allTypes.put(FileResource.TYPE_IMAGE, 114 JasperServerConst.TYPE_RSRC_IMAGE); 115 allTypes.put(FileResource.TYPE_FONT, 116 JasperServerConst.TYPE_RSRC_FONT); 117 allTypes.put(FileResource.TYPE_JAR, 118 JasperServerConst.TYPE_RSRC_CLASS_JAR); 119 allTypes.put(FileResource.TYPE_JRXML, 120 JasperServerConst.TYPE_RSRC_SUB_REPORT); 121 allTypes.put(FileResource.TYPE_RESOURCE_BUNDLE, 122 JasperServerConst.TYPE_RSRC_RESOURCE_BUNDLE); 123 allTypes.put(ResourceDescriptor.TYPE_MONDRIAN_SCHEMA, 124 JasperServerConst.TYPE_RSRC_OLAP_SCHEMA); 125 } 126 return allTypes; 127 } 128 129 public void setAllTypes(Map allTypes) { 130 this.allTypes = allTypes; 131 } 132 133 public FileResource getFileResource() { 134 return fileResource; 135 } 136 137 public void setFileResource(FileResource fileResource) { 138 this.fileResource = fileResource; 139 } 140 141 public void afterBind() { 142 if (getSource() != null 143 && fileResource != null 144 && getSource().equals( 145 JasperServerConst.FIELD_CHOICE_FILE_SYSTEM)) { 146 fileResource.setReferenceURI(null); 147 } 148 } 149 150 public static String getTypeForExtention(String extension) { 151 String type = null; 152 if (extension != null) { 153 if (extension.equalsIgnoreCase(FileResource.TYPE_JRXML)) 154 type = FileResource.TYPE_JRXML; 155 else if (extension.equalsIgnoreCase("ttf")) 156 type = FileResource.TYPE_FONT; 157 else if (extension.equalsIgnoreCase("xml")) 158 type = ResourceDescriptor.TYPE_MONDRIAN_SCHEMA; 159 else if (extension.equalsIgnoreCase(FileResource.TYPE_JAR)) { 160 type = FileResource.TYPE_JAR; 161 } else if (extension.indexOf(FileResource.TYPE_RESOURCE_BUNDLE) != -1) { 162 type = FileResource.TYPE_RESOURCE_BUNDLE; 163 } else { 164 String [] imageTypes = { "jpg", "jpeg", "gif", "bmp" }; 165 for (int i = 0; i < imageTypes.length; i++) { 166 if (extension.equalsIgnoreCase(imageTypes[i])) { 167 type = FileResource.TYPE_IMAGE; 168 } 169 } 170 } 171 } 172 return type; 173 } 174 175 public byte[] getNewData() { 176 return newData; 177 } 178 179 public void setNewData(byte[] newData) { 180 if (newData != null && newData.length != 0) { 181 fileResource.setData(newData); 182 } 183 this.newData = newData; 184 } 185 186 public String getNewUri() { 187 return newUri; 188 } 189 190 public void setNewUri(String newUri) { 191 if (newUri != null && newUri.trim().length() != 0) 192 fileResource.setReferenceURI(newUri); 193 this.newUri = newUri; 194 } 195 196 public Resource getResource() { 197 return resource; 198 } 199 200 public void setResource(Resource resource) { 201 this.resource = resource; 202 } 203 204 public List getExistingResources() { 205 return existingResources; 206 } 207 208 public void setExistingResources(List existingResources) { 209 this.existingResources = existingResources; 210 } 211 212 public String getFolder() { 213 return folder; 214 } 215 216 public void setFolder(String folder) { 217 this.folder = folder; 218 } 219 220 public List getAllFolders() { 221 return allFolders; 222 } 223 224 public void setAllFolders(List allFolders) { 225 this.allFolders = allFolders; 226 } 227 } 228 | Popular Tags |