Changeset 3839
- Timestamp:
- Oct 16, 2007, 1:41:10 PM (16 years ago)
- Location:
- branches/webservices/src/webservices
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/webservices/src/webservices/client/java/net/sf/basedb/ws/client/BioAssaySetClient.java
r3836 r3839 67 67 ( 68 68 "downloadBAS", 69 "exportFile",69 receivedFile.getName(), 70 70 session.getId(), 71 71 bioAssaySetId, -
branches/webservices/src/webservices/client/java/net/sf/basedb/ws/info/ItemInfo.java
r3831 r3839 27 27 28 28 /** 29 Class that holds information about a Nameable item sent through web services29 Class that holds information about a Nameable item used by web services. 30 30 @author Nicklas, Martin 31 31 @version 2.5 … … 40 40 {} 41 41 42 /** 43 Creates a new object with specified item 44 @param item An object of type {@link net.sf.basedb.core.Nameable} 45 to hold information about. 46 */ 42 47 public ItemInfo(Nameable item) 43 48 { … … 47 52 } 48 53 54 /** 55 Gets item's id. 56 @return id as an Integer 57 */ 49 58 public int getId() 50 59 { 51 60 return id; 52 61 } 62 /** 63 Sets item's id. 64 @param id The id of the item this info-object is about 65 */ 53 66 public void setId(int id) 54 67 { … … 56 69 } 57 70 71 /** 72 Gets item's name 73 @return The name as a String 74 */ 58 75 public String getName() 59 76 { 60 77 return name; 61 78 } 79 /** 80 Sets item's name 81 @param name 82 */ 62 83 public void setName(String name) 63 84 { … … 65 86 } 66 87 88 /** 89 Gets item's description 90 @return A String with description of the item 91 */ 67 92 public String getDescription() 68 93 { 69 94 return description; 70 95 } 96 /** 97 Sets item's description 98 @param description 99 */ 71 100 public void setDescription(String description) 72 101 { -
branches/webservices/src/webservices/server/net/sf/basedb/ws/server/AbstractRPCService.java
r3831 r3839 27 27 import net.sf.basedb.core.SessionControl; 28 28 29 import java.io.File; 30 31 import javax.activation.DataHandler; 32 import javax.activation.FileDataSource; 33 34 import org.apache.axiom.om.OMAbstractFactory; 35 import org.apache.axiom.om.OMElement; 36 import org.apache.axiom.om.OMFactory; 37 import org.apache.axiom.om.OMNamespace; 38 import org.apache.axiom.om.OMText; 29 39 import org.apache.axis2.context.MessageContext; 30 40 31 41 /** 32 An abstract class for all Web service classes to extend from. 33 This contains methods that every service class needs. 42 An abstract class for Web service classes to extend from. 43 This contains common methods and fields for WebService classes 44 on the server side in BASE. 34 45 @author Nicklas, Martin 35 46 @version 2.5 … … 52 63 } 53 64 65 /** 66 Gets the remote id to identify connection with. 67 @return A string with the address to the connected client. 68 */ 54 69 protected String getRemoteId() 55 70 { … … 57 72 return msgCtx.getFrom().getAddress(); 58 73 } 74 75 /** 76 Attach a file to an OMElement so it can be sent with webservices. 77 Following code shows an example of how to get to the file on the client side: 78 <code> 79 OMElement response = ..... 80 OMElement fileElement = response.getFirstElement(); 81 OMElement dataElement = fileElement.getFirstElement(); 82 OMText node = (OMText) dataElement.getFirstOMChild(); 83 DataHandler dataHandler = (DataHandler) node.getDataHandler(); 84 InputStream in = dataHandler.getInputStream(); 85 </code> 86 @param file File to be attached. 87 @param elementName The name to call the element by. 88 @return OMElement where the file is attached to. 89 */ 90 protected OMElement attachFile(File file, String elementName) 91 { 92 OMFactory messageFactory = OMAbstractFactory.getOMFactory(); 93 OMNamespace nameSpace = messageFactory.createOMNamespace(getRemoteId(), elementName); 94 OMElement fileElement = messageFactory.createOMElement(elementName, nameSpace); 95 96 FileDataSource fileDataSource = new FileDataSource(file); 97 DataHandler dataHandler = new DataHandler(fileDataSource); 98 OMText node = messageFactory.createOMText(dataHandler, true); 99 fileElement.addChild(node); 100 101 return fileElement; 102 } 59 103 } -
branches/webservices/src/webservices/server/net/sf/basedb/ws/server/BioAssaySetService.java
r3836 r3839 27 27 import net.sf.basedb.core.BioAssaySet; 28 28 import net.sf.basedb.core.DbControl; 29 import net.sf.basedb.core.ItemNotFoundException;30 import net.sf.basedb.core.PluginDefinition;31 29 import net.sf.basedb.core.SessionControl; 32 30 import net.sf.basedb.plugins.BioAssaySetExporter; … … 37 35 import java.util.Arrays; 38 36 import java.util.Collections; 39 40 37 import java.util.List; 41 38 42 import javax.activation.DataHandler;43 import javax.activation.FileDataSource;44 45 import org.apache.axiom.om.OMAbstractFactory;46 39 import org.apache.axiom.om.OMElement; 47 import org.apache.axiom.om.OMFactory;48 import org.apache.axiom.om.OMNamespace;49 import org.apache.axiom.om.OMText;50 40 51 41 /** 52 Web service for BioAssaySet {@link net.sf.basedb.core.BioAssaySet} 42 Web service for BioAssaySet {@link net.sf.basedb.core.BioAssaySet}. 43 This class provides services to get information and data from BioAssaySet. 53 44 @author Martin 54 45 @version 2.5 … … 59 50 private static final String SERIAL_BASEFILE = "Serial BASEfile"; 60 51 private static final String MATRIX_BASEFILE = "Matrix BASEfile"; 61 private static final String MEV = "Mev"; 52 private static final String MEV = "Mev file"; 53 54 62 55 public BioAssaySetService() 63 56 {} 64 57 65 58 /** 66 67 @param ID 68 @return 59 Gets the available file formats a bioassay set can be exported in 60 through webservices. 61 @param ID A string that identify the active session 62 @return A string-array with the available formats or 63 null if there is no active session. 69 64 */ 70 65 public String[] getExportFormats(String ID) 71 66 { 72 SessionControl sc = getSessionControl(ID);73 DbControl dc = sc.newDbControl();74 67 String[] formats = {SERIAL_BASEFILE, MATRIX_BASEFILE, MEV}; 75 76 try 77 { 78 PluginDefinition.getByClassName(dc, "net.sf.basedb.plugins.BioAssaySetExporter"); 79 return formats; 80 } 81 catch(ItemNotFoundException ex) 82 { 83 ex.printStackTrace(); 84 return null; 85 } 86 finally 87 { 88 if (dc != null) dc.close(); 89 } 68 return formats; 90 69 } 91 70 71 /** 72 Returns an OMElement with an attached file that contains the exported bioassay set. 73 Different file formats to export the bioassay set is available 74 There may be some parameters that needs to be configured 75 depending on the selected file format. 76 @param ID An id to identify the active session with 77 @param bioAssaySetId The id of the bioassay-set, which should be exported. 78 @param format File format of which the bioassay set should be exported in. 79 Available formats are: 80 <ul> 81 <li>{@value #MEV} 82 <li>{@value #SERIAL_BASEFILE} 83 <li>{@value #MATRIX_BASEFILE} 84 </ul> 85 @param reporterFieldArray The reporter fields to include in the export 86 @param spotFieldArray The spot fields to include in the export 87 @param mergeReporters TRUE to merge spot data having the same reporter. 88 see {@link net.sf.basedb.plugins.BioAssaySetExporter} 89 @return An OMElement containing the exported file or 90 NULL if there an exception is thrown. 91 */ 92 92 @SuppressWarnings("unchecked") 93 93 public OMElement downloadBAS(String ID, int bioAssaySetId, String format, String[] reporterFieldArray, … … 95 95 { 96 96 if (format == null) return null; 97 OMElement fileElement = null;97 98 98 String elementName = "exportFile"; 99 99 … … 112 112 113 113 BioAssaySetExporter exporter = new BioAssaySetExporter(); 114 114 //Export to MeV-file format 115 115 if (format.equals(MEV)) 116 116 { … … 119 119 exporter.exportMeV(bioassayset, fos, null); 120 120 fos.close(); 121 } 121 } 122 //Export the data from the bioassayset as one big matrix in a BASEfile 122 123 else if(format.equals(MATRIX_BASEFILE)) 123 124 { … … 126 127 exporter.exportBaseFileMatrix(bioassayset, fos, Collections.EMPTY_MAP, reporterFields, spotFields, mergeReporters); 127 128 fos.close(); 128 } 129 } 130 //Export the data from a bioassayset as a serial BASEfile. 129 131 else if (format.equals(SERIAL_BASEFILE)) 130 132 { … … 133 135 exporter.exportBaseFileSerial(bioassayset, fos, Collections.EMPTY_MAP, reporterFields, spotFields, mergeReporters); 134 136 fos.close(); 135 } 137 } 136 138 else 137 139 { 138 140 throw new BaseException("BASE web services does not support this format: " + format); 139 141 } 140 141 OMFactory messageFactory = OMAbstractFactory.getOMFactory();142 OMNamespace nameSpace = messageFactory.createOMNamespace(getRemoteId(), "exportfile");143 fileElement = messageFactory.createOMElement(elementName, nameSpace);144 145 FileDataSource fileDataSource = new FileDataSource(exportFile);146 DataHandler dataHandler = new DataHandler(fileDataSource);147 OMText node = messageFactory.createOMText(dataHandler, true);148 fileElement.addChild(node);149 142 } 150 143 catch(Throwable th) … … 157 150 if (dc != null) dc.close(); 158 151 } 159 return fileElement;152 return attachFile(exportFile, elementName); 160 153 } 161 162 163 154 } -
branches/webservices/src/webservices/server/net/sf/basedb/ws/server/ExperimentService.java
r3831 r3839 82 82 83 83 /** 84 85 @param ID 86 @param experimentId 87 @param qOpt 88 @return 84 Gets information about the bioassay sets in an experiment. The caller 85 of this method can put restriction on the query that gets the bioassay sets. 86 @param ID Id to identify the active session with 87 @param experimentId Id of the experiment the bioassay sets are in. 88 @param qOpt Includes and restrictions to put on query that gets the bioassay sets. 89 @return Array of ItemInfo:s, one for each bioassay set that where found by the query. 89 90 */ 90 91 public ItemInfo[] getBioAssaySets(String ID, int experimentId, QueryOptions qOpt)
Note: See TracChangeset
for help on using the changeset viewer.