1 | <%-- $Id: view_sample.jsp 4539 2008-09-18 15:16:23Z martin $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Johan Enell, Jari Hakkinen, Nicklas Nordborg, Martin Svensson |
---|
4 | Copyright (C) 2007 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 session="false" |
---|
27 | import="net.sf.basedb.core.SessionControl" |
---|
28 | import="net.sf.basedb.core.DbControl" |
---|
29 | import="net.sf.basedb.core.SystemItems" |
---|
30 | import="net.sf.basedb.core.Extract" |
---|
31 | import="net.sf.basedb.core.Item" |
---|
32 | import="net.sf.basedb.core.ItemContext" |
---|
33 | import="net.sf.basedb.core.Permission" |
---|
34 | import="net.sf.basedb.core.Sample" |
---|
35 | import="net.sf.basedb.core.BioSource" |
---|
36 | import="net.sf.basedb.core.BioMaterialEvent" |
---|
37 | import="net.sf.basedb.core.Protocol" |
---|
38 | import="net.sf.basedb.core.User" |
---|
39 | import="net.sf.basedb.core.Group" |
---|
40 | import="net.sf.basedb.core.ItemProxy" |
---|
41 | import="net.sf.basedb.core.ItemQuery" |
---|
42 | import="net.sf.basedb.core.ItemResultIterator" |
---|
43 | import="net.sf.basedb.core.ItemResultList" |
---|
44 | import="net.sf.basedb.core.Include" |
---|
45 | import="net.sf.basedb.core.MultiPermissions" |
---|
46 | import="net.sf.basedb.core.query.Orders" |
---|
47 | import="net.sf.basedb.core.query.Hql" |
---|
48 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
49 | import="net.sf.basedb.core.PluginDefinition" |
---|
50 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
51 | import="net.sf.basedb.core.plugin.Plugin" |
---|
52 | import="net.sf.basedb.core.Project" |
---|
53 | import="net.sf.basedb.clients.web.Base" |
---|
54 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
55 | import="net.sf.basedb.clients.web.util.HTML" |
---|
56 | import="net.sf.basedb.util.Values" |
---|
57 | import="net.sf.basedb.util.formatter.Formatter" |
---|
58 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
59 | import="java.util.ArrayList" |
---|
60 | import="java.util.Collections" |
---|
61 | import="java.util.Date" |
---|
62 | import="java.util.Map" |
---|
63 | import="java.util.Set" |
---|
64 | import="java.util.List" |
---|
65 | %> |
---|
66 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
67 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
68 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
69 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
70 | <%! |
---|
71 | private static final Item itemType = Item.SAMPLE; |
---|
72 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
73 | %> |
---|
74 | <% |
---|
75 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
76 | final String ID = sc.getId(); |
---|
77 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
78 | final int itemId = cc.getId(); |
---|
79 | final String tab = Values.getString(request.getParameter("tab"), "properties"); |
---|
80 | final float scale = Base.getScale(sc); |
---|
81 | final DbControl dc = sc.newDbControl(); |
---|
82 | try |
---|
83 | { |
---|
84 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
85 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
86 | |
---|
87 | String title = null; |
---|
88 | Sample sample = Sample.getById(dc, itemId); |
---|
89 | BioMaterialEvent creationEvent = sample.getCreationEvent(); |
---|
90 | |
---|
91 | final boolean usePermission = sample.hasPermission(Permission.USE); |
---|
92 | final boolean writePermission = sample.hasPermission(Permission.WRITE); |
---|
93 | final boolean deletePermission = sample.hasPermission(Permission.DELETE); |
---|
94 | final boolean sharePermission = sample.hasPermission(Permission.SET_PERMISSION); |
---|
95 | final boolean setOwnerPermission = sample.hasPermission(Permission.SET_OWNER); |
---|
96 | final boolean isRemoved = sample.isRemoved(); |
---|
97 | final boolean isUsed = isRemoved && sample.isUsed(); |
---|
98 | final boolean deletePermanentlyPermission = deletePermission && !isUsed; |
---|
99 | final boolean isOwner = sample.isOwner(); |
---|
100 | %> |
---|
101 | |
---|
102 | <base:page title="<%=title%>"> |
---|
103 | <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css"> |
---|
104 | <script language="JavaScript"> |
---|
105 | function editItem() |
---|
106 | { |
---|
107 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
108 | } |
---|
109 | function shareItem() |
---|
110 | { |
---|
111 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareSample', 600, 400); |
---|
112 | } |
---|
113 | function newExtract() |
---|
114 | { |
---|
115 | Main.viewOrEditItem('<%=ID%>', 'EXTRACT', 0, true, '&sample_id=<%=itemId%>'); |
---|
116 | } |
---|
117 | function deleteItem() |
---|
118 | { |
---|
119 | location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>'); |
---|
120 | } |
---|
121 | function restoreItem() |
---|
122 | { |
---|
123 | location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>'); |
---|
124 | } |
---|
125 | function deleteItemPermanently() |
---|
126 | { |
---|
127 | Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted'); |
---|
128 | } |
---|
129 | function itemDeleted() |
---|
130 | { |
---|
131 | Main.listItems('<%=ID%>', '<%=itemType.name()%>'); |
---|
132 | } |
---|
133 | function showUsingItems() |
---|
134 | { |
---|
135 | Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>); |
---|
136 | } |
---|
137 | function takeOwnership() |
---|
138 | { |
---|
139 | if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.')) |
---|
140 | { |
---|
141 | location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>'); |
---|
142 | } |
---|
143 | } |
---|
144 | function runPlugin(cmd) |
---|
145 | { |
---|
146 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540); |
---|
147 | } |
---|
148 | function viewEvents() |
---|
149 | { |
---|
150 | location.href = '../events/index.jsp?ID=<%=ID%>&cmd=List&biomaterial_id=<%=itemId%>&biomaterial_type=<%=itemType.name()%>'; |
---|
151 | } |
---|
152 | function switchTab(tabControlId, tabId) |
---|
153 | { |
---|
154 | if (tabId == 'events') |
---|
155 | { |
---|
156 | viewEvents(); |
---|
157 | } |
---|
158 | else |
---|
159 | { |
---|
160 | TabControl.setActiveTab(tabControlId, tabId); |
---|
161 | } |
---|
162 | } |
---|
163 | </script> |
---|
164 | </base:head> |
---|
165 | <base:body> |
---|
166 | <p> |
---|
167 | <p:path> |
---|
168 | <p:pathelement title="Samples" href="<%="index.jsp?ID="+ID%>" /> |
---|
169 | <p:pathelement title="<%=HTML.encodeTags(sample.getName())%>" /> |
---|
170 | </p:path> |
---|
171 | |
---|
172 | <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab"> |
---|
173 | <t:tab id="properties" title="Properties"> |
---|
174 | |
---|
175 | <tbl:toolbar |
---|
176 | > |
---|
177 | <tbl:button |
---|
178 | disabled="<%=writePermission ? false : true%>" |
---|
179 | image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" |
---|
180 | onclick="editItem()" |
---|
181 | title="Edit…" |
---|
182 | tooltip="<%=writePermission ? "Edit this sample" : "You do not have permission to edit this sample"%>" |
---|
183 | /> |
---|
184 | <tbl:button |
---|
185 | disabled="<%=deletePermission ? false : true%>" |
---|
186 | image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" |
---|
187 | onclick="deleteItem()" |
---|
188 | title="Delete" |
---|
189 | visible="<%=!sample.isRemoved()%>" |
---|
190 | tooltip="<%=deletePermission ? "Delete this sample" : "You do not have permission to delete this sample"%>" |
---|
191 | /> |
---|
192 | <tbl:button |
---|
193 | disabled="<%=writePermission ? false : true%>" |
---|
194 | image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" |
---|
195 | onclick="restoreItem()" |
---|
196 | title="Restore" |
---|
197 | visible="<%=sample.isRemoved()%>" |
---|
198 | tooltip="<%=writePermission ? "Restore this sample" : "You do not have permission to restore this sample"%>" |
---|
199 | /> |
---|
200 | <tbl:button |
---|
201 | disabled="<%=sharePermission ? false : true%>" |
---|
202 | image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>" |
---|
203 | onclick="shareItem()" |
---|
204 | title="Share…" |
---|
205 | tooltip="<%=sharePermission ? "Share this sample to other user, groups and projects" : "You do not have permission to share this sample"%>" |
---|
206 | /> |
---|
207 | <tbl:button |
---|
208 | disabled="<%=setOwnerPermission ? false : true%>" |
---|
209 | image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>" |
---|
210 | onclick="takeOwnership()" |
---|
211 | title="Take ownership…" |
---|
212 | visible="<%=!isOwner%>" |
---|
213 | tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>" |
---|
214 | /> |
---|
215 | <tbl:button |
---|
216 | image="add.png" |
---|
217 | onclick="newExtract()" |
---|
218 | title="New extract…" |
---|
219 | tooltip="Create a new extract from this sample" |
---|
220 | visible="<%=sc.hasPermission(Permission.CREATE, Item.EXTRACT) && usePermission%>" |
---|
221 | /> |
---|
222 | <tbl:button |
---|
223 | image="import.gif" |
---|
224 | onclick="runPlugin('ImportItem')" |
---|
225 | title="Import…" |
---|
226 | tooltip="Import data" |
---|
227 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
228 | /> |
---|
229 | <tbl:button |
---|
230 | image="export.gif" |
---|
231 | onclick="runPlugin('ExportItem')" |
---|
232 | title="Export…" |
---|
233 | tooltip="Export data" |
---|
234 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
235 | /> |
---|
236 | <tbl:button |
---|
237 | image="runplugin.gif" |
---|
238 | onclick="runPlugin('RunPlugin')" |
---|
239 | title="Run plugin…" |
---|
240 | tooltip="Run a plugin" |
---|
241 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
242 | /> |
---|
243 | <tbl:button |
---|
244 | image="help.gif" |
---|
245 | onclick="<%="Main.openHelp('" + ID +"', 'sample.view.properties')"%>" |
---|
246 | title="Help…" |
---|
247 | tooltip="Get help about this page" |
---|
248 | /> |
---|
249 | </tbl:toolbar> |
---|
250 | <div class="boxedbottom"> |
---|
251 | <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(sample)%></i></div> |
---|
252 | <% |
---|
253 | if (sample.isRemoved() || sample.isShared()) |
---|
254 | { |
---|
255 | %> |
---|
256 | <div class="itemstatus"> |
---|
257 | <base:icon |
---|
258 | image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>" |
---|
259 | onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>" |
---|
260 | tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>" |
---|
261 | visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon> |
---|
262 | <base:icon image="used.gif" |
---|
263 | onclick="showUsingItems()" |
---|
264 | tooltip="Show the items that are using this one" |
---|
265 | visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon> |
---|
266 | <base:icon image="shared.gif" |
---|
267 | visible="<%=sample.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon> |
---|
268 | </div> |
---|
269 | <% |
---|
270 | } |
---|
271 | %> |
---|
272 | <table class="form" cellspacing="0"> |
---|
273 | <tr> |
---|
274 | <td class="prompt">Name</td> |
---|
275 | <td><%=HTML.encodeTags(sample.getName())%></td> |
---|
276 | </tr> |
---|
277 | <tr> |
---|
278 | <td class="prompt">External ID</td> |
---|
279 | <td><%=HTML.encodeTags(sample.getExternalId())%></td> |
---|
280 | </tr> |
---|
281 | <tr> |
---|
282 | <td class="prompt">Created</td> |
---|
283 | <td><%=dateFormatter.format(creationEvent.getEventDate())%></td> |
---|
284 | </tr> |
---|
285 | <tr> |
---|
286 | <td class="prompt">Registered</td> |
---|
287 | <td><%=dateFormatter.format(creationEvent.getEntryDate())%></td> |
---|
288 | </tr> |
---|
289 | <% |
---|
290 | if (!sample.isPooled()) |
---|
291 | { |
---|
292 | %> |
---|
293 | <tr> |
---|
294 | <td class="prompt">Biosource</td> |
---|
295 | <td><base:propertyvalue item="<%=sample%>" property="parent" /></td> |
---|
296 | </tr> |
---|
297 | <% |
---|
298 | } |
---|
299 | %> |
---|
300 | <tr> |
---|
301 | <td class="prompt">Protocol</td> |
---|
302 | <td><base:propertyvalue item="<%=creationEvent%>" property="protocol" /></td> |
---|
303 | </tr> |
---|
304 | <tr> |
---|
305 | <td class="prompt">Original quantity</td> |
---|
306 | <td><%=Values.formatNumber(sample.getOriginalQuantity(), 2, " µg")%></td> |
---|
307 | </tr> |
---|
308 | <tr> |
---|
309 | <td class="prompt">Remaining quantity</td> |
---|
310 | <td><%=Values.formatNumber(sample.getRemainingQuantity(), 2, " µg")%></td> |
---|
311 | </tr> |
---|
312 | <tr> |
---|
313 | <td class="prompt">Owner</td> |
---|
314 | <td><base:propertyvalue item="<%=sample%>" property="owner" /></td> |
---|
315 | </tr> |
---|
316 | <tr valign="baseline"> |
---|
317 | <td class="prompt">Description</td> |
---|
318 | <td><%=HTML.niceFormat(sample.getDescription())%></td> |
---|
319 | </tr> |
---|
320 | </table> |
---|
321 | |
---|
322 | <% |
---|
323 | if (sample.isPooled()) |
---|
324 | { |
---|
325 | ItemQuery<Sample> samplesQuery = (ItemQuery<Sample>)creationEvent.getSources(); |
---|
326 | samplesQuery.include(Include.ALL); |
---|
327 | samplesQuery.order(Orders.asc(Hql.property("name"))); |
---|
328 | ItemResultList<Sample> samples = samplesQuery.list(dc); |
---|
329 | %> |
---|
330 | <h4 class="docked">Pooled from samples</h4> |
---|
331 | <tbl:table |
---|
332 | id="pooled" |
---|
333 | clazz="itemlist" |
---|
334 | columns="all" |
---|
335 | > |
---|
336 | <tbl:columndef |
---|
337 | id="name" |
---|
338 | title="Name" |
---|
339 | /> |
---|
340 | <tbl:columndef |
---|
341 | id="quantity" |
---|
342 | title="Used quantity (µg)" |
---|
343 | /> |
---|
344 | <tbl:columndef |
---|
345 | id="description" |
---|
346 | title="Description" |
---|
347 | /> |
---|
348 | <tbl:data> |
---|
349 | <tbl:columns> |
---|
350 | </tbl:columns> |
---|
351 | <tbl:rows> |
---|
352 | <% |
---|
353 | for (Sample item : samples) |
---|
354 | { |
---|
355 | %> |
---|
356 | <tbl:row> |
---|
357 | <tbl:cell column="name"><base:icon |
---|
358 | image="deleted.gif" |
---|
359 | tooltip="This item has been scheduled for deletion" |
---|
360 | visible="<%=item.isRemoved()%>" |
---|
361 | /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell> |
---|
362 | <tbl:cell column="quantity"><%=Values.formatNumber(creationEvent.getUsedQuantity(item), 2)%></tbl:cell> |
---|
363 | <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> |
---|
364 | </tbl:row> |
---|
365 | <% |
---|
366 | } |
---|
367 | %> |
---|
368 | </tbl:rows> |
---|
369 | </tbl:data> |
---|
370 | </tbl:table> |
---|
371 | <% |
---|
372 | } |
---|
373 | |
---|
374 | // Samples this item is pooled in. |
---|
375 | Set<ItemProxy> childSet = sample.getUsingItems(); |
---|
376 | List<Sample> childSamples = new ArrayList<Sample>(); |
---|
377 | for (ItemProxy itemProxy : childSet) |
---|
378 | { |
---|
379 | if (Item.SAMPLE.equals(itemProxy.getType())) |
---|
380 | { |
---|
381 | childSamples.add((Sample)itemProxy.getItem(dc)); |
---|
382 | } |
---|
383 | } |
---|
384 | if (childSamples.size() == 0) |
---|
385 | { |
---|
386 | %> |
---|
387 | <h4>Pooled in extracts</h4> |
---|
388 | No samples have been pooled from this sample |
---|
389 | (or, you don't have permission to view them). |
---|
390 | <% |
---|
391 | } |
---|
392 | else |
---|
393 | { |
---|
394 | %> |
---|
395 | <h4 class="docked">Pooled in samples</h4> |
---|
396 | <tbl:table |
---|
397 | id="poolChilds" |
---|
398 | clazz="itemlist" |
---|
399 | columns="all" |
---|
400 | > |
---|
401 | <tbl:columndef |
---|
402 | id="name" |
---|
403 | title="Name" |
---|
404 | /> |
---|
405 | <tbl:columndef |
---|
406 | id="quantity" |
---|
407 | title="Original quantity (µg)" |
---|
408 | /> |
---|
409 | <tbl:columndef |
---|
410 | id="parents" |
---|
411 | title="Used samples[quantity]" |
---|
412 | /> |
---|
413 | <tbl:columndef |
---|
414 | id="description" |
---|
415 | title="Description" |
---|
416 | /> |
---|
417 | <tbl:data> |
---|
418 | <tbl:columns></tbl:columns> |
---|
419 | <tbl:rows> |
---|
420 | <% |
---|
421 | for (Sample s : childSamples) |
---|
422 | { |
---|
423 | BioMaterialEvent poolEvent = s.getCreationEvent(); |
---|
424 | ItemQuery<Sample> samplesQuery = (ItemQuery<Sample>)poolEvent.getSources(); |
---|
425 | samplesQuery.include(Include.ALL); |
---|
426 | samplesQuery.order(Orders.asc(Hql.property("name"))); |
---|
427 | ItemResultList<Sample> parentSamples = samplesQuery.list(dc); |
---|
428 | %> |
---|
429 | <tbl:row> |
---|
430 | <tbl:cell column="name"> |
---|
431 | <base:icon |
---|
432 | image="deleted.gif" |
---|
433 | tooltip="This item has been scheduled for deletion" |
---|
434 | visible="<%=s.isRemoved()%>" |
---|
435 | /> |
---|
436 | <%=Base.getLinkedName(ID, s, false, true)%> |
---|
437 | </tbl:cell> |
---|
438 | <tbl:cell column="quantity"><%=Values.formatNumber(s.getOriginalQuantity(), 2)%></tbl:cell> |
---|
439 | <tbl:cell column="parents"> |
---|
440 | <% |
---|
441 | String separator = ""; |
---|
442 | for (Sample parent : parentSamples) |
---|
443 | { |
---|
444 | out.write(separator); |
---|
445 | if (parent.equals(sample)) |
---|
446 | out.write(HTML.encodeTags(parent.getName())); |
---|
447 | else |
---|
448 | out.write(Base.getLinkedName(ID, parent, false, true)); |
---|
449 | out.write("[" + Values.formatNumber(poolEvent.getUsedQuantity(parent), 2) + "µg]"); |
---|
450 | separator = ", "; |
---|
451 | } |
---|
452 | %> |
---|
453 | </tbl:cell> |
---|
454 | <tbl:cell column="description"><%=HTML.encodeTags(s.getDescription())%></tbl:cell> |
---|
455 | </tbl:row> |
---|
456 | <% |
---|
457 | } |
---|
458 | %> |
---|
459 | </tbl:rows> |
---|
460 | </tbl:data> |
---|
461 | </tbl:table> |
---|
462 | <% |
---|
463 | } |
---|
464 | |
---|
465 | // Extracts created from this sample |
---|
466 | ItemQuery<Extract> extractQuery = sample.getExtracts(); |
---|
467 | extractQuery.include(Include.ALL); |
---|
468 | extractQuery.order(Orders.asc(Hql.property("name"))); |
---|
469 | ItemResultList<Extract> extracts = extractQuery.list(dc); |
---|
470 | if (extracts.size() == 0) |
---|
471 | { |
---|
472 | %> |
---|
473 | <h4>Extracts</h4> |
---|
474 | No extracts have been created from this sample |
---|
475 | (or, you don't have permission to view them). |
---|
476 | <% |
---|
477 | } |
---|
478 | else |
---|
479 | { |
---|
480 | %> |
---|
481 | <h4 class="docked">Extracts</h4> |
---|
482 | <tbl:table |
---|
483 | id="extracts" |
---|
484 | clazz="itemlist" |
---|
485 | columns="all" |
---|
486 | > |
---|
487 | <tbl:columndef |
---|
488 | id="name" |
---|
489 | title="Name" |
---|
490 | /> |
---|
491 | <tbl:columndef |
---|
492 | id="quantity" |
---|
493 | title="Used quantity (µg)" |
---|
494 | /> |
---|
495 | <tbl:columndef |
---|
496 | id="description" |
---|
497 | title="Description" |
---|
498 | /> |
---|
499 | <tbl:data> |
---|
500 | <tbl:columns></tbl:columns> |
---|
501 | <tbl:rows> |
---|
502 | <% |
---|
503 | for (Extract e : extracts) |
---|
504 | { |
---|
505 | %> |
---|
506 | <tbl:row> |
---|
507 | <tbl:cell column="name"><base:icon |
---|
508 | image="deleted.gif" |
---|
509 | tooltip="This item has been scheduled for deletion" |
---|
510 | visible="<%=e.isRemoved()%>" |
---|
511 | /><%=Base.getLinkedName(ID, e, false, true)%></tbl:cell> |
---|
512 | <tbl:cell column="quantity"><%=Values.formatNumber(e.getCreationEvent().getUsedQuantity(sample), 2)%></tbl:cell> |
---|
513 | <tbl:cell column="description"><%=HTML.encodeTags(e.getDescription())%></tbl:cell> |
---|
514 | </tbl:row> |
---|
515 | <% |
---|
516 | } |
---|
517 | %> |
---|
518 | </tbl:rows> |
---|
519 | </tbl:data> |
---|
520 | </tbl:table> |
---|
521 | <% |
---|
522 | } |
---|
523 | |
---|
524 | // Tables with users/groups/projects that this item is shared to |
---|
525 | MultiPermissions mp = new MultiPermissions(Collections.singleton(sample)); |
---|
526 | ItemResultIterator<User> users = mp.getUsers().iterate(dc); |
---|
527 | ItemResultIterator<Group> groups = mp.getGroups().iterate(dc); |
---|
528 | ItemResultIterator<Project> projects = mp.getProjects().iterate(dc); |
---|
529 | |
---|
530 | if (users.hasNext() || groups.hasNext() || projects.hasNext()) |
---|
531 | { |
---|
532 | %> |
---|
533 | <h4 class="docked">Shared to</h4> |
---|
534 | <tbl:table |
---|
535 | id="itemsSharedTo" |
---|
536 | clazz="itemlist" |
---|
537 | columns="all" |
---|
538 | > |
---|
539 | <tbl:columndef |
---|
540 | id="itemType" |
---|
541 | title="Item type" |
---|
542 | /> |
---|
543 | <tbl:columndef |
---|
544 | id="name" |
---|
545 | title="Name" |
---|
546 | /> |
---|
547 | <tbl:columndef |
---|
548 | id="permissions" |
---|
549 | title="Permissions" |
---|
550 | /> |
---|
551 | <tbl:data> |
---|
552 | <tbl:columns> |
---|
553 | </tbl:columns> |
---|
554 | <tbl:rows> |
---|
555 | <% |
---|
556 | while(projects.hasNext()) |
---|
557 | { |
---|
558 | Project project = projects.next(); |
---|
559 | Set<Permission> permissions = mp.getPermissions(project).values().iterator().next(); |
---|
560 | %> |
---|
561 | <tbl:row> |
---|
562 | <tbl:cell column="itemType"><%=project.getType()%></tbl:cell> |
---|
563 | <tbl:cell column="name"><base:icon |
---|
564 | image="deleted.gif" |
---|
565 | tooltip="This item has been scheduled for deletion" |
---|
566 | visible="<%=project.isRemoved()%>" |
---|
567 | /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell> |
---|
568 | <tbl:cell column="permissions"> |
---|
569 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
570 | </tbl:cell> |
---|
571 | </tbl:row> |
---|
572 | <% |
---|
573 | } |
---|
574 | while(groups.hasNext()) |
---|
575 | { |
---|
576 | Group group = groups.next(); |
---|
577 | Set<Permission> permissions = mp.getPermissions(group).values().iterator().next(); |
---|
578 | %> |
---|
579 | <tbl:row> |
---|
580 | <tbl:cell column="itemType"><%=group.getType()%></tbl:cell> |
---|
581 | <tbl:cell column="name"><base:icon |
---|
582 | image="deleted.gif" |
---|
583 | tooltip="This item has been scheduled for deletion" |
---|
584 | visible="<%=group.isRemoved()%>" |
---|
585 | /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell> |
---|
586 | <tbl:cell column="permissions"> |
---|
587 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
588 | </tbl:cell> |
---|
589 | </tbl:row> |
---|
590 | <% |
---|
591 | } |
---|
592 | while (users.hasNext()) |
---|
593 | { |
---|
594 | User user = users.next(); |
---|
595 | Set<Permission> permissions = mp.getPermissions(user).values().iterator().next(); |
---|
596 | %> |
---|
597 | <tbl:row> |
---|
598 | <tbl:cell column="itemType"><%=user.getType()%></tbl:cell> |
---|
599 | <tbl:cell column="name"><base:icon |
---|
600 | image="deleted.gif" |
---|
601 | tooltip="This item has been scheduled for deletion" |
---|
602 | visible="<%=user.isRemoved()%>" |
---|
603 | /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell> |
---|
604 | <tbl:cell column="permissions"> |
---|
605 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
606 | </tbl:cell> |
---|
607 | </tbl:row> |
---|
608 | <% |
---|
609 | } |
---|
610 | %> |
---|
611 | </tbl:rows> |
---|
612 | </tbl:data> |
---|
613 | </tbl:table> |
---|
614 | <% |
---|
615 | } |
---|
616 | else |
---|
617 | { |
---|
618 | %> |
---|
619 | <h4>Shared to</h4> |
---|
620 | This sample is not shared |
---|
621 | (or, you don't have permission to view the ones it is shared to). |
---|
622 | <% |
---|
623 | } |
---|
624 | %> |
---|
625 | </div> |
---|
626 | </t:tab> |
---|
627 | |
---|
628 | <t:tab id="annotations" title="Annotations & parameters" |
---|
629 | tooltip="View annotation values and protocol parameters"> |
---|
630 | <div class="boxed"> |
---|
631 | <jsp:include page="../../common/annotations/list_annotations.jsp"> |
---|
632 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
633 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
634 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
635 | </jsp:include> |
---|
636 | </div> |
---|
637 | </t:tab> |
---|
638 | |
---|
639 | <t:tab id="events" title="Events" /> |
---|
640 | |
---|
641 | </t:tabcontrol> |
---|
642 | |
---|
643 | |
---|
644 | </base:body> |
---|
645 | </base:page> |
---|
646 | <% |
---|
647 | } |
---|
648 | finally |
---|
649 | { |
---|
650 | if (dc != null) dc.close(); |
---|
651 | } |
---|
652 | |
---|
653 | %> |
---|