Changeset 5718
- Timestamp:
- Sep 6, 2011, 12:44:53 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/build.xml
r5706 r5718 1012 1012 > 1013 1013 <mkdir dir="${webservices.wsdlpath}" /> 1014 <webservices.wsdl serviceClassName="AnnotationTypeService"/> 1014 1015 <webservices.wsdl serviceClassName="ArrayDesignService"/> 1015 1016 <webservices.wsdl serviceClassName="BioAssaySetService"/> 1016 1017 <webservices.wsdl serviceClassName="ExperimentService"/> 1018 <webservices.wsdl serviceClassName="FileService"/> 1017 1019 <webservices.wsdl serviceClassName="ProjectService"/> 1018 1020 <webservices.wsdl serviceClassName="RawBioAssayService"/> 1021 <webservices.wsdl serviceClassName="ReporterService"/> 1019 1022 <webservices.wsdl serviceClassName="SessionService"/> 1020 <webservices.wsdl serviceClassName="ReporterService"/>1021 <webservices.wsdl serviceClassName="AnnotationTypeService"/>1022 1023 </target> 1023 1024 -
trunk/src/core/net/sf/basedb/core/File.java
r5652 r5718 30 30 import net.sf.basedb.core.data.ItemSubtypeData; 31 31 import net.sf.basedb.core.data.MimeTypeData; 32 import net.sf.basedb.info.FileInfo; 33 import net.sf.basedb.info.ToTransferable; 32 34 import net.sf.basedb.util.EqualsHelper; 33 35 import net.sf.basedb.util.FileUtil; … … 79 81 public class File 80 82 extends CommonItem<FileData> 81 implements Transactional, DiskConsumable, Subtypable 83 implements Transactional, DiskConsumable, Subtypable, ToTransferable<FileInfo> 82 84 { 83 85 /** … … 700 702 if (isWriteProtected()) denied |= Permission.deny(Permission.DELETE); 701 703 super.initPermissions(granted, denied); 704 } 705 /** 706 @since 3.0 707 */ 708 @Override 709 public FileInfo toTransferable(FileInfo info) 710 { 711 super.toTransferable(info); 712 info.setSize(this.getSize()); 713 info.setMimeType(this.getMimeType()); 714 info.setMd5(this.getMd5()); 715 info.setCharacterSet(this.getCharacterSet()); 716 info.setPath(this.getPath().toString()); 717 return info; 702 718 } 703 719 // ------------------------------------------- -
trunk/src/core/net/sf/basedb/core/FileSet.java
r5714 r5718 581 581 ) 582 582 ); 583 query.setDistinct(true); 583 584 return query; 584 585 } -
trunk/src/core/net/sf/basedb/core/FileSetMember.java
r5713 r5718 26 26 import net.sf.basedb.core.query.Hql; 27 27 import net.sf.basedb.core.query.Restrictions; 28 import net.sf.basedb.info.DataFileTypeInfo; 29 import net.sf.basedb.info.FileInfo; 30 import net.sf.basedb.info.FileSetMemberInfo; 31 import net.sf.basedb.info.ToTransferable; 28 32 29 33 /** … … 36 40 public class FileSetMember 37 41 extends BasicItem<FileSetMemberData> 42 implements ToTransferable<FileSetMemberInfo> 38 43 { 39 44 … … 156 161 return PluginPermission.NO_PLUGIN; 157 162 } 163 /** 164 @since 3.0 165 */ 166 public FileSetMemberInfo toTransferable(FileSetMemberInfo info) 167 { 168 super.toTransferable(info); 169 info.setDataFileTypeInfo(this.getDataFileType().toTransferable(new DataFileTypeInfo())); 170 info.setFileInfo(this.getFile().toTransferable(new FileInfo())); 171 info.setValid(this.isValid()); 172 info.setErrorMessage(this.getErrorMessage()); 173 return info; 174 } 158 175 // ------------------------------------------- 159 176 -
trunk/src/test/TestWebservices.java
r5657 r5718 34 34 import net.sf.basedb.info.ExperimentInfo; 35 35 import net.sf.basedb.info.ExtendedPropertyInfo; 36 import net.sf.basedb.info.FileInfo; 37 import net.sf.basedb.info.FileSetMemberInfo; 36 38 import net.sf.basedb.info.ProjectInfo; 37 39 import net.sf.basedb.info.QueryOptions; … … 44 46 import net.sf.basedb.ws.client.BioAssaySetClient; 45 47 import net.sf.basedb.ws.client.ExperimentClient; 48 import net.sf.basedb.ws.client.FileClient; 46 49 import net.sf.basedb.ws.client.ProjectClient; 47 50 import net.sf.basedb.ws.client.RawBioAssayClient; … … 52 55 import java.io.File; 53 56 import java.io.FileOutputStream; 57 import java.io.IOException; 54 58 import java.io.InputStream; 55 59 import java.io.OutputStream; … … 179 183 BioAssaySetClient basClient = new BioAssaySetClient(client); 180 184 ExperimentClient experimentClient = new ExperimentClient(client); 185 FileClient fileClient = new FileClient(client); 181 186 182 187 int bioAssaySetId = 0; … … 201 206 try 202 207 { 203 DataFileTypeInfo[] dataFiles = basClient.getDataFileTypes(bioAssaySetId, null);204 if ( dataFiles == null)208 FileSetMemberInfo[] members = basClient.getDataFiles(bioAssaySetId, null); 209 if (members == null || members.length == 0) 205 210 { 206 211 throw new Exception("Cant find any data files on bioassay set with id = " + bioAssaySetId); 207 212 } 208 213 209 for (DataFileTypeInfo info : dataFiles) 210 { 211 File receivedFile = new File(info.getExternalId()); 214 for (FileSetMemberInfo info : members) 215 { 216 DataFileTypeInfo fileType = info.getDataFileTypeInfo(); 217 FileInfo file = info.getFileInfo(); 218 long expectedSize = file.getSize(); 219 File receivedFile = new File(file.getName()); 212 220 OutputStream out = new FileOutputStream(receivedFile); 213 write("--Downloading file from BioAssaySet: " + info.getExternalId());214 InputStream in = basClient.downloadDataFile(bioAssaySetId, info.getExternalId());221 write("--Downloading file from BioAssaySet: " + fileType.getExternalId()); 222 InputStream in = fileClient.download(file.getId()); 215 223 if (in == null) 216 224 { … … 220 228 in.close(); 221 229 out.close(); 230 if (receivedFile.length() != expectedSize) 231 { 232 throw new IOException("Download failed. Got " + 233 receivedFile.length() + " bytes, expected " + expectedSize); 234 } 222 235 write("--Download OK; size=" + receivedFile.length() + " bytes"); 223 236 receivedFile.delete(); … … 248 261 if (client == null || rawBioAssayId == 0) return; 249 262 ArrayDesignClient arrayDesignClient = new ArrayDesignClient(client); 250 RawBioAssayClient rawClient = new RawBioAssayClient(client); 263 RawBioAssayClient rawClient = new RawBioAssayClient(client); 264 FileClient fileClient = new FileClient(client); 251 265 ArrayDesignInfo designInfo = null; 252 266 … … 268 282 int arrayDesignId = designInfo.getId(); 269 283 boolean hasDownloadableData = arrayDesignClient.hasDownloadableData(arrayDesignId); 270 DataFileTypeInfo[] fileTypes = arrayDesignClient.getDataFileTypes(arrayDesignId, new QueryOptions());284 FileSetMemberInfo[] members = arrayDesignClient.getDataFiles(arrayDesignId, new QueryOptions()); 271 285 272 if (hasDownloadableData && fileTypes.length > 0) 273 { 274 write("--Downloading " + fileTypes[0].getName() + " for array design '" + designInfo.getName() + "'"); 275 File receivedFile = new File(fileTypes[0].getName()); 286 if (hasDownloadableData && members.length > 0) 287 { 288 DataFileTypeInfo fileType = members[0].getDataFileTypeInfo(); 289 FileInfo file = members[0].getFileInfo(); 290 long expectedSize = file.getSize(); 291 write("--Downloading " + fileType.getName() + " for array design '" + designInfo.getName() + "': " + file.getName()); 292 File receivedFile = new File(file.getName()); 276 293 OutputStream out = new FileOutputStream(receivedFile); 277 InputStream in = arrayDesignClient.downloadArrayDesignByType(arrayDesignId, fileTypes[0].getExternalId());294 InputStream in = fileClient.download(file.getId()); 278 295 if (in == null) 279 296 { … … 283 300 in.close(); 284 301 out.close(); 302 if (receivedFile.length() != expectedSize) 303 { 304 throw new IOException("Download failed. Got " + 305 receivedFile.length() + " bytes, expected " + expectedSize); 306 } 285 307 write("--Download OK; size=" + receivedFile.length() + " bytes"); 286 308 receivedFile.delete(); … … 316 338 ExperimentClient experimentClient = new ExperimentClient(client); 317 339 RawBioAssayClient rawClient = new RawBioAssayClient(client); 340 FileClient fileClient = new FileClient(client); 318 341 try 319 342 { … … 343 366 344 367 Boolean hasDownloadableData = rawClient.hasDownloadableData(rawBioAssayId); 345 DataFileTypeInfo[] fileTypes = rawClient.getDataFileTypes(rawBioAssayId, null); 346 347 if (hasDownloadableData && fileTypes.length > 0) 348 { 349 write("--Downloading " + fileTypes[0].getName() + " for RawBioAssay '" + raw.getName() + "'"); 350 File receivedFile = new File(fileTypes[0].getName()); 368 FileSetMemberInfo[] members = rawClient.getDataFiles(rawBioAssayId, null); 369 370 if (hasDownloadableData && members.length > 0) 371 { 372 DataFileTypeInfo fileType = members[0].getDataFileTypeInfo(); 373 FileInfo file = members[0].getFileInfo(); 374 long expectedSize = file.getSize(); 375 write("--Downloading " + fileType.getName() + " for RawBioAssay '" + raw.getName() + "': " + file.getName()); 376 File receivedFile = new File(file.getName()); 351 377 OutputStream out = new FileOutputStream(receivedFile); 352 InputStream in = rawClient.downloadRawDataByType(rawBioAssayId, fileTypes[0].getExternalId());378 InputStream in = fileClient.download(file.getId()); 353 379 if (in == null) 354 380 { … … 360 386 in.close(); 361 387 out.close(); 388 if (receivedFile.length() != expectedSize) 389 { 390 throw new IOException("Download failed. Got " + 391 receivedFile.length() + " bytes, expected " + expectedSize); 392 } 362 393 write("--Download OK; size=" + receivedFile.length() + " bytes"); 363 394 receivedFile.delete(); -
trunk/src/webservices/client/java/net/sf/basedb/ws/client/ArrayDesignClient.java
r4513 r5718 24 24 import net.sf.basedb.info.ArrayDesignInfo; 25 25 import net.sf.basedb.info.DataFileTypeInfo; 26 import net.sf.basedb.info.FileSetMemberInfo; 26 27 import net.sf.basedb.info.QueryOptions; 27 28 … … 92 93 @throws IOException If writing to the file fails. 93 94 */ 94 public InputStream downloadArrayDesignByType(int arrayDesignId, String dataFileType)95 public InputStream xdownloadArrayDesignByType(int arrayDesignId, String dataFileType) 95 96 throws IOException 96 97 { … … 129 130 130 131 /** 132 Returns information about data files that are used storing 133 feature information for an array design. 134 @param arrayDesignId Id of the array design to get the information about. 135 @param qOpt Restrictions and includes to put on the query when getting the information. 136 @return An array of FileSetMemberInfo, one for each data file used in the array design. 137 @throws AxisFault If communication with webservice fails. 138 @since 3.0 139 */ 140 public FileSetMemberInfo[] getDataFiles(int arrayDesignId, QueryOptions qOpt) 141 throws AxisFault 142 { 143 return invokeBlocking 144 ( 145 "getDataFiles", 146 FileSetMemberInfo[].class, 147 session.getId(), 148 arrayDesignId, 149 qOpt 150 ); 151 } 152 153 /** 131 154 Gets if data in an array design can be downloaded as a file or not. 132 155 @param arrayDesignId Id of the array design to check -
trunk/src/webservices/client/java/net/sf/basedb/ws/client/BioAssaySetClient.java
r5590 r5718 26 26 27 27 import net.sf.basedb.info.DataFileTypeInfo; 28 import net.sf.basedb.info.FileSetMemberInfo; 28 29 import net.sf.basedb.info.QueryOptions; 29 30 … … 97 98 98 99 /** 100 Returns information about data files that are used storing 101 data for a bioassay set 102 @param bioAssaySetId Id of the bioassay set to get the information about. 103 @param qOpt Restrictions and includes to put on the query when getting the information. 104 @return An array of FileSetMemberInfo, one for each data file used in the bioassay set. 105 @throws AxisFault If communication with webservice fails. 106 @since 3.0 107 */ 108 public FileSetMemberInfo[] getDataFiles(int bioAssaySetId, QueryOptions qOpt) 109 throws AxisFault 110 { 111 return invokeBlocking 112 ( 113 "getDataFiles", 114 FileSetMemberInfo[].class, 115 session.getId(), 116 bioAssaySetId, 117 qOpt 118 ); 119 } 120 121 122 /** 99 123 Gets spot data as a file for a bioassay set if it is stored in a file 100 124 in BASE. … … 107 131 @since 2.12 108 132 */ 109 public InputStream downloadDataFile(int bioAssaySetId, String dataFileType)133 public InputStream xdownloadDataFile(int bioAssaySetId, String dataFileType) 110 134 throws AxisFault, IOException 111 135 { -
trunk/src/webservices/client/java/net/sf/basedb/ws/client/RawBioAssayClient.java
r4513 r5718 25 25 import net.sf.basedb.info.ArrayDesignInfo; 26 26 import net.sf.basedb.info.DataFileTypeInfo; 27 import net.sf.basedb.info.FileSetMemberInfo; 27 28 import net.sf.basedb.info.QueryOptions; 28 29 import net.sf.basedb.info.RawBioAssayInfo; … … 170 171 171 172 /** 173 Returns information about data files that are used storing 174 raw data for a raw bioassay. 175 @param rawBioAssayId Id of the raw bioassay to get the information about. 176 @param qOpt Restrictions and includes to put on the query when getting the information. 177 @return An array of FileSetMemberInfo, one for each data file used in the raw bioassay. 178 @throws AxisFault If communication with webservice fails. 179 @since 3.0 180 */ 181 public FileSetMemberInfo[] getDataFiles(int rawBioAssayId, QueryOptions qOpt) 182 throws AxisFault 183 { 184 return invokeBlocking 185 ( 186 "getDataFiles", 187 FileSetMemberInfo[].class, 188 session.getId(), 189 rawBioAssayId, 190 qOpt 191 ); 192 } 193 194 195 /** 172 196 Get annotation values for one or more annotation types. 173 197 @param rawBioAssayId Id of the raw bioassay to load the annotations from -
trunk/src/webservices/server/META-INF/services.xml
r3978 r5718 96 96 <parameter name="ServiceClass" locked="false">net.sf.basedb.ws.server.AnnotationTypeService</parameter> 97 97 </service> 98 <service name="File" scope="application"> 99 <description> 100 This service handles files 101 </description> 102 <messageReceivers> 103 <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" 104 class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /> 105 <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only" 106 class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" /> 107 </messageReceivers> 108 <parameter name="ServiceClass" locked="false">net.sf.basedb.ws.server.FileService</parameter> 109 </service> 98 110 </serviceGroup> -
trunk/src/webservices/server/net/sf/basedb/ws/server/ArrayDesignService.java
r4513 r5718 33 33 import net.sf.basedb.info.ArrayDesignInfo; 34 34 import net.sf.basedb.info.DataFileTypeInfo; 35 import net.sf.basedb.info.FileSetMemberInfo; 35 36 import net.sf.basedb.info.QueryOptions; 36 37 … … 101 102 /** 102 103 Returns array design file of a certain type, attached to an OMElement. 104 This method assumes that only a single file of the given type exists. If there 105 are two or more files, then it is not specified which one that is returned. 106 Use {@link #getDataFiles(String, int, QueryOptions)} and 107 {@link FileService} to handle the multi-file case. 108 103 109 @param ID Used to identify an active session with. 104 110 @param arrayDesignId Id of the array design the file is associated with. … … 189 195 190 196 /** 197 Returns information objects for each data file that is associated with 198 an Array design. 199 @param ID Id of the active session. 200 @param arrayDesignId Id of the array design it concerns 201 @param qOpt Restrictions and includes to put on the query 202 @return An array with FileSetMemberInfo 203 @since 3.0 204 */ 205 public FileSetMemberInfo[] getDataFiles(String ID, int arrayDesignId, QueryOptions qOpt) 206 { 207 SessionControl sc = getSessionControl(ID); 208 DbControl dc = sc.newDbControl(); 209 try 210 { 211 ArrayDesign design = ArrayDesign.getById(dc, arrayDesignId); 212 return util.getDataFiles(dc, design, qOpt); 213 } 214 finally 215 { 216 if (dc != null) dc.close(); 217 } 218 } 219 220 221 /** 191 222 Get the annotation values for one or more annotation types. 192 223 @param ID Id of the active session. -
trunk/src/webservices/server/net/sf/basedb/ws/server/BioAssaySetService.java
r5590 r5718 31 31 import net.sf.basedb.info.AnnotationInfo; 32 32 import net.sf.basedb.info.DataFileTypeInfo; 33 import net.sf.basedb.info.FileSetMemberInfo; 33 34 import net.sf.basedb.info.QueryOptions; 34 35 … … 56 57 /** 57 58 Returns a data file of a certain type attached to an OMElement. 59 This method assumes that only a single file of the given type exists. If there 60 are two or more files, then it is not specified which one that is returned. 61 Use {@link #getDataFiles(String, int, QueryOptions)} and 62 {@link FileService} to handle the multi-file case. 63 58 64 @param ID Used to identify an active session with. 59 65 @param bioAssaySetId Id of the bioassay set the file belongs to. … … 144 150 } 145 151 152 /** 153 Returns information objects for each data file that is associated with 154 a bioassay set. 155 @param ID Id of the active session. 156 @param bioAssaySetId Id of the bioassay set it concerns 157 @param qOpt Restrictions and includes to put on the query 158 @return An array with FileSetMemberInfo 159 @since 3.0 160 */ 161 public FileSetMemberInfo[] getDataFiles(String ID, int bioAssaySetId, QueryOptions qOpt) 162 { 163 SessionControl sc = getSessionControl(ID); 164 DbControl dc = sc.newDbControl(); 165 try 166 { 167 BioAssaySet bas = BioAssaySet.getById(dc, bioAssaySetId); 168 return util.getDataFiles(dc, bas, qOpt); 169 } 170 finally 171 { 172 if (dc != null) dc.close(); 173 } 174 } 175 146 176 147 177 /** -
trunk/src/webservices/server/net/sf/basedb/ws/server/RawBioAssayService.java
r4513 r5718 33 33 import net.sf.basedb.info.ArrayDesignInfo; 34 34 import net.sf.basedb.info.DataFileTypeInfo; 35 import net.sf.basedb.info.FileSetMemberInfo; 35 36 import net.sf.basedb.info.QueryOptions; 36 37 import net.sf.basedb.info.RawBioAssayInfo; … … 122 123 123 124 /** 124 Returns a rawdata file of a certain type attached to an OMElement. 125 Returns a rawdata file of a certain type attached to an OMElement. This 126 method assumes that only a single file of the given type exists. If there 127 are two or more files, then it is not specified which one that is returned. 128 Use {@link #getDataFiles(String, int, QueryOptions)} and 129 {@link FileService} to handle the multi-file case. 130 125 131 @param ID Used to identify an active session with. 126 132 @param rawBioAssayId Id of the rawbio assay the file belongs to. … … 129 135 or NULL if no file was found. 130 136 @see DataFileType 137 @see #getDataFiles(String, int, QueryOptions) 131 138 */ 132 139 public OMElement downloadRawDataByType(String ID, … … 211 218 212 219 /** 220 Returns information objects for each data file that is associated with 221 a RawBioAssay. 222 @param ID Id of the active session. 223 @param rawBioAssayId Id of the rawbioassay it concerns 224 @param qOpt Restrictions and includes to put on the query 225 @return An array with FileSetMemberInfo 226 @since 3.0 227 */ 228 public FileSetMemberInfo[] getDataFiles(String ID, int rawBioAssayId, QueryOptions qOpt) 229 { 230 SessionControl sc = getSessionControl(ID); 231 DbControl dc = sc.newDbControl(); 232 try 233 { 234 RawBioAssay rawBioAssay = RawBioAssay.getById(dc, rawBioAssayId); 235 return util.getDataFiles(dc, rawBioAssay, qOpt); 236 } 237 finally 238 { 239 if (dc != null) dc.close(); 240 } 241 } 242 243 244 /** 213 245 Get the annotation values for one or more annotation types. 214 246 @param ID Id of the active session. -
trunk/src/webservices/server/net/sf/basedb/ws/server/ServicesUtil.java
r5319 r5718 28 28 import net.sf.basedb.core.BasicItem; 29 29 import net.sf.basedb.core.DbControl; 30 import net.sf.basedb.core.FileSetMember; 31 import net.sf.basedb.core.FileStoreEnabled; 30 32 import net.sf.basedb.core.Include; 31 33 import net.sf.basedb.core.ItemQuery; … … 33 35 import net.sf.basedb.core.query.Hql; 34 36 import net.sf.basedb.info.AnnotationInfo; 37 import net.sf.basedb.info.FileSetMemberInfo; 35 38 import net.sf.basedb.info.QueryOptions; 36 39 import net.sf.basedb.info.QueryParameter; … … 167 170 return result; 168 171 } 172 173 /** 174 Returns information objects for each data file that is associated with 175 a {@link FileStoreEnabled} item. 176 @param item The item with files 177 @param qOpt Restrictions and includes to put on the query 178 @return An array with FileSetMemberInfo 179 @since 3.0 180 */ 181 public FileSetMemberInfo[] getDataFiles(DbControl dc, FileStoreEnabled item, QueryOptions qOpt) 182 { 183 FileSetMemberInfo[] members = null; 184 if (item.hasFileSet()) 185 { 186 ItemQuery<FileSetMember> query = item.getFileSet().getMembers(); 187 query = getConfiguredItemQuery(query, qOpt); 188 members = listToInfo(query.list(dc), FileSetMemberInfo.class); 189 } 190 else 191 { 192 members = new FileSetMemberInfo[0]; 193 } 194 return members; 195 } 196 169 197 }
Note: See TracChangeset
for help on using the changeset viewer.