1 | <%-- $Id: view_bioplate.jsp 4853 2009-03-26 12:19:33Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 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 Martin |
---|
24 | @version 2.10 |
---|
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.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.PlateGeometry" |
---|
38 | import="net.sf.basedb.core.User" |
---|
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.MultiPermissions" |
---|
44 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
45 | import="net.sf.basedb.core.PluginDefinition" |
---|
46 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
47 | import="net.sf.basedb.core.plugin.Plugin" |
---|
48 | import="net.sf.basedb.core.Project" |
---|
49 | import="net.sf.basedb.core.query.Orders" |
---|
50 | import="net.sf.basedb.core.query.Hql" |
---|
51 | import="net.sf.basedb.clients.web.Base" |
---|
52 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
53 | import="net.sf.basedb.clients.web.util.HTML" |
---|
54 | import="net.sf.basedb.util.Values" |
---|
55 | import="java.util.Collections" |
---|
56 | import="java.util.Date" |
---|
57 | import="java.util.Map" |
---|
58 | import="java.util.Set" |
---|
59 | import="java.util.List" |
---|
60 | %> |
---|
61 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
62 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
63 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
64 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
65 | <%! |
---|
66 | private static final Item itemType = Item.BIOPLATE; |
---|
67 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
68 | %> |
---|
69 | <% |
---|
70 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
71 | final String ID = sc.getId(); |
---|
72 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
73 | final int itemId = cc.getId(); |
---|
74 | final String tab = Values.getString(request.getParameter("tab"), "properties"); |
---|
75 | final float scale = Base.getScale(sc); |
---|
76 | final DbControl dc = sc.newDbControl(); |
---|
77 | try |
---|
78 | { |
---|
79 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
80 | |
---|
81 | String title = null; |
---|
82 | BioPlate bioplate = BioPlate.getById(dc, itemId); |
---|
83 | |
---|
84 | final boolean writePermission = bioplate.hasPermission(Permission.WRITE); |
---|
85 | final boolean deletePermission = bioplate.hasPermission(Permission.DELETE); |
---|
86 | final boolean sharePermission = bioplate.hasPermission(Permission.SET_PERMISSION); |
---|
87 | final boolean setOwnerPermission = bioplate.hasPermission(Permission.SET_OWNER); |
---|
88 | final boolean isRemoved = bioplate.isRemoved(); |
---|
89 | final boolean isUsed = isRemoved && bioplate.isUsed(); |
---|
90 | final boolean deletePermanentlyPermission = deletePermission && !isUsed; |
---|
91 | final boolean isOwner = bioplate.isOwner(); |
---|
92 | %> |
---|
93 | <base:page title="<%=title%>"> |
---|
94 | <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css"> |
---|
95 | <script language="JavaScript"> |
---|
96 | function editItem() |
---|
97 | { |
---|
98 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
99 | } |
---|
100 | function shareItem() |
---|
101 | { |
---|
102 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'SharePlate', 600, 400); |
---|
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 deleteItemPermanently() |
---|
113 | { |
---|
114 | Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted'); |
---|
115 | } |
---|
116 | function itemDeleted() |
---|
117 | { |
---|
118 | Main.listItems('<%=ID%>', '<%=itemType.name()%>'); |
---|
119 | } |
---|
120 | function showUsingItems() |
---|
121 | { |
---|
122 | Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>); |
---|
123 | } |
---|
124 | function setOwner() |
---|
125 | { |
---|
126 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 150); |
---|
127 | } |
---|
128 | function runPlugin(cmd) |
---|
129 | { |
---|
130 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540); |
---|
131 | } |
---|
132 | function viewWells() |
---|
133 | { |
---|
134 | location.href = 'wells/index.jsp?ID=<%=ID%>&bioplate_id=<%=itemId%>'; |
---|
135 | } |
---|
136 | function switchTab(tabControlId, tabId) |
---|
137 | { |
---|
138 | if (tabId == 'wells') |
---|
139 | { |
---|
140 | viewWells(); |
---|
141 | } |
---|
142 | else |
---|
143 | { |
---|
144 | TabControl.setActiveTab(tabControlId, tabId); |
---|
145 | } |
---|
146 | } |
---|
147 | </script> |
---|
148 | </base:head> |
---|
149 | <base:body> |
---|
150 | <p> |
---|
151 | <p:path> |
---|
152 | <p:pathelement title="Bioplates" href="<%="index.jsp?ID="+ID%>" /> |
---|
153 | <p:pathelement title="<%=HTML.encodeTags(bioplate.getName())%>" /> |
---|
154 | </p:path> |
---|
155 | |
---|
156 | <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab"> |
---|
157 | <t:tab id="properties" title="Properties"> |
---|
158 | <tbl:toolbar |
---|
159 | > |
---|
160 | <tbl:button |
---|
161 | disabled="<%=writePermission ? false : true%>" |
---|
162 | image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" |
---|
163 | onclick="editItem()" |
---|
164 | title="Edit…" |
---|
165 | tooltip="<%=writePermission ? "Edit this bioplate" : "You do not have permission to edit this bioplate"%>" |
---|
166 | /> |
---|
167 | <tbl:button |
---|
168 | disabled="<%=deletePermission ? false : true%>" |
---|
169 | image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" |
---|
170 | onclick="deleteItem()" |
---|
171 | title="Delete" |
---|
172 | visible="<%=!bioplate.isRemoved()%>" |
---|
173 | tooltip="<%=deletePermission ? "Delete this bioplate" : "You do not have permission to delete this bioplate"%>" |
---|
174 | /> |
---|
175 | <tbl:button |
---|
176 | disabled="<%=writePermission ? false : true%>" |
---|
177 | image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" |
---|
178 | onclick="restoreItem()" |
---|
179 | title="Restore" |
---|
180 | visible="<%=bioplate.isRemoved()%>" |
---|
181 | tooltip="<%=writePermission ? "Restore this bioplate" : "You do not have permission to restore this bioplate"%>" |
---|
182 | /> |
---|
183 | <tbl:button |
---|
184 | disabled="<%=sharePermission ? false : true%>" |
---|
185 | image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>" |
---|
186 | onclick="shareItem()" |
---|
187 | title="Share…" |
---|
188 | tooltip="<%=sharePermission ? "Share this bioplate to other user, groups and projects" : "You do not have permission to share this bioplate"%>" |
---|
189 | /> |
---|
190 | <tbl:button |
---|
191 | disabled="<%=setOwnerPermission ? false : true%>" |
---|
192 | image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>" |
---|
193 | onclick="setOwner()" |
---|
194 | title="Set owner…" |
---|
195 | tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>" |
---|
196 | /> |
---|
197 | <tbl:button |
---|
198 | image="import.gif" |
---|
199 | onclick="runPlugin('ImportItem')" |
---|
200 | title="Import…" |
---|
201 | tooltip="Import data" |
---|
202 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
203 | /> |
---|
204 | <tbl:button |
---|
205 | image="export.gif" |
---|
206 | onclick="runPlugin('ExportItem')" |
---|
207 | title="Export…" |
---|
208 | tooltip="Export data" |
---|
209 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
210 | /> |
---|
211 | <tbl:button |
---|
212 | image="runplugin.gif" |
---|
213 | onclick="runPlugin('RunPlugin')" |
---|
214 | title="Run plugin…" |
---|
215 | tooltip="Run a plugin" |
---|
216 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
217 | /> |
---|
218 | <tbl:button |
---|
219 | image="help.gif" |
---|
220 | onclick="<%="Main.openHelp('" + ID +"', 'plate.view.properties')"%>" |
---|
221 | title="Help…" |
---|
222 | tooltip="Get help about this page" |
---|
223 | /> |
---|
224 | </tbl:toolbar> |
---|
225 | <div class="boxedbottom"> |
---|
226 | <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(bioplate)%></i></div> |
---|
227 | <% |
---|
228 | if (bioplate.isRemoved() || bioplate.isShared()) |
---|
229 | { |
---|
230 | %> |
---|
231 | <div class="itemstatus"> |
---|
232 | <base:icon |
---|
233 | image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>" |
---|
234 | onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>" |
---|
235 | tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>" |
---|
236 | visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon> |
---|
237 | <base:icon image="used.gif" |
---|
238 | onclick="showUsingItems()" |
---|
239 | tooltip="Show the items that are using this one" |
---|
240 | visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon> |
---|
241 | <base:icon image="shared.gif" |
---|
242 | visible="<%=bioplate.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon> |
---|
243 | </div> |
---|
244 | <% |
---|
245 | } |
---|
246 | %> |
---|
247 | <table class="form" cellspacing="0"> |
---|
248 | <tr> |
---|
249 | <td class="prompt">Name</td> |
---|
250 | <td><%=HTML.encodeTags(bioplate.getName())%></td> |
---|
251 | </tr> |
---|
252 | <tr> |
---|
253 | <td class="prompt">Barcode</td> |
---|
254 | <td><%=HTML.encodeTags(bioplate.getBarcode())%></td> |
---|
255 | </tr> |
---|
256 | <tr> |
---|
257 | <td class="prompt">Geometry</td> |
---|
258 | <td><base:propertyvalue item="<%=bioplate%>" property="plateGeometry" /></td> |
---|
259 | </tr> |
---|
260 | <tr> |
---|
261 | <td class="prompt">Freezer</td> |
---|
262 | <td><base:propertyvalue item="<%=bioplate%>" property="freezer"></base:propertyvalue> |
---|
263 | </tr> |
---|
264 | <tr> |
---|
265 | <td class="prompt">Owner</td> |
---|
266 | <td><base:propertyvalue item="<%=bioplate%>" property="owner" /></td> |
---|
267 | </tr> |
---|
268 | <tr> |
---|
269 | <td class="prompt">Description</td> |
---|
270 | <td><%=HTML.niceFormat(bioplate.getDescription())%></td> |
---|
271 | </tr> |
---|
272 | </table> |
---|
273 | |
---|
274 | <% |
---|
275 | |
---|
276 | // Tables with users/groups/projects that this item is shared to |
---|
277 | MultiPermissions mp = new MultiPermissions(Collections.singleton(bioplate)); |
---|
278 | ItemResultIterator<User> users = mp.getUsers().iterate(dc); |
---|
279 | ItemResultIterator<Group> groups = mp.getGroups().iterate(dc); |
---|
280 | ItemResultIterator<Project> projects = mp.getProjects().iterate(dc); |
---|
281 | |
---|
282 | if (users.hasNext() || groups.hasNext() || projects.hasNext()) |
---|
283 | { |
---|
284 | %> |
---|
285 | <h4 class="docked">Shared to</h4> |
---|
286 | <tbl:table |
---|
287 | id="itemsSharedTo" |
---|
288 | clazz="itemlist" |
---|
289 | columns="all" |
---|
290 | > |
---|
291 | <tbl:columndef |
---|
292 | id="itemType" |
---|
293 | title="Item type" |
---|
294 | /> |
---|
295 | <tbl:columndef |
---|
296 | id="name" |
---|
297 | title="Name" |
---|
298 | /> |
---|
299 | <tbl:columndef |
---|
300 | id="permissions" |
---|
301 | title="Permissions" |
---|
302 | /> |
---|
303 | <tbl:data> |
---|
304 | <tbl:columns> |
---|
305 | </tbl:columns> |
---|
306 | <tbl:rows> |
---|
307 | <% |
---|
308 | while(projects.hasNext()) |
---|
309 | { |
---|
310 | Project project = projects.next(); |
---|
311 | Set<Permission> permissions = mp.getPermissions(project).values().iterator().next(); |
---|
312 | %> |
---|
313 | <tbl:row> |
---|
314 | <tbl:cell column="itemType"><%=project.getType()%></tbl:cell> |
---|
315 | <tbl:cell column="name"><base:icon |
---|
316 | image="deleted.gif" |
---|
317 | tooltip="This item has been scheduled for deletion" |
---|
318 | visible="<%=project.isRemoved()%>" |
---|
319 | /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell> |
---|
320 | <tbl:cell column="permissions"> |
---|
321 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
322 | </tbl:cell> |
---|
323 | </tbl:row> |
---|
324 | <% |
---|
325 | } |
---|
326 | while(groups.hasNext()) |
---|
327 | { |
---|
328 | Group group = groups.next(); |
---|
329 | Set<Permission> permissions = mp.getPermissions(group).values().iterator().next(); |
---|
330 | %> |
---|
331 | <tbl:row> |
---|
332 | <tbl:cell column="itemType"><%=group.getType()%></tbl:cell> |
---|
333 | <tbl:cell column="name"><base:icon |
---|
334 | image="deleted.gif" |
---|
335 | tooltip="This item has been scheduled for deletion" |
---|
336 | visible="<%=group.isRemoved()%>" |
---|
337 | /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell> |
---|
338 | <tbl:cell column="permissions"> |
---|
339 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
340 | </tbl:cell> |
---|
341 | </tbl:row> |
---|
342 | <% |
---|
343 | } |
---|
344 | while (users.hasNext()) |
---|
345 | { |
---|
346 | User user = users.next(); |
---|
347 | Set<Permission> permissions = mp.getPermissions(user).values().iterator().next(); |
---|
348 | %> |
---|
349 | <tbl:row> |
---|
350 | <tbl:cell column="itemType"><%=user.getType()%></tbl:cell> |
---|
351 | <tbl:cell column="name"><base:icon |
---|
352 | image="deleted.gif" |
---|
353 | tooltip="This item has been scheduled for deletion" |
---|
354 | visible="<%=user.isRemoved()%>" |
---|
355 | /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell> |
---|
356 | <tbl:cell column="permissions"> |
---|
357 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
358 | </tbl:cell> |
---|
359 | </tbl:row> |
---|
360 | <% |
---|
361 | } |
---|
362 | %> |
---|
363 | </tbl:rows> |
---|
364 | </tbl:data> |
---|
365 | </tbl:table> |
---|
366 | <% |
---|
367 | } |
---|
368 | else |
---|
369 | { |
---|
370 | %> |
---|
371 | <h4>Shared to</h4> |
---|
372 | This bioplate is not shared |
---|
373 | (or, you don't have permission to view the ones it is shared to). |
---|
374 | <% |
---|
375 | } |
---|
376 | %> |
---|
377 | |
---|
378 | |
---|
379 | </div> |
---|
380 | </t:tab> |
---|
381 | |
---|
382 | <t:tab id="annotations" title="Annotations" > |
---|
383 | <div class="boxed"> |
---|
384 | <jsp:include page="../../common/annotations/list_annotations.jsp"> |
---|
385 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
386 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
387 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
388 | </jsp:include> |
---|
389 | </div> |
---|
390 | </t:tab> |
---|
391 | <t:tab id="wells" title="Wells" /> |
---|
392 | </t:tabcontrol> |
---|
393 | </base:body> |
---|
394 | </base:page> |
---|
395 | <% |
---|
396 | } |
---|
397 | finally |
---|
398 | { |
---|
399 | if (dc != null) dc.close(); |
---|
400 | } |
---|
401 | %> |
---|