source: branches/filedb/www/views/experiments/list_experiments.jsp @ 3814

Last change on this file since 3814 was 3814, checked in by Nicklas Nordborg, 16 years ago

References #721: Store data in files instead of in the database

  • Experiments are now aware of file-only raw data types
  • Fixed test programs
  • A few remaining Affymetrix issues


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