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

Last change on this file was 2209, checked in by Nicklas Nordborg, 9 years ago

Fixes #567: Update MEV extension to new scripting pattern

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 8.7 KB
Line 
1<%-- $Id: launch_mev.jsp 2209 2014-02-03 07:36:18Z 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%>" id="mev-launch">
130<base:head scripts="~scripts/mev.js" />
131<base:body>
132  <h1><%=title%></h1>
133 
134  <div id="page-data" class="datacontainer"
135    data-bioassayset-id="<%=bioAssaySetId%>"
136  ></div>
137
138  <form name="mev">
139  <div class="content bottomborder">
140
141  <table class="fullform">
142    <tbody class="sectionheader">
143      <tr>
144        <th colspan="2">MeV analysis file</th>
145      </tr>
146    </tbody>
147    <tbody>
148      <tr>
149        <td style="padding-bottom: 1em;"><base:button 
150          title="Start MeV" 
151          subclass="auto-init"
152          data-auto-init="start-mev"
153          data-mev-file-type="mev.anl"
154          image="<%=homeUrl + "/images/tm4.png" %>" 
155          disabled="<%=anlFile == null%>"/></td>
156        <td style="padding-bottom: 1em;">
157        <%
158        if (anlFile == null)
159        {
160          %>
161          There is currently no MeV analysis file associated with the bioassay set.
162          <%
163        }
164        else
165        {
166          %>
167          Start MeV with the current analysis file:<br>
168          <%=HTML.encodeTags(anlFile.getName())%> <%=Base.getFileLinks(ID, anlFile, root) %>
169          <%
170        }
171        %>
172        </td>
173      </tr>
174    </tbody>
175    <tbody class="sectionheader">
176      <tr>
177        <th colspan="2">TDMS - Tab-delimited multiple sample</th>
178      </tr>
179    </tbody>
180    <tbody>
181      <tr>
182        <td><base:button 
183          title="Start MeV" 
184          subclass="auto-init"
185          data-auto-init="start-mev"
186          data-mev-file-type="mev.tdms"
187          image="<%=homeUrl + "/images/tm4.png" %>" 
188          disabled="<%=tdmsFile == null%>"/></td>
189        <td>
190        <%
191        if (tdmsFile == null)
192        {
193          %>
194          There is currently no TDMS file associated with the bioassay set.
195          <%
196        }
197        else
198        {
199          %>
200          Start MeV with the current TDMS file:<br>
201          <%=HTML.encodeTags(tdmsFile.getName())%> <%=Base.getFileLinks(ID, tdmsFile, root) %>
202          <%
203        }
204        %>
205        </td>
206      </tr>
207      <tr>
208        <td style="padding-bottom: 1em;"><base:button 
209          id="export-tdms"
210          title="Export" 
211          disabled="<%=!allowCreateFile%>" 
212          data-job-name="<%=HTML.encodeTags(tdmsJobName) %>"
213          data-save-as="<%=HTML.encodeTags(defaultPath+defaultTdmsFileName)%>"
214          image="export.png" /></td>
215        <td style="padding-bottom: 1em;">
216        <%
217        if (allowCreateFile)
218        {
219          %>
220          Export the spot data to a MeV TDMS file that can be opened with MeV.
221          <%
222        }
223        else
224        {
225          %>
226          You don't have enough permissions to create a MeV TDSM file.
227          <%
228        }
229        %>
230        </td>
231      </tr>
232    </tbody>
233    <tbody class="sectionheader">
234      <tr>
235        <th colspan="2">CGH - Comparative genomics hybridization</th>
236      </tr>
237    </tbody>
238    <tbody>
239      <tr>
240        <td><base:button 
241          title="Start MeV" 
242          subclass="auto-init"
243          data-auto-init="start-mev"
244          data-mev-file-type="mev.cgh"
245          image="<%=homeUrl + "/images/tm4.png" %>" 
246          disabled="<%=cghFile == null%>"/></td>
247        <td>
248        <%
249        if (cghFile == null)
250        {
251          %>
252          There is currently no CGH file associated with the bioassay set.
253          <%
254        }
255        else
256        {
257          %>
258          Start MeV with the current CGH file:<br>
259          <%=HTML.encodeTags(cghFile.getName())%> <%=Base.getFileLinks(ID, cghFile, root) %>
260          <%
261        }
262        %>
263        </td>
264      </tr>
265      <tr>
266        <td><base:button 
267          id="export-cgh"
268          title="Export" 
269          disabled="<%=!canCreateCGHFile%>" 
270          data-job-name="<%=HTML.encodeTags(cghJobName) %>"
271          data-save-as="<%=HTML.encodeTags(defaultPath+defaultCghFileName)%>"
272          image="export.png" /></td>
273        <td>
274        <%
275        if (canCreateCGHFile)
276        {
277          %>
278          Export the spot data to a MeV CGH file that can be opened with MeV.
279          <%
280        }
281        else
282        {
283          %>
284          You don't have enough permissions to create a MeV CGH file.
285          <%
286        }
287        %>
288        </td>
289      </tr>
290      <%
291      if (canCreateCGHFile)
292      {
293        %>
294        <tr>
295          <td style="text-align: right;">-configuration</td>
296          <td>
297            <select name="cgh_configuration">
298            <%
299            for (PluginConfiguration cfg : cghConfigurations)
300            {
301              %>
302              <option value="<%=cfg.getId()%>"><%=HTML.encodeTags(cfg.getName())%>
303              <%
304            }
305            %>
306            </select>
307          </td>
308        </tr>
309        <%
310      }
311      %>
312    </tbody>
313    <tr class="dynamic">
314      <td></td>
315      <td></td>
316    </tr>
317  </table>
318  </div>
319  </form>
320
321  <base:buttongroup subclass="dialogbuttons">
322    <base:button id="close" title="Close" />
323  </base:buttongroup>
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.