source: extensions/net.sf.basedb.mev/trunk/resources/launch_mev.jsp @ 1083

Last change on this file since 1083 was 1083, checked in by Nicklas Nordborg, 13 years ago

References #212: Add support for exporting CGH data to MeV

I have changed the GUI a bit to make sure that it can handle both CGH and TDMS files. It is now also possible to generate a new export file directly from the MeV button.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 8.4 KB
Line 
1<%-- $Id: launch_mev.jsp 1083 2009-05-18 12:19:18Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2009 Nicklas Nordborg
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 2
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Jari, Nicklas
25--%>
26<%@ page
27  pageEncoding="UTF-8"
28  session="false"
29  import="net.sf.basedb.core.Application"
30  import="net.sf.basedb.core.BioAssaySet"
31  import="net.sf.basedb.core.Experiment"
32  import="net.sf.basedb.core.Directory"
33  import="net.sf.basedb.core.File"
34  import="net.sf.basedb.core.User"
35  import="net.sf.basedb.core.DbControl"
36  import="net.sf.basedb.core.SessionControl"
37  import="net.sf.basedb.core.ItemContext"
38  import="net.sf.basedb.core.Item"
39  import="net.sf.basedb.core.Include"
40  import="net.sf.basedb.core.Permission"
41  import="net.sf.basedb.core.Path"
42  import="net.sf.basedb.core.FileStoreUtil"
43  import="net.sf.basedb.core.ItemQuery"
44  import="net.sf.basedb.core.PluginConfiguration"
45  import="net.sf.basedb.core.query.Restrictions"
46  import="net.sf.basedb.core.query.Expressions"
47  import="net.sf.basedb.core.query.Hql"
48  import="net.sf.basedb.core.query.Orders"
49  import="net.sf.basedb.clients.web.Base"
50  import="net.sf.basedb.clients.web.util.HTML"
51  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
52  import="net.sf.basedb.util.Values"
53  import="java.util.List"
54%>
55<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
56<%
57final SessionControl sc = Base.getExistingSessionControl(request, true);
58final String ID = sc.getId();
59final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id"));
60final String title = "Launch MeV";
61final String homeUrl = ExtensionsControl.getHomeUrl("net.sf.basedb.mev.launchmev");
62final String root = request.getContextPath()+"/";
63
64DbControl dc = null;
65String defaultPath = "/";
66
67try
68{
69  dc = sc.newDbControl();
70  BioAssaySet bas = BioAssaySet.getById(dc, bioAssaySetId);
71  ItemContext cc = sc.getCurrentContext(Item.BIOASSAYSET);
72  cc.setId(bioAssaySetId);
73
74  // Get the current files
75  File tdmsFile = FileStoreUtil.getDataFile(dc, bas, "mev.tdms");
76  File cghFile = FileStoreUtil.getDataFile(dc, bas, "mev.cgh");
77  boolean allowCreateFile = bas.hasPermission(Permission.WRITE)
78    && sc.hasPermission(Permission.CREATE, Item.FILE);
79 
80  // Get the avilable CGH export configurations
81  ItemQuery<PluginConfiguration> cghQuery = PluginConfiguration.getQuery();
82  cghQuery.restrict(Restrictions.eq(
83      Hql.property("pluginDefinition.className"),
84      Expressions.string("net.sf.basedb.mev.plugin.CghExporterPlugin")));
85  cghQuery.order(Orders.asc(Hql.property("name")));
86  cghQuery.include(Include.MINE, Include.IN_PROJECT, Include.SHARED, Include.OTHERS);
87  List<PluginConfiguration> cghConfigurations = cghQuery.list(dc);
88  boolean canCreateCGHFile = cghConfigurations.size() > 0;
89 
90  // Default names of export files and export jobs
91  String defaultTdmsFileName = Path.makeSafeFilename(bas.getName() + "-" + bas.getId() + ".tdms.txt", "");
92  String defaultCghFileName = Path.makeSafeFilename(bas.getName() + "-" + bas.getId() + ".cgh.txt", "");
93  String tdmsJobName = "Create TDMS file for " + bas.getName();
94  String cghJobName = "Create CGH file for " + bas.getName();
95 
96  // Default home directory of either experiment or user
97  try
98  {
99    Experiment exp = bas.getExperiment();
100    Directory dir = exp.getDirectory();
101    if (dir == null)
102    {
103      User user = User.getById(dc, sc.getLoggedInUserId());
104      dir = user.getHomeDirectory();
105    }
106    if (dir != null)
107    {
108      defaultPath = dir.getPath().toString() + "/";
109    }
110  }
111  catch (Throwable t)
112  {}
113%>
114<base:page type="popup" title="<%=title%>">
115<base:head>
116  <script language="JavaScript">
117  function launchMev(fileType)
118  {
119    var url = 'mev_jnlp.jsp?ID=<%=ID%>&bioassayset_id=<%=bioAssaySetId%>';
120    url += '&filetype=' + fileType;
121    window.opener.location.href = url;
122    window.close();
123  }
124  function exportTdms()
125  {
126    var url = getRoot()+'common/plugin/index.jsp?ID='+getSessionId();
127    url += '&cmd=NewJob&plugin_class=net.sf.basedb.mev.plugin.TdmsExporterPlugin';
128    url += '&item_type=BIOASSAYSET&context_type=ITEM';
129    url += '&job_name=' + encodeURIComponent('<%=HTML.javaScriptEncode(tdmsJobName)%>');
130    url += '&parameter:saveAs='+encodeURIComponent('<%=HTML.javaScriptEncode(defaultPath+defaultTdmsFileName)%>');
131    url += '&parameter:attachToBioAssaySet=true';
132    Main.openPopup(url, 'CreateTDMSFile', 740, 540);
133    window.close();
134  }
135  function exportCgh()
136  {
137    var frm = document.forms['mev'];
138    var url = getRoot()+'common/plugin/index.jsp?ID='+getSessionId();
139    url += '&cmd=NewJob&plugin_class=net.sf.basedb.mev.plugin.CghExporterPlugin';
140    url += '&pluginconfiguration_id=' + frm.cgh_configuration[frm.cgh_configuration.selectedIndex].value;
141    url += '&item_type=BIOASSAYSET&context_type=ITEM';
142    url += '&job_name=' + encodeURIComponent('<%=HTML.javaScriptEncode(cghJobName)%>');
143    url += '&parameter:saveAs='+encodeURIComponent('<%=HTML.javaScriptEncode(defaultPath+defaultCghFileName)%>');
144    url += '&parameter:attachToBioAssaySet=true';
145    Main.openPopup(url, 'CreateCGHFile', 740, 540);
146    window.close();
147  }
148  </script>
149</base:head>
150<base:body>
151
152  <form name="mev">
153  <h3><%=title%></h3>
154  <div class="boxedbottom">
155  <table class="form">
156  <tr>
157    <td class="prompt" colspan="2">TDMS - Tab-delimited multiple sample</td>
158  </tr>
159  <tr>
160    <td><base:button title="Start MeV" 
161      onclick="launchMev('mev.tdms')" 
162      image="<%=tdmsFile == null ? homeUrl + "/images/tm4_disabled.png" : homeUrl + "/images/tm4.png" %>" 
163      disabled="<%=tdmsFile == null%>"/></td>
164    <td>
165    <%
166    if (tdmsFile == null)
167    {
168      %>
169      There is currently no TDMS file associated with the bioassay set.
170      <%
171    }
172    else
173    {
174      %>
175      Start MeV with the current TDMS file:<br>
176      <%=HTML.encodeTags(tdmsFile.getName())%> <%=Base.getFileLinks(ID, tdmsFile, root) %>
177      <%
178    }
179    %>
180    </td>
181  </tr>
182  <tr>
183    <td><base:button title="Export" 
184      onclick="exportTdms()"
185      disabled="<%=!allowCreateFile%>" 
186      image="<%=allowCreateFile ? "export.gif" : homeUrl + "/images/export_disabled.gif"%>" /></td>
187    <td>
188    <%
189    if (allowCreateFile)
190    {
191      %>
192      Export the spot data to a MeV TDMS file that can be opened with MeV.
193      <%
194    }
195    else
196    {
197      %>
198      You don't have enough permissions to create a MeV TDSM file.
199      <%
200    }
201    %>
202    </td>
203  </tr>
204  <tr>
205    <td class="prompt" colspan="2">CGH - Comparative genomics hybridization</td>
206  </tr>
207  <tr>
208    <td><base:button title="Start MeV" 
209      onclick="launchMev('mev.cgh')" 
210      image="<%=tdmsFile == null ? homeUrl + "/images/tm4_disabled.png" : homeUrl + "/images/tm4.png" %>" 
211      disabled="<%=cghFile == null%>"/></td>
212    <td>
213    <%
214    if (cghFile == null)
215    {
216      %>
217      There is currently no CGH file associated with the bioassay set.
218      <%
219    }
220    else
221    {
222      %>
223      Start MeV with the current CGH file:<br>
224      <%=HTML.encodeTags(cghFile.getName())%> <%=Base.getFileLinks(ID, cghFile, root) %>
225      <%
226    }
227    %>
228    </td>
229  </tr>
230  <tr>
231    <td><base:button title="Export" 
232      onclick="exportCgh()" 
233      disabled="<%=!canCreateCGHFile%>" 
234      image="<%=canCreateCGHFile ? "export.gif" : homeUrl + "/images/export_disabled.gif"%>" /></td>
235    <td>
236    <%
237    if (canCreateCGHFile)
238    {
239      %>
240      Export the spot data to a MeV CGH file that can be opened with MeV.
241      <%
242    }
243    else
244    {
245      %>
246      You don't have enough permissions to create a MeV CGH file.
247      <%
248    }
249    %>
250    </td>
251  </tr>
252  <%
253  if (canCreateCGHFile)
254  {
255    %>
256    <tr>
257      <td style="text-align: right;">-configuration</td>
258      <td>
259        <select name="cgh_configuration">
260        <%
261        for (PluginConfiguration cfg : cghConfigurations)
262        {
263          %>
264          <option value="<%=cfg.getId()%>"><%=HTML.encodeTags(cfg.getName())%>
265          <%
266        }
267        %>
268        </select>
269      </td>
270    </tr>
271    <%
272  }
273  %>
274  </table>
275  </div>
276  </form>
277
278  <table align="center">
279  <tr>
280    <td><base:button onclick="window.close();" title="Close" /></td>
281  </tr>
282  </table>
283
284</base:body>
285</base:page>
286  <%
287}
288finally
289{
290  if (dc != null) dc.close();
291}
292%>
Note: See TracBrowser for help on using the repository browser.