1 | <%-- $Id: view_sample.jsp 2875 2006-11-08 14:27:29Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) Authors contributing to this file. |
---|
4 | |
---|
5 | This file is part of BASE - BioArray Software Environment. |
---|
6 | Available at http://base.thep.lu.se/ |
---|
7 | |
---|
8 | BASE is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License |
---|
10 | as published by the Free Software Foundation; either version 2 |
---|
11 | of the License, or (at your option) any later version. |
---|
12 | |
---|
13 | BASE is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with this program; if not, write to the Free Software |
---|
20 | Foundation, Inc., 59 Temple Place - Suite 330, |
---|
21 | Boston, MA 02111-1307, USA. |
---|
22 | ------------------------------------------------------------------ |
---|
23 | |
---|
24 | @author Nicklas |
---|
25 | @version 2.0 |
---|
26 | --%> |
---|
27 | <%@ page |
---|
28 | import="net.sf.basedb.core.SessionControl" |
---|
29 | import="net.sf.basedb.core.DbControl" |
---|
30 | import="net.sf.basedb.core.SystemItems" |
---|
31 | import="net.sf.basedb.core.Extract" |
---|
32 | import="net.sf.basedb.core.Item" |
---|
33 | import="net.sf.basedb.core.ItemContext" |
---|
34 | import="net.sf.basedb.core.Permission" |
---|
35 | import="net.sf.basedb.core.Sample" |
---|
36 | import="net.sf.basedb.core.BioSource" |
---|
37 | import="net.sf.basedb.core.BioMaterialEvent" |
---|
38 | import="net.sf.basedb.core.Protocol" |
---|
39 | import="net.sf.basedb.core.User" |
---|
40 | import="net.sf.basedb.core.ItemQuery" |
---|
41 | import="net.sf.basedb.core.ItemResultList" |
---|
42 | import="net.sf.basedb.core.Include" |
---|
43 | import="net.sf.basedb.core.query.Orders" |
---|
44 | import="net.sf.basedb.core.query.Hql" |
---|
45 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
46 | import="net.sf.basedb.core.PluginDefinition" |
---|
47 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
48 | import="net.sf.basedb.core.plugin.Plugin" |
---|
49 | import="net.sf.basedb.clients.web.Base" |
---|
50 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
51 | import="net.sf.basedb.clients.web.util.HTML" |
---|
52 | import="net.sf.basedb.util.Values" |
---|
53 | import="java.util.Date" |
---|
54 | import="java.util.Map" |
---|
55 | import="java.util.Set" |
---|
56 | import="java.util.List" |
---|
57 | %> |
---|
58 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
59 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
60 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
61 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
62 | <%! |
---|
63 | private static final Item itemType = Item.SAMPLE; |
---|
64 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
65 | %> |
---|
66 | <% |
---|
67 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
68 | final String ID = sc.getId(); |
---|
69 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
70 | final int itemId = cc.getId(); |
---|
71 | final String tab = Values.getString(request.getParameter("tab"), "properties"); |
---|
72 | final float scale = Base.getScale(sc); |
---|
73 | final DbControl dc = sc.newDbControl(); |
---|
74 | try |
---|
75 | { |
---|
76 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
77 | |
---|
78 | String title = null; |
---|
79 | Sample sample = Sample.getById(dc, itemId); |
---|
80 | BioMaterialEvent creationEvent = sample.getCreationEvent(); |
---|
81 | |
---|
82 | final boolean usePermission = sample.hasPermission(Permission.USE); |
---|
83 | final boolean writePermission = sample.hasPermission(Permission.WRITE); |
---|
84 | final boolean deletePermission = sample.hasPermission(Permission.DELETE); |
---|
85 | final boolean sharePermission = sample.hasPermission(Permission.SET_PERMISSION); |
---|
86 | |
---|
87 | %> |
---|
88 | |
---|
89 | <base:page title="<%=title%>"> |
---|
90 | <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css"> |
---|
91 | <script language="JavaScript"> |
---|
92 | function editItem() |
---|
93 | { |
---|
94 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
95 | } |
---|
96 | function shareItem() |
---|
97 | { |
---|
98 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareSample', 500, 400); |
---|
99 | } |
---|
100 | function newExtract() |
---|
101 | { |
---|
102 | Main.viewOrEditItem('<%=ID%>', 'EXTRACT', 0, true, '&sample_id=<%=itemId%>'); |
---|
103 | } |
---|
104 | function deleteItem() |
---|
105 | { |
---|
106 | location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>'); |
---|
107 | } |
---|
108 | function restoreItem() |
---|
109 | { |
---|
110 | location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>'); |
---|
111 | } |
---|
112 | function runPlugin(cmd) |
---|
113 | { |
---|
114 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540); |
---|
115 | } |
---|
116 | function viewEvents() |
---|
117 | { |
---|
118 | location.href = '../events/index.jsp?ID=<%=ID%>&cmd=List&biomaterial_id=<%=itemId%>&biomaterial_type=<%=itemType.name()%>'; |
---|
119 | } |
---|
120 | function switchTab(tabControlId, tabId) |
---|
121 | { |
---|
122 | if (tabId == 'events') |
---|
123 | { |
---|
124 | viewEvents(); |
---|
125 | } |
---|
126 | else |
---|
127 | { |
---|
128 | TabControl.setActiveTab(tabControlId, tabId); |
---|
129 | } |
---|
130 | } |
---|
131 | </script> |
---|
132 | </base:head> |
---|
133 | <base:body> |
---|
134 | <p> |
---|
135 | <p:path> |
---|
136 | <p:pathelement title="Samples" href="<%="index.jsp?ID="+ID%>" /> |
---|
137 | <p:pathelement title="<%=HTML.encodeTags(sample.getName())%>" /> |
---|
138 | </p:path> |
---|
139 | |
---|
140 | <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab"> |
---|
141 | <t:tab id="properties" title="Properties"> |
---|
142 | |
---|
143 | <tbl:toolbar |
---|
144 | > |
---|
145 | <tbl:button |
---|
146 | disabled="<%=writePermission ? false : true%>" |
---|
147 | image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" |
---|
148 | onclick="editItem()" |
---|
149 | title="Edit…" |
---|
150 | tooltip="<%=writePermission ? "Edit this sample" : "You do not have permission to edit this sample"%>" |
---|
151 | /> |
---|
152 | <tbl:button |
---|
153 | disabled="<%=deletePermission ? false : true%>" |
---|
154 | image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" |
---|
155 | onclick="deleteItem()" |
---|
156 | title="Delete" |
---|
157 | visible="<%=!sample.isRemoved()%>" |
---|
158 | tooltip="<%=deletePermission ? "Delete this sample" : "You do not have permission to delete this sample"%>" |
---|
159 | /> |
---|
160 | <tbl:button |
---|
161 | disabled="<%=writePermission ? false : true%>" |
---|
162 | image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" |
---|
163 | onclick="restoreItem()" |
---|
164 | title="Restore" |
---|
165 | visible="<%=sample.isRemoved()%>" |
---|
166 | tooltip="<%=writePermission ? "Restore this sample" : "You do not have permission to restore this sample"%>" |
---|
167 | /> |
---|
168 | <tbl:button |
---|
169 | disabled="<%=sharePermission ? false : true%>" |
---|
170 | image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>" |
---|
171 | onclick="shareItem()" |
---|
172 | title="Share…" |
---|
173 | tooltip="<%=sharePermission ? "Share this sample to other user, groups and projects" : "You do not have permission to share this sample"%>" |
---|
174 | /> |
---|
175 | <tbl:button |
---|
176 | image="add.png" |
---|
177 | onclick="newExtract()" |
---|
178 | title="New extract…" |
---|
179 | tooltip="Create a new extract from this sample" |
---|
180 | visible="<%=sc.hasPermission(Permission.CREATE, Item.EXTRACT) && usePermission%>" |
---|
181 | /> |
---|
182 | <tbl:button |
---|
183 | image="import.gif" |
---|
184 | onclick="runPlugin('ImportItem')" |
---|
185 | title="Import…" |
---|
186 | tooltip="Import data" |
---|
187 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
188 | /> |
---|
189 | <tbl:button |
---|
190 | image="export.gif" |
---|
191 | onclick="runPlugin('ExportItem')" |
---|
192 | title="Export…" |
---|
193 | tooltip="Export data" |
---|
194 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
195 | /> |
---|
196 | <tbl:button |
---|
197 | image="runplugin.gif" |
---|
198 | onclick="runPlugin('RunPlugin')" |
---|
199 | title="Run plugin…" |
---|
200 | tooltip="Run a plugin" |
---|
201 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
202 | /> |
---|
203 | <tbl:button |
---|
204 | image="help.gif" |
---|
205 | onclick="<%="Main.openHelp('" + ID +"', 'sample.view.properties')"%>" |
---|
206 | title="Help…" |
---|
207 | tooltip="Get help about this page" |
---|
208 | /> |
---|
209 | </tbl:toolbar> |
---|
210 | <div class="boxedbottom"> |
---|
211 | <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(sample)%></i></div> |
---|
212 | <% |
---|
213 | if (sample.isRemoved() || sample.isShared()) |
---|
214 | { |
---|
215 | %> |
---|
216 | <div class="itemstatus"> |
---|
217 | <base:icon image="deleted.gif" |
---|
218 | visible="<%=sample.isRemoved()%>"> This item has been flagged for deletion<br></base:icon> |
---|
219 | <base:icon image="shared.gif" |
---|
220 | visible="<%=sample.isShared()%>"> This item is shared to other user, groups and/or projects</base:icon> |
---|
221 | </div> |
---|
222 | <% |
---|
223 | } |
---|
224 | %> |
---|
225 | <table class="form" cellspacing=0> |
---|
226 | <tr> |
---|
227 | <td class="prompt">Name</td> |
---|
228 | <td><%=HTML.encodeTags(sample.getName())%></td> |
---|
229 | </tr> |
---|
230 | <tr> |
---|
231 | <td class="prompt">External ID</td> |
---|
232 | <td><%=HTML.encodeTags(sample.getExternalId())%></td> |
---|
233 | </tr> |
---|
234 | <tr> |
---|
235 | <td class="prompt">Created</td> |
---|
236 | <td><%=Values.formatDate(creationEvent.getEventDate())%></td> |
---|
237 | </tr> |
---|
238 | <tr> |
---|
239 | <td class="prompt">Registered</td> |
---|
240 | <td><%=Values.formatDate(creationEvent.getEntryDate())%></td> |
---|
241 | </tr> |
---|
242 | <% |
---|
243 | if (!sample.isPooled()) |
---|
244 | { |
---|
245 | %> |
---|
246 | <tr> |
---|
247 | <td class="prompt">Biosource</td> |
---|
248 | <td><base:propertyvalue item="<%=sample%>" property="parent" /></td> |
---|
249 | </tr> |
---|
250 | <% |
---|
251 | } |
---|
252 | %> |
---|
253 | <tr> |
---|
254 | <td class="prompt">Protocol</td> |
---|
255 | <td><base:propertyvalue item="<%=creationEvent%>" property="protocol" /></td> |
---|
256 | </tr> |
---|
257 | <tr> |
---|
258 | <td class="prompt">Original quantity</td> |
---|
259 | <td><%=Values.formatNumber(sample.getOriginalQuantity(), 2, " µg")%></td> |
---|
260 | </tr> |
---|
261 | <tr> |
---|
262 | <td class="prompt">Remaining quantity</td> |
---|
263 | <td><%=Values.formatNumber(sample.getRemainingQuantity(), 2, " µg")%></td> |
---|
264 | </tr> |
---|
265 | <tr> |
---|
266 | <td class="prompt">Owner</td> |
---|
267 | <td><base:propertyvalue item="<%=sample%>" property="owner" /></td> |
---|
268 | </tr> |
---|
269 | <tr valign="baseline"> |
---|
270 | <td class="prompt">Description</td> |
---|
271 | <td><%=HTML.niceFormat(sample.getDescription())%></td> |
---|
272 | </tr> |
---|
273 | </table> |
---|
274 | |
---|
275 | <% |
---|
276 | if (sample.isPooled()) |
---|
277 | { |
---|
278 | ItemQuery<Sample> samplesQuery = (ItemQuery<Sample>)creationEvent.getSources(); |
---|
279 | samplesQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS); |
---|
280 | samplesQuery.order(Orders.asc(Hql.property("name"))); |
---|
281 | ItemResultList<Sample> samples = samplesQuery.list(dc); |
---|
282 | String sampleLink = "index.jsp?ID="+ID; |
---|
283 | %> |
---|
284 | <h4 class="docked">Pooled from samples</h4> |
---|
285 | <tbl:table |
---|
286 | id="pooled" |
---|
287 | clazz="itemlist" |
---|
288 | columns="all" |
---|
289 | > |
---|
290 | <tbl:columndef |
---|
291 | id="name" |
---|
292 | title="Name" |
---|
293 | /> |
---|
294 | <tbl:columndef |
---|
295 | id="quantity" |
---|
296 | title="Used quantity (µg)" |
---|
297 | /> |
---|
298 | <tbl:columndef |
---|
299 | id="description" |
---|
300 | title="Description" |
---|
301 | /> |
---|
302 | <tbl:data> |
---|
303 | <tbl:columns> |
---|
304 | </tbl:columns> |
---|
305 | <tbl:rows> |
---|
306 | <% |
---|
307 | for (Sample item : samples) |
---|
308 | { |
---|
309 | %> |
---|
310 | <tbl:row> |
---|
311 | <tbl:cell column="name"><%=Base.getEncodedName(item, false, sampleLink)%></tbl:cell> |
---|
312 | <tbl:cell column="quantity"><%=Values.formatNumber(creationEvent.getUsedQuantity(item), 2)%></tbl:cell> |
---|
313 | <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> |
---|
314 | </tbl:row> |
---|
315 | <% |
---|
316 | } |
---|
317 | %> |
---|
318 | </tbl:rows> |
---|
319 | </tbl:data> |
---|
320 | </tbl:table> |
---|
321 | <% |
---|
322 | } |
---|
323 | ItemQuery<Extract> extractQuery = sample.getExtracts(); |
---|
324 | extractQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT); |
---|
325 | extractQuery.order(Orders.asc(Hql.property("name"))); |
---|
326 | ItemResultList<Extract> extracts = extractQuery.list(dc); |
---|
327 | if (extracts.size() == 0) |
---|
328 | { |
---|
329 | %> |
---|
330 | <h4>Extracts</h4> |
---|
331 | No extracts have been created from this sample |
---|
332 | (or, you don't have permission to view them). |
---|
333 | <% |
---|
334 | } |
---|
335 | else |
---|
336 | { |
---|
337 | %> |
---|
338 | <h4 class="docked">Extracts</h4> |
---|
339 | <tbl:table |
---|
340 | id="extracts" |
---|
341 | clazz="itemlist" |
---|
342 | columns="all" |
---|
343 | > |
---|
344 | <tbl:columndef |
---|
345 | id="name" |
---|
346 | title="Name" |
---|
347 | /> |
---|
348 | <tbl:columndef |
---|
349 | id="description" |
---|
350 | title="Description" |
---|
351 | /> |
---|
352 | <tbl:data> |
---|
353 | <tbl:columns></tbl:columns> |
---|
354 | <tbl:rows> |
---|
355 | <% |
---|
356 | for (Extract e : extracts) |
---|
357 | { |
---|
358 | %> |
---|
359 | <tbl:row> |
---|
360 | <tbl:cell column="name"><%=Base.getLinkedName(ID, e, false, true)%></tbl:cell> |
---|
361 | <tbl:cell column="description"><%=HTML.encodeTags(e.getDescription())%></tbl:cell> |
---|
362 | </tbl:row> |
---|
363 | <% |
---|
364 | } |
---|
365 | %> |
---|
366 | </tbl:rows> |
---|
367 | </tbl:data> |
---|
368 | </tbl:table> |
---|
369 | <% |
---|
370 | } |
---|
371 | %> |
---|
372 | </div> |
---|
373 | </t:tab> |
---|
374 | |
---|
375 | <t:tab id="annotations" title="Annotations & parameters" |
---|
376 | tooltip="View annotation values and protocol parameters"> |
---|
377 | <div class="boxed"> |
---|
378 | <jsp:include page="../../common/annotations/list_annotations.jsp"> |
---|
379 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
380 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
381 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
382 | </jsp:include> |
---|
383 | </div> |
---|
384 | </t:tab> |
---|
385 | |
---|
386 | <t:tab id="events" title="Events" /> |
---|
387 | |
---|
388 | </t:tabcontrol> |
---|
389 | |
---|
390 | |
---|
391 | </base:body> |
---|
392 | </base:page> |
---|
393 | <% |
---|
394 | } |
---|
395 | finally |
---|
396 | { |
---|
397 | if (dc != null) dc.close(); |
---|
398 | } |
---|
399 | |
---|
400 | %> |
---|