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