Ignore:
Timestamp:
Mar 16, 2011, 12:48:47 PM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #1589: Delete deprecated classes and methods

Removed deprecated methods and classes from the core API.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/webservices/server/net/sf/basedb/ws/server/BioAssaySetService.java

    r4931 r5590  
    2222package net.sf.basedb.ws.server;
    2323
    24 import net.sf.basedb.core.BaseException;
    2524import net.sf.basedb.core.BioAssaySet;
    2625import net.sf.basedb.core.DataFileType;
     
    3332import net.sf.basedb.info.DataFileTypeInfo;
    3433import net.sf.basedb.info.QueryOptions;
    35 
    36 import java.io.File;
    37 import java.io.FileOutputStream;
    38 import java.util.ArrayList;
    39 import java.util.Arrays;
    40 import java.util.Collections;
    41 import java.util.List;
    42 
    43 import javax.activation.DataSource;
    4434
    4535import org.apache.axiom.om.OMElement;
     
    6353  public BioAssaySetService()
    6454  {}
    65  
    66   /**
    67     Gets the available file formats a bioassay set can be exported in
    68     through webservices.
    69       @param ID A string that identify the active session
    70       @return A string-array with the available formats or
    71         null if there is no active session.
    72       @deprecated In 2.12. Use {@link #getDataFileTypes(String, int, QueryOptions)}
    73         instead
    74   */
    75   public String[] getExportFormats(String ID)
    76   {
    77     String[] formats = {SERIAL_BASEFILE, MATRIX_BASEFILE, MEV};
    78     return formats;
    79   }
    80  
    81   /**
    82     Returns an OMElement with an attached file that contains the exported bioassay set.
    83     Different file formats to export the bioassay set is available
    84     There may be some parameters that needs to be configured
    85     depending on the selected file format.
    86       @param ID An id to identify the active session with
    87       @param bioAssaySetId The id of the bioassay-set, which should be exported.
    88       @param format File format of which the bioassay set should be exported in.
    89         Available formats are:
    90         <ul>
    91           <li>{@value #MEV} (deprecated in BASE 2.12). MeV support has been
    92             completely moved to the MeV extension (http://baseplugins.thep.lu.se/wiki/net.sf.basedb.mev)
    93             This web service will continue to
    94           <li>{@value #SERIAL_BASEFILE}
    95           <li>{@value #MATRIX_BASEFILE}
    96         </ul>         
    97       @param reporterFieldArray The reporter fields to include in the export
    98       @param spotFieldArray The spot fields to include in the export
    99       @param mergeReporters TRUE to merge spot data having the same reporter.
    100         see {@link net.sf.basedb.plugins.BioAssaySetExporter}
    101       @return An OMElement containing the exported file or
    102         NULL if there an exception is thrown.
    103     @throws Exception If the data could not be exported to the file.
    104     @deprecated In 2.12. Spot data should not be exported dynamically. Instead,
    105       plug-ins should be used and attach the result to the bioassay set and
    106       the files can then be downloaded when needed. Use
    107       {@link #downloadDataFile(String, int, String)} instead.
    108   */
    109   @SuppressWarnings("unchecked")
    110   public OMElement downloadBioAssaySet(String ID, int bioAssaySetId, String format, String[] reporterFieldArray,
    111       String[] spotFieldArray, Boolean mergeReporters)
    112     throws Exception
    113   {
    114     if (format == null) return null;
    115    
    116     String elementName = "downloadFile";
    117     OMElement elementWithAttachment = null;
    118    
    119     SessionControl sc = getSessionControl(ID);
    120     DbControl dc = sc.newDbControl();
    121     File exportFile = null;   
    122     FileOutputStream fos = null;
    123     try
    124     {
    125       BioAssaySet bioassayset = BioAssaySet.getById(dc, bioAssaySetId);
    126       List<String> reporterFields = new ArrayList<String>();
    127       List<String> spotFields = new ArrayList<String>();
    128       if (reporterFieldArray != null) reporterFields = Arrays.asList(reporterFieldArray);
    129       if (spotFieldArray != null) spotFields = Arrays.asList(spotFieldArray);
    130       mergeReporters = mergeReporters == null ? false : mergeReporters;
    131      
    132       exportFile =  File.createTempFile("BioAssaySetFile", null);
    133       fos = new FileOutputStream(exportFile);
    134      
    135       net.sf.basedb.plugins.BioAssaySetExporter exporter =
    136         new net.sf.basedb.plugins.BioAssaySetExporter();
    137       //Export to MeV-file format     
    138       if (format.equals(MEV))
    139       {             
    140         exporter.exportMeV(bioassayset, fos, null);       
    141       }           
    142       //Export the data from the bioassayset as one big matrix in a BASEfile
    143       else if(format.equals(MATRIX_BASEFILE))
    144       {
    145         exporter.exportBaseFileMatrix(bioassayset, fos, Collections.EMPTY_MAP, reporterFields, spotFields, mergeReporters, null);
    146       }
    147       //Export the data from a bioassayset as a serial BASEfile.       
    148       else if (format.equals(SERIAL_BASEFILE))
    149       {
    150         exporter.exportBaseFileSerial(bioassayset, fos, Collections.EMPTY_MAP, reporterFields, spotFields, mergeReporters, null);
    151       }
    152       else
    153       {
    154         throw new BaseException("BASE web services does not support this format: " + format);
    155       }
    156       fos.close();
    157       DataSource source = new TempFileDataSource(exportFile, "text/plain");
    158       elementWithAttachment = attachFile(source, elementName);
    159     }
    160     finally
    161     {   
    162       if (dc != null) dc.close();
    163     }
    164    
    165     return elementWithAttachment;
    166   }
    16755 
    16856  /**
Note: See TracChangeset for help on using the changeset viewer.