1 | <%-- $Id: view_slide.jsp 5044 2009-08-11 14:35:03Z martin $ |
---|
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 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.Item" |
---|
31 | import="net.sf.basedb.core.ItemContext" |
---|
32 | import="net.sf.basedb.core.Permission" |
---|
33 | import="net.sf.basedb.core.AnnotationType" |
---|
34 | import="net.sf.basedb.core.AnnotationSet" |
---|
35 | import="net.sf.basedb.core.Hybridization" |
---|
36 | import="net.sf.basedb.core.ArraySlide" |
---|
37 | import="net.sf.basedb.core.ArrayBatch" |
---|
38 | import="net.sf.basedb.core.ArrayDesign" |
---|
39 | import="net.sf.basedb.core.User" |
---|
40 | import="net.sf.basedb.core.Group" |
---|
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.ItemResultList" |
---|
45 | import="net.sf.basedb.core.MultiPermissions" |
---|
46 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
47 | import="net.sf.basedb.core.PluginDefinition" |
---|
48 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
49 | import="net.sf.basedb.core.plugin.Plugin" |
---|
50 | import="net.sf.basedb.core.Project" |
---|
51 | import="net.sf.basedb.core.query.Orders" |
---|
52 | import="net.sf.basedb.core.query.Hql" |
---|
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="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
60 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
61 | import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer" |
---|
62 | import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil" |
---|
63 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
64 | import="java.util.Collections" |
---|
65 | import="java.util.Date" |
---|
66 | import="java.util.Map" |
---|
67 | import="java.util.Set" |
---|
68 | import="java.util.List" |
---|
69 | %> |
---|
70 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
71 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
72 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
73 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
74 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
75 | <%! |
---|
76 | private static final Item itemType = Item.ARRAYSLIDE; |
---|
77 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
78 | %> |
---|
79 | <% |
---|
80 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
81 | final String ID = sc.getId(); |
---|
82 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
83 | final int itemId = cc.getId(); |
---|
84 | final String tab = Values.getString(request.getParameter("tab"), "properties"); |
---|
85 | final float scale = Base.getScale(sc); |
---|
86 | final DbControl dc = sc.newDbControl(); |
---|
87 | try |
---|
88 | { |
---|
89 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
90 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
91 | |
---|
92 | String title = null; |
---|
93 | ArraySlide slide = ArraySlide.getById(dc, itemId); |
---|
94 | |
---|
95 | final boolean writePermission = slide.hasPermission(Permission.WRITE); |
---|
96 | final boolean deletePermission = slide.hasPermission(Permission.DELETE); |
---|
97 | final boolean sharePermission = slide.hasPermission(Permission.SET_PERMISSION); |
---|
98 | final boolean setOwnerPermission = slide.hasPermission(Permission.SET_OWNER); |
---|
99 | final boolean isRemoved = slide.isRemoved(); |
---|
100 | final boolean isUsed = isRemoved && slide.isUsed(); |
---|
101 | final boolean deletePermanentlyPermission = deletePermission && !isUsed; |
---|
102 | final boolean isOwner = slide.isOwner(); |
---|
103 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, slide); |
---|
104 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
105 | %> |
---|
106 | <base:page title="<%=title%>"> |
---|
107 | <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css"> |
---|
108 | <ext:scripts context="<%=jspContext%>" /> |
---|
109 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
110 | <script language="JavaScript"> |
---|
111 | function editItem() |
---|
112 | { |
---|
113 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
114 | } |
---|
115 | function shareItem() |
---|
116 | { |
---|
117 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareArraySlide', 600, 400); |
---|
118 | } |
---|
119 | function deleteItem() |
---|
120 | { |
---|
121 | location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>'); |
---|
122 | } |
---|
123 | function restoreItem() |
---|
124 | { |
---|
125 | location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>'); |
---|
126 | } |
---|
127 | function deleteItemPermanently() |
---|
128 | { |
---|
129 | Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted'); |
---|
130 | } |
---|
131 | function itemDeleted() |
---|
132 | { |
---|
133 | Main.listItems('<%=ID%>', '<%=itemType.name()%>'); |
---|
134 | } |
---|
135 | function showUsingItems() |
---|
136 | { |
---|
137 | Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>); |
---|
138 | } |
---|
139 | function setOwner() |
---|
140 | { |
---|
141 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 150); |
---|
142 | } |
---|
143 | function runPlugin(cmd) |
---|
144 | { |
---|
145 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540); |
---|
146 | } |
---|
147 | function switchTab(tabControlId, tabId) |
---|
148 | { |
---|
149 | if (TabControl.isActive(tabControlId, tabId)) return; |
---|
150 | if (tabId == 'overview' && tabId != '<%=tab%>') |
---|
151 | { |
---|
152 | location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId; |
---|
153 | } |
---|
154 | else |
---|
155 | { |
---|
156 | TabControl.setActiveTab(tabControlId, tabId); |
---|
157 | } |
---|
158 | } |
---|
159 | </script> |
---|
160 | </base:head> |
---|
161 | <base:body> |
---|
162 | <p> |
---|
163 | <p:path> |
---|
164 | <p:pathelement title="Array slides" href="<%="index.jsp?ID="+ID%>" /> |
---|
165 | <p:pathelement title="<%=HTML.encodeTags(slide.getName())%>" /> |
---|
166 | </p:path> |
---|
167 | |
---|
168 | <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab" remember="false"> |
---|
169 | <t:tab id="properties" title="Properties"> |
---|
170 | <tbl:toolbar |
---|
171 | > |
---|
172 | <tbl:button |
---|
173 | disabled="<%=writePermission ? false : true%>" |
---|
174 | image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" |
---|
175 | onclick="editItem()" |
---|
176 | title="Edit…" |
---|
177 | tooltip="<%=writePermission ? "Edit this array slide" : "You do not have permission to edit this array slide"%>" |
---|
178 | /> |
---|
179 | <tbl:button |
---|
180 | disabled="<%=deletePermission ? false : true%>" |
---|
181 | image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" |
---|
182 | onclick="deleteItem()" |
---|
183 | title="Delete" |
---|
184 | visible="<%=!slide.isRemoved()%>" |
---|
185 | tooltip="<%=deletePermission ? "Delete this array slide" : "You do not have permission to delete this array slide"%>" |
---|
186 | /> |
---|
187 | <tbl:button |
---|
188 | disabled="<%=writePermission ? false : true%>" |
---|
189 | image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" |
---|
190 | onclick="restoreItem()" |
---|
191 | title="Restore" |
---|
192 | visible="<%=slide.isRemoved()%>" |
---|
193 | tooltip="<%=writePermission ? "Restore this array slide" : "You do not have permission to restore this array slide"%>" |
---|
194 | /> |
---|
195 | <tbl:button |
---|
196 | disabled="<%=sharePermission ? false : true%>" |
---|
197 | image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>" |
---|
198 | onclick="shareItem()" |
---|
199 | title="Share…" |
---|
200 | tooltip="<%=sharePermission ? "Share this array slide to other user, groups and projects" : "You do not have permission to share this array slide"%>" |
---|
201 | /> |
---|
202 | <tbl:button |
---|
203 | disabled="<%=setOwnerPermission ? false : true%>" |
---|
204 | image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>" |
---|
205 | onclick="setOwner()" |
---|
206 | title="Set owner…" |
---|
207 | tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>" |
---|
208 | /> |
---|
209 | <tbl:button |
---|
210 | image="import.gif" |
---|
211 | onclick="runPlugin('ImportItem')" |
---|
212 | title="Import…" |
---|
213 | tooltip="Import data" |
---|
214 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
215 | /> |
---|
216 | <tbl:button |
---|
217 | image="export.gif" |
---|
218 | onclick="runPlugin('ExportItem')" |
---|
219 | title="Export…" |
---|
220 | tooltip="Export data" |
---|
221 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
222 | /> |
---|
223 | <tbl:button |
---|
224 | image="runplugin.gif" |
---|
225 | onclick="runPlugin('RunPlugin')" |
---|
226 | title="Run plugin…" |
---|
227 | tooltip="Run a plugin" |
---|
228 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
229 | /> |
---|
230 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
231 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
232 | <tbl:button |
---|
233 | image="help.gif" |
---|
234 | onclick="<%="Main.openHelp('" + ID +"', 'arrayslide.view.properties')"%>" |
---|
235 | title="Help…" |
---|
236 | tooltip="Get help about this page" |
---|
237 | /> |
---|
238 | </tbl:toolbar> |
---|
239 | <div class="boxedbottom"> |
---|
240 | <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(slide)%></i></div> |
---|
241 | <% |
---|
242 | if (slide.isRemoved() || slide.isShared()) |
---|
243 | { |
---|
244 | %> |
---|
245 | <div class="itemstatus"> |
---|
246 | <base:icon |
---|
247 | image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>" |
---|
248 | onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>" |
---|
249 | tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>" |
---|
250 | visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon> |
---|
251 | <base:icon image="used.gif" |
---|
252 | onclick="showUsingItems()" |
---|
253 | tooltip="Show the items that are using this one" |
---|
254 | visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon> |
---|
255 | <base:icon image="shared.gif" |
---|
256 | visible="<%=slide.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon> |
---|
257 | </div> |
---|
258 | <% |
---|
259 | } |
---|
260 | %> |
---|
261 | <table class="form" cellspacing="0"> |
---|
262 | <tr> |
---|
263 | <td class="prompt">Name</td> |
---|
264 | <td><%=HTML.encodeTags(slide.getName())%></td> |
---|
265 | </tr> |
---|
266 | <tr> |
---|
267 | <td class="prompt">Registered</td> |
---|
268 | <td><%=dateFormatter.format(slide.getEntryDate())%></td> |
---|
269 | </tr> |
---|
270 | <tr> |
---|
271 | <td class="prompt">Barcode</td> |
---|
272 | <td><%=HTML.encodeTags(slide.getBarcode())%></td> |
---|
273 | </tr> |
---|
274 | <tr> |
---|
275 | <td class="prompt">Destroyed</td> |
---|
276 | <td><%=slide.isDestroyed() ? "yes" : "no"%></td> |
---|
277 | </tr> |
---|
278 | <tr> |
---|
279 | <td class="prompt">Hybridization</td> |
---|
280 | <td><base:propertyvalue item="<%=slide%>" property="hybridization" /></td> |
---|
281 | </tr> |
---|
282 | <tr> |
---|
283 | <td class="prompt">Array batch</td> |
---|
284 | <td><base:propertyvalue item="<%=slide%>" property="arrayBatch" /> |
---|
285 | (index: <%=slide.getBatchIndex()%>) |
---|
286 | </td> |
---|
287 | </tr> |
---|
288 | <tr> |
---|
289 | <td class="prompt">Array design</td> |
---|
290 | <td><base:propertyvalue item="<%=slide%>" property="arrayBatch.arrayDesign" /></td> |
---|
291 | </tr> |
---|
292 | <tr> |
---|
293 | <td class="prompt">Owner</td> |
---|
294 | <td><base:propertyvalue item="<%=slide%>" property="owner" /></td> |
---|
295 | </tr> |
---|
296 | <tr> |
---|
297 | <td class="prompt">Description</td> |
---|
298 | <td><%=HTML.niceFormat(slide.getDescription())%></td> |
---|
299 | </tr> |
---|
300 | </table> |
---|
301 | <% |
---|
302 | |
---|
303 | // Tables with users/groups/projects that this item is shared to |
---|
304 | MultiPermissions mp = new MultiPermissions(Collections.singleton(slide)); |
---|
305 | ItemResultList<User> users = mp.getUsers().list(dc); |
---|
306 | ItemResultList<Group> groups = mp.getGroups().list(dc); |
---|
307 | ItemResultList<Project> projects = mp.getProjects().list(dc); |
---|
308 | int totalShare = users.size() + groups.size() + projects.size(); |
---|
309 | |
---|
310 | if (totalShare > 0) |
---|
311 | { |
---|
312 | %> |
---|
313 | <base:section |
---|
314 | id="sharedTo" |
---|
315 | title="<%="Shared to (" + totalShare + ")"%>" |
---|
316 | context="<%=cc%>" |
---|
317 | > |
---|
318 | <tbl:table |
---|
319 | id="itemsSharedTo" |
---|
320 | clazz="itemlist" |
---|
321 | columns="all" |
---|
322 | > |
---|
323 | <tbl:columndef |
---|
324 | id="itemType" |
---|
325 | title="Item type" |
---|
326 | /> |
---|
327 | <tbl:columndef |
---|
328 | id="name" |
---|
329 | title="Name" |
---|
330 | /> |
---|
331 | <tbl:columndef |
---|
332 | id="permissions" |
---|
333 | title="Permissions" |
---|
334 | /> |
---|
335 | <tbl:data> |
---|
336 | <tbl:columns> |
---|
337 | </tbl:columns> |
---|
338 | <tbl:rows> |
---|
339 | <% |
---|
340 | for (Project project : projects) |
---|
341 | { |
---|
342 | Set<Permission> permissions = mp.getPermissions(project).values().iterator().next(); |
---|
343 | %> |
---|
344 | <tbl:row> |
---|
345 | <tbl:cell column="itemType"><%=project.getType()%></tbl:cell> |
---|
346 | <tbl:cell column="name"><base:icon |
---|
347 | image="deleted.gif" |
---|
348 | tooltip="This item has been scheduled for deletion" |
---|
349 | visible="<%=project.isRemoved()%>" |
---|
350 | /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell> |
---|
351 | <tbl:cell column="permissions"> |
---|
352 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
353 | </tbl:cell> |
---|
354 | </tbl:row> |
---|
355 | <% |
---|
356 | } |
---|
357 | for (Group group : groups) |
---|
358 | { |
---|
359 | Set<Permission> permissions = mp.getPermissions(group).values().iterator().next(); |
---|
360 | %> |
---|
361 | <tbl:row> |
---|
362 | <tbl:cell column="itemType"><%=group.getType()%></tbl:cell> |
---|
363 | <tbl:cell column="name"><base:icon |
---|
364 | image="deleted.gif" |
---|
365 | tooltip="This item has been scheduled for deletion" |
---|
366 | visible="<%=group.isRemoved()%>" |
---|
367 | /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell> |
---|
368 | <tbl:cell column="permissions"> |
---|
369 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
370 | </tbl:cell> |
---|
371 | </tbl:row> |
---|
372 | <% |
---|
373 | } |
---|
374 | for (User user : users) |
---|
375 | { |
---|
376 | Set<Permission> permissions = mp.getPermissions(user).values().iterator().next(); |
---|
377 | %> |
---|
378 | <tbl:row> |
---|
379 | <tbl:cell column="itemType"><%=user.getType()%></tbl:cell> |
---|
380 | <tbl:cell column="name"><base:icon |
---|
381 | image="deleted.gif" |
---|
382 | tooltip="This item has been scheduled for deletion" |
---|
383 | visible="<%=user.isRemoved()%>" |
---|
384 | /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell> |
---|
385 | <tbl:cell column="permissions"> |
---|
386 | <%=PermissionUtil.translatePermissionsToString(permissions)%> |
---|
387 | </tbl:cell> |
---|
388 | </tbl:row> |
---|
389 | <% |
---|
390 | } |
---|
391 | %> |
---|
392 | </tbl:rows> |
---|
393 | </tbl:data> |
---|
394 | </tbl:table> |
---|
395 | </base:section> |
---|
396 | <% |
---|
397 | } |
---|
398 | else |
---|
399 | { |
---|
400 | %> |
---|
401 | <h4>Shared to</h4> |
---|
402 | This array slide is not shared |
---|
403 | (or, you don't have permission to view the ones it is shared to). |
---|
404 | <% |
---|
405 | } |
---|
406 | %> |
---|
407 | </div> |
---|
408 | </t:tab> |
---|
409 | |
---|
410 | <t:tab id="annotations" title="Annotations" > |
---|
411 | <div class="boxed"> |
---|
412 | <jsp:include page="../../common/annotations/list_annotations.jsp"> |
---|
413 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
414 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
415 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
416 | </jsp:include> |
---|
417 | </div> |
---|
418 | </t:tab> |
---|
419 | <t:tab id="overview" title="Overview" |
---|
420 | tooltip="Display a tree overview of related items"> |
---|
421 | <% |
---|
422 | if ("overview".equals(tab)) |
---|
423 | { |
---|
424 | %> |
---|
425 | <jsp:include page="../../common/overview/overview.jsp"> |
---|
426 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
427 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
428 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
429 | </jsp:include> |
---|
430 | <% |
---|
431 | } |
---|
432 | %> |
---|
433 | </t:tab> |
---|
434 | </t:tabcontrol> |
---|
435 | |
---|
436 | </base:body> |
---|
437 | </base:page> |
---|
438 | <% |
---|
439 | } |
---|
440 | finally |
---|
441 | { |
---|
442 | if (dc != null) dc.close(); |
---|
443 | } |
---|
444 | |
---|
445 | %> |
---|