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

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

Merge BASE 3.16.1 to the trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 37.1 KB
Line 
1<%-- $Id: list_extracts.jsp 7813 2020-05-19 12:24:30Z 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  try
188  {
189    final ItemQuery<Extract> query = Base.getConfiguredQuery(dc, cc, true, Extract.getQuery(), mode);
190    extracts = query.iterate(dc);
191  }
192  catch (Throwable t)
193  {
194    cc.setMessage(t.getMessage());
195    t.printStackTrace();
196  }
197  int numListed = 0;
198  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
199  Formatter<Number> numericFormatter = FormatterFactory.getNumberFormatter(sc);
200  WellCoordinateFormatter rowFormatter = new WellCoordinateFormatter(true);
201  WellCoordinateFormatter columnFormatter = new WellCoordinateFormatter(false);
202 
203  Enumeration<String, String> wellRows = new Enumeration<String, String>();
204  ItemQuery<PlateGeometry> geometryQuery = PlateGeometry.getQuery(); 
205  geometryQuery.order(Orders.desc(Hql.property("rows")));
206  ItemResultIterator<PlateGeometry> result = geometryQuery.iterate(dc);
207  int maxRows = result.next().getRows();
208  for (int r = 0; r < maxRows && r < 256; r++)
209  {
210    wellRows.add(Integer.toString(r), rowFormatter.format(r));
211  }
212
213  Enumeration<String, String> wellColumns = new Enumeration<String, String>();
214  ItemQuery<PlateGeometry> columnsGeometryQuery = PlateGeometry.getQuery(); 
215  columnsGeometryQuery.order(Orders.desc(Hql.property("columns")));
216  ItemResultIterator<PlateGeometry> columnsResult = columnsGeometryQuery.iterate(dc);
217  int maxColumns = columnsResult.next().getColumns();
218  for (int c = 0; c < maxColumns && c < 256; c++)
219  {
220    wellColumns.add(Integer.toString(c), columnFormatter.format(c));
221  }
222
223  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null);
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"
246      data-inherited-annotations="true"
247      data-parent-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:headers>
747        <tbl:rows>
748          <%
749          if (cc.getMessage() != null)
750          {
751            %>
752            <tbl:panel subclass="bg-filled-50">
753              <div class="messagecontainer error"><%=cc.getMessage()%></div>
754            </tbl:panel>
755            <%
756            cc.setMessage(null);
757          }
758          int index = cc.getPage()*cc.getRowsPerPage();
759          int selectedItemId = cc.getId();
760          if (extracts != null)
761          {           
762            while (extracts.hasNext())
763            {
764              Extract item = extracts.next();
765              Item parentType = item.getParentType();
766              BioMaterialEvent creationEvent = item.getCreationEvent();
767              int itemId = item.getId();
768              boolean usePermission = item.hasPermission(Permission.USE);
769             
770             
771              boolean deletePermission = item.hasPermission(Permission.DELETE);
772              boolean sharePermission = item.hasPermission(Permission.SET_PERMISSION);
773              boolean writePermission = item.hasPermission(Permission.WRITE);
774              String tooltip = mode.isSelectionMode() ? 
775                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
776              String name = HTML.encodeTags(item.getName());
777              index++;
778              numListed++;
779              %>
780              <tbl:row>
781                <tbl:header 
782                  clazz="index"
783                  ><%=index%></tbl:header>
784                <tbl:header 
785                  clazz="check" 
786                  visible="<%=mode.hasCheck()%>"
787                  ><input 
788                    type="checkbox" 
789                    name="<%=itemId%>" 
790                    value="<%=itemId%>" 
791                    title="<%=name%>" 
792                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
793                  ></tbl:header>
794                <tbl:header 
795                  clazz="check" 
796                  visible="<%=mode.hasRadio()%>"
797                  ><input 
798                    type="radio" 
799                    name="item_id" 
800                    value="<%=itemId%>" 
801                    title="<%=name%>" 
802                    <%=selectedItemId == itemId ? "checked" : ""%>
803                  ></tbl:header>
804                <tbl:header 
805                  clazz="icons" 
806                  visible="<%=mode.hasIcons()%>"
807                  ><base:icon 
808                    image="deleted.png"
809                    id="<%="delete."+itemId %>"
810                    subclass="<%=deletePermission ? "table-delete-item" : "disabled" %>"
811                    data-item-id="<%=itemId%>"
812                    tooltip="This item has been scheduled for deletion" 
813                    visible="<%=item.isRemoved()%>"
814                  /><base:icon 
815                    image="shared.png" 
816                    id="<%="share."+itemId %>"
817                    subclass="<%=sharePermission ? "table-share-item" : "disabled" %>"
818                    data-item-id="<%=itemId%>"
819                    tooltip="This item is shared to other users, groups and/or projects" 
820                    visible="<%=item.isShared()%>"
821                  />&nbsp;</tbl:header>
822                <tbl:cell column="name"><div
823                  class="link table-item"
824                  data-item-id="<%=itemId%>"
825                  data-no-edit="<%=writePermission ? 0 : 1 %>" 
826                  tabindex="0"
827                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
828                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
829                <tbl:cell column="itemSubtype"><base:propertyvalue 
830                    item="<%=item%>" 
831                    property="itemSubtype"
832                    enableEditLink="<%=mode.hasEditLink()%>" 
833                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
834                  /></tbl:cell>
835                <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell>
836                <tbl:cell column="originalQuantity" value="<%=item.getOriginalQuantity()%>" />
837                <tbl:cell column="remainingQuantity" value="<%=item.getRemainingQuantity()%>" />
838                <tbl:cell column="tag"
839                  ><base:propertyvalue 
840                    item="<%=item%>" 
841                    property="tag"
842                    enableEditLink="<%=mode.hasEditLink()%>" 
843                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
844                  /></tbl:cell>
845                <tbl:cell column="protocol"
846                  ><base:propertyvalue 
847                    item="<%=creationEvent%>" 
848                    property="protocol"
849                    enableEditLink="<%=mode.hasEditLink()%>" 
850                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
851                  /></tbl:cell>
852                <tbl:cell column="kit"
853                  ><base:propertyvalue 
854                    item="<%=creationEvent%>" 
855                    property="kit"
856                    enableEditLink="<%=mode.hasEditLink()%>" 
857                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
858                  /></tbl:cell>
859                <tbl:cell column="eventDate" value="<%=creationEvent.getEventDate()%>" />
860                <tbl:cell column="entryDate" value="<%=creationEvent.getEntryDate()%>" />
861                <tbl:cell column="parentType"><%=parentType == null ? "" : parentType.toString() %></tbl:cell>
862                <tbl:cell column="parents">
863                  <%
864                  if (item.hasSingleParent() || parentType == null)
865                  {
866                    Float usedQuantity = null;
867                    if (parentType != null)
868                    {
869                      try
870                      {
871                        usedQuantity = creationEvent.getUsedQuantity((MeasuredBioMaterial)item.getParent());
872                      }
873                      catch (PermissionDeniedException ex)
874                      {}
875                    }
876                    %>
877                    <base:propertyvalue item="<%=item%>" property="parent" />
878                    <%=usedQuantity != null ? "(" + numericFormatter.format(usedQuantity) + "µg)" : ""%>
879                    <%
880                  }
881                  else
882                  {
883                    String separator = "";
884                    parentExtractsQuery.setEntityParameter("creationEvent", creationEvent);
885                    for (Extract e : parentExtractsQuery.list(dc))
886                    {
887                      Float usedQuantity = creationEvent.getUsedQuantity(e);
888                      out.write(separator);
889                      if (mode.hasPropertyLink())
890                      {
891                        out.write(Base.getLinkedName(ID, e, false, mode.hasEditLink()));
892                      }
893                      else
894                      {
895                        out.write(HTML.encodeTags(e.getName()));
896                      }
897                      if (usedQuantity != null)
898                      {
899                        out.write(" (" + numericFormatter.format(usedQuantity) + "µg)");
900                      }
901                      separator = ", ";
902                    }
903                  }
904                  %>
905                  <%=parentType != null ? "<span class=\"itemsubtype\">(" + parentType + ")</span>" : "" %>
906                </tbl:cell>
907                <tbl:cell column="children">
908                  <%
909                  childExtractsQuery.setEntityParameter("extract", item);
910                  %>
911                  <%=Values.getString(childExtractsQuery.list(dc), ", ", false, nameableFormatter) %>
912                  <base:icon
913                    id="<%="newextract."+itemId%>"
914                    image="add.png" 
915                    subclass="auto-init"
916                    data-auto-init="new-extract"
917                    data-item-id="<%=itemId %>"
918                    tooltip="Create new child extract" 
919                    visible="<%=mode.hasEditLink() && createPermission && usePermission %>"
920                  />
921                </tbl:cell>
922                <tbl:cell column="physicalBioAssays">
923                  <%                 
924                  bioAssayQuery.setEntityParameter("extract", item);
925                  %>
926                  <%=Values.getString(bioAssayQuery.list(dc), ", ", false, nameableFormatter) %>
927                </tbl:cell>
928                <tbl:cell column="derivedBioAssays">
929                  <%                 
930                  derivedAssayQuery.setEntityParameter("extract", item);
931                  %>
932                  <%=Values.getString(derivedAssayQuery.list(dc), ", ", false, nameableFormatter) %>
933                  <base:icon
934                    id="<%="newDerivedBioAssay."+itemId%>"
935                    image="add.png" 
936                    subclass="auto-init"
937                    data-auto-init="new-derived-bioassay"
938                    data-item-id="<%=itemId %>"
939                    tooltip="Create new derived bioassay from this extract" 
940                    visible="<%=mode.hasEditLink() && createDerivedBioAssayPermission && usePermission %>"
941                  />
942                </tbl:cell>
943                <tbl:cell column="rawBioAssays">
944                  <%                 
945                  rawAssayQuery.setEntityParameter("extract", item);
946                  %>
947                  <%=Values.getString(rawAssayQuery.list(dc), ", ", false, nameableFormatter) %>
948                  <base:icon
949                    id="<%="newRawBioAssay."+itemId%>"
950                    image="add.png" 
951                    subclass="auto-init"
952                    data-auto-init="new-raw-bioassay"
953                    data-item-id="<%=itemId %>"
954                    tooltip="Create new raw bioassay from this extract" 
955                    visible="<%=mode.hasEditLink() && createRawBioAssayPermission && usePermission %>"
956                  />
957                </tbl:cell>
958                <tbl:cell column="itemList">
959                  <%
960                  listQuery.setParameter("itemId", itemId, Type.INT);
961                  %>
962                  <%=Values.getString(listQuery.list(dc), ", ", false, nameableFormatter) %>
963                </tbl:cell>
964                <%               
965                BioWell well = null;
966                BioPlate bioPlate = null;
967                boolean readBioWell = true;
968                try
969                {
970                  well = item.getBioWell();
971                  if (well != null) bioPlate = well.getPlate();
972                }
973                catch(PermissionDeniedException e)
974                {
975                  readBioWell = false;
976                }
977                if (!readBioWell)
978                {
979                  %>
980                  <tbl:cell column="bioWellRow"><i>- denied -</i> </tbl:cell>
981                  <tbl:cell column="bioWellColumn"><i>- denied -</i> </tbl:cell>
982                  <tbl:cell column="bioPlate"><i>- denied -</i> </tbl:cell>
983                  <%
984                }
985                else if (well == null)
986                {
987                  %>
988                  <tbl:cell column="bioWellRow"><i>- none -</i> </tbl:cell>
989                  <tbl:cell column="bioWellColumn"><i>- none -</i> </tbl:cell>
990                  <tbl:cell column="bioPlate"><i>- none -</i> </tbl:cell>
991                  <%
992                 
993                }
994                else
995                {               
996                  %>
997                  <tbl:cell column="bioWellRow">
998                    <tbl:cellvalue value="<%=well.getRow()%>"/>
999                  </tbl:cell>
1000                  <tbl:cell column="bioWellColumn">
1001                    <tbl:cellvalue value="<%=well.getColumn()%>"/>
1002                  </tbl:cell>
1003                  <tbl:cell column="bioPlate"><%=Base.getLinkedName(ID, bioPlate, false, true)%></tbl:cell>
1004                  <%
1005                }
1006                %>
1007                <tbl:cell column="owner"
1008                  ><base:propertyvalue 
1009                    item="<%=item%>" 
1010                    property="owner"
1011                    enableEditLink="<%=mode.hasEditLink()%>" 
1012                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
1013                  /></tbl:cell>
1014                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>               
1015                <%
1016                if (item.isAnnotated())
1017                {
1018                  AnnotationSetSnapshot snapshot = manager.getSnapshot(dc, item.getAnnotationSet().getId());
1019                  for (AnnotationLoaderUtil loader : annotationLoaders)
1020                  {
1021                    %>
1022                    <tbl:cell 
1023                      column="<%=(loader.isSearchingInheritedAnnotations() ? "ia" : "at")+loader.getId()%>"
1024                      ><%
1025                      if (loader.find(snapshot, psInfo.reset())) 
1026                      {
1027                        %><tbl:cellvalue 
1028                          list="<%=loader.getValues()%>"
1029                          suffix="<%=loader.getUnitSymbol()%>"
1030                          clazz="<%=psInfo.overridesDefaultAnnotation() ? "ps-annotation" : null%>"
1031                        /><%
1032                      }
1033                      %></tbl:cell>
1034                    <%
1035                  }
1036                }
1037                if (bioPlate != null && bioPlate.isAnnotated())
1038                {
1039                  AnnotationSetSnapshot snapshot = manager.getSnapshot(dc, bioPlate.getAnnotationSet().getId());
1040                  for (AnnotationLoaderUtil loader : bioPlateAnnotationLoaders)
1041                  {
1042                    %>
1043                    <tbl:cell 
1044                      column="<%="pa"+loader.getId()%>"
1045                      ><%
1046                      if (loader.find(snapshot, psInfo.reset())) 
1047                      {
1048                        %><tbl:cellvalue 
1049                          list="<%=loader.getValues()%>"
1050                          suffix="<%=loader.getUnitSymbol()%>"
1051                          clazz="<%=psInfo.overridesDefaultAnnotation() ? "ps-annotation" : null%>"
1052                        /><%
1053                      }
1054                      %></tbl:cell>
1055                    <%
1056                  }
1057                }
1058                %>
1059                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
1060                <tbl:cell column="sharedTo">
1061                  <%=Values.getString(ShareableUtil.getSharedTo(dc, item), ", ", false, nameableFormatter) %>
1062                </tbl:cell>
1063                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
1064                  <tbl:cell column="xt-columns" />
1065                </tbl:xt-cells>
1066              </tbl:row>
1067              <%
1068              }
1069            }
1070            if (numListed == 0)
1071            {
1072              %>
1073              <tbl:panel subclass="bg-filled-50">
1074                <div class="messagecontainer note">
1075                <%=extracts == null || extracts.getTotalCount() == 0 ? "No extracts were found" : "No extracts on this page. Please select another page!" %>
1076                </div>
1077              </tbl:panel>
1078              <%
1079            }
1080          %>         
1081        </tbl:rows>
1082      </tbl:data>
1083    </tbl:table>
1084    </div>
1085    <base:buttongroup subclass="dialogbuttons">
1086      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
1087      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
1088      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
1089    </base:buttongroup>
1090   
1091  </base:body>
1092  </base:page>
1093  <%
1094}
1095finally
1096{
1097  if (extracts != null) extracts.close();
1098  if (dc != null) dc.close();
1099}
1100%>
Note: See TracBrowser for help on using the repository browser.