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

Last change on this file since 5674 was 5674, checked in by Nicklas Nordborg, 12 years ago

Fixes #1611: Checkbox enabled lists for enumerated annotations

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