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