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

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

References #1912: Add more filter rows in list pages

Fixes a problem with using non-unique id for the 'Add filter row' icon when used on pages that has multiple lists. This caused the icon to not work or add rows to the incorrect list.

The add/remove icons are now based on class names instead which means we can target each icon within the table context it is defined in.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 19.2 KB
Line 
1<%-- $Id: list_experiments.jsp 6699 2015-01-30 10:32:48Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, 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 3
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 BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  @author Nicklas
24  @version 2.0
25--%>
26<%@ page pageEncoding="UTF-8" session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.Item"
30  import="net.sf.basedb.core.Experiment"
31  import="net.sf.basedb.core.RawDataType"
32  import="net.sf.basedb.core.RawDataTypes"
33  import="net.sf.basedb.core.ItemQuery"
34  import="net.sf.basedb.core.Include"
35  import="net.sf.basedb.core.ItemResultIterator"
36  import="net.sf.basedb.core.ItemResultList"
37  import="net.sf.basedb.core.ItemContext"
38  import="net.sf.basedb.core.Nameable"
39  import="net.sf.basedb.core.Permission"
40  import="net.sf.basedb.core.PluginDefinition"
41  import="net.sf.basedb.core.Quantity"
42  import="net.sf.basedb.core.Unit"
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.util.units.UnitUtil"
51  import="net.sf.basedb.clients.web.Base"
52  import="net.sf.basedb.clients.web.ModeInfo"
53  import="net.sf.basedb.clients.web.PermissionUtil"
54  import="net.sf.basedb.clients.web.util.HTML"
55  import="net.sf.basedb.util.Values"
56  import="net.sf.basedb.util.formatter.Formatter"
57  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
58  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
59  import="net.sf.basedb.clients.web.extensions.JspContext"
60  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
61  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
62  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
63  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
64  import="java.util.Iterator"
65  import="java.util.List"
66  import="java.util.Map"
67  import="java.util.Date"
68%>
69<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
70<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
71<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
72<%!
73  private static final Item itemType = Item.EXPERIMENT;
74  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
75%>
76<%
77final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
78final String ID = sc.getId();
79final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType);
80final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
81
82final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
83final String callback = request.getParameter("callback");
84final String title = mode.generateTitle("experiment", "experiments");
85final DbControl dc = sc.newDbControl();
86ItemResultIterator<Experiment> experiments = null;
87try
88{
89  Unit bytes = UnitUtil.getUnit(dc, Quantity.STORAGE_SIZE, "B");
90  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
91  try
92  {
93    final ItemQuery<Experiment> query = Base.getConfiguredQuery(dc, cc, true, Experiment.getQuery(), mode);
94    experiments = query.iterate(dc);
95  }
96  catch (Throwable t)
97  {
98    cc.setMessage(t.getMessage());
99  }
100  int numListed = 0;
101  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
102  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null);
103  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
104  ExtensionsInvoker columnsInvoker = ListColumnUtil.useExtensions(jspContext);
105  %>
106  <base:page title="<%=title==null ? "Experiments" : title%>" type="<%=mode.getPageType()%>" id="list-page">
107  <base:head scripts="table.js,~experiments.js" styles="table.css,toolbar.css">
108    <ext:scripts context="<%=jspContext%>" />
109    <ext:stylesheets context="<%=jspContext%>" />
110  </base:head>
111 
112  <base:body>
113    <h1><%=title==null ? "Experiments" : title%></h1>
114    <div class="content">
115    <tbl:table 
116      id="experiments" 
117      columns="<%=cc.getSetting("columns")%>"
118      sortby="<%=cc.getSortProperty()%>" 
119      direction="<%=cc.getSortDirection()%>"
120      action="index.jsp"
121      sc="<%=sc%>"
122      item="<%=itemType%>"
123      filterrows="<%=cc.getFilterRows()%>"
124      subclass="fulltable"
125      >
126      <tbl:hidden 
127        name="mode" 
128        value="<%=mode.getName()%>" 
129      />
130      <tbl:hidden 
131        name="callback" 
132        value="<%=callback%>" 
133        skip="<%=callback == null%>" 
134      />
135      <tbl:columndef 
136        id="name"
137        property="name"
138        datatype="string"
139        title="Name"
140        sortable="true" 
141        filterable="true"
142        exportable="true"
143        show="always" 
144      />
145      <tbl:columndef 
146        id="id"
147        clazz="uniquecol"
148        property="id"
149        datatype="int"
150        title="ID"
151        sortable="true"
152        filterable="true"
153        exportable="true"
154      />
155      <tbl:columndef 
156        id="entryDate"
157        property="entryDate"
158        datatype="date"
159        title="Registered"
160        sortable="true" 
161        filterable="true"
162        exportable="true"
163        formatter="<%=dateFormatter%>"
164      />
165      <%
166      Enumeration<String, String> rawEnumeration = new Enumeration<String, String>();
167      for (RawDataType rdt : RawDataTypes.getRawDataTypes())
168      {
169        rawEnumeration.add(rdt.getId(), HTML.encodeTags(rdt.getName()));
170      }
171      rawEnumeration.sortValues();
172      %>
173      <tbl:columndef 
174        id="rawDataType"
175        property="rawDataType"
176        datatype="string"
177        enumeration="<%=rawEnumeration%>"
178        title="Raw data type"
179        sortable="true" 
180        filterable="true"
181        exportable="true"
182      />
183      <tbl:columndef 
184        id="bytes"
185        property="bytes"
186        datatype="long"
187        title="Bytes"
188        sortable="true" 
189        filterable="true"
190        exportable="true"
191        unit="<%=bytes%>"
192      />
193      <tbl:columndef 
194        id="directory"
195        property="directory.name"
196        datatype="string"
197        title="Directory"
198        sortable="true" 
199        filterable="true"
200        exportable="true"
201      />
202      <tbl:columndef 
203        id="reporterCloneTemplate"
204        property="virtualDb.reporterCloneTemplate.name"
205        datatype="string"
206        title="Reporter clone template"
207        sortable="true" 
208        filterable="true"
209        exportable="true"
210      />
211      <tbl:columndef 
212        id="title"
213        property="title"
214        datatype="string"
215        title="Title"
216        sortable="true" 
217        filterable="true"
218        exportable="true"
219      />
220      <tbl:columndef 
221        id="abstract"
222        property="abstract"
223        datatype="string"
224        title="Abstract"
225        sortable="true" 
226        filterable="true"
227        exportable="true"
228      />
229      <tbl:columndef 
230        id="affiliations"
231        property="affiliations"
232        datatype="string"
233        title="Affiliations"
234        sortable="true" 
235        filterable="true"
236        exportable="true"
237      />
238      <tbl:columndef 
239        id="authors"
240        property="authors"
241        datatype="string"
242        title="Authors"
243        sortable="true" 
244        filterable="true"
245        exportable="true"
246      />
247      <tbl:columndef 
248        id="experimentDesign"
249        property="experimentDesign"
250        datatype="string"
251        title="Experiment design"
252        sortable="true" 
253        filterable="true"
254        exportable="true"
255      />
256      <tbl:columndef 
257        id="experimentType"
258        property="experimentType"
259        datatype="string"
260        title="Experiment type"
261        sortable="true" 
262        filterable="true"
263        exportable="true"
264      />
265      <tbl:columndef 
266        id="publication"
267        property="publication"
268        datatype="string"
269        title="Publication"
270        sortable="true" 
271        filterable="true"
272        exportable="true"
273      />
274      <tbl:columndef 
275        id="publicationDate"
276        property="publicationDate"
277        datatype="date"
278        title="Publication date"
279        sortable="true" 
280        filterable="true"
281        exportable="true"
282        formatter="<%=dateFormatter%>"
283      />
284      <tbl:columndef 
285        id="pubMedId"
286        property="pubMedId"
287        datatype="string"
288        title="PubMedId"
289        sortable="true" 
290        filterable="true"
291        exportable="true"
292      />
293      <tbl:columndef 
294        id="owner"
295        property="owner.name"
296        datatype="string"
297        title="Owner"
298        sortable="true" 
299        filterable="true"
300        exportable="true"
301      />
302      <tbl:columndef 
303        id="description"
304        property="description"
305        datatype="string"
306        title="Description" 
307        sortable="true" 
308        filterable="true" 
309        exportable="true"
310      />
311      <tbl:columndef 
312        id="actions"
313        title="Actions"
314      />
315      <tbl:columndef
316        id="permission"
317        title="Permission"
318      />
319      <tbl:columndef
320        id="sharedTo"
321        title="Shared to"
322        filterable="true"
323        filterproperty="!sharedTo.name"
324        datatype="string"
325      />
326      <tbl:columndef 
327        id="xt-columns" 
328        extensions="<%=columnsInvoker%>" 
329        jspcontext="<%=jspContext%>" 
330      />
331      <div class="panelgroup bg-filled-50 bottomborder">
332        <tbl:toolbar
333          subclass="bottomborder"
334          visible="<%=mode.hasToolbar()%>"
335          >
336          <tbl:button 
337            id="btnNewItem"
338            disabled="<%=!createPermission%>" 
339            image="new.png" 
340            title="New&hellip;" 
341            tooltip="<%=createPermission ? "Create new experiment" : "You do not have permission to create experiments"%>" 
342          />
343          <tbl:button 
344            id="btnDeleteItems"
345            image="delete.png"
346            title="Delete" 
347            tooltip="Delete the selected items" 
348          />
349          <tbl:button 
350            id="btnRestoreItems"
351            image="restore.png"
352            title="Restore" 
353            tooltip="Restore the selected (deleted) items"
354          />
355          <tbl:button 
356            id="btnShareItems"
357            image="share.png"
358            title="Share&hellip;" 
359            tooltip="Share the selected items"
360          />
361          <tbl:button 
362            id="btnSetOwner"
363            image="take_ownership.png"
364            title="Set owner&hellip;"
365            tooltip="Change owner of the selected items"
366          />
367          <tbl:button 
368            id="btnColumns"
369            image="columns.png" 
370            title="Columns&hellip;" 
371            tooltip="Show, hide and re-order columns" 
372          />
373          <tbl:button 
374            id="btnImport"
375            data-plugin-type="IMPORT"
376            image="import.png" 
377            title="Import&hellip;" 
378            tooltip="Import data" 
379            visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
380          />
381          <tbl:button 
382            id="btnExport"
383            data-plugin-type="EXPORT"
384            image="export.png" 
385            title="Export&hellip;" 
386            tooltip="Export data" 
387            visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
388          />
389          <tbl:button 
390            id="btnRunPlugin"
391            data-plugin-type="OTHER"
392            image="runplugin.png" 
393            title="Run plugin&hellip;" 
394            tooltip="Run a plugin" 
395            visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
396          />
397          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
398            wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
399        </tbl:toolbar>
400        <tbl:panel>
401          <tbl:presetselector />
402          <tbl:navigator
403            page="<%=cc.getPage()%>" 
404            rowsperpage="<%=cc.getRowsPerPage()%>" 
405            totalrows="<%=experiments == null ? 0 : experiments.getTotalCount()%>" 
406            visible="<%=mode.hasNavigator()%>"
407          />
408        </tbl:panel>
409      </div>
410      <tbl:data>
411        <tbl:headers>
412          <tbl:headerrow>
413            <tbl:header colspan="3" />
414            <tbl:columnheaders />
415          </tbl:headerrow>
416          <%
417          int numFilters = cc.getNumPropertyFilters();
418          int numRows = cc.getFilterRows();
419          for (int filterNo = 0; filterNo < numRows; filterNo++)
420          {
421            boolean lastRow = filterNo == numRows-1;
422            %>
423            <tbl:headerrow>
424              <tbl:header subclass="index" />
425              <tbl:header 
426                subclass="check" 
427                visible="<%=mode.hasCheck()%>"
428                ><base:icon 
429                  id="check.uncheck"
430                  image="check_uncheck.png" 
431                  tooltip="Check/uncheck all" 
432                  visible="<%=lastRow%>"
433                /></tbl:header>
434              <tbl:header 
435                subclass="check" 
436                visible="<%=mode.hasRadio()%>"
437                />
438              <tbl:header 
439                subclass="icons" 
440                visible="<%=mode.hasIcons()%>"
441                >
442                <base:icon
443                  subclass="link table-filter-row-action"
444                  image="add.png"
445                  tooltip="Add extra filter row"
446                  visible="<%=lastRow%>"
447                /><base:icon
448                  subclass="link table-filter-row-action"
449                  image="remove.png"
450                  tooltip="Remove this filter row"
451                  visible="<%=numRows > 1 || numFilters > 0 %>"
452                  data-remove-row="<%=filterNo%>"
453                />
454              </tbl:header>
455              <tbl:propertyfilter row="<%=filterNo%>" />
456            </tbl:headerrow>
457            <%
458          }
459          %>
460        </tbl:headers>
461        <tbl:rows>
462          <%
463          if (cc.getMessage() != null)
464          {
465            %>
466            <tbl:panel subclass="bg-filled-50">
467              <div class="messagecontainer error"><%=cc.getMessage()%></div>
468            </tbl:panel>
469            <%
470            cc.setMessage(null);
471          }
472          int index = cc.getPage()*cc.getRowsPerPage();
473          int selectedItemId = Values.getInt(request.getParameter("item_id"));
474          if (experiments != null)
475          {           
476            while (experiments.hasNext())
477            {
478              Experiment item = experiments.next();
479              int itemId = item.getId();
480             
481             
482              boolean deletePermission = item.hasPermission(Permission.DELETE);
483              boolean sharePermission = item.hasPermission(Permission.SET_PERMISSION);
484              boolean writePermission = item.hasPermission(Permission.WRITE);
485              String tooltip = mode.isSelectionMode() ?
486                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
487              String name = HTML.encodeTags(item.getName());
488              index++;
489              numListed++;
490              %>
491              <tbl:row>
492                <tbl:header 
493                  clazz="index"
494                  ><%=index%></tbl:header>
495                <tbl:header 
496                  clazz="check" 
497                  visible="<%=mode.hasCheck()%>"
498                  ><input 
499                    type="checkbox" 
500                    name="<%=itemId%>" 
501                    value="<%=itemId%>" 
502                    title="<%=name%>" 
503                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
504                  ></tbl:header>
505                <tbl:header 
506                  clazz="check" 
507                  visible="<%=mode.hasRadio()%>"
508                  ><input 
509                    type="radio" 
510                    name="item_id" 
511                    value="<%=itemId%>" 
512                    title="<%=name%>" 
513                    <%=selectedItemId == itemId ? "checked" : ""%>
514                  ></tbl:header>
515                <tbl:header 
516                  clazz="icons" 
517                  visible="<%=mode.hasIcons()%>"
518                  ><base:icon 
519                    image="deleted.png"
520                    id="<%="delete."+itemId %>"
521                    subclass="<%=deletePermission ? "table-delete-item" : null %>"
522                    data-item-id="<%=itemId%>"
523                    tooltip="This item has been scheduled for deletion" 
524                    visible="<%=item.isRemoved()%>"
525                  /><base:icon 
526                    image="shared.png" 
527                    id="<%="share."+itemId %>"
528                    subclass="<%=sharePermission ? "table-share-item" : null %>"
529                    data-item-id="<%=itemId%>"
530                    tooltip="This item is shared to other users, groups and/or projects" 
531                    visible="<%=item.isShared()%>"
532                  />&nbsp;</tbl:header>
533                <tbl:cell column="name"><div 
534                  class="link table-item"
535                  data-item-id="<%=itemId%>"
536                  data-no-edit="<%=writePermission ? 0 : 1 %>" 
537                  tabindex="0"
538                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
539                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
540                <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" />
541                <tbl:cell column="bytes"><%=Values.formatBytes(item.getBytes())%></tbl:cell>
542                <tbl:cell column="rawDataType"><%=HTML.encodeTags(item.getRawDataType().getName())%></tbl:cell>
543                <tbl:cell column="directory"
544                  ><base:propertyvalue 
545                    item="<%=item%>" 
546                    property="directory" 
547                    enableEditLink="<%=mode.hasEditLink()%>" 
548                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
549                  /></tbl:cell>
550                <tbl:cell column="reporterCloneTemplate"
551                  ><base:propertyvalue 
552                    item="<%=item%>" 
553                    property="virtualDb.reporterCloneTemplate" 
554                    enableEditLink="<%=mode.hasEditLink()%>" 
555                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
556                  /></tbl:cell>
557                <tbl:cell column="title"><%=HTML.encodeTags(item.getTitle())%></tbl:cell>
558                <tbl:cell column="abstract"><%=HTML.encodeTags(item.getAbstract())%></tbl:cell>
559                <tbl:cell column="affiliations"><%=HTML.encodeTags(item.getAffiliations())%></tbl:cell>
560                <tbl:cell column="authors"><%=HTML.encodeTags(item.getAuthors())%></tbl:cell>
561                <tbl:cell column="experimentDesign"><%=HTML.encodeTags(item.getExperimentDesign())%></tbl:cell>
562                <tbl:cell column="experimentType"><%=HTML.encodeTags(item.getExperimentType())%></tbl:cell>
563                <tbl:cell column="publication"><%=HTML.encodeTags(item.getPublication())%></tbl:cell>
564                <tbl:cell column="publicationDate" value="<%=item.getPublicationDate()%>" />
565                <tbl:cell column="pubMedId"><%=HTML.encodeTags(item.getPubMedId())%></tbl:cell>
566                <tbl:cell column="owner"
567                  ><base:propertyvalue 
568                    item="<%=item%>" 
569                    property="owner"
570                    enableEditLink="<%=mode.hasEditLink()%>" 
571                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
572                  /></tbl:cell>
573                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
574                <tbl:cell column="actions"><a href="bioassaysets/index.jsp?ID=<%=ID%>&amp;experiment_id=<%=itemId%>">Analyze</a></tbl:cell>
575                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
576                <tbl:cell column="sharedTo">
577                  <%
578                  Iterator<Nameable> sharees = ShareableUtil.getSharedTo(dc, item).iterator();
579                  while(sharees.hasNext())
580                  {
581                    Nameable n = sharees.next();
582                    if (mode.hasPropertyLink())
583                    {
584                      out.write(Base.getLinkedName(ID, n, false, mode.hasEditLink()));
585                    }
586                    else
587                    {
588                      out.write(HTML.encodeTags(n.getName()));
589                    }
590                    out.write(sharees.hasNext() ? ", " : "");
591                  }
592                  %>
593                </tbl:cell>
594                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
595                  <tbl:cell column="xt-columns" />
596                </tbl:xt-cells>
597              </tbl:row>
598              <%
599              }
600            }
601          if (numListed == 0)
602          {
603            %>
604            <tbl:panel subclass="bg-filled-50">
605              <div class="messagecontainer note">
606              <%=experiments == null || experiments.getTotalCount() == 0 ? "No experiments were found" : "No experiments on this page. Please select another page!" %>
607              </div>
608            </tbl:panel>
609            <%
610          }
611          %>
612        </tbl:rows>
613      </tbl:data>
614    </tbl:table>
615    </div>
616   
617    <base:buttongroup subclass="dialogbuttons">
618      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
619      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
620      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
621    </base:buttongroup>
622   
623  </base:body>
624  </base:page>
625  <%
626}
627finally
628{
629  if (experiments != null) experiments.close();
630  if (dc != null) dc.close();
631}
632%>
Note: See TracBrowser for help on using the repository browser.