1 | <%-- $Id: view_annotationtype.jsp 5941 2012-02-01 13:26:23Z 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 Nicklas |
---|
24 | @version 2.0 |
---|
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.Item" |
---|
31 | import="net.sf.basedb.core.Include" |
---|
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.AnnotationTypeCategory" |
---|
36 | import="net.sf.basedb.core.User" |
---|
37 | import="net.sf.basedb.core.Type" |
---|
38 | import="net.sf.basedb.core.ItemQuery" |
---|
39 | import="net.sf.basedb.core.ItemResultList" |
---|
40 | import="net.sf.basedb.core.MultiPermissions" |
---|
41 | import="net.sf.basedb.core.Group" |
---|
42 | import="net.sf.basedb.core.Project" |
---|
43 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
44 | import="net.sf.basedb.core.PluginDefinition" |
---|
45 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
46 | import="net.sf.basedb.core.plugin.Plugin" |
---|
47 | import="net.sf.basedb.core.query.Orders" |
---|
48 | import="net.sf.basedb.core.query.Hql" |
---|
49 | import="net.sf.basedb.clients.web.Base" |
---|
50 | import="net.sf.basedb.clients.web.ChangeHistoryUtil" |
---|
51 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
52 | import="net.sf.basedb.clients.web.util.HTML" |
---|
53 | import="net.sf.basedb.util.Values" |
---|
54 | import="net.sf.basedb.util.formatter.Formatter" |
---|
55 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
56 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
57 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
58 | import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer" |
---|
59 | import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil" |
---|
60 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
61 | import="java.util.Map" |
---|
62 | import="java.util.Collections" |
---|
63 | import="java.util.Date" |
---|
64 | import="java.util.Set" |
---|
65 | import="java.util.List" |
---|
66 | %> |
---|
67 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
68 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
69 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
70 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
71 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
72 | <%! |
---|
73 | private static final Item itemType = Item.ANNOTATIONTYPE; |
---|
74 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
75 | %> |
---|
76 | <% |
---|
77 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
78 | final String ID = sc.getId(); |
---|
79 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
80 | final int itemId = cc.getId(); |
---|
81 | final String tab = Values.getString(request.getParameter("tab"), "properties"); |
---|
82 | final float scale = Base.getScale(sc); |
---|
83 | final DbControl dc = sc.newDbControl(); |
---|
84 | try |
---|
85 | { |
---|
86 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
87 | |
---|
88 | String title = null; |
---|
89 | AnnotationType annotationType = AnnotationType.getById(dc, itemId); |
---|
90 | |
---|
91 | final boolean writePermission = annotationType.hasPermission(Permission.WRITE); |
---|
92 | final boolean deletePermission = annotationType.hasPermission(Permission.DELETE); |
---|
93 | final boolean sharePermission = annotationType.hasPermission(Permission.SET_PERMISSION); |
---|
94 | final boolean setOwnerPermission = annotationType.hasPermission(Permission.SET_OWNER); |
---|
95 | final boolean isOwner = annotationType.isOwner(); |
---|
96 | final boolean isRemoved = annotationType.isRemoved(); |
---|
97 | final boolean isUsed = isRemoved && annotationType.isUsed(); |
---|
98 | final boolean deletePermanentlyPermission = deletePermission && !isUsed; |
---|
99 | Formatter dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
100 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, annotationType); |
---|
101 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
102 | %> |
---|
103 | <base:page title="<%=title%>"> |
---|
104 | <base:head scripts="tabcontrol.js ,table.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css"> |
---|
105 | <ext:scripts context="<%=jspContext%>" /> |
---|
106 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
107 | <script language="JavaScript"> |
---|
108 | function editItem() |
---|
109 | { |
---|
110 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
111 | } |
---|
112 | function shareItem() |
---|
113 | { |
---|
114 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareAnnotationType', 600, 400); |
---|
115 | } |
---|
116 | function deleteItem() |
---|
117 | { |
---|
118 | location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>'); |
---|
119 | } |
---|
120 | function restoreItem() |
---|
121 | { |
---|
122 | location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>'); |
---|
123 | } |
---|
124 | function deleteItemPermanently() |
---|
125 | { |
---|
126 | Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted'); |
---|
127 | } |
---|
128 | function itemDeleted() |
---|
129 | { |
---|
130 | Main.listItems('<%=ID%>', '<%=itemType.name()%>'); |
---|
131 | } |
---|
132 | function showUsingItems() |
---|
133 | { |
---|
134 | Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>); |
---|
135 | } |
---|
136 | function setOwner() |
---|
137 | { |
---|
138 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300); |
---|
139 | } |
---|
140 | function runPlugin(cmd) |
---|
141 | { |
---|
142 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500); |
---|
143 | } |
---|
144 | function switchTab(tabControlId, tabId) |
---|
145 | { |
---|
146 | if (TabControl.isActive(tabControlId, tabId)) return; |
---|
147 | if (tabId == 'history' && tabId != '<%=tab%>') |
---|
148 | { |
---|
149 | location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId; |
---|
150 | } |
---|
151 | else |
---|
152 | { |
---|
153 | TabControl.setActiveTab(tabControlId, tabId); |
---|
154 | } |
---|
155 | } |
---|
156 | </script> |
---|
157 | </base:head> |
---|
158 | <base:body> |
---|
159 | <p:path><p:pathelement |
---|
160 | title="Annotation types" href="<%="index.jsp?ID="+ID%>" |
---|
161 | /><p:pathelement title="<%=HTML.encodeTags(annotationType.getName())%>" |
---|
162 | /></p:path> |
---|
163 | |
---|
164 | <t:tabcontrol |
---|
165 | id="main" |
---|
166 | subclass="content mastertabcontrol" |
---|
167 | active="<%=tab%>" switch="switchTab" remember="false"> |
---|
168 | <t:tab id="properties" title="Properties"> |
---|
169 | <div> |
---|
170 | <table class="fullform bottomborder"> |
---|
171 | <tr> |
---|
172 | <th class="itemstatus"> |
---|
173 | <base:icon |
---|
174 | image="shared.gif" |
---|
175 | visible="<%=annotationType.isShared()%>" |
---|
176 | tooltip="This item is shared to other users, groups and/or projects" |
---|
177 | /> |
---|
178 | <base:icon |
---|
179 | image="deleted.gif" |
---|
180 | onclick="deleteItemPermanently()" |
---|
181 | tooltip="This item has been flagged for deletion. Click to delete it now." |
---|
182 | enabled="<%=deletePermanentlyPermission %>" |
---|
183 | visible="<%=isRemoved%>" |
---|
184 | /> |
---|
185 | <base:icon image="used.gif" |
---|
186 | onclick="showUsingItems()" |
---|
187 | tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one" |
---|
188 | visible="<%=isRemoved && isUsed%>" /> |
---|
189 | </th> |
---|
190 | <td style="padding: 0px;"> |
---|
191 | <tbl:toolbar subclass="bottomborder"> |
---|
192 | <tbl:button |
---|
193 | disabled="<%=writePermission ? false : true%>" |
---|
194 | image="edit.gif" |
---|
195 | onclick="editItem()" |
---|
196 | title="Edit…" |
---|
197 | tooltip="<%=writePermission ? "Edit this annotation type" : "You do not have permission to edit this annotation type"%>" |
---|
198 | /> |
---|
199 | <tbl:button |
---|
200 | disabled="<%=deletePermission ? false : true%>" |
---|
201 | image="delete.gif" |
---|
202 | onclick="deleteItem()" |
---|
203 | title="Delete" |
---|
204 | visible="<%=!annotationType.isRemoved()%>" |
---|
205 | tooltip="<%=deletePermission ? "Delete this annotation type" : "You do not have permission to delete this annotation type"%>" |
---|
206 | /> |
---|
207 | <tbl:button |
---|
208 | disabled="<%=writePermission ? false : true%>" |
---|
209 | image="restore.gif" |
---|
210 | onclick="restoreItem()" |
---|
211 | title="Restore" |
---|
212 | visible="<%=annotationType.isRemoved()%>" |
---|
213 | tooltip="<%=writePermission ? "Restore this annotation type" : "You do not have permission to restore this annotation type"%>" |
---|
214 | /> |
---|
215 | <tbl:button |
---|
216 | disabled="<%=sharePermission ? false : true%>" |
---|
217 | image="share.gif" |
---|
218 | onclick="shareItem()" |
---|
219 | title="Share…" |
---|
220 | tooltip="<%=sharePermission ? "Share this annotation type to other user, groups and projects" : "You do not have permission to share this annotation type"%>" |
---|
221 | /> |
---|
222 | <tbl:button |
---|
223 | disabled="<%=setOwnerPermission ? false : true%>" |
---|
224 | image="take_ownership.png" |
---|
225 | onclick="setOwner()" |
---|
226 | title="Set ownership…" |
---|
227 | tooltip="<%=setOwnerPermission ? "Set owner of this item" : "You do not have permission to change ownership of this item"%>" |
---|
228 | /> |
---|
229 | <tbl:button |
---|
230 | image="import.gif" |
---|
231 | onclick="runPlugin('ImportItem')" |
---|
232 | title="Import…" |
---|
233 | tooltip="Import data" |
---|
234 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
235 | /> |
---|
236 | <tbl:button |
---|
237 | image="export.gif" |
---|
238 | onclick="runPlugin('ExportItem')" |
---|
239 | title="Export…" |
---|
240 | tooltip="Export data" |
---|
241 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
242 | /> |
---|
243 | <tbl:button |
---|
244 | image="runplugin.gif" |
---|
245 | onclick="runPlugin('RunPlugin')" |
---|
246 | title="Run plugin…" |
---|
247 | tooltip="Run a plugin" |
---|
248 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
249 | /> |
---|
250 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
251 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
252 | <tbl:button |
---|
253 | image="help.png" |
---|
254 | onclick="<%="Main.openHelp('" + ID +"', 'annotationtype.view.properties')"%>" |
---|
255 | title="Help…" |
---|
256 | tooltip="Get help about this page" |
---|
257 | /> |
---|
258 | </tbl:toolbar> |
---|
259 | </td> |
---|
260 | </tr> |
---|
261 | <tr> |
---|
262 | <th>Name</th> |
---|
263 | <td><%=HTML.encodeTags(annotationType.getName())%></td> |
---|
264 | </tr> |
---|
265 | <tr> |
---|
266 | <th>Registered</th> |
---|
267 | <td><%=dateFormatter.format(annotationType.getEntryDate())%></td> |
---|
268 | </tr> |
---|
269 | <tr> |
---|
270 | <th>External ID</th> |
---|
271 | <td><%=HTML.encodeTags(annotationType.getExternalId())%></td> |
---|
272 | </tr> |
---|
273 | <tr> |
---|
274 | <th>Value type</th> |
---|
275 | <td><%=annotationType.getValueType()%></td> |
---|
276 | </tr> |
---|
277 | <tr> |
---|
278 | <th>Default unit</th> |
---|
279 | <td> |
---|
280 | <% |
---|
281 | if (annotationType.supportUnits()) |
---|
282 | { |
---|
283 | %> |
---|
284 | <base:propertyvalue item="<%=annotationType%>" property="quantity" /> |
---|
285 | › |
---|
286 | <base:propertyvalue item="<%=annotationType%>" property="defaultUnit" /> |
---|
287 | <% |
---|
288 | } |
---|
289 | else |
---|
290 | { |
---|
291 | %> |
---|
292 | <i>- none -</i> |
---|
293 | <% |
---|
294 | } |
---|
295 | %> |
---|
296 | </td> |
---|
297 | </tr> |
---|
298 | <tr> |
---|
299 | <th>Enumeration</th> |
---|
300 | <td><%=annotationType.isEnumeration() ? |
---|
301 | HTML.encodeTags(Values.getString((List)annotationType.getValues(), ", ", true, |
---|
302 | (Formatter)FormatterFactory.getTypeFormatter(sc, annotationType.getValueType()))) : "no"%></td> |
---|
303 | </tr> |
---|
304 | <tr> |
---|
305 | <th>Default value</th> |
---|
306 | <td><%=HTML.encodeTags(annotationType.getDefaultValue())%></td> |
---|
307 | </tr> |
---|
308 | <tr> |
---|
309 | <th>Multiplicity</th> |
---|
310 | <td><%=annotationType.getMultiplicity() == 0 ? "<i>- unlimited -</i>" : annotationType.getMultiplicity()%></td> |
---|
311 | </tr> |
---|
312 | <tr> |
---|
313 | <th>Required by MIAME</th> |
---|
314 | <td><%=annotationType.isRequiredForMiame() ? "yes" : "no"%></td> |
---|
315 | </tr> |
---|
316 | <tr> |
---|
317 | <th>Protocol parameter</th> |
---|
318 | <td><%=annotationType.isProtocolParameter() ? "yes" : "no"%></td> |
---|
319 | </tr> |
---|
320 | <tr> |
---|
321 | <th>Items</th> |
---|
322 | <td><%=Values.getString(annotationType.getEnabledItems(), ", ", true)%></td> |
---|
323 | </tr> |
---|
324 | <tr> |
---|
325 | <th>Owner</th> |
---|
326 | <td><base:propertyvalue item="<%=annotationType%>" property="owner" /></td> |
---|
327 | </tr> |
---|
328 | <tr> |
---|
329 | <th>Permissions</th> |
---|
330 | <td><%=PermissionUtil.getFullPermissionNames(annotationType)%></td> |
---|
331 | </tr> |
---|
332 | <tr > |
---|
333 | <th>Description</th> |
---|
334 | <td><%=HTML.niceFormat(annotationType.getDescription())%></td> |
---|
335 | </tr> |
---|
336 | </table> |
---|
337 | </div> |
---|
338 | <% |
---|
339 | ItemQuery<AnnotationTypeCategory> categoryQuery = |
---|
340 | annotationType.getCategories(); |
---|
341 | categoryQuery.include(Include.ALL); |
---|
342 | categoryQuery.order(Orders.asc(Hql.property("name"))); |
---|
343 | ItemResultList<AnnotationTypeCategory> categories = categoryQuery.list(dc); |
---|
344 | %> |
---|
345 | <base:section |
---|
346 | id="categories" |
---|
347 | title="<%="Categories (" + categories.size() + ")"%>" |
---|
348 | context="<%=cc%>" |
---|
349 | > |
---|
350 | <% |
---|
351 | if (categories.size() == 0) |
---|
352 | { |
---|
353 | %> |
---|
354 | <div class="messagecontainer note"> |
---|
355 | This annotation type isn't a member of any category (or, you don't have permission to view them). |
---|
356 | </div> |
---|
357 | <% |
---|
358 | } |
---|
359 | else |
---|
360 | { |
---|
361 | %> |
---|
362 | <tbl:table |
---|
363 | id="members" |
---|
364 | columns="all" |
---|
365 | > |
---|
366 | <tbl:columndef |
---|
367 | id="name" |
---|
368 | title="Name" |
---|
369 | /> |
---|
370 | <tbl:columndef |
---|
371 | id="description" |
---|
372 | title="Description" |
---|
373 | /> |
---|
374 | <tbl:data> |
---|
375 | <tbl:headers> |
---|
376 | <tbl:headerrow> |
---|
377 | <tbl:columnheaders /> |
---|
378 | </tbl:headerrow> |
---|
379 | </tbl:headers> |
---|
380 | <tbl:rows> |
---|
381 | <% |
---|
382 | for (AnnotationTypeCategory category : categories) |
---|
383 | { |
---|
384 | %> |
---|
385 | <tbl:row> |
---|
386 | <tbl:cell column="name"><base:icon |
---|
387 | image="deleted.gif" |
---|
388 | tooltip="This item has been scheduled for deletion" |
---|
389 | visible="<%=category.isRemoved()%>" |
---|
390 | /><%=Base.getLinkedName(ID, category, false, true)%></tbl:cell> |
---|
391 | <tbl:cell column="description"><%=HTML.encodeTags(category.getDescription())%></tbl:cell> |
---|
392 | </tbl:row> |
---|
393 | <% |
---|
394 | } |
---|
395 | %> |
---|
396 | </tbl:rows> |
---|
397 | </tbl:data> |
---|
398 | </tbl:table> |
---|
399 | <% |
---|
400 | } |
---|
401 | %> |
---|
402 | </base:section> |
---|
403 | <jsp:include page="../../common/anytoany/list_anytoany.jsp"> |
---|
404 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
405 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
406 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
407 | <jsp:param name="title" value="Other items related to this annotation type" /> |
---|
408 | </jsp:include> |
---|
409 | <jsp:include page="../../common/share/list_share.jsp"> |
---|
410 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
411 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
412 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
413 | <jsp:param name="title" value="Shared to" /> |
---|
414 | </jsp:include> |
---|
415 | </t:tab> |
---|
416 | <t:tab id="history" title="Change history" |
---|
417 | tooltip="Displays a log of all modifications made to this item" |
---|
418 | visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>"> |
---|
419 | <% |
---|
420 | if ("history".equals(tab)) |
---|
421 | { |
---|
422 | %> |
---|
423 | <jsp:include page="../../common/history/frameset.jsp"> |
---|
424 | <jsp:param name="source_type" value="<%=itemType.name()%>" /> |
---|
425 | <jsp:param name="source_id" value="<%=itemId%>" /> |
---|
426 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
427 | </jsp:include> |
---|
428 | <% |
---|
429 | } |
---|
430 | %> |
---|
431 | </t:tab> |
---|
432 | </t:tabcontrol> |
---|
433 | |
---|
434 | </base:body> |
---|
435 | </base:page> |
---|
436 | <% |
---|
437 | } |
---|
438 | finally |
---|
439 | { |
---|
440 | if (dc != null) dc.close(); |
---|
441 | } |
---|
442 | |
---|
443 | %> |
---|