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

Last change on this file since 6690 was 6690, checked in by Nicklas Nordborg, 8 years ago

References #1906: Display inherited annotations in list views

Implemented this for samples, extracts physical bioassays, derived bioassays and array (slide/batch/desing) list views

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