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

Last change on this file since 6604 was 6604, checked in by Nicklas Nordborg, 9 years ago

References #1890: Improve skinnability of BASE

Updated table listings with some new css classes to make it easier to modify background color.

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