1 | <%-- $Id: view_bioplate.jsp 5722 2011-09-07 09:26:07Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Häkkinen, 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 Martin |
---|
24 | @version 2.10 |
---|
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.SystemItems" |
---|
30 | import="net.sf.basedb.core.Group" |
---|
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.AnnotationType" |
---|
35 | import="net.sf.basedb.core.AnnotationSet" |
---|
36 | import="net.sf.basedb.core.BioPlate" |
---|
37 | import="net.sf.basedb.core.BioWell" |
---|
38 | import="net.sf.basedb.core.MeasuredBioMaterial" |
---|
39 | import="net.sf.basedb.core.PlateGeometry" |
---|
40 | import="net.sf.basedb.core.User" |
---|
41 | import="net.sf.basedb.core.ItemQuery" |
---|
42 | import="net.sf.basedb.core.Include" |
---|
43 | import="net.sf.basedb.core.ItemResultList" |
---|
44 | import="net.sf.basedb.core.MultiPermissions" |
---|
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.core.Project" |
---|
50 | import="net.sf.basedb.core.query.Orders" |
---|
51 | import="net.sf.basedb.core.query.Hql" |
---|
52 | import="net.sf.basedb.clients.web.Base" |
---|
53 | import="net.sf.basedb.clients.web.ChangeHistoryUtil" |
---|
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.util.formatter.WellCoordinateFormatter" |
---|
59 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
60 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
61 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
62 | import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer" |
---|
63 | import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil" |
---|
64 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
65 | import="java.util.Collections" |
---|
66 | import="java.util.Date" |
---|
67 | import="java.util.Map" |
---|
68 | import="java.util.Set" |
---|
69 | import="java.util.List" |
---|
70 | %> |
---|
71 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
72 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
73 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
74 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
75 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
76 | <%! |
---|
77 | private static final Item itemType = Item.BIOPLATE; |
---|
78 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
79 | %> |
---|
80 | <% |
---|
81 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
82 | final String ID = sc.getId(); |
---|
83 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
84 | final int itemId = cc.getId(); |
---|
85 | final String tab = Values.getString(request.getParameter("tab"), "properties"); |
---|
86 | final float scale = Base.getScale(sc); |
---|
87 | final DbControl dc = sc.newDbControl(); |
---|
88 | try |
---|
89 | { |
---|
90 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
91 | |
---|
92 | String title = null; |
---|
93 | BioPlate bioplate = BioPlate.getById(dc, itemId); |
---|
94 | Item bioMaterialType = bioplate.getBioPlateType().getBioMaterialType(); |
---|
95 | PlateGeometry geometry = bioplate.getPlateGeometry(); |
---|
96 | |
---|
97 | final boolean writePermission = bioplate.hasPermission(Permission.WRITE); |
---|
98 | final boolean deletePermission = bioplate.hasPermission(Permission.DELETE); |
---|
99 | final boolean sharePermission = bioplate.hasPermission(Permission.SET_PERMISSION); |
---|
100 | final boolean setOwnerPermission = bioplate.hasPermission(Permission.SET_OWNER); |
---|
101 | final boolean isRemoved = bioplate.isRemoved(); |
---|
102 | final boolean isUsed = isRemoved && bioplate.isUsed(); |
---|
103 | final boolean deletePermanentlyPermission = deletePermission && !isUsed; |
---|
104 | final boolean isOwner = bioplate.isOwner(); |
---|
105 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, bioplate); |
---|
106 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
107 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
108 | %> |
---|
109 | <base:page title="<%=title%>"> |
---|
110 | <base:head scripts="tabcontrol.js,table.js,ajax.js,json2.js" |
---|
111 | styles="toolbar.css,table.css,headertabcontrol.css,path.css,plate.css"> |
---|
112 | <ext:scripts context="<%=jspContext%>" /> |
---|
113 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
114 | <script language="JavaScript"> |
---|
115 | function editItem() |
---|
116 | { |
---|
117 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
118 | } |
---|
119 | function shareItem() |
---|
120 | { |
---|
121 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'SharePlate', 600, 400); |
---|
122 | } |
---|
123 | function deleteItem() |
---|
124 | { |
---|
125 | location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>'); |
---|
126 | } |
---|
127 | function restoreItem() |
---|
128 | { |
---|
129 | location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>'); |
---|
130 | } |
---|
131 | function deleteItemPermanently() |
---|
132 | { |
---|
133 | Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted'); |
---|
134 | } |
---|
135 | function itemDeleted() |
---|
136 | { |
---|
137 | Main.listItems('<%=ID%>', '<%=itemType.name()%>'); |
---|
138 | } |
---|
139 | function showUsingItems() |
---|
140 | { |
---|
141 | Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>); |
---|
142 | } |
---|
143 | function setOwner() |
---|
144 | { |
---|
145 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 150); |
---|
146 | } |
---|
147 | function runPlugin(cmd) |
---|
148 | { |
---|
149 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540); |
---|
150 | } |
---|
151 | function viewWells() |
---|
152 | { |
---|
153 | location.href = 'wells/index.jsp?ID=<%=ID%>&bioplate_id=<%=itemId%>'; |
---|
154 | } |
---|
155 | function viewEvents() |
---|
156 | { |
---|
157 | location.href = 'events/index.jsp?ID=<%=ID%>&bioplate_id=<%=itemId%>'; |
---|
158 | } |
---|
159 | function switchTab(tabControlId, tabId) |
---|
160 | { |
---|
161 | if (tabId == 'history' && tabId != '<%=tab%>') |
---|
162 | { |
---|
163 | location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId; |
---|
164 | } |
---|
165 | else if (tabId == 'wells') |
---|
166 | { |
---|
167 | viewWells(); |
---|
168 | } |
---|
169 | else if (tabId == 'events') |
---|
170 | { |
---|
171 | viewEvents(); |
---|
172 | } |
---|
173 | else |
---|
174 | { |
---|
175 | TabControl.setActiveTab(tabControlId, tabId); |
---|
176 | } |
---|
177 | } |
---|
178 | function editWell(wellId) |
---|
179 | { |
---|
180 | Main.viewOrEditItem('<%=ID%>', 'BIOWELL', wellId, true); |
---|
181 | } |
---|
182 | function showWellInfo(evt, coordinate, wellId) |
---|
183 | { |
---|
184 | // Display the 'wellInfo' postit note |
---|
185 | var wellInfo = document.getElementById('wellInfo'); |
---|
186 | var wellTd = document.getElementById('well.' + wellId); |
---|
187 | var pos = Main.getElementPosition(wellTd); |
---|
188 | wellInfo.style.left = (pos.left + pos.width - 5) + 'px'; |
---|
189 | wellInfo.style.top = (pos.top + 10) + 'px'; |
---|
190 | Main.show('wellInfo'); |
---|
191 | |
---|
192 | // Get the well information |
---|
193 | var info = wellInfoCache['well.'+wellId]; |
---|
194 | if (!info) |
---|
195 | { |
---|
196 | // Use Ajax to load the information |
---|
197 | wellInfo.innerHTML = '[' + coordinate + '] loading, please wait...'; |
---|
198 | info = loadWellInfo(wellId); |
---|
199 | } |
---|
200 | var html; |
---|
201 | var bioMaterial = info.bioMaterial; |
---|
202 | if (bioMaterial) |
---|
203 | { |
---|
204 | if (bioMaterial.denied) |
---|
205 | { |
---|
206 | html = 'Denied'; |
---|
207 | } |
---|
208 | else |
---|
209 | { |
---|
210 | var id = bioMaterial.id; |
---|
211 | var type = bioMaterial.type; |
---|
212 | var subtype = bioMaterial.subtype; |
---|
213 | html = Main.linkItem('<%=ID%>', type, id, bioMaterial.editable, bioMaterial.name); |
---|
214 | html += ': <b>' + type + '</b>'; |
---|
215 | if (subtype) html += ' <span class="itemsubtype">[' + subtype.name + ']</span>'; |
---|
216 | html += '<br>'+bioMaterial.description; |
---|
217 | } |
---|
218 | } |
---|
219 | else |
---|
220 | { |
---|
221 | html = 'Empty'; |
---|
222 | } |
---|
223 | wellInfo.innerHTML = html; |
---|
224 | } |
---|
225 | function hideWellInfo() |
---|
226 | { |
---|
227 | Main.hide('wellInfo'); |
---|
228 | } |
---|
229 | var wellInfoCache = new Array(); |
---|
230 | function loadWellInfo(wellId) |
---|
231 | { |
---|
232 | var request = Ajax.getXmlHttpRequest(); |
---|
233 | var url = 'wells/ajax.jsp?ID=<%=ID%>&cmd=WellInfo&encodeStrings=1&item_id=' + wellId; |
---|
234 | request.open("GET", url, false); |
---|
235 | // NOTE! 'false' causes code to wait for the response. aka. 'Synchronous AJAX' or SJAX. |
---|
236 | request.send(null); |
---|
237 | var response = Ajax.parseJsonResponse(request.responseText); |
---|
238 | if (response.status != 'ok') |
---|
239 | { |
---|
240 | alert(response.message); |
---|
241 | return false; |
---|
242 | } |
---|
243 | |
---|
244 | wellInfoCache['well.'+wellId] = response; |
---|
245 | return response; |
---|
246 | } |
---|
247 | function viewOrEditWellItem(event, itemType, itemId, editable) |
---|
248 | { |
---|
249 | //Main.viewOrEditItem('<%=ID%>', itemType, itemId, editable); |
---|
250 | Main.itemOnClick(event, '<%=ID%>', itemType, itemId, editable); |
---|
251 | } |
---|
252 | function moveBioMaterial() |
---|
253 | { |
---|
254 | Main.openPopup('index.jsp?ID=<%=ID%>&item_id=<%=itemId%>&cmd=MoveBioMaterial', 'MoveBioMaterial', 900, 600); |
---|
255 | } |
---|
256 | function createChildBioPlate() |
---|
257 | { |
---|
258 | Main.openPopup('index.jsp?ID=<%=ID%>&item_id=<%=itemId%>&cmd=CreateChildBioPlate', 'CreateChildBioPlate', 900, 600); |
---|
259 | } |
---|
260 | </script> |
---|
261 | </base:head> |
---|
262 | <base:body attributes="onmouseout='hideWellInfo()'"> |
---|
263 | <p> |
---|
264 | <p:path> |
---|
265 | <p:pathelement title="Bioplates" href="<%="index.jsp?ID="+ID%>" /> |
---|
266 | <p:pathelement title="<%=HTML.encodeTags(bioplate.getName())%>" /> |
---|
267 | </p:path> |
---|
268 | |
---|
269 | <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab" remember="false"> |
---|
270 | <t:tab id="properties" title="Properties"> |
---|
271 | <tbl:toolbar |
---|
272 | > |
---|
273 | <tbl:button |
---|
274 | disabled="<%=writePermission ? false : true%>" |
---|
275 | image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" |
---|
276 | onclick="editItem()" |
---|
277 | title="Edit…" |
---|
278 | tooltip="<%=writePermission ? "Edit this bioplate" : "You do not have permission to edit this bioplate"%>" |
---|
279 | /> |
---|
280 | <tbl:button |
---|
281 | disabled="<%=deletePermission ? false : true%>" |
---|
282 | image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" |
---|
283 | onclick="deleteItem()" |
---|
284 | title="Delete" |
---|
285 | visible="<%=!bioplate.isRemoved()%>" |
---|
286 | tooltip="<%=deletePermission ? "Delete this bioplate" : "You do not have permission to delete this bioplate"%>" |
---|
287 | /> |
---|
288 | <tbl:button |
---|
289 | disabled="<%=writePermission ? false : true%>" |
---|
290 | image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" |
---|
291 | onclick="restoreItem()" |
---|
292 | title="Restore" |
---|
293 | visible="<%=bioplate.isRemoved()%>" |
---|
294 | tooltip="<%=writePermission ? "Restore this bioplate" : "You do not have permission to restore this bioplate"%>" |
---|
295 | /> |
---|
296 | <tbl:button |
---|
297 | disabled="<%=sharePermission ? false : true%>" |
---|
298 | image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>" |
---|
299 | onclick="shareItem()" |
---|
300 | title="Share…" |
---|
301 | tooltip="<%=sharePermission ? "Share this bioplate to other user, groups and projects" : "You do not have permission to share this bioplate"%>" |
---|
302 | /> |
---|
303 | <tbl:button |
---|
304 | disabled="<%=setOwnerPermission ? false : true%>" |
---|
305 | image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>" |
---|
306 | onclick="setOwner()" |
---|
307 | title="Set owner…" |
---|
308 | tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>" |
---|
309 | /> |
---|
310 | <tbl:button |
---|
311 | image="move_to_plate.png" |
---|
312 | onclick="moveBioMaterial()" |
---|
313 | title="Move biomaterial…" |
---|
314 | tooltip="Move biomaterial on this plate to another plate" |
---|
315 | /> |
---|
316 | <tbl:button |
---|
317 | image="add.png" |
---|
318 | onclick="createChildBioPlate()" |
---|
319 | title="<%="Create child bioplate" + (bioMaterialType == Item.EXTRACT ? "/bioassay" : "") +"…"%>" |
---|
320 | tooltip="Create one or more child biomaterial plates" |
---|
321 | visible="<%=bioMaterialType != null%>" |
---|
322 | /> |
---|
323 | <tbl:button |
---|
324 | image="import.gif" |
---|
325 | onclick="runPlugin('ImportItem')" |
---|
326 | title="Import…" |
---|
327 | tooltip="Import data" |
---|
328 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
329 | /> |
---|
330 | <tbl:button |
---|
331 | image="export.gif" |
---|
332 | onclick="runPlugin('ExportItem')" |
---|
333 | title="Export…" |
---|
334 | tooltip="Export data" |
---|
335 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
336 | /> |
---|
337 | <tbl:button |
---|
338 | image="runplugin.gif" |
---|
339 | onclick="runPlugin('RunPlugin')" |
---|
340 | title="Run plugin…" |
---|
341 | tooltip="Run a plugin" |
---|
342 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
343 | /> |
---|
344 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
345 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
346 | <tbl:button |
---|
347 | image="help.gif" |
---|
348 | onclick="<%="Main.openHelp('" + ID +"', 'plate.view.properties')"%>" |
---|
349 | title="Help…" |
---|
350 | tooltip="Get help about this page" |
---|
351 | /> |
---|
352 | </tbl:toolbar> |
---|
353 | <div class="boxedbottom"> |
---|
354 | <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(bioplate)%></i></div> |
---|
355 | <% |
---|
356 | if (bioplate.isRemoved() || bioplate.isShared()) |
---|
357 | { |
---|
358 | %> |
---|
359 | <div class="itemstatus"> |
---|
360 | <base:icon |
---|
361 | image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>" |
---|
362 | onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>" |
---|
363 | tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>" |
---|
364 | visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon> |
---|
365 | <base:icon image="used.gif" |
---|
366 | onclick="showUsingItems()" |
---|
367 | tooltip="Show the items that are using this one" |
---|
368 | visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon> |
---|
369 | <base:icon image="shared.gif" |
---|
370 | visible="<%=bioplate.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon> |
---|
371 | </div> |
---|
372 | <% |
---|
373 | } |
---|
374 | %> |
---|
375 | <table class="form" cellspacing="0"> |
---|
376 | <tr> |
---|
377 | <td class="prompt">Name</td> |
---|
378 | <td><%=HTML.encodeTags(bioplate.getName())%></td> |
---|
379 | </tr> |
---|
380 | <tr> |
---|
381 | <td class="prompt">Barcode</td> |
---|
382 | <td><%=HTML.encodeTags(bioplate.getBarcode())%></td> |
---|
383 | </tr> |
---|
384 | <tr> |
---|
385 | <td class="prompt">Destroyed</td> |
---|
386 | <td><%=bioplate.isDestroyed() ? "yes" : "no"%></td> |
---|
387 | </tr> |
---|
388 | <tr> |
---|
389 | <td class="prompt">Bioplate type</td> |
---|
390 | <td><base:propertyvalue item="<%=bioplate%>" property="bioPlateType" /></td> |
---|
391 | </tr> |
---|
392 | <tr> |
---|
393 | <td class="prompt">Geometry</td> |
---|
394 | <td><base:propertyvalue item="<%=bioplate%>" property="plateGeometry" /></td> |
---|
395 | </tr> |
---|
396 | <tr> |
---|
397 | <td class="prompt">Free (total) wells</td> |
---|
398 | <td><%=bioplate.getFreeWells()%> (<%=bioplate.getTotalWells()%>)</td> |
---|
399 | </tr> |
---|
400 | <tr> |
---|
401 | <td class="prompt">Freezer</td> |
---|
402 | <td><base:propertyvalue item="<%=bioplate%>" property="freezer" /></td> |
---|
403 | </tr> |
---|
404 | <tr> |
---|
405 | <td class="prompt">Owner</td> |
---|
406 | <td><base:propertyvalue item="<%=bioplate%>" property="owner" /></td> |
---|
407 | </tr> |
---|
408 | <tr> |
---|
409 | <td class="prompt">Description</td> |
---|
410 | <td><%=HTML.niceFormat(bioplate.getDescription())%></td> |
---|
411 | </tr> |
---|
412 | </table> |
---|
413 | |
---|
414 | <base:section id="wells" title="Wells" context="<%=cc%>"> |
---|
415 | <table class="plate" cellspacing="0" cellpadding="0" onmouseout="event.cancelBubble=true"> |
---|
416 | <% |
---|
417 | int columns = geometry.getColumns(); |
---|
418 | int rows = geometry.getRows(); |
---|
419 | WellCoordinateFormatter rowF = new WellCoordinateFormatter(true); |
---|
420 | WellCoordinateFormatter colF = new WellCoordinateFormatter(false); |
---|
421 | %> |
---|
422 | <tr><td></td> |
---|
423 | <% |
---|
424 | for (int c = 0; c < columns; ++c) |
---|
425 | { |
---|
426 | %> |
---|
427 | <td class="columnheader"><%=colF.format(c)%></td> |
---|
428 | <% |
---|
429 | } |
---|
430 | %> |
---|
431 | </tr> |
---|
432 | <% |
---|
433 | for (int r = 0; r < rows; ++r) |
---|
434 | { |
---|
435 | String row = rowF.format(r); |
---|
436 | %> |
---|
437 | <tr><td class="rowheader"><%=row%></td> |
---|
438 | <% |
---|
439 | for (int c = 0; c < columns; ++c) |
---|
440 | { |
---|
441 | BioWell well = bioplate.getBioWell(r, c); |
---|
442 | boolean isEmpty = well.isEmpty(); |
---|
443 | boolean hasBeenUsed = well.hasBeenUsed(); |
---|
444 | boolean canAddBioMaterial = well.canAddBioMaterial(); |
---|
445 | boolean canClearBioMaterial = well.canClearBioMaterial(); |
---|
446 | boolean usePermission = well.hasPermission(Permission.USE); |
---|
447 | |
---|
448 | boolean deniedBioMaterial = false; |
---|
449 | |
---|
450 | String cls = "well"; |
---|
451 | String tooltip = ""; |
---|
452 | String onClick = null; |
---|
453 | String onMouseOver = "hideWellInfo()"; |
---|
454 | |
---|
455 | if (isEmpty) |
---|
456 | { |
---|
457 | cls += " empty"; |
---|
458 | if (usePermission && canAddBioMaterial) |
---|
459 | { |
---|
460 | // The used is allowed to add biomaterial to the empty well |
---|
461 | cls += " editable"; |
---|
462 | onClick = "editWell(" + well.getId() + ")"; |
---|
463 | tooltip = "Add biomaterial to this well"; |
---|
464 | } |
---|
465 | else if (hasBeenUsed) |
---|
466 | { |
---|
467 | // The well has been used and it is not allowed to add biomaterial |
---|
468 | cls += " used"; |
---|
469 | onMouseOver = "showWellInfo(event, '" + row + (c+1) + "', " + well.getId() + ")"; |
---|
470 | tooltip = "This well has already been used"; |
---|
471 | } |
---|
472 | else |
---|
473 | { |
---|
474 | // The user doesn't have permission to add biomaterial |
---|
475 | cls += " locked"; |
---|
476 | tooltip = "You are not allowed to add biomaterial to this well"; |
---|
477 | } |
---|
478 | } |
---|
479 | else |
---|
480 | { |
---|
481 | cls += " filled"; |
---|
482 | try |
---|
483 | { |
---|
484 | MeasuredBioMaterial bioMaterial = well.getBioMaterial(); |
---|
485 | onMouseOver = "showWellInfo(event, '" + row + (c+1) + "', " + well.getId() + ")"; |
---|
486 | if (usePermission && canClearBioMaterial && bioMaterial.hasPermission(Permission.WRITE)) |
---|
487 | { |
---|
488 | // The user is allowed to replace/remove the biomaterial in the well |
---|
489 | cls += " editable"; |
---|
490 | onClick = "editWell(" + well.getId() + ")"; |
---|
491 | if (canAddBioMaterial) |
---|
492 | { |
---|
493 | // Replace and/or remove |
---|
494 | tooltip = "Change biomaterial in this well"; |
---|
495 | } |
---|
496 | else |
---|
497 | { |
---|
498 | // Remove only |
---|
499 | tooltip = "Remove the biomaterial from this well"; |
---|
500 | } |
---|
501 | } |
---|
502 | else |
---|
503 | { |
---|
504 | cls += " locked"; |
---|
505 | tooltip = "This well is locked for modifications"; |
---|
506 | } |
---|
507 | } |
---|
508 | catch (PermissionDeniedException ex) |
---|
509 | { |
---|
510 | cls += " denied"; |
---|
511 | tooltip = "Access denied"; |
---|
512 | } |
---|
513 | } |
---|
514 | %> |
---|
515 | <td class="<%=cls%>" id="well.<%=well.getId()%>" |
---|
516 | <%=onClick != null ? "onclick=\"" + onClick + "\"" : ""%> |
---|
517 | <%=onMouseOver != null ? "onmouseover=\"" + onMouseOver + "\"" : ""%> |
---|
518 | title="<%=tooltip%>"></td> |
---|
519 | <% |
---|
520 | } |
---|
521 | %> |
---|
522 | </tr> |
---|
523 | <% |
---|
524 | } |
---|
525 | %> |
---|
526 | </table> |
---|
527 | <div class="postit" id="wellInfo" style="display:none; width: 300px; min-height: 30px;" onmouseout="event.cancelBubble=true"></div> |
---|
528 | </base:section> |
---|
529 | <jsp:include page="../../common/anytoany/list_anytoany.jsp"> |
---|
530 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
531 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
532 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
533 | <jsp:param name="title" value="Other items related to this bioplate" /> |
---|
534 | </jsp:include> |
---|
535 | <% |
---|
536 | // Tables with users/groups/projects that this item is shared to |
---|
537 | MultiPermissions mp = new MultiPermissions(Collections.singleton(bioplate)); |
---|
538 | ItemResultList<User> users = mp.getUsers().list(dc); |
---|
539 | ItemResultList<Group> groups = mp.getGroups().list(dc); |
---|
540 | ItemResultList<Project> projects = mp.getProjects().list(dc); |
---|
541 | int totalShare = users.size() + groups.size() + projects.size(); |
---|
542 | |
---|
543 | if (totalShare > 0) |
---|
544 | { |
---|
545 | %> |
---|
546 | <base:section |
---|
547 | id="sharedTo" |
---|
548 | title="<%="Shared to (" + totalShare + ")"%>" |
---|
549 | context="<%=cc%>" |
---|
550 | > |
---|
551 | <tbl:table |
---|
552 | id="itemsSharedTo" |
---|
553 | clazz="itemlist" |
---|
554 | columns="all" |
---|
555 | > |
---|
556 | <tbl:columndef |
---|
557 | id="itemType" |
---|
558 | title="Item type" |
---|
559 | /> |
---|
560 | <tbl:columndef |
---|
561 | id="name" |
---|
562 | title="Name" |
---|
563 | /> |
---|
564 | <tbl:columndef |
---|
565 | id="permissions" |
---|
566 | title="Permissions" |
---|
567 | /> |
---|
568 | <tbl:data> |
---|
569 | <tbl:columns> |
---|
570 | </tbl:columns> |
---|
571 | <tbl:rows> |
---|
572 | <% |
---|
573 | for (Project project : projects) |
---|
574 | { |
---|
575 | Set<Permission> permissions = mp.getPermissions(project).values().iterator().next(); |
---|
576 | %> |
---|
577 | <tbl:row> |
---|
578 | <tbl:cell column="itemType"><%=project.getType()%></tbl:cell> |
---|
579 | <tbl:cell column="name"><base:icon |
---|
580 | image="deleted.gif" |
---|
581 | tooltip="This item has been scheduled for deletion" |
---|
582 | visible="<%=project.isRemoved()%>" |
---|
583 | /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell> |
---|
584 | <tbl:cell column="permissions"> |
---|
585 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
586 | </tbl:cell> |
---|
587 | </tbl:row> |
---|
588 | <% |
---|
589 | } |
---|
590 | for (Group group : groups) |
---|
591 | { |
---|
592 | Set<Permission> permissions = mp.getPermissions(group).values().iterator().next(); |
---|
593 | %> |
---|
594 | <tbl:row> |
---|
595 | <tbl:cell column="itemType"><%=group.getType()%></tbl:cell> |
---|
596 | <tbl:cell column="name"><base:icon |
---|
597 | image="deleted.gif" |
---|
598 | tooltip="This item has been scheduled for deletion" |
---|
599 | visible="<%=group.isRemoved()%>" |
---|
600 | /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell> |
---|
601 | <tbl:cell column="permissions"> |
---|
602 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
603 | </tbl:cell> |
---|
604 | </tbl:row> |
---|
605 | <% |
---|
606 | } |
---|
607 | for (User user : users) |
---|
608 | { |
---|
609 | Set<Permission> permissions = mp.getPermissions(user).values().iterator().next(); |
---|
610 | %> |
---|
611 | <tbl:row> |
---|
612 | <tbl:cell column="itemType"><%=user.getType()%></tbl:cell> |
---|
613 | <tbl:cell column="name"><base:icon |
---|
614 | image="deleted.gif" |
---|
615 | tooltip="This item has been scheduled for deletion" |
---|
616 | visible="<%=user.isRemoved()%>" |
---|
617 | /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell> |
---|
618 | <tbl:cell column="permissions"> |
---|
619 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
620 | </tbl:cell> |
---|
621 | </tbl:row> |
---|
622 | <% |
---|
623 | } |
---|
624 | %> |
---|
625 | </tbl:rows> |
---|
626 | </tbl:data> |
---|
627 | </tbl:table> |
---|
628 | </base:section> |
---|
629 | <% |
---|
630 | } |
---|
631 | else |
---|
632 | { |
---|
633 | %> |
---|
634 | <h4>Shared to</h4> |
---|
635 | This bioplate is not shared |
---|
636 | (or, you don't have permission to view the ones it is shared to). |
---|
637 | <% |
---|
638 | } |
---|
639 | %> |
---|
640 | |
---|
641 | |
---|
642 | </div> |
---|
643 | </t:tab> |
---|
644 | |
---|
645 | <t:tab id="annotations" title="Annotations" > |
---|
646 | <div class="boxed"> |
---|
647 | <jsp:include page="../../common/annotations/list_annotations.jsp"> |
---|
648 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
649 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
650 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
651 | </jsp:include> |
---|
652 | </div> |
---|
653 | </t:tab> |
---|
654 | <t:tab id="wells" title="Wells" /> |
---|
655 | <t:tab id="events" title="Plate events" /> |
---|
656 | <t:tab id="history" title="Change history" |
---|
657 | tooltip="Displays a log of all modifications made to this item" |
---|
658 | visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>"> |
---|
659 | <% |
---|
660 | if ("history".equals(tab)) |
---|
661 | { |
---|
662 | %> |
---|
663 | <jsp:include page="../../common/history/frameset.jsp"> |
---|
664 | <jsp:param name="source_type" value="<%=itemType.name()%>" /> |
---|
665 | <jsp:param name="source_id" value="<%=itemId%>" /> |
---|
666 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
667 | </jsp:include> |
---|
668 | <% |
---|
669 | } |
---|
670 | %> |
---|
671 | </t:tab> |
---|
672 | </t:tabcontrol> |
---|
673 | </base:body> |
---|
674 | </base:page> |
---|
675 | <% |
---|
676 | } |
---|
677 | finally |
---|
678 | { |
---|
679 | if (dc != null) dc.close(); |
---|
680 | } |
---|
681 | %> |
---|