source: extensions/net.sf.basedb.mev/tags/1.8/resources/launch_mev.jsp

Last change on this file was 1416, checked in by Nicklas Nordborg, 11 years ago

Fixes #328: Switch to GPL3

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