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

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

References #1908: Batch inheriting multiple annotations

Added to list pages for samples, extracts, physical bioassays, derived bioassays and array lims.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 32.3 KB
Line 
1<%-- $Id: list_extracts.jsp 6695 2015-01-28 06:59:57Z 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.BioPlate"
35  import="net.sf.basedb.core.BioMaterialEvent"
36  import="net.sf.basedb.core.BioWell"
37  import="net.sf.basedb.core.MeasuredBioMaterial"
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="btnInheritAnnotations"
564          image="inherit.png"
565          title="Inherit annotations&hellip;"
566          tooltip="Batch inherit annotations from parent items"
567        />
568        <tbl:button 
569          id="btnImport"
570          data-plugin-type="IMPORT"
571          image="import.png" 
572          title="Import&hellip;" 
573          tooltip="Import data" 
574          visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
575        />
576        <tbl:button 
577          id="btnExport"
578          data-plugin-type="EXPORT"
579          image="export.png" 
580          title="Export&hellip;" 
581          tooltip="Export data" 
582          visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
583        />
584        <tbl:button 
585          id="btnRunPlugin"
586          data-plugin-type="OTHER"
587          image="runplugin.png" 
588          title="Run plugin&hellip;" 
589          tooltip="Run a plugin" 
590          visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
591        />
592        <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
593          wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
594      </tbl:toolbar>
595      <tbl:panel>
596          <tbl:presetselector />
597        <tbl:navigator
598          page="<%=cc.getPage()%>" 
599          rowsperpage="<%=cc.getRowsPerPage()%>" 
600          totalrows="<%=extracts == null ? 0 : extracts.getTotalCount()%>" 
601          visible="<%=mode.hasNavigator()%>"
602        />
603      </tbl:panel>
604    </div>
605      <tbl:data>
606        <tbl:headers>
607          <tbl:headerrow>
608            <tbl:header colspan="3" />
609            <tbl:columnheaders />
610          </tbl:headerrow>
611          <tbl:headerrow>
612            <tbl:header subclass="index" />
613            <tbl:header 
614              subclass="check" 
615              visible="<%=mode.hasCheck()%>"
616              ><base:icon 
617                id="check.uncheck"
618                image="check_uncheck.png" 
619                tooltip="Check/uncheck all" 
620                 
621              /></tbl:header>
622            <tbl:header 
623              subclass="check" 
624              visible="<%=mode.hasRadio()%>"
625              />
626            <tbl:header 
627              subclass="icons" 
628              visible="<%=mode.hasIcons()%>"
629              />
630            <tbl:propertyfilter />
631          </tbl:headerrow>
632        </tbl:headers>
633        <tbl:rows>
634          <%
635          if (cc.getMessage() != null)
636          {
637            %>
638            <tbl:panel subclass="bg-filled-50">
639              <div class="messagecontainer error"><%=cc.getMessage()%></div>
640            </tbl:panel>
641            <%
642            cc.setMessage(null);
643          }
644          int index = cc.getPage()*cc.getRowsPerPage();
645          int selectedItemId = cc.getId();
646          if (extracts != null)
647          {           
648            while (extracts.hasNext())
649            {
650              Extract item = extracts.next();
651              Item parentType = item.getParentType();
652              BioMaterialEvent creationEvent = item.getCreationEvent();
653              int itemId = item.getId();
654              boolean usePermission = item.hasPermission(Permission.USE);
655             
656             
657              boolean deletePermission = item.hasPermission(Permission.DELETE);
658              boolean sharePermission = item.hasPermission(Permission.SET_PERMISSION);
659              boolean writePermission = item.hasPermission(Permission.WRITE);
660              String tooltip = mode.isSelectionMode() ? 
661                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
662              String name = HTML.encodeTags(item.getName());
663              index++;
664              numListed++;
665              %>
666              <tbl:row>
667                <tbl:header 
668                  clazz="index"
669                  ><%=index%></tbl:header>
670                <tbl:header 
671                  clazz="check" 
672                  visible="<%=mode.hasCheck()%>"
673                  ><input 
674                    type="checkbox" 
675                    name="<%=itemId%>" 
676                    value="<%=itemId%>" 
677                    title="<%=name%>" 
678                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
679                  ></tbl:header>
680                <tbl:header 
681                  clazz="check" 
682                  visible="<%=mode.hasRadio()%>"
683                  ><input 
684                    type="radio" 
685                    name="item_id" 
686                    value="<%=itemId%>" 
687                    title="<%=name%>" 
688                    <%=selectedItemId == itemId ? "checked" : ""%>
689                  ></tbl:header>
690                <tbl:header 
691                  clazz="icons" 
692                  visible="<%=mode.hasIcons()%>"
693                  ><base:icon 
694                    image="deleted.png"
695                    id="<%="delete."+itemId %>"
696                    subclass="<%=deletePermission ? "table-delete-item" : null %>"
697                    data-item-id="<%=itemId%>"
698                    tooltip="This item has been scheduled for deletion" 
699                    visible="<%=item.isRemoved()%>"
700                  /><base:icon 
701                    image="shared.png" 
702                    id="<%="share."+itemId %>"
703                    subclass="<%=sharePermission ? "table-share-item" : null %>"
704                    data-item-id="<%=itemId%>"
705                    tooltip="This item is shared to other users, groups and/or projects" 
706                    visible="<%=item.isShared()%>"
707                  />&nbsp;</tbl:header>
708                <tbl:cell column="name"><div
709                  class="link table-item"
710                  data-item-id="<%=itemId%>"
711                  data-no-edit="<%=writePermission ? 0 : 1 %>" 
712                  tabindex="0"
713                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
714                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
715                <tbl:cell column="itemSubtype"><base:propertyvalue 
716                    item="<%=item%>" 
717                    property="itemSubtype"
718                    enableEditLink="<%=mode.hasEditLink()%>" 
719                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
720                  /></tbl:cell>
721                <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell>
722                <tbl:cell column="originalQuantity" value="<%=item.getOriginalQuantity()%>" />
723                <tbl:cell column="remainingQuantity" value="<%=item.getRemainingQuantity()%>" />
724                <tbl:cell column="tag"
725                  ><base:propertyvalue 
726                    item="<%=item%>" 
727                    property="tag"
728                    enableEditLink="<%=mode.hasEditLink()%>" 
729                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
730                  /></tbl:cell>
731                <tbl:cell column="protocol"
732                  ><base:propertyvalue 
733                    item="<%=creationEvent%>" 
734                    property="protocol"
735                    enableEditLink="<%=mode.hasEditLink()%>" 
736                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
737                  /></tbl:cell>
738                <tbl:cell column="eventDate" value="<%=creationEvent.getEventDate()%>" />
739                <tbl:cell column="entryDate" value="<%=creationEvent.getEntryDate()%>" />
740                <tbl:cell column="parentType"><%=parentType == null ? "" : parentType.toString() %></tbl:cell>
741                <tbl:cell column="parents">
742                  <%
743                  if (item.hasSingleParent() || parentType == null)
744                  {
745                    Float usedQuantity = null;
746                    if (parentType != null)
747                    {
748                      try
749                      {
750                        usedQuantity = creationEvent.getUsedQuantity((MeasuredBioMaterial)item.getParent());
751                      }
752                      catch (PermissionDeniedException ex)
753                      {}
754                    }
755                    %>
756                    <base:propertyvalue item="<%=item%>" property="parent" />
757                    <%=usedQuantity != null ? "(" + numericFormatter.format(usedQuantity) + "µg)" : ""%>
758                    <%
759                  }
760                  else
761                  {
762                    String separator = "";
763                    parentExtractsQuery.setEntityParameter("creationEvent", creationEvent);
764                    for (Extract e : parentExtractsQuery.list(dc))
765                    {
766                      Float usedQuantity = creationEvent.getUsedQuantity(e);
767                      out.write(separator);
768                      if (mode.hasPropertyLink())
769                      {
770                        out.write(Base.getLinkedName(ID, e, false, mode.hasEditLink()));
771                      }
772                      else
773                      {
774                        out.write(HTML.encodeTags(e.getName()));
775                      }
776                      if (usedQuantity != null)
777                      {
778                        out.write(" (" + numericFormatter.format(usedQuantity) + "µg)");
779                      }
780                      separator = ", ";
781                    }
782                  }
783                  %>
784                  <%=parentType != null ? "<span class=\"itemsubtype\">(" + parentType + ")</span>" : "" %>
785                </tbl:cell>
786                <tbl:cell column="children">
787                  <%
788                  childExtractsQuery.setEntityParameter("extract", item);
789                  String separator = "";
790                  for (Extract e : childExtractsQuery.list(dc))
791                  {
792                    out.write(separator);
793                    if (mode.hasPropertyLink())
794                    {
795                      out.write(Base.getLinkedName(ID, e, false, mode.hasEditLink()));
796                    }
797                    else
798                    {
799                      out.write(HTML.encodeTags(e.getName()));
800                    }
801                    separator = ", ";
802                  }
803                  %>
804                  <base:icon
805                    id="<%="newextract."+itemId%>"
806                    image="add.png" 
807                    subclass="auto-init"
808                    data-auto-init="new-extract"
809                    data-item-id="<%=itemId %>"
810                    tooltip="Create new child extract" 
811                    visible="<%=mode.hasEditLink() && createPermission && usePermission %>"
812                  />
813                </tbl:cell>
814                <tbl:cell column="physicalBioAssays">
815                  <%                 
816                  try
817                  {
818                    bioAssayQuery.setEntityParameter("extract", item);
819                    String separator = "";
820                    for (PhysicalBioAssay pba : bioAssayQuery.list(dc))
821                    {
822                      out.write(separator);
823                      if (mode.hasPropertyLink())
824                      {
825                        out.write(Base.getLinkedName(ID, pba, false, mode.hasEditLink()));
826                      }
827                      else
828                      {
829                        out.write(HTML.encodeTags(pba.getName()));
830                      }
831                      separator = ", ";
832                    }
833                  }
834                  catch (Throwable t)
835                  {
836                    %>
837                    <div class="error"><%=t.getMessage()%></div>
838                    <%
839                  }
840                  %>
841                </tbl:cell>
842                <tbl:cell column="rawBioAssays">
843                  <%                 
844                  try
845                  {
846                    rawAssayQuery.setEntityParameter("extract", item);
847                    String separator = "";
848                    for (RawBioAssay rba : rawAssayQuery.list(dc))
849                    {
850                      out.write(separator);
851                      if (mode.hasPropertyLink())
852                      {
853                        out.write(Base.getLinkedName(ID, rba, false, mode.hasEditLink()));
854                      }
855                      else
856                      {
857                        out.write(HTML.encodeTags(rba.getName()));
858                      }
859                      separator = ", ";
860                    }
861                  }
862                  catch (Throwable t)
863                  {
864                    %>
865                    <div class="error"><%=t.getMessage()%></div>
866                    <%
867                  }
868                  %>
869                  <base:icon
870                    id="<%="newRawBioAssay."+itemId%>"
871                    image="add.png" 
872                    subclass="auto-init"
873                    data-auto-init="new-raw-bioassay"
874                    data-item-id="<%=itemId %>"
875                    tooltip="Create new raw bioassay from this extract" 
876                    visible="<%=mode.hasEditLink() && createRawBioAssayPermission && usePermission %>"
877                  />
878                </tbl:cell>
879                <%               
880                BioWell well = null;
881                boolean readBioWell = true;
882                try
883                {
884                  well = item.getBioWell();
885                }
886                catch(PermissionDeniedException e)
887                {
888                  readBioWell = false;
889                }
890                if (!readBioWell)
891                {
892                  %>
893                  <tbl:cell column="bioWellRow"><i>- denied -</i> </tbl:cell>
894                  <tbl:cell column="bioWellColumn"><i>- denied -</i> </tbl:cell>
895                  <tbl:cell column="bioPlate"><i>- denied -</i> </tbl:cell>
896                  <%
897                }
898                else if (well == null)
899                {
900                  %>
901                  <tbl:cell column="bioWellRow"><i>- none -</i> </tbl:cell>
902                  <tbl:cell column="bioWellColumn"><i>- none -</i> </tbl:cell>
903                  <tbl:cell column="bioPlate"><i>- none -</i> </tbl:cell>
904                  <%
905                 
906                }
907                else
908                {               
909                  %>
910                  <tbl:cell column="bioWellRow">
911                    <tbl:cellvalue value="<%=well.getRow()%>"/>
912                  </tbl:cell>
913                  <tbl:cell column="bioWellColumn">
914                    <tbl:cellvalue value="<%=well.getColumn()%>"/>
915                  </tbl:cell>
916                  <tbl:cell column="bioPlate"><%=Base.getLinkedName(ID, well.getPlate(), false, true)%></tbl:cell>
917                  <%
918                }
919                %>
920                <tbl:cell column="owner"
921                  ><base:propertyvalue 
922                    item="<%=item%>" 
923                    property="owner"
924                    enableEditLink="<%=mode.hasEditLink()%>" 
925                    enablePropertyLink="<%=mode.hasPropertyLink()%>"
926                  /></tbl:cell>
927                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>               
928                <%
929                if (item.isAnnotated())
930                {
931                  AnnotationSetSnapshot snapshot = manager.getSnapshot(dc, item.getAnnotationSet().getId());
932                  for (AnnotationLoaderUtil loader : annotationLoaders)
933                  {
934                    if (loader.find(snapshot))
935                    {
936                      %>
937                      <tbl:cell 
938                        column="<%=(loader.isSearchingInheritedAnnotations() ? "ia" : "at")+loader.getId()%>"
939                        ><tbl:cellvalue 
940                          list="<%=loader.getValues()%>"
941                          suffix="<%=loader.getUnitSymbol()%>"
942                      /></tbl:cell>
943                      <%
944                    }
945                  }
946                }
947                %>
948                <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell>
949                <tbl:cell column="sharedTo">
950                  <%
951                  Iterator<Nameable> sharees = ShareableUtil.getSharedTo(dc, item).iterator();
952                  while(sharees.hasNext())
953                  {
954                    Nameable n = sharees.next();
955                    if (mode.hasPropertyLink())
956                    {
957                      out.write(Base.getLinkedName(ID, n, false, mode.hasEditLink()));
958                    }
959                    else
960                    {
961                      out.write(HTML.encodeTags(n.getName()));
962                    }
963                    out.write(sharees.hasNext() ? ", " : "");
964                  }
965                  %>
966                </tbl:cell>
967                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
968                  <tbl:cell column="xt-columns" />
969                </tbl:xt-cells>
970              </tbl:row>
971              <%
972              }
973            }
974            if (numListed == 0)
975            {
976              %>
977              <tbl:panel subclass="bg-filled-50">
978                <div class="messagecontainer note">
979                <%=extracts == null || extracts.getTotalCount() == 0 ? "No extracts were found" : "No extracts on this page. Please select another page!" %>
980                </div>
981              </tbl:panel>
982              <%
983            }
984          %>         
985        </tbl:rows>
986      </tbl:data>
987    </tbl:table>
988    </div>
989    <base:buttongroup subclass="dialogbuttons">
990      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
991      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
992      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
993    </base:buttongroup>
994   
995  </base:body>
996  </base:page>
997  <%
998}
999finally
1000{
1001  if (extracts != null) extracts.close();
1002  if (dc != null) dc.close();
1003}
1004%>
Note: See TracBrowser for help on using the repository browser.