source: branches/3.18-stable/www/biomaterials/extracts/list_extracts.jsp @ 7930

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

References #2246: Sticky table headers

Started to implement this. In order to not break existing tables, the sticky-headers class must be set on lists that should have sticky headers. Tested on the extracts list page so far.

Note! The implementation only works with Firefox since it is the only browser that currently supports position: sticky; on the <thead> element. Other browsers support it on <th> elements, but we can't use that since we have more than one header row in the tables.

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