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