source: trunk/www/views/experiments/list_experiments.jsp @ 3190

Last change on this file since 3190 was 3190, checked in by Johan Enell, 16 years ago

Merged log:branches/2.2.2#3116:3186 to trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 17.3 KB
Line 
1<%-- $Id: list_experiments.jsp 3190 2007-03-13 10:05:42Z enell $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
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 Nicklas
25  @version 2.0
26--%>
27<%@ page session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.Experiment"
32  import="net.sf.basedb.core.RawDataType"
33  import="net.sf.basedb.core.RawDataTypes"
34  import="net.sf.basedb.core.ItemQuery"
35  import="net.sf.basedb.core.Include"
36  import="net.sf.basedb.core.ItemResultIterator"
37  import="net.sf.basedb.core.ItemResultList"
38  import="net.sf.basedb.core.ItemContext"
39  import="net.sf.basedb.core.Permission"
40  import="net.sf.basedb.core.PluginDefinition"
41  import="net.sf.basedb.core.query.Hql"
42  import="net.sf.basedb.core.query.Restrictions"
43  import="net.sf.basedb.core.query.Expressions"
44  import="net.sf.basedb.core.plugin.GuiContext"
45  import="net.sf.basedb.core.plugin.Plugin"
46  import="net.sf.basedb.util.Enumeration"
47  import="net.sf.basedb.clients.web.Base"
48  import="net.sf.basedb.clients.web.ModeInfo"
49  import="net.sf.basedb.clients.web.PermissionUtil"
50  import="net.sf.basedb.clients.web.util.HTML"
51  import="net.sf.basedb.util.Values"
52  import="net.sf.basedb.util.formatter.Formatter"
53  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
54  import="java.util.List"
55  import="java.util.Map"
56  import="java.util.Date"
57%>
58<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
59<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
60<%!
61  private static final Item itemType = Item.EXPERIMENT;
62  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
63%>
64<%
65final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
66final String ID = sc.getId();
67final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType);
68final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
69
70final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
71final String callback = request.getParameter("callback");
72final String title = mode.generateTitle("experiment", "experiments");
73final DbControl dc = sc.newDbControl();
74ItemResultIterator<Experiment> experiments = null;
75try
76{
77  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
78  try
79  {
80    final ItemQuery<Experiment> query = Base.getConfiguredQuery(cc, true, Experiment.getQuery(), mode);
81    experiments = query.iterate(dc);
82  }
83  catch (Throwable t)
84  {
85    cc.setMessage(t.getMessage());
86  }
87  int numListed = 0;
88  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
89  %>
90  <base:page title="<%=title==null ? "Experiments" : title%>" type="<%=mode.getPageType()%>">
91  <base:head scripts="menu.js,table.js" styles="menu.css,table.css">
92    <script language="JavaScript">
93    var submitPage = 'index.jsp';
94    var formId = 'experiments';
95    function newItem()
96    {
97      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', 0, true);
98    }
99    function editItem(itemId)
100    {
101      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, true);
102    }
103    function viewItem(itemId)
104    {
105      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, false);
106    }
107    function itemOnClick(evt, itemId)
108    {
109      Table.itemOnClick(formId, evt, itemId, '<%=mode.getName()%>', viewItem, editItem, returnSelected);
110    }
111    function deleteItems()
112    {
113      var frm = document.forms[formId];
114      if (Forms.numChecked(frm) == 0)
115      {
116        alert('Please select at least one item in the list');
117        return;
118      }
119      frm.action = submitPage;
120      frm.cmd.value = 'DeleteItems';
121      frm.submit();
122    }
123    function restoreItems()
124    {
125      var frm = document.forms[formId];
126      if (Forms.numChecked(frm) == 0)
127      {
128        alert('Please select at least one item in the list');
129        return;
130      }
131      frm.action = submitPage;
132      frm.cmd.value = 'RestoreItems';
133      frm.submit();
134    }
135    function takeOwnership()
136    {
137      var frm = document.forms[formId];
138      if (Forms.numChecked(frm) == 0)
139      {
140        alert('Please select at least one item in the list');
141        return;
142      }
143      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
144      {
145        frm.action = submitPage;
146        frm.cmd.value = 'TakeOwnershipOfItems';
147        frm.submit();
148      }
149    }
150    function shareItem(itemId)
151    {
152      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id='+itemId, 'SharedExperiments', 500, 400);
153    }
154    function shareItems()
155    {
156      Table.shareItems(submitPage, '<%=ID%>', formId, '<%=itemType.name()%>', 'ShareItems');
157    }
158    function configureColumns()
159    {
160      Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
161    }
162    function runPlugin(cmd)
163    {
164      Table.submitToPopup(formId, cmd, 740, 540);
165    }
166    function returnSelected()
167    {
168      Table.returnSelected(formId, <%=callback != null ? "window.opener."+callback : "null" %>);
169      window.close();
170    }
171    function presetOnChange()
172    {
173      Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
174    }
175    </script>
176  </base:head>
177 
178  <base:body>
179    <%
180    if (cc.getMessage() != null)
181    {
182      %>
183      <div class="error"><%=cc.getMessage()%></div>
184      <%
185      cc.setMessage(null);
186    }
187    %>
188    <tbl:table 
189      id="experiments" 
190      clazz="itemlist" 
191      columns="<%=cc.getSetting("columns")%>"
192      sortby="<%=cc.getSortProperty()%>" 
193      direction="<%=cc.getSortDirection()%>"
194      title="<%=title%>"
195      action="index.jsp"
196      sc="<%=sc%>"
197      item="<%=itemType%>"
198      >
199      <tbl:hidden 
200        name="mode" 
201        value="<%=mode.getName()%>" 
202      />
203      <tbl:hidden 
204        name="callback" 
205        value="<%=callback%>" 
206        skip="<%=callback == null%>" 
207      />
208      <tbl:columndef 
209        id="name"
210        property="name"
211        datatype="string"
212        title="Name"
213        sortable="true" 
214        filterable="true"
215        exportable="true"
216        show="always" 
217      />
218      <%
219      Enumeration<String, String> rawEnumeration = new Enumeration<String, String>();
220      for (RawDataType rdt : RawDataTypes.getRawDataTypes())
221      {
222        rawEnumeration.add(rdt.getId(), HTML.encodeTags(rdt.getName()));
223      }
224      %>
225      <tbl:columndef 
226        id="rawDataType"
227        property="rawDataType"
228        datatype="string"
229        enumeration="<%=rawEnumeration%>"
230        title="Raw data type"
231        sortable="true" 
232        filterable="true"
233        exportable="true"
234      />
235      <tbl:columndef 
236        id="bytes"
237        property="bytes"
238        datatype="long"
239        title="Bytes"
240        sortable="true" 
241        filterable="true"
242        exportable="true"
243      />
244      <tbl:columndef 
245        id="directory"
246        property="directory.name"
247        datatype="string"
248        title="Directory"
249        sortable="true" 
250        filterable="true"
251        exportable="true"
252      />
253      <tbl:columndef 
254        id="title"
255        property="title"
256        datatype="string"
257        title="Title"
258        sortable="true" 
259        filterable="true"
260        exportable="true"
261      />
262      <tbl:columndef 
263        id="abstract"
264        property="abstract"
265        datatype="string"
266        title="Abstract"
267        sortable="true" 
268        filterable="true"
269        exportable="true"
270      />
271      <tbl:columndef 
272        id="affiliations"
273        property="affiliations"
274        datatype="string"
275        title="Affiliations"
276        sortable="true" 
277        filterable="true"
278        exportable="true"
279      />
280      <tbl:columndef 
281        id="authors"
282        property="authors"
283        datatype="string"
284        title="Authors"
285        sortable="true" 
286        filterable="true"
287        exportable="true"
288      />
289      <tbl:columndef 
290        id="experimentDesign"
291        property="experimentDesign"
292        datatype="string"
293        title="Experiment design"
294        sortable="true" 
295        filterable="true"
296        exportable="true"
297      />
298      <tbl:columndef 
299        id="experimentType"
300        property="experimentType"
301        datatype="string"
302        title="Experiment type"
303        sortable="true" 
304        filterable="true"
305        exportable="true"
306      />
307      <tbl:columndef 
308        id="publication"
309        property="publication"
310        datatype="string"
311        title="Publication"
312        sortable="true" 
313        filterable="true"
314        exportable="true"
315      />
316      <tbl:columndef 
317        id="publicationDate"
318        property="publicationDate"
319        datatype="date"
320        title="Publication date"
321        sortable="true" 
322        filterable="true"
323        exportable="true"
324        formatter="<%=dateFormatter%>"
325      />
326      <tbl:columndef 
327        id="pubMedId"
328        property="pubMedId"
329        datatype="string"
330        title="PubMedId"
331        sortable="true" 
332        filterable="true"
333        exportable="true"
334      />
335      <tbl:columndef 
336        id="owner"
337        property="owner.name"
338        datatype="string"
339        title="Owner"
340        sortable="true" 
341        filterable="true"
342        exportable="true"
343      />
344      <tbl:columndef 
345        id="description"
346        property="description"
347        datatype="string"
348        title="Description" 
349        sortable="true" 
350        filterable="true" 
351        exportable="true"
352      />
353      <tbl:columndef 
354        id="actions"
355        title="Actions"
356      />
357      <tbl:columndef
358        id="permission"
359        title="Permission"
360      />
361      <tbl:toolbar
362        visible="<%=mode.hasToolbar()%>"
363        >
364        <tbl:button 
365          disabled="<%=createPermission ? false : true%>" 
366          image="<%=createPermission ? "new.gif" : "new_disabled.gif"%>" 
367          onclick="newItem()" 
368          title="New&hellip;" 
369          tooltip="<%=createPermission ? "Create new experiment" : "You do not have permission to create experiments"%>" 
370        />
371        <tbl:button 
372          image="delete.gif"
373          onclick="deleteItems()" 
374          title="Delete" 
375          tooltip="Delete the selected items" 
376        />
377        <tbl:button 
378          image="restore.gif"
379          onclick="restoreItems()" 
380          title="Restore" 
381          tooltip="Restore the selected (deleted) items"
382        />
383        <tbl:button 
384          image="share.gif"
385          onclick="shareItems()" 
386          title="Share&hellip;" 
387          tooltip="Share the selected items"
388        />
389        <tbl:button 
390          image="take_ownership.png"
391          onclick="takeOwnership()" 
392          title="Take ownership&hellip;"
393          tooltip="Take ownership of the selected items"
394        />
395        <tbl:button 
396          image="columns.gif" 
397          onclick="configureColumns()" 
398          title="Columns&hellip;" 
399          tooltip="Show, hide and re-order columns" 
400        />
401        <tbl:button 
402          image="import.gif" 
403          onclick="runPlugin('ImportItems')" 
404          title="Import&hellip;" 
405          tooltip="Import data" 
406          visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
407        />
408        <tbl:button 
409          image="export.gif" 
410          onclick="runPlugin('ExportItems')" 
411          title="Export&hellip;" 
412          tooltip="Export data" 
413          visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
414        />
415        <tbl:button 
416          image="runplugin.gif" 
417          onclick="runPlugin('RunListPlugin')" 
418          title="Run plugin&hellip;" 
419          tooltip="Run a plugin" 
420          visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
421        />
422      </tbl:toolbar>
423      <tbl:navigator
424        page="<%=cc.getPage()%>" 
425        rowsperpage="<%=cc.getRowsPerPage()%>" 
426        totalrows="<%=experiments == null ? 0 : experiments.getTotalCount()%>" 
427        visible="<%=mode.hasNavigator()%>"
428      />
429      <tbl:data>
430        <tbl:columns>
431        <tbl:presetselector 
432          clazz="columnheader"
433          colspan="3"
434          onchange="presetOnChange()"
435        />
436        </tbl:columns>
437
438        <tr>
439          <tbl:header 
440            clazz="index"
441            >&nbsp;</tbl:header>
442          <tbl:header 
443            clazz="check" 
444            visible="<%=mode.hasCheck()%>"
445            ><base:icon 
446              image="check_uncheck.gif" 
447              tooltip="Check/uncheck all" 
448              onclick="Forms.checkUncheck(document.forms[formId])" style="align: left;"
449            /></tbl:header>
450          <tbl:header 
451            clazz="check" 
452            visible="<%=mode.hasRadio()%>"
453            >&nbsp;</tbl:header>
454          <tbl:header 
455            clazz="icons" 
456            visible="<%=mode.hasIcons()%>"
457            >&nbsp;</tbl:header>
458          <tbl:propertyfilter />
459        </tr>
460         
461          <tbl:rows>
462          <%
463          int index = cc.getPage()*cc.getRowsPerPage();
464          int selectedItemId = Values.getInt(request.getParameter("item_id"));
465          if (experiments != null)
466          {           
467            while (experiments.hasNext())
468            {
469              Experiment item = experiments.next();
470              int itemId = item.getId();
471              String openSharePopup = "shareItem("+itemId+")";
472              boolean sharePermission = item.hasPermission(Permission.SET_PERMISSION);
473              boolean writePermission = item.hasPermission(Permission.WRITE);
474              String tooltip = mode.isSelectionMode() ?
475                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
476              String name = HTML.encodeTags(item.getName());
477              index++;
478              numListed++;
479              %>
480              <tbl:row>
481                <tbl:header 
482                  clazz="index"
483                  ><%=index%></tbl:header>
484                <tbl:header 
485                  clazz="check" 
486                  visible="<%=mode.hasCheck()%>"
487                  ><input 
488                    type="checkbox" 
489                    name="<%=itemId%>" 
490                    value="<%=itemId%>" 
491                    title="<%=name%>" 
492                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
493                  ></tbl:header>
494                <tbl:header 
495                  clazz="check" 
496                  visible="<%=mode.hasRadio()%>"
497                  ><input 
498                    type="radio" 
499                    name="item_id" 
500                    value="<%=itemId%>" 
501                    title="<%=name%>" 
502                    <%=selectedItemId == itemId ? "checked" : ""%>
503                  ></tbl:header>
504                <tbl:header 
505                  clazz="icons" 
506                  visible="<%=mode.hasIcons()%>"
507                  ><base:icon 
508                    image="deleted.gif" 
509                    tooltip="This item has been scheduled for deletion" 
510                    visible="<%=item.isRemoved()%>"
511                  /><base:icon 
512                    image="<%=sharePermission ? "shared.gif" : "shared_disabled.gif"%>" 
513                    onclick="<%=sharePermission ? openSharePopup : null%>"
514                    tooltip="This item is shared to other users, groups and/or projects" 
515                    visible="<%=item.isShared()%>"
516                  />&nbsp;</tbl:header>
517                <tbl:cell column="name"><div class="link" 
518                  onclick="itemOnClick(<%=writePermission ? "event" : null%>, <%=itemId%>)" 
519                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
520                <tbl:cell column="bytes"><%=Values.formatBytes(item.getBytes())%></tbl:cell>
521                <tbl:cell column="rawDataType"><%=HTML.encodeTags(item.getRawDataType().getName())%></tbl:cell>
522                <tbl:cell column="directory"
523                  ><base:propertyvalue 
524                    item="<%=item%>" 
525                    property="directory" 
526                    enableEditLink="<%=mode.hasEditLink()%>" 
527                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
528                  /></tbl:cell>
529                <tbl:cell column="title"><%=HTML.encodeTags(item.getTitle())%></tbl:cell>
530                <tbl:cell column="abstract"><%=HTML.encodeTags(item.getAbstract())%></tbl:cell>
531                <tbl:cell column="affiliations"><%=HTML.encodeTags(item.getAffiliations())%></tbl:cell>
532                <tbl:cell column="authors"><%=HTML.encodeTags(item.getAuthors())%></tbl:cell>
533                <tbl:cell column="experimentDesign"><%=HTML.encodeTags(item.getExperimentDesign())%></tbl:cell>
534                <tbl:cell column="experimentType"><%=HTML.encodeTags(item.getExperimentType())%></tbl:cell>
535                <tbl:cell column="publication"><%=HTML.encodeTags(item.getPublication())%></tbl:cell>
536                <tbl:cell column="publicationDate" value="<%=item.getPublicationDate()%>" />
537                <tbl:cell column="pubMedId"><%=HTML.encodeTags(item.getPubMedId())%></tbl:cell>
538                <tbl:cell column="owner"
539                  ><base:propertyvalue 
540                    item="<%=item%>" 
541                    property="owner"
542                    enableEditLink="<%=mode.hasEditLink()%>" 
543                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
544                  /></tbl:cell>
545                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
546                <tbl:cell column="actions"><a href="bioassaysets/index.jsp?ID=<%=ID%>&experiment_id=<%=itemId%>">Analyze</a></tbl:cell>
547                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
548              </tbl:row>
549              <%
550              }
551            }
552          %>
553          </tbl:rows>
554      </tbl:data>
555      <%
556      if (numListed == 0)
557      {
558        %>
559        <tbl:panel><%=experiments == null || experiments.getTotalCount() == 0 ? "No experiments were found" : "No experiments on this page. Please select another page!" %></tbl:panel>
560        <%
561      }
562      else
563      {
564        %>
565        <tbl:navigator
566          page="<%=cc.getPage()%>" 
567          rowsperpage="<%=cc.getRowsPerPage()%>" 
568          totalrows="<%=experiments == null ? 0 : experiments.getTotalCount()%>" 
569          visible="<%=mode.hasNavigator()%>"
570          locked="true"
571        />
572        <%
573      }
574      %>
575    </tbl:table>
576    <base:buttongroup align="center" clazz="fixedatbottom">
577      <base:button onclick="returnSelected();" title="Ok" visible="<%=mode.hasOkButton()%>" />
578      <base:button onclick="window.close();" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
579      <base:button onclick="window.close();" title="Close" visible="<%=mode.hasCloseButton()%>" />
580    </base:buttongroup>
581    <br><br><br>
582  </base:body>
583  </base:page>
584  <%
585}
586finally
587{
588  if (experiments != null) experiments.close();
589  if (dc != null) dc.close();
590}
591%>
Note: See TracBrowser for help on using the repository browser.