Changeset 974


Ignore:
Timestamp:
Feb 26, 2009, 10:48:02 AM (13 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #178: The MeV launcher should use attached file instead of running BioAssaySetExporter?

Location:
extensions/net.sf.basedb.mev/trunk
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.mev/trunk/META-INF/extensions.xml

    r666 r974  
    1212  </about>
    1313  <extension
    14     id="net.sf.basedb.mev.launcher"
     14    id="net.sf.basedb.mev.launchmev"
    1515    extends="net.sf.basedb.clients.web.bioassayset.list.tools"
    1616    >
     
    1919      <name>MEV Launcher</name>
    2020      <description>
    21         Adds an action to the "Tools" column that starts MEV using Java
     21        Adds an action to the "Tools" column that starts MeV using Java
    2222        web start and automatically loads data from the current bioassay
    23         set.
     23        set. The bioassay set must have a MeV TDMS file attached to it.
    2424      </description>
    2525    </about>
     
    2929      </factory-class>
    3030      <parameters>
    31         <title>Start MEV</title>
    32         <tooltip>Launch MEV with data from this bioassay set</tooltip>
     31        <requireMevFile>true</requireMevFile>
     32        <title>Start MeV</title>
     33        <tooltip>Launch MeV with data from this bioassay set</tooltip>
    3334        <onClick>MeV.launch($ID$)</onClick>
    34         <icon>~/images/tm4.png</icon>
     35        <icon>~/images/tm4_launch.png</icon>
     36        <script>~/scripts/mev.jsp</script>
     37      </parameters>
     38    </action-factory>
     39  </extension>
     40  <extension
     41    id="net.sf.basedb.mev.launchexport"
     42    extends="net.sf.basedb.clients.web.bioassayset.list.tools"
     43    >
     44    <index>2</index>
     45    <about>
     46      <name>MEV Launcher</name>
     47      <description>
     48        Adds an action to the "Tools" column that exports data to a
     49        MeV TDMS file.
     50      </description>
     51    </about>
     52    <action-factory>
     53      <factory-class>
     54        net.sf.basedb.mev.factory.MevButtonFactory
     55      </factory-class>
     56      <parameters>
     57        <requireMevFile>false</requireMevFile>
     58        <requireSpotData>true</requireSpotData>
     59        <requireWritePermission>true</requireWritePermission>
     60        <title>Generate MeV TDSM file</title>
     61        <tooltip>Create a MeV TDMS file from the data in this bioassay set</tooltip>
     62        <onClick>MeV.createTDMS($ID$)</onClick>
     63        <icon>~/images/tm4_export.png</icon>
    3564        <script>~/scripts/mev.jsp</script>
    3665      </parameters>
  • extensions/net.sf.basedb.mev/trunk/README

    r690 r974  
    11== Requirements ==
    22
    3  1. BASE 2.7.0 or later.
     3 1. BASE 2.11.0 or later.
    44 
    55== Introduction ==
     
    3131== Known issues ==
    3232
    33  * It is not possible to add more data to MEV. If you try 'File -> Load data'
     33 * It is not possible to add more data to MeV. If you try 'File -> Load data'
    3434   in MEV the same bioassay set will be loaded a second time.
    3535
     
    4848 2. Type `ant download-lib` to automatically download the BASE core JAR file that
    4949    are neeed for compilation. You can also do this manually by copying the
    50     BASE2Core.jar, BASE2Webclient.jar and BASE2CorePlugins.jar from
    51     the BASE installation directory (<basedir>/www/WEB-INF/lib/) to the
     50    BASE2Core.jar, BASE2Webclient.jar, BASE2CorePlugins.jar and BASE2WsClient.jar
     51    from the BASE installation directory (<basedir>/www/WEB-INF/lib/) to the
    5252    ./lib/compile directory.
    5353
  • extensions/net.sf.basedb.mev/trunk/build.xml

    r697 r974  
    2323  <property name="javac.target" value="1.5" />
    2424  <property name="javac.encoding" value="ISO-8859-1" />
    25   <property name="depend.jars" value="http://base2.thep.lu.se/base/jars/2.7.0" />
     25  <property name="depend.jars" value="http://base2.thep.lu.se/base/jars/2.11.0" />
    2626
    2727  <!-- set up classpath for compiling -->
     
    9999  <target
    100100    name="checkjar"
    101     description="Checks that the BASE2Core.jar, BASE2Webclient.jar and BASE2CorePlugins.jar exists."
     101    description="Checks that the BASE2Core.jar, BASE2Webclient.jar, BASE2CorePlugins.jar and BASE2WSClient.jar exists."
    102102    >
    103103    <available classname="net.sf.basedb.core.Application"
     
    107107    <available classname="net.sf.basedb.clients.web.extensions.toolbar.FixedButtonFactory"
    108108      classpathref="classpath" property="base2web" />
     109    <available classname="net.sf.basedb.info.BioAssaySetInfo"
     110      classpathref="classpath" property="base2webservice" />
    109111    <fail unless="base2core" message="Can't find BASE2Core.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." />
    110112    <fail unless="base2plugins" message="Can't find BASE2CorePlugins.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." />
    111113    <fail unless="base2web" message="Can't find BASE2Webclient.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." />
    112     <echo>Found BASE2Core.jar, BASE2CorePlugins.jar and BASE2Webclient.jar.</echo>
     114    <fail unless="base2webservice" message="Can't find BASE2WSClient.jar in ./lib/compile. Try 'ant download-lib' to download the missing file." />
     115    <echo>Found BASE2Core.jar, BASE2CorePlugins.jar, BASE2Webclient.jar and BASE2WSClient.jar.</echo>
    113116  </target>
    114117 
    115118  <target
    116119    name="download-lib"
    117     description="Download BASE2Core.jar, BASE2Webclient.jar and BASE2CorePlugins.jar."
     120    description="Download BASE2Core.jar, BASE2Webclient.jar, BASE2CorePlugins.jar and BASE2WSClient.jar"
    118121    >
    119122    <echo>
     
    127130    <download-lib file="BASE2CorePlugins.jar" />
    128131    <download-lib file="BASE2Webclient.jar" />
     132    <download-lib file="BASE2WSClient.jar" />
    129133  </target>
    130134 
  • extensions/net.sf.basedb.mev/trunk/resources/launch_mev.jsp

    r666 r974  
    4545final String serverName = request.getServerName();
    4646final int serverPort = request.getServerPort();
    47 final String homeUrl = ExtensionsControl.getHomeUrl("net.sf.basedb.mev.launcher");
     47final String homeUrl = ExtensionsControl.getHomeUrl("net.sf.basedb.mev.launchmev");
    4848final String fullHomeUrl = "http://" + serverName + ":" + serverPort + homeUrl;
    4949
     
    129129  </resources>
    130130  <application-desc main-class="org.tigr.microarray.mev.TMEV">
    131     <argument>-download_url <%=fullHomeUrl%>/MevExport.servlet?ID=<%=ID%>&bioassayset_id=<%=bioAssaySetId%></argument>
     131    <argument>-download_url <%=fullHomeUrl%>/MevExport/<%=ID%>/<%=bioAssaySetId%>.servlet</argument>
    132132    <argument>-row <%=row_idx%></argument>
    133133    <argument>-column <%=column_idx%></argument>
  • extensions/net.sf.basedb.mev/trunk/resources/others.jsp

    r666 r974  
    3333final String serverName = request.getServerName();
    3434final int serverPort = request.getServerPort();
    35 final String homeUrl = ExtensionsControl.getHomeUrl("net.sf.basedb.mev.launcher");
     35final String homeUrl = ExtensionsControl.getHomeUrl("net.sf.basedb.mev.launchmev");
    3636final String fullHomeUrl = "http://" + serverName + ":" + serverPort + homeUrl;
    3737out.clearBuffer();
  • extensions/net.sf.basedb.mev/trunk/resources/scripts/mev.jsp

    r666 r974  
    55%>
    66<%!
    7   final String homeUrl = ExtensionsControl.getHomeUrl("net.sf.basedb.mev.launcher");
     7  final String homeUrl = ExtensionsControl.getHomeUrl("net.sf.basedb.mev.launchmev");
    88%>
    99var MeV = new function()
     
    1616    location.href = url;
    1717  }
    18 }();
     18 
     19  this.createTDMS = function(bioAssaySetId)
     20  {
     21    var url = '<%=homeUrl%>/launch_export.jsp';
     22    url += '?ID='+getSessionId();
     23    url += '&bioassayset_id=' + bioAssaySetId;
     24    Main.openPopup(url, 'CreateTDMSFile', 400, 300);
     25  }
     26}
     27();
  • extensions/net.sf.basedb.mev/trunk/src/net/sf/basedb/mev/factory/MevButtonFactory.java

    r722 r974  
    2828import net.sf.basedb.clients.web.extensions.toolbar.FixedButtonFactory;
    2929import net.sf.basedb.core.BioAssaySet;
     30import net.sf.basedb.core.DataFileType;
     31import net.sf.basedb.core.DbControl;
     32import net.sf.basedb.core.File;
     33import net.sf.basedb.core.FileStoreUtil;
     34import net.sf.basedb.core.Location;
     35import net.sf.basedb.core.Permission;
     36import net.sf.basedb.util.Values;
    3037import net.sf.basedb.util.extensions.InvokationContext;
    3138
    3239/**
    33   Button factory for creating the Luanch MeV button. This factory
    34   extends the {@link FixedButtonFactory} and supports the same set
    35   of parameters. This factory will only create an action if the current
     40  Button factory for creating the Luanch MeV button.
     41  This factory will only create an action if the current
    3642  item is a {@link BioAssaySet}. The {@link #getOnClick()} value
    3743  is scanned for the substring <code>$ID$</code> which is replaced
    3844  with the ID of the bioassay set.
     45  <p>
     46  This factory extends the {@link FixedButtonFactory} and supports
     47  the same set of parameters as well as two conditional parameters:
     48  <ul>
     49  <li>requireMevFile: if set, the bioassay set is checked if a
     50    MeV TDMS file is attached to it or not. See
     51    {@link DataFileType#MEV_TDMS}.
     52  <li>requireSpotData: if set, the bioassay set is checked if it
     53    has spot data in the database.
     54  </ul>
     55  An action button is only created if all conditions that are
     56  set evaluate to true.
    3957 
    4058  @author nicklas
     
    4563  extends FixedButtonFactory
    4664{
     65  private Boolean requireMevFile;
     66  private Boolean requireSpotData;
     67  private Boolean requireWritePermission;
    4768 
    4869  /**
     
    6485    {
    6586      BioAssaySet bas = (BioAssaySet)currentItem;
    66       if (bas.getNumSpots() > 0)
     87      DbControl dc = context.getClientContext().getDbControl();
     88      boolean hasMevFile = hasAccessibleMevFile(dc, bas);
     89      boolean hasSpotData = bas.getNumSpots() > 0;
     90      boolean hasWritePermission = bas.hasPermission(Permission.WRITE);
     91      boolean createAction = true;
     92      if (getRequireMevFile() != null) createAction &= getRequireMevFile() == hasMevFile;
     93      if (getRequireSpotData() != null) createAction &= getRequireSpotData() == hasSpotData;
     94      if (getRequireWritePermission() != null) createAction &= getRequireWritePermission() == hasWritePermission;
     95      if (createAction)
    6796      {
    6897        String ID = String.valueOf(bas.getId());
     
    84113  // ------------------------------------
    85114
     115  /**
     116    @since 1.1
     117  */
     118  public void setRequireMevFile(String requireMevFile)
     119  {
     120    this.requireMevFile = Values.getBoolean(requireMevFile);
     121  }
     122 
     123  /**
     124    @since 1.1
     125  */
     126  public Boolean getRequireMevFile()
     127  {
     128    return requireMevFile;
     129  }
     130 
     131  /**
     132    @since 1.1
     133  */
     134  public void setRequireSpotData(String requireSpotData)
     135  {
     136    this.requireSpotData = Values.getBoolean(requireSpotData);
     137  }
     138 
     139  /**
     140    @since 1.1
     141  */
     142  public Boolean getRequireSpotData()
     143  {
     144    return requireSpotData;
     145  }
     146
     147  /**
     148    @since 1.1
     149  */
     150  public void setRequireWritePermission(String requireWritePermission)
     151  {
     152    this.requireWritePermission = Values.getBoolean(requireWritePermission);
     153  }
     154 
     155  /**
     156    @since 1.1
     157  */
     158  public Boolean getRequireWritePermission()
     159  {
     160    return requireWritePermission;
     161  }
     162 
     163  private boolean hasAccessibleMevFile(DbControl dc, BioAssaySet bas)
     164  {
     165    File mevFile = null;
     166    try
     167    {
     168      mevFile = FileStoreUtil.getDataFile(dc, bas, DataFileType.MEV_TDMS);
     169      if (mevFile != null)
     170      {
     171        if (mevFile.getLocation() != Location.PRIMARY) mevFile = null;
     172      }
     173    }
     174    catch (Throwable t)
     175    {}
     176    return mevFile != null;
     177  }
     178 
    86179}
  • extensions/net.sf.basedb.mev/trunk/src/net/sf/basedb/mev/servlet/MevExport.java

    r666 r974  
    2626import net.sf.basedb.core.Application;
    2727import net.sf.basedb.core.BioAssaySet;
     28import net.sf.basedb.core.DataFileType;
     29import net.sf.basedb.core.File;
     30import net.sf.basedb.core.FileStoreUtil;
     31import net.sf.basedb.core.ItemNotFoundException;
    2832import net.sf.basedb.core.SessionControl;
    2933import net.sf.basedb.core.DbControl;
    30 import net.sf.basedb.plugins.BioAssaySetExporter;
    3134import net.sf.basedb.util.Values;
    3235
     
    3942
    4043/**
    41   A servlet for exporting the spot data of a bioassayset to
    42   a MeV-compatible file. The file is sent back to the requesting
    43   client in the response. This servlet uses the functionality
    44   in the {@link BioAssaySetExporter} to export the data.
     44  A servlet for exposing the spot data of a bioassayset that already
     45  exists as a MeV TDMS file attached to the bioassay set. The file is
     46  sent back to the requesting client in the response.
    4547
    4648  @author Nicklas
    4749  @version 1.0
    4850  @base.modified $Date$
    49  */
     51*/
    5052public final class MevExport
    5153  extends HttpServlet
     
    5860  {
    5961    // The session ID
    60     final String ID = request.getParameter("ID");
     62    String ID = null;
     63    // The bioassay set to export
     64    int bioAssaySetId = 0;
    6165   
    62     // The bioassay set to export
    63     final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id"));
    6466    DbControl dc = null;
    6567    try
    6668    {
     69      if (request.getQueryString() != null)
     70      {
     71        // Paremeters where given on query string: ?ID=...&bioassayset_id=...
     72        ID = request.getParameter("ID");
     73        bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id"));
     74      }
     75      else if (request.getPathInfo() != null)
     76      {
     77        // Parameters are given as path: /ID/bioassayset_id
     78        String[] path = request.getPathInfo().split("/");
     79        ID = path[path.length-2];
     80        bioAssaySetId = Values.getInt(path[path.length-1]);
     81      }   
    6782      final SessionControl sc = Application.getSessionControl(ID, request.getRemoteAddr());
    6883
    69       // Load bioassay set
     84      // Load bioassay set and file with MeV data
    7085      dc = sc.newDbControl();
    7186      BioAssaySet bas = BioAssaySet.getById(dc, bioAssaySetId);
     87      File mevFile = FileStoreUtil.getDataFile(dc, bas, DataFileType.MEV_TDMS);
     88     
     89      if (mevFile == null)
     90      {
     91        throw new ItemNotFoundException("No MeV TDMS file found on bioassay set: " +
     92          bas.getName());
     93      }
    7294     
    7395      // Set up output stream
    7496      OutputStream out = response.getOutputStream();
    7597      response.setContentType("text/plain");
    76      
     98      if (mevFile.getSize() < Integer.MAX_VALUE)
     99      {
     100        response.setContentLength((int)mevFile.getSize());
     101      }
    77102      // Do the export
    78       BioAssaySetExporter exporter = new BioAssaySetExporter();
    79       exporter.exportMeV(bas, out, null);
     103      mevFile.download(out, 0);
    80104      out.flush();
    81105      out.close();
Note: See TracChangeset for help on using the changeset viewer.