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