source: trunk/www/biomaterials/extracts/list_extracts.jsp @ 7773

Last change on this file since 7773 was 7773, checked in by Nicklas Nordborg, 3 years ago

References #2202: Include information from parent items in list pages

Implemented a simple dialog for selecting parent item columns. It currently allows selecting to display the name of a parent item or any annotation that is attached to it. It can probably be improved a bit more.

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