source: branches/3.18-stable/www/biomaterials/samples/list_samples.jsp @ 7933

Last change on this file since 7933 was 7933, checked in by Nicklas Nordborg, 2 years ago

References #2246: Sticky table headers

Added support for setting sticky columns. The idea is to have the counter/checkbox/icon column sticky as well as the "Name" column for all item lists. This has been implemented in the samples list page.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 31.9 KB
Line 
1<%-- $Id: list_samples.jsp 7933 2021-04-29 12:19:17Z 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.Sample"
31  import="net.sf.basedb.core.Extract"
32  import="net.sf.basedb.core.BioPlate"
33  import="net.sf.basedb.core.BioSource"
34  import="net.sf.basedb.core.BioMaterialEvent"
35  import="net.sf.basedb.core.BioWell"
36  import="net.sf.basedb.core.AnnotationType"
37  import="net.sf.basedb.core.ItemSubtype"
38  import="net.sf.basedb.core.AnnotationSet"
39  import="net.sf.basedb.core.ItemQuery"
40  import="net.sf.basedb.core.Include"
41  import="net.sf.basedb.core.ItemResultIterator"
42  import="net.sf.basedb.core.ItemResultList"
43  import="net.sf.basedb.core.ItemContext"
44  import="net.sf.basedb.core.ItemList"
45  import="net.sf.basedb.core.Nameable"
46  import="net.sf.basedb.core.Permission"
47  import="net.sf.basedb.core.PermissionDeniedException"
48  import="net.sf.basedb.core.PlateGeometry"
49  import="net.sf.basedb.core.PluginDefinition"
50  import="net.sf.basedb.core.Annotation"
51  import="net.sf.basedb.core.Quantity"
52  import="net.sf.basedb.core.Unit"
53  import="net.sf.basedb.core.query.Hql"
54  import="net.sf.basedb.core.query.Restrictions"
55  import="net.sf.basedb.core.query.Expressions"
56  import="net.sf.basedb.core.query.Orders"
57  import="net.sf.basedb.core.plugin.GuiContext"
58  import="net.sf.basedb.core.plugin.Plugin"
59  import="net.sf.basedb.core.snapshot.AnnotationLoaderUtil"
60  import="net.sf.basedb.core.snapshot.AnnotationTypeFilter"
61  import="net.sf.basedb.core.snapshot.AnnotationSnapshot"
62  import="net.sf.basedb.core.snapshot.AnnotationSetSnapshot"
63  import="net.sf.basedb.core.snapshot.SnapshotManager"
64  import="net.sf.basedb.core.Type"
65  import="net.sf.basedb.util.Enumeration"
66  import="net.sf.basedb.util.ShareableUtil"
67  import="net.sf.basedb.util.units.UnitUtil"
68  import="net.sf.basedb.clients.web.Base"
69  import="net.sf.basedb.clients.web.ModeInfo"
70  import="net.sf.basedb.clients.web.PermissionUtil"
71  import="net.sf.basedb.clients.web.util.HTML"
72  import="net.sf.basedb.util.Values"
73  import="net.sf.basedb.util.formatter.Formatter"
74  import="net.sf.basedb.util.formatter.WellCoordinateFormatter"
75  import="net.sf.basedb.util.formatter.NameableFormatter"
76  import="net.sf.basedb.clients.web.formatter.LinkedItemFormatter"
77  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
78  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
79  import="net.sf.basedb.clients.web.extensions.JspContext"
80  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
81  import="net.sf.basedb.clients.web.extensions.toolbar.ButtonAction" 
82  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
83  import="net.sf.basedb.clients.web.extensions.list.ListColumnAction"
84  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
85  import="net.sf.basedb.clients.web.util.ProjectSpecificInfoFilter"
86  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
87  import="java.util.Iterator" 
88  import="java.util.List"
89  import="java.util.Map"
90  import="java.util.Date"
91  import="java.util.ArrayList"
92%>
93<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
94<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
95<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
96<%!
97  private static final Item itemType = Item.SAMPLE;
98  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
99%>
100<%
101final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
102final String ID = sc.getId();
103final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType);
104final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
105
106final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
107final Formatter<Nameable> nameableFormatter = mode.hasPropertyLink() ? new LinkedItemFormatter(mode.hasEditLink()) : new NameableFormatter();
108final String callback = request.getParameter("callback");
109final String title = mode.generateTitle("sample", "samples");
110final DbControl dc = sc.newDbControl();
111ItemResultIterator<Sample> samples = null;
112List<AnnotationLoaderUtil> annotationLoaders = new ArrayList<AnnotationLoaderUtil>();
113try
114{
115  ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
116  final ItemQuery<ItemSubtype> subtypesQuery = Base.getSubtypesQuery(itemType);
117 
118  // Child extracts
119  final ItemQuery<Extract> extractQuery = Extract.getQuery();
120  extractQuery.include(cc.getInclude());
121  extractQuery.restrict(Restrictions.eq(Hql.property("parent"), Hql.entityParameter("sample", Item.SAMPLE)));
122  extractQuery.order(Orders.asc(Hql.property("name")));
123  final boolean createExtractPermission = sc.hasPermission(Permission.CREATE, Item.EXTRACT);
124
125  // Child samples
126  final ItemQuery<Sample> childSamplesQuery = Sample.getQuery();
127  childSamplesQuery.join(Hql.innerJoin("creationEvent", "ce"));
128  childSamplesQuery.join(Hql.innerJoin("ce", "sources", "src"));
129  childSamplesQuery.restrict(Restrictions.eq(Hql.property("src", "bioMaterial"), Hql.entityParameter("sample", Item.SAMPLE)));
130  childSamplesQuery.order(Orders.asc(Hql.property("name")));
131  childSamplesQuery.setIncludes(cc.getInclude());
132 
133  // Parent samples
134  final ItemQuery<Sample> parentSamplesQuery = Sample.getQuery();
135  parentSamplesQuery.join(Hql.innerJoin("childCreationEvents", "cce"));
136  parentSamplesQuery.join(Hql.innerJoin("cce", "event", "evt"));
137  parentSamplesQuery.restrict(Restrictions.eq(Hql.alias("evt"), Hql.entityParameter("creationEvent", Item.BIOMATERIALEVENT)));
138  parentSamplesQuery.order(Orders.asc(Hql.property("name")));
139  parentSamplesQuery.setIncludes(cc.getInclude());
140
141  // List membership
142  final ItemQuery<ItemList> listQuery = ItemList.getQuery();
143  listQuery.setIncludes(cc.getInclude());
144  listQuery.join(Hql.innerJoin("members", "m"));
145  listQuery.restrict(Restrictions.eq(Hql.property("memberType"), Expressions.integer(itemType.getValue())));
146  listQuery.restrict(Restrictions.eq(Hql.alias("m"), Expressions.parameter("itemId", Type.INT)));
147  listQuery.order(Orders.asc(Hql.property("name")));
148 
149  Unit microGram = UnitUtil.getUnit(dc, Quantity.MASS, "µg");
150  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
151  SnapshotManager manager = new SnapshotManager();
152  ProjectSpecificInfoFilter psInfo = new ProjectSpecificInfoFilter();
153  for (AnnotationType at : annotationTypeQuery.list(dc))
154  {
155    annotationLoaders.add(new AnnotationLoaderUtil(dc, manager, at));
156  }
157  annotationTypeQuery = Base.getInheritedAnnotationColumns(cc.getSetting("columns"));
158  for (AnnotationType at : annotationTypeQuery.list(dc))
159  {
160    annotationLoaders.add(new AnnotationLoaderUtil(dc, manager, at, false, true));
161  }
162  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null);
163  try
164  {
165    final ItemQuery<Sample> query = Base.getConfiguredQuery(dc, cc, jspContext, true, Sample.getQuery(), mode);
166    samples = query.iterate(dc);
167  }
168  catch (Throwable t)
169  {
170    cc.setMessage(t.getMessage());
171    t.printStackTrace();
172  }
173  int numListed = 0;
174  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
175  Formatter<Number> numericFormatter = FormatterFactory.getNumberFormatter(sc);
176  WellCoordinateFormatter rowFormatter = new WellCoordinateFormatter(true);
177  WellCoordinateFormatter columnFormatter = new WellCoordinateFormatter(false);
178 
179  Enumeration<String, String> wellRows = new Enumeration<String, String>();
180  ItemQuery<PlateGeometry> geometryQuery = PlateGeometry.getQuery(); 
181  geometryQuery.order(Orders.desc(Hql.property("rows")));
182  ItemResultIterator<PlateGeometry> result = geometryQuery.iterate(dc);
183  int maxRows = result.next().getRows();
184  for (int r = 0; r < maxRows && r < 256; r++)
185  {
186    wellRows.add(Integer.toString(r), rowFormatter.format(r));
187  }
188 
189  Enumeration<String, String> wellColumns = new Enumeration<String, String>();
190  ItemQuery<PlateGeometry> columnsGeometryQuery = PlateGeometry.getQuery(); 
191  columnsGeometryQuery.order(Orders.desc(Hql.property("columns")));
192  ItemResultIterator<PlateGeometry> columnsResult = columnsGeometryQuery.iterate(dc);
193  int maxColumns = columnsResult.next().getColumns();
194  for (int c = 0; c < maxColumns && c < 256; c++)
195  {
196    wellColumns.add(Integer.toString(c), columnFormatter.format(c));
197  }
198
199  ExtensionsInvoker<ButtonAction> invoker = ToolbarUtil.useExtensions(jspContext);
200  ExtensionsInvoker<ListColumnAction<Sample,?>> columnsInvoker = ListColumnUtil.useExtensions(jspContext);
201  %>
202  <base:page title="<%=title==null ? "Samples" : title%>" type="<%=mode.getPageType()%>" id="list-page">
203  <base:head scripts="table.js,~samples.js" styles="table.css,toolbar.css,toolbar.css">
204    <ext:scripts context="<%=jspContext%>" />
205    <ext:stylesheets context="<%=jspContext%>" />
206  </base:head>
207 
208  <base:body>
209    <h1><%=title==null ? "Samples" : title%></h1>
210    <div class="content">
211    <tbl:table 
212      id="samples" 
213      columns="<%=cc.getSetting("columns")%>"
214      sortby="<%=cc.getSortProperty()%>" 
215      direction="<%=cc.getSortDirection()%>"
216      action="index.jsp"
217      sc="<%=sc%>"
218      item="<%=itemType%>"
219      filterrows="<%=cc.getFilterRows()%>"
220      subclass="fulltable"
221      data-inherited-annotations="true"
222      data-relateditem-columns="true"
223      stickyheaders="name"
224      >
225      <tbl:hidden 
226        name="mode" 
227        value="<%=mode.getName()%>" 
228      />
229      <tbl:hidden 
230        name="callback" 
231        value="<%=callback%>" 
232        skip="<%=callback == null%>" 
233      />
234      <tbl:columndef 
235        id="name"
236        property="name"
237        datatype="string"
238        title="Name"
239        sortable="true" 
240        filterable="true"
241        exportable="true"
242        show="always" 
243      />
244      <tbl:columndef 
245        id="itemSubtype"
246        property="itemSubtype"
247        sortproperty="itemSubtype.name"
248        exportproperty="itemSubtype.name:string"
249        datatype="int"
250        enumeration="<%=Enumeration.fromItems(subtypesQuery.list(dc), "-none-")%>"
251        title="Type"
252        sortable="true" 
253        filterable="true"
254        exportable="true"
255      />
256      <tbl:columndef 
257        id="id"
258        clazz="uniquecol"
259        property="id"
260        datatype="int"
261        title="ID"
262        sortable="true" 
263        filterable="true"
264        exportable="true" 
265      />
266      <tbl:columndef 
267        id="externalId"
268        property="externalId"
269        datatype="string"
270        title="External id"
271        sortable="true" 
272        filterable="true"
273        exportable="true"
274      />     
275      <tbl:columndef 
276        id="originalQuantity"
277        property="originalQuantity"
278        datatype="float"
279        title="Original quantity (µg)"
280        sortable="true" 
281        filterable="true"
282        exportable="true"
283        unit="<%=microGram%>"
284        formatter="<%=numericFormatter%>"
285      />
286      <tbl:columndef 
287        id="remainingQuantity"
288        property="remainingQuantity"
289        datatype="float"
290        title="Remaining quantity (µg)"
291        sortable="true" 
292        filterable="true"
293        exportable="true"
294        unit="<%=microGram%>"
295        formatter="<%=numericFormatter%>"
296      />
297      <tbl:columndef 
298        id="protocol"
299        property="creationEvent.protocol"
300        sortproperty="creationEvent.protocol.name"
301        filterproperty="creationEvent.protocol.name"
302        exportproperty="creationEvent.protocol.name"
303        datatype="string"
304        title="Protocol"
305        sortable="true" 
306        filterable="true"
307        exportable="true"
308      />
309      <tbl:columndef 
310        id="kit"
311        property="creationEvent.kit"
312        sortproperty="creationEvent.kit.name"
313        filterproperty="creationEvent.kit.name"
314        exportproperty="creationEvent.kit.name"
315        datatype="string"
316        title="Kit"
317        sortable="true" 
318        filterable="true"
319        exportable="true"
320      />
321      <tbl:columndef 
322        id="eventDate"
323        property="creationEvent.eventDate"
324        datatype="date"
325        title="Created"
326        sortable="true" 
327        filterable="true"
328        exportable="true"
329        formatter="<%=dateFormatter%>"
330      />
331      <tbl:columndef 
332        id="entryDate"
333        property="creationEvent.entryDate"
334        datatype="date"
335        title="Registered"
336        sortable="true" 
337        filterable="true"
338        exportable="true"
339        formatter="<%=dateFormatter%>"
340      />
341      <%
342      Enumeration<String, String> parentTypes = new Enumeration<String, String>();
343      parentTypes.add("", "-none-");
344      parentTypes.add(Integer.toString(Item.BIOSOURCE.getValue()), Item.BIOSOURCE.toString());
345      parentTypes.add(Integer.toString(Item.SAMPLE.getValue()), Item.SAMPLE.toString());
346      %>
347      <tbl:columndef
348        id="parentType"
349        title="Parent type"
350        property="parentType"
351        enumeration="<%=parentTypes%>"
352        datatype="int"
353        filterable="true"
354        exportable="true"
355        sortable="true"
356      />
357      <tbl:columndef
358        id="parents"
359        title="Parent items"
360        property="&creationEvent.sources(bioMaterial.name)"
361        sortproperty="parent.name"
362        datatype="string"
363        filterable="true"
364        exportable="true"
365        sortable="true"
366      />
367      <tbl:columndef
368        id="children"
369        title="Child samples"
370        property="&childCreationEvents(event.bioMaterial.name)"
371        datatype="string"
372        filterable="true"
373        exportable="true"
374      />
375      <tbl:columndef
376        id="extracts"
377        title="Extracts"
378        property="&children(name)"
379        datatype="string"
380        filterable="true"
381        exportable="true"
382      />
383      <tbl:columndef 
384        id="bioPlate"
385        property="bioWell.bioPlate.name"
386        sortproperty="bioWell.bioPlate.name"
387        filterproperty="bioWell.bioPlate.name"
388        exportproperty="bioWell.bioPlate.name"
389        datatype="string"
390        title="Bioplate"
391        sortable="true" 
392        filterable="true"
393        exportable="true"
394      />
395      <tbl:columndef 
396        id="bioWellRow"
397        property="bioWell.row"
398        sortproperty="bioWell.row"
399        datatype="int"
400        title="Biowell row" 
401        filterable="true"
402        enumeration="<%=wellRows%>"
403        exportable="true"
404        sortable="true"
405        formatter="<%=rowFormatter%>"
406      />
407      <tbl:columndef 
408        id="bioWellColumn"
409        property="bioWell.column"
410        sortproperty="bioWell.column"
411        datatype="int"
412        title="Biowell column"   
413        filterable="true"
414        enumeration="<%=wellColumns%>"
415        exportable="true"
416        sortable="true"
417        formatter="<%=columnFormatter%>"
418      />     
419      <tbl:columndef 
420        id="owner"
421        property="owner.name"
422        datatype="string"
423        title="Owner"
424        sortable="true" 
425        filterable="true"
426        exportable="true"
427      />
428      <tbl:columndef 
429        id="description"
430        property="description"
431        datatype="string"
432        title="Description" 
433        sortable="true" 
434        filterable="true" 
435        exportable="true"
436      />     
437      <tbl:columndef
438        id="itemList"
439        property="§itemLists"
440        datatype="int"
441        title="Item list"
442        filterable="true"
443        enumeration="<%=Base.getItemListsEnum(dc, itemType, cc.getInclude())%>"
444      />
445      <%
446      for (AnnotationLoaderUtil loader : annotationLoaders)
447      {
448        AnnotationType at = loader.getAnnotationType();
449        Enumeration<String, String> annotationEnum = null;
450        Formatter<Object> formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
451        if (at.isEnumeration())
452        {
453          annotationEnum = new Enumeration<String, String>();
454          if (!at.getDisplayAsList()) annotationEnum.add("", "-none-");
455          List<?> values = at.getValues();
456          for (Object value : values)
457          {
458            String encoded = formatter.format(value);
459            annotationEnum.add(encoded, encoded);
460          }
461        }
462        %>
463        <tbl:columndef 
464          id="<%=(loader.isSearchingInheritedAnnotations() ? "ia" : "at")+at.getId()%>"
465          title="<%=HTML.encodeTags(at.getName())+(loader.isSearchingInheritedAnnotations() ? " [I]" : " [A]")%>" 
466          property="<%=(loader.isSearchingInheritedAnnotations() ? "##" : "#")+at.getId()%>"
467          annotation="true"
468          datatype="<%=at.getValueType().getStringValue()%>"
469          enumeration="<%=annotationEnum%>"
470          smartenum="<%=at.getDisplayAsList() %>"
471          sortable="<%=at.getMultiplicity() == 1 && !loader.isSearchingInheritedAnnotations()%>" 
472          filterable="true" 
473          exportable="true"
474          formatter="<%=formatter%>"
475          unit="<%=at.getDefaultUnit()%>"
476        />
477        <%
478      }
479      %>
480      <tbl:columndef
481        id="permission"
482        title="Permission"
483      />
484      <tbl:columndef
485        id="sharedTo"
486        title="Shared to"
487        filterable="true"
488        filterproperty="!sharedTo.name"
489        datatype="string"
490      />
491      <tbl:columndef 
492        id="xt-columns" 
493        extensions="<%=columnsInvoker%>" 
494        jspcontext="<%=jspContext%>" 
495      />
496     
497      <div class="panelgroup bg-filled-50 bottomborder">
498        <tbl:toolbar
499          subclass="bottomborder"
500          visible="<%=mode.hasToolbar()%>"
501          >
502          <tbl:button 
503            id="btnNewItem"
504            disabled="<%=!createPermission%>" 
505            image="new.png" 
506            title="New&hellip;" 
507            tooltip="<%=createPermission ? "Create new sample" : "You do not have permission to create samples"%>" 
508          />
509          <tbl:button 
510            id="btnNewPooledItem"
511            disabled="<%=!createPermission%>" 
512            image="new_pooled.png" 
513            title="Pool&hellip;" 
514            tooltip="<%=createPermission ? "Create new pooled sample" : "You do not have permission to create samples"%>" 
515          />
516          <tbl:button 
517            id="btnDeleteItems"
518            image="delete.png"
519            title="Delete" 
520            tooltip="Delete the selected items" 
521          />
522          <tbl:button 
523            id="btnRestoreItems"
524            image="restore.png"
525            title="Restore" 
526            tooltip="Restore the selected (deleted) items"
527          />
528          <tbl:button 
529            id="btnShareItems"
530            image="share.png"
531            title="Share&hellip;" 
532            tooltip="Share the selected items"
533          />
534          <tbl:button 
535            id="btnSetOwner"
536            image="take_ownership.png"
537            title="Set owner&hellip;"
538            tooltip="Change owner of the selected items"
539          />
540          <tbl:button 
541            id="btnColumns"
542            image="columns.png" 
543            title="Columns&hellip;" 
544            tooltip="Show, hide and re-order columns" 
545          />
546          <tbl:button
547            id="btnNewItemList"
548            image="add.png"
549            title="New item list&hellip;"
550            tooltip="Create a new item list from matching samples"
551            visible="<%=sc.hasPermission(Permission.CREATE, Item.ITEMLIST)%>"
552          />
553          <tbl:button
554            id="btnAddToItemList"
555            image="add.png"
556            title="Add to item list&hellip;"
557            tooltip="Add samples to an existing item list"
558          />
559          <tbl:button 
560            id="btnPlaceOnPlate"
561            image="place_on_plate.png" 
562            title="Place on plate&hellip;" 
563            tooltip="Place the selected/matching samples on a bioplate" 
564          />
565          <tbl:button
566            id="btnInheritAnnotations"
567            image="inherit.png"
568            title="Inherit annotations&hellip;"
569            tooltip="Batch inherit annotations from parent items"
570          />
571          <tbl:button 
572            id="btnImport"
573            data-plugin-type="IMPORT"
574            image="import.png" 
575            title="Import&hellip;" 
576            tooltip="Import data" 
577            visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
578          />
579          <tbl:button 
580            id="btnExport"
581            data-plugin-type="EXPORT"
582            image="export.png" 
583            title="Export&hellip;" 
584            tooltip="Export data" 
585            visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
586          />
587          <tbl:button 
588            id="btnRunPlugin"
589            data-plugin-type="OTHER"
590            image="runplugin.png" 
591            title="Run plugin&hellip;" 
592            tooltip="Run a plugin" 
593            visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
594          />
595          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
596            wrapper="<%=new PrefixSuffixRenderer<ButtonAction>(jspContext, "<td>", "</td>") %>"/>
597        </tbl:toolbar>
598        <tbl:panel>
599          <tbl:presetselector />
600          <tbl:navigator
601            page="<%=cc.getPage()%>" 
602            rowsperpage="<%=cc.getRowsPerPage()%>" 
603            totalrows="<%=samples == null ? 0 : samples.getTotalCount()%>" 
604            visible="<%=mode.hasNavigator()%>"
605          />
606        </tbl:panel>
607      </div>
608      <tbl:data>
609        <tbl:headers>
610          <tbl:headerrow>
611            <tbl:header clazz="row-index bg-filled-100" />
612            <tbl:columnheaders />
613          </tbl:headerrow>
614          <%
615          int numFilters = cc.getNumPropertyFilters();
616          int numRows = cc.getFilterRows();
617          for (int filterNo = 0; filterNo < numRows; filterNo++)
618          {
619            boolean lastRow = filterNo == numRows-1;
620            %>
621            <tbl:headerrow>
622              <tbl:header subclass="row-index bg-filled-100">
623                <div class="index-<%=mode.getName()%>">
624                  <div class="index"></div>
625                  <div class="check">
626                    <base:icon 
627                      subclass="link table-check"
628                      image="check_uncheck.png" 
629                      tooltip="Toggle all (use CTRL, ALT or SHIFT to check/uncheck)" 
630                      visible="<%=lastRow && mode.hasCheck()%>"
631                    />
632                  </div>
633                  <div class="icons">
634                    <base:icon
635                      subclass="link table-filter-row-action"
636                      image="add.png"
637                      tooltip="Add extra filter row"
638                      visible="<%=lastRow%>"
639                    /><base:icon
640                      subclass="link table-filter-row-action"
641                      image="remove.png"
642                      tooltip="Remove this filter row"
643                      visible="<%=numRows > 1 || numFilters > 0 %>"
644                      data-remove-row="<%=filterNo%>"
645                    />
646                  </div>
647                </div>
648              </tbl:header>
649              <tbl:propertyfilter row="<%=filterNo%>" />
650            </tbl:headerrow>
651            <%
652          }
653          %>
654          <tbl:columnsubtitles />
655        </tbl:headers>
656        <tbl:rows>
657          <%
658          if (cc.getMessage() != null)
659          {
660            %>
661            <tbl:panel subclass="bg-filled-50">
662              <div class="messagecontainer error"><%=cc.getMessage()%></div>
663            </tbl:panel>
664            <%
665            cc.setMessage(null);
666          }
667         
668          int index = cc.getPage()*cc.getRowsPerPage();
669          int selectedItemId = cc.getId();
670          if (samples != null)
671          {           
672            while (samples.hasNext())
673            {
674              Sample item = samples.next();
675              Item parentType = item.getParentType();
676              BioMaterialEvent creationEvent = item.getCreationEvent();
677              int itemId = item.getId();
678              boolean usePermission = item.hasPermission(Permission.USE);
679             
680             
681              boolean deletePermission = item.hasPermission(Permission.DELETE);
682              boolean sharePermission = item.hasPermission(Permission.SET_PERMISSION);
683              boolean writePermission = item.hasPermission(Permission.WRITE);
684              String tooltip = mode.isSelectionMode() ?
685                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
686              String name = HTML.encodeTags(item.getName());
687              index++;
688              numListed++;
689              %>
690              <tbl:row>
691                <tbl:header clazz="row-index bg-filled-100">
692                  <div class="index-<%=mode.getName()%>">
693                    <div class="index"><%=index%></div>
694                    <div class="check">
695                      <base:input
696                        type="checkbox" 
697                        name="<%=itemId%>" 
698                        value="<%=itemId%>" 
699                        title="<%=name%>" 
700                        checked="<%=cc.getSelected().contains(itemId)%>"
701                        visible="<%=mode.hasCheck()%>"
702                      />
703                      <base:input 
704                        type="radio" 
705                        name="item_id" 
706                        value="<%=itemId%>" 
707                        title="<%=name%>" 
708                        checked="<%=selectedItemId == itemId%>"
709                        visible="<%=mode.hasRadio()%>"
710                      />
711                    </div>
712                    <div class="icons">
713                      <base:icon 
714                        image="deleted.png"
715                        id="<%="delete."+itemId %>"
716                        subclass="<%=deletePermission ? "table-delete-item" : "disabled" %>"
717                        data-item-id="<%=itemId%>"
718                        tooltip="This item has been scheduled for deletion" 
719                        visible="<%=item.isRemoved()%>"
720                      /><base:icon 
721                        image="shared.png" 
722                        id="<%="share."+itemId %>"
723                        subclass="<%=sharePermission ? "table-share-item" : "disabled" %>"
724                        data-item-id="<%=itemId%>"
725                        tooltip="This item is shared to other users, groups and/or projects" 
726                        visible="<%=item.isShared()%>"
727                      />
728                    </div>
729                  </div>
730                </tbl:header>
731                <tbl:cell column="name"><div 
732                  class="link table-item"
733                  data-item-id="<%=itemId%>"
734                  data-no-edit="<%=writePermission ? 0 : 1 %>" 
735                  tabindex="0"
736                  title="<%=tooltip%>"
737                  ><%=name%></div></tbl:cell>
738                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
739                <tbl:cell column="itemSubtype"><base:propertyvalue 
740                    item="<%=item%>" 
741                    property="itemSubtype"
742                    enableEditLink="<%=mode.hasEditLink()%>" 
743                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
744                  /></tbl:cell>
745                <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell>               
746                <tbl:cell column="originalQuantity" value="<%=item.getOriginalQuantity()%>" />
747                <tbl:cell column="remainingQuantity" value="<%=item.getRemainingQuantity()%>" />
748                <tbl:cell column="protocol"
749                  ><base:propertyvalue 
750                    item="<%=creationEvent%>" 
751                    property="protocol"
752                    enableEditLink="<%=mode.hasEditLink()%>" 
753                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
754                  /></tbl:cell>
755                <tbl:cell column="kit"
756                  ><base:propertyvalue 
757                    item="<%=creationEvent%>" 
758                    property="kit"
759                    enableEditLink="<%=mode.hasEditLink()%>" 
760                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
761                  /></tbl:cell>
762                <%               
763                BioWell well = null;
764                boolean readBioWell = true;
765                try
766                {
767                  well = item.getBioWell();
768                }
769                catch(PermissionDeniedException e)
770                {
771                  readBioWell = false;
772                }
773                if (!readBioWell)
774                {
775                  %>
776                  <tbl:cell column="bioWellRow"><i>- denied -</i> </tbl:cell>
777                  <tbl:cell column="bioWellColumn"><i>- denied -</i> </tbl:cell>
778                  <tbl:cell column="bioPlate"><i>- denied -</i> </tbl:cell>
779                  <%
780                }
781                else if (well == null)
782                {
783                  %>
784                  <tbl:cell column="bioWellRow"><i>- none -</i> </tbl:cell>
785                  <tbl:cell column="bioWellColumn"><i>- none -</i> </tbl:cell>
786                  <tbl:cell column="bioPlate"><i>- none -</i> </tbl:cell>
787                  <%
788                 
789                }
790                else
791                {               
792                  %>
793                  <tbl:cell column="bioWellRow">
794                    <tbl:cellvalue value="<%=well.getRow()%>"/>
795                  </tbl:cell>
796                  <tbl:cell column="bioWellColumn">
797                    <tbl:cellvalue value="<%=well.getColumn()%>"/>
798                  </tbl:cell>
799                  <tbl:cell column="bioPlate"><%=Base.getLinkedName(ID, well.getPlate(), false, true)%></tbl:cell>
800                  <%
801                }
802                %>
803                <tbl:cell column="eventDate" value="<%=creationEvent.getEventDate()%>" />
804                <tbl:cell column="entryDate" value="<%=creationEvent.getEntryDate()%>" />
805                <tbl:cell column="parentType"><%=parentType == null ? "" : parentType.toString() %></tbl:cell>
806                <tbl:cell column="parents">
807                  <%
808                  if (item.hasSingleParent() || parentType == null)
809                  {
810                    Float usedQuantity = null;
811                    if (parentType == Item.SAMPLE)
812                    {
813                      try
814                      {
815                        usedQuantity = creationEvent.getUsedQuantity((Sample)item.getParent());
816                      }
817                      catch (PermissionDeniedException ex)
818                      {}
819                    }
820                    %>
821                    <base:propertyvalue item="<%=item%>" property="parent"/>
822                    <%=usedQuantity != null ? "(" + numericFormatter.format(usedQuantity) + "µg)" : ""%>
823                    <%
824                  }
825                  else
826                  {
827                    String separator = "";
828                    parentSamplesQuery.setEntityParameter("creationEvent", creationEvent);
829                    for (Sample s : parentSamplesQuery.list(dc))
830                    {
831                      Float usedQuantity = creationEvent.getUsedQuantity(s);
832                      out.write(separator);
833                      if (mode.hasPropertyLink())
834                      {
835                        out.write(Base.getLinkedName(ID, s, false, mode.hasEditLink()));
836                      }
837                      else
838                      {
839                        out.write(HTML.encodeTags(s.getName()));
840                      }
841                      if (usedQuantity != null)
842                      {
843                        out.write(" (" + numericFormatter.format(usedQuantity) + "µg)");
844                      }
845                      separator = ", ";
846                    }
847                  }
848                  %>
849                  <%=parentType != null ? "<span class=\"itemsubtype\">(" + parentType + ")</span>" : "" %>
850                </tbl:cell>
851                <tbl:cell column="children">
852                  <%
853                  childSamplesQuery.setEntityParameter("sample", item);
854                  %>
855                  <%=Values.getString(childSamplesQuery.list(dc), ", ", false, nameableFormatter) %>
856                  <base:icon
857                    id="<%="newsample."+itemId%>"
858                    image="add.png" 
859                    subclass="auto-init"
860                    data-auto-init="new-sample"
861                    data-item-id="<%=itemId %>"
862                    tooltip="Create new child sample" 
863                    visible="<%=mode.hasEditLink() && createPermission && usePermission %>"
864                  />
865                </tbl:cell>
866                <tbl:cell column="extracts">
867                  <%
868                  extractQuery.setEntityParameter("sample", item);
869                  %>
870                  <%=Values.getString(extractQuery.list(dc), ", ", false, nameableFormatter) %>
871                  <base:icon
872                    id="<%="newsample."+itemId%>"
873                    image="add.png" 
874                    subclass="auto-init"
875                    data-auto-init="new-extract"
876                    data-item-id="<%=itemId %>"
877                    tooltip="Create new extract" 
878                    visible="<%=mode.hasEditLink() && createExtractPermission && usePermission %>"
879                  />
880                </tbl:cell>
881                <tbl:cell column="itemList">
882                  <%
883                  listQuery.setParameter("itemId", itemId, Type.INT);
884                  %>
885                  <%=Values.getString(listQuery.list(dc), ", ", false, nameableFormatter) %>
886                </tbl:cell>
887                <tbl:cell column="owner"
888                  ><base:propertyvalue 
889                    item="<%=item%>" 
890                    property="owner"
891                    enableEditLink="<%=mode.hasEditLink()%>" 
892                    enablePropertyLink="<%=mode.hasPropertyLink()%>" 
893                  /></tbl:cell>
894                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>               
895                <%
896                if (item.isAnnotated())
897                {
898                  AnnotationSetSnapshot snapshot = manager.getSnapshot(dc, item.getAnnotationSet().getId());
899                  for (AnnotationLoaderUtil loader : annotationLoaders)
900                  {
901                    %>
902                    <tbl:cell 
903                      column="<%=(loader.isSearchingInheritedAnnotations() ? "ia" : "at")+loader.getId()%>"
904                      ><%
905                      if (loader.find(snapshot, psInfo.reset())) 
906                      {
907                        %><tbl:cellvalue 
908                          list="<%=loader.getValues()%>"
909                          suffix="<%=loader.getUnitSymbol()%>"
910                          clazz="<%=psInfo.overridesDefaultAnnotation() ? "ps-annotation" : null%>"
911                        /><%
912                      }
913                      %></tbl:cell>
914                    <%
915                  }
916                }
917                %>
918                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
919                <tbl:cell column="sharedTo">
920                  <%=Values.getString(ShareableUtil.getSharedTo(dc, item), ", ", false, nameableFormatter) %>
921                </tbl:cell>
922                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
923                  <tbl:cell column="xt-columns" />
924                </tbl:xt-cells>
925              </tbl:row>
926              <%
927              }
928            }
929            if (numListed == 0)
930            {
931              %>
932              <tbl:panel subclass="bg-filled-50">
933                <div class="messagecontainer note">
934                <%=samples == null || samples.getTotalCount() == 0 ? "No samples were found" : "No samples on this page. Please select another page!" %>
935                </div>
936              </tbl:panel>
937              <%
938            }
939            %>
940          </tbl:rows>
941      </tbl:data>
942    </tbl:table>
943    </div>
944
945    <base:buttongroup subclass="dialogbuttons">
946      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
947      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
948      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
949    </base:buttongroup>
950  </base:body>
951  </base:page>
952  <%
953}
954finally
955{
956  if (samples != null) samples.close();
957  if (dc != null) dc.close();
958}
959%>
Note: See TracBrowser for help on using the repository browser.