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