Changeset 3839


Ignore:
Timestamp:
Oct 16, 2007, 1:41:10 PM (16 years ago)
Author:
Martin Svensson
Message:

References #492 Updated javadoc

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  
    6767      (
    6868        "downloadBAS",
    69         "exportFile",
     69        receivedFile.getName(),
    7070        session.getId(),
    7171        bioAssaySetId,
  • branches/webservices/src/webservices/client/java/net/sf/basedb/ws/info/ItemInfo.java

    r3831 r3839  
    2727
    2828/**
    29   Class that holds information about a Nameable item sent through web services
     29  Class that holds information about a Nameable item used by web services.
    3030    @author Nicklas, Martin
    3131    @version 2.5
     
    4040  {}
    4141 
     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   */
    4247  public ItemInfo(Nameable item)
    4348  {
     
    4752  }
    4853 
     54  /**
     55    Gets item's id.
     56      @return id as an Integer
     57   */
    4958  public int getId()
    5059  {
    5160    return id;
    5261  }
     62  /**
     63    Sets item's id.
     64      @param id The id of the item this info-object is about
     65   */
    5366  public void setId(int id)
    5467  {
     
    5669  }
    5770 
     71  /**
     72    Gets item's name
     73    @return The name as a String
     74   */
    5875  public String getName()
    5976  {
    6077    return name;
    6178  }
     79  /**
     80    Sets item's name
     81      @param name
     82   */
    6283  public void setName(String name)
    6384  {
     
    6586  }
    6687
     88  /**
     89    Gets item's description
     90      @return A String with description of the item
     91   */
    6792  public String getDescription()
    6893  {
    6994    return description;
    7095  }
     96  /**
     97    Sets item's description
     98      @param description
     99   */
    71100  public void setDescription(String description)
    72101  {
  • branches/webservices/src/webservices/server/net/sf/basedb/ws/server/AbstractRPCService.java

    r3831 r3839  
    2727import net.sf.basedb.core.SessionControl;
    2828
     29import java.io.File;
     30
     31import javax.activation.DataHandler;
     32import javax.activation.FileDataSource;
     33
     34import org.apache.axiom.om.OMAbstractFactory;
     35import org.apache.axiom.om.OMElement;
     36import org.apache.axiom.om.OMFactory;
     37import org.apache.axiom.om.OMNamespace;
     38import org.apache.axiom.om.OMText;
    2939import org.apache.axis2.context.MessageContext;
    3040
    3141/**
    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.
    3445    @author Nicklas, Martin
    3546    @version 2.5
     
    5263  }
    5364 
     65  /**
     66    Gets the remote id to identify connection with.
     67      @return A string with the address to the connected client.
     68   */
    5469  protected String getRemoteId()
    5570  {
     
    5772    return msgCtx.getFrom().getAddress();
    5873  }
     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  }
    59103}
  • branches/webservices/src/webservices/server/net/sf/basedb/ws/server/BioAssaySetService.java

    r3836 r3839  
    2727import net.sf.basedb.core.BioAssaySet;
    2828import net.sf.basedb.core.DbControl;
    29 import net.sf.basedb.core.ItemNotFoundException;
    30 import net.sf.basedb.core.PluginDefinition;
    3129import net.sf.basedb.core.SessionControl;
    3230import net.sf.basedb.plugins.BioAssaySetExporter;
     
    3735import java.util.Arrays;
    3836import java.util.Collections;
    39 
    4037import java.util.List;
    4138
    42 import javax.activation.DataHandler;
    43 import javax.activation.FileDataSource;
    44 
    45 import org.apache.axiom.om.OMAbstractFactory;
    4639import 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;
    5040
    5141/**
    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.
    5344    @author Martin
    5445    @version 2.5
     
    5950  private static final String SERIAL_BASEFILE = "Serial BASEfile";
    6051  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 
    6255  public BioAssaySetService()
    6356  {}
    6457 
    6558  /**
    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.
    6964   */
    7065  public String[] getExportFormats(String ID)
    7166  {
    72     SessionControl sc = getSessionControl(ID);
    73     DbControl dc = sc.newDbControl();   
    7467    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;
    9069  }
    9170 
     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   */
    9292  @SuppressWarnings("unchecked")
    9393  public OMElement downloadBAS(String ID, int bioAssaySetId, String format, String[] reporterFieldArray,
     
    9595  {
    9696    if (format == null) return null;
    97     OMElement fileElement = null;
     97   
    9898    String elementName = "exportFile";
    9999   
     
    112112     
    113113      BioAssaySetExporter exporter = new BioAssaySetExporter();
    114      
     114      //Export to MeV-file format     
    115115      if (format.equals(MEV))
    116116      {     
     
    119119          exporter.exportMeV(bioassayset, fos, null);
    120120          fos.close();
    121       }
     121      }           
     122      //Export the data from the bioassayset as one big matrix in a BASEfile
    122123      else if(format.equals(MATRIX_BASEFILE))
    123124      {
     
    126127        exporter.exportBaseFileMatrix(bioassayset, fos, Collections.EMPTY_MAP, reporterFields, spotFields, mergeReporters);
    127128        fos.close();
    128       }
     129      }     
     130      //Export the data from a bioassayset as a serial BASEfile.       
    129131      else if (format.equals(SERIAL_BASEFILE))
    130132      {
     
    133135        exporter.exportBaseFileSerial(bioassayset, fos, Collections.EMPTY_MAP, reporterFields, spotFields, mergeReporters);
    134136        fos.close();
    135       }
     137      }     
    136138      else
    137139      {
    138140        throw new BaseException("BASE web services does not support this format: " + format);
    139141      }
    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);     
    149142    }
    150143    catch(Throwable th)
     
    157150      if (dc != null) dc.close();
    158151    }   
    159     return fileElement;   
     152    return attachFile(exportFile, elementName);   
    160153  }
    161  
    162  
    163154}
  • branches/webservices/src/webservices/server/net/sf/basedb/ws/server/ExperimentService.java

    r3831 r3839  
    8282 
    8383  /**
    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.
    8990   */
    9091  public ItemInfo[] getBioAssaySets(String ID, int experimentId, QueryOptions qOpt)
Note: See TracChangeset for help on using the changeset viewer.