source: trunk/www/admin/annotationtypes/view_annotationtype.jsp @ 5425

Last change on this file since 5425 was 5425, checked in by Nicklas Nordborg, 13 years ago

References #1514: Fix character encoding of jsp files

I hope this fixes most of the issues, including the reporter list filtering in many places. Let's keep an eye open for more issues until it is time to release 2.16

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 17.4 KB
Line 
1<%-- $Id: view_annotationtype.jsp 5425 2010-09-23 13:30: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 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.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<%
77final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
78final String ID = sc.getId();
79final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
80final int itemId = cc.getId();
81final String tab = Values.getString(request.getParameter("tab"), "properties");
82final float scale = Base.getScale(sc);
83final DbControl dc = sc.newDbControl();
84try
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, 150);
139    }
140    function runPlugin(cmd)
141    {
142      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
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>
160    <p:path>
161      <p:pathelement title="Annotation types" href="<%="index.jsp?ID="+ID%>" />
162      <p:pathelement title="<%=HTML.encodeTags(annotationType.getName())%>" />
163    </p:path>
164   
165    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab" remember="false">
166    <t:tab id="properties" title="Properties">
167   
168    <tbl:toolbar
169      >
170      <tbl:button 
171        disabled="<%=writePermission ? false : true%>" 
172        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
173        onclick="editItem()" 
174        title="Edit&hellip;" 
175        tooltip="<%=writePermission ? "Edit this annotation type" : "You do not have permission to edit this annotation type"%>" 
176      />
177      <tbl:button 
178        disabled="<%=deletePermission ? false : true%>" 
179        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
180        onclick="deleteItem()" 
181        title="Delete"
182        visible="<%=!annotationType.isRemoved()%>"
183        tooltip="<%=deletePermission ? "Delete this annotation type" : "You do not have permission to delete this annotation type"%>" 
184      />
185      <tbl:button 
186        disabled="<%=writePermission ? false : true%>" 
187        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
188        onclick="restoreItem()" 
189        title="Restore"
190        visible="<%=annotationType.isRemoved()%>"
191        tooltip="<%=writePermission ? "Restore this annotation type" : "You do not have permission to restore this annotation type"%>" 
192      />
193      <tbl:button 
194        disabled="<%=sharePermission ? false : true%>"
195        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
196        onclick="shareItem()" 
197        title="Share&hellip;" 
198        tooltip="<%=sharePermission ? "Share this annotation type to other user, groups and projects" : "You do not have permission to share this annotation type"%>"
199      />
200      <tbl:button 
201        disabled="<%=setOwnerPermission ? false : true%>"
202        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
203        onclick="setOwner()" 
204        title="Set ownership&hellip;"
205        tooltip="<%=setOwnerPermission ? "Set owner of this item" : "You do not have permission to change ownership of this item"%>"
206      />
207      <tbl:button 
208        image="import.gif" 
209        onclick="runPlugin('ImportItem')" 
210        title="Import&hellip;" 
211        tooltip="Import data" 
212        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
213      />
214      <tbl:button 
215        image="export.gif" 
216        onclick="runPlugin('ExportItem')" 
217        title="Export&hellip;" 
218        tooltip="Export data" 
219        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
220      />
221      <tbl:button 
222        image="runplugin.gif" 
223        onclick="runPlugin('RunPlugin')" 
224        title="Run plugin&hellip;" 
225        tooltip="Run a plugin" 
226        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
227      />
228      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
229        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
230      <tbl:button
231        image="help.gif"
232        onclick="<%="Main.openHelp('" + ID +"', 'annotationtype.view.properties')"%>"
233        title="Help&hellip;"
234        tooltip="Get help about this page"
235      />
236      </tbl:toolbar>
237    <div class="boxedbottom">
238      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(annotationType)%></i></div>
239      <%
240      if (annotationType.isRemoved() || annotationType.isShared())
241      {
242        %>
243        <div class="itemstatus">
244          <base:icon 
245            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
246            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
247            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
248            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
249          <base:icon image="used.gif" 
250            onclick="showUsingItems()"
251            tooltip="Show the items that are using this one"
252            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
253          <base:icon image="shared.gif" 
254            visible="<%=annotationType.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
255        </div>
256        <%
257      }
258      %>
259      <table class="form" cellspacing=0>
260      <tr>
261        <td class="prompt">Name</td>
262        <td><%=HTML.encodeTags(annotationType.getName())%></td>
263      </tr>
264      <tr>
265        <td class="prompt">Registered</td>
266        <td><%=dateFormatter.format(annotationType.getEntryDate())%></td>
267      </tr>
268      <tr>
269        <td class="prompt">External ID</td>
270        <td><%=HTML.encodeTags(annotationType.getExternalId())%></td>
271      </tr>
272      <tr>
273        <td class="prompt">Value type</td>
274        <td><%=annotationType.getValueType()%></td>
275      </tr>
276      <tr>
277        <td class="prompt">Default unit</td>
278        <td><base:propertyvalue item="<%=annotationType%>" property="quantity" />
279          <base:icon image="submenu.gif" style="vertical-align: baseline;"/>
280          <base:propertyvalue item="<%=annotationType%>" property="defaultUnit" />
281        </td>
282      </tr>
283      <tr>
284        <td class="prompt">Enumeration</td>
285        <td><%=annotationType.isEnumeration() ? 
286          HTML.encodeTags(Values.getString((List)annotationType.getValues(), ", ", true, 
287            (Formatter)FormatterFactory.getTypeFormatter(sc, annotationType.getValueType()))) : "no"%></td>
288      </tr>
289      <tr>
290        <td class="prompt">Default value</td>
291        <td><%=HTML.encodeTags(annotationType.getDefaultValue())%></td>
292      </tr>
293      <tr>
294        <td class="prompt">Multiplicity</td>
295        <td><%=annotationType.getMultiplicity() == 0 ? "<i>- unlimited -</i>" : annotationType.getMultiplicity()%></td>
296      </tr>
297      <tr>
298        <td class="prompt">Required by MIAME</td>
299        <td><%=annotationType.isRequiredForMiame() ? "yes" : "no"%></td>
300      </tr>
301      <tr>
302        <td class="prompt">Protocol parameter</td>
303        <td><%=annotationType.isProtocolParameter() ? "yes" : "no"%></td>
304      </tr>
305      <tr>
306        <td class="prompt">Items</td>
307        <td><%=Values.getString(annotationType.getEnabledItems(), ", ", true)%></td>
308      </tr>
309      <tr>
310        <td class="prompt">Owner</td>
311        <td><base:propertyvalue item="<%=annotationType%>" property="owner" /></td>
312      </tr>
313      <tr valign="baseline">
314        <td class="prompt">Description</td>
315        <td><%=HTML.niceFormat(annotationType.getDescription())%></td>
316      </tr>
317      </table>
318     
319
320      <%
321      ItemQuery<AnnotationTypeCategory> categoryQuery = 
322        annotationType.getCategories();
323      categoryQuery.include(Include.ALL);
324      categoryQuery.order(Orders.asc(Hql.property("name")));
325      ItemResultList<AnnotationTypeCategory> categories = categoryQuery.list(dc);
326     
327      if (categories.size() == 0)
328      {
329        %>
330        <h4>Categories</h4>
331        This annotation type isn't a member of any category (or, you don't have permission to view them).
332        <%
333      }
334      else
335      {
336        %>
337        <base:section 
338          id="categories" 
339          title="<%="Categories (" + categories.size() + ")"%>"
340          context="<%=cc%>"
341          >
342          <tbl:table
343            id="members"
344            clazz="itemlist"
345            columns="all"
346            >
347          <tbl:columndef 
348            id="name"
349            title="Name"
350          />
351          <tbl:columndef 
352            id="description"
353            title="Description"
354          />
355          <tbl:data>
356            <tbl:columns>
357            </tbl:columns>
358            <tbl:rows>
359            <%
360           
361            for (AnnotationTypeCategory category : categories)
362            {
363              %>
364              <tbl:row>
365                <tbl:cell column="name"><base:icon 
366                    image="deleted.gif" 
367                    tooltip="This item has been scheduled for deletion" 
368                    visible="<%=category.isRemoved()%>"
369                  /><%=Base.getLinkedName(ID, category, false, true)%></tbl:cell>
370                <tbl:cell column="description"><%=HTML.encodeTags(category.getDescription())%></tbl:cell>
371              </tbl:row>
372              <%
373            }
374            %>
375            </tbl:rows>
376          </tbl:data>
377          </tbl:table>
378        </base:section>
379        <%
380      }
381
382      // Tables with users/groups/projects that this item is shared to
383      MultiPermissions mp = new MultiPermissions(Collections.singleton(annotationType));
384      ItemResultList<User> users = mp.getUsers().list(dc);
385      ItemResultList<Group> groups = mp.getGroups().list(dc);
386      ItemResultList<Project> projects = mp.getProjects().list(dc);
387      int totalShare = users.size() + groups.size() + projects.size();
388     
389      if (totalShare > 0)
390      {
391        %>
392        <base:section 
393          id="sharedTo" 
394          title="<%="Shared to (" + totalShare + ")"%>" 
395          context="<%=cc%>"
396          >
397          <tbl:table 
398            id="itemsSharedTo"
399            clazz="itemlist"
400            columns="all"
401          >
402            <tbl:columndef 
403              id="itemType"
404              title="Item type"
405            />
406            <tbl:columndef 
407              id="name"
408              title="Name"
409            />
410            <tbl:columndef 
411              id="permissions"
412              title="Permissions"
413            />
414            <tbl:data>
415              <tbl:columns>
416              </tbl:columns>
417              <tbl:rows>
418              <%
419              for (Project project : projects)
420              {
421                Set<Permission> permissions = mp.getPermissions(project).values().iterator().next();
422                %>     
423                <tbl:row>
424                  <tbl:cell column="itemType"><%=project.getType()%></tbl:cell>
425                  <tbl:cell column="name"><base:icon 
426                    image="deleted.gif" 
427                    tooltip="This item has been scheduled for deletion" 
428                    visible="<%=project.isRemoved()%>"
429                  /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell>
430                  <tbl:cell column="permissions">
431                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
432                  </tbl:cell>
433                </tbl:row>
434                <%
435              }
436              for (Group group : groups)
437              {
438                Set<Permission> permissions = mp.getPermissions(group).values().iterator().next();
439                %>
440                <tbl:row>             
441                  <tbl:cell column="itemType"><%=group.getType()%></tbl:cell>
442                  <tbl:cell column="name"><base:icon 
443                    image="deleted.gif" 
444                    tooltip="This item has been scheduled for deletion" 
445                    visible="<%=group.isRemoved()%>"
446                  /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
447                  <tbl:cell column="permissions">
448                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
449                  </tbl:cell>
450                </tbl:row>
451                <% 
452              }
453              for (User user : users)
454              {
455                Set<Permission> permissions = mp.getPermissions(user).values().iterator().next();
456                %>
457                <tbl:row>             
458                  <tbl:cell column="itemType"><%=user.getType()%></tbl:cell>
459                  <tbl:cell column="name"><base:icon 
460                    image="deleted.gif" 
461                    tooltip="This item has been scheduled for deletion" 
462                    visible="<%=user.isRemoved()%>"
463                  /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
464                  <tbl:cell column="permissions">
465                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
466                  </tbl:cell>
467                </tbl:row>
468                <%
469              }
470              %>
471              </tbl:rows>
472            </tbl:data>
473          </tbl:table>
474        </base:section>
475        <%
476      }
477      else
478      {
479        %>
480        <h4>Shared to</h4>
481        This annotation type is not shared
482        (or, you don't have permission to view the ones it is shared to).
483        <%
484      }
485      %>
486     
487    </div>
488      </t:tab>
489      <t:tab id="history" title="Change history" 
490        tooltip="Displays a log of all modifications made to this item"
491        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
492        <%
493        if ("history".equals(tab))
494        {
495          %>
496          <jsp:include page="../../common/history/frameset.jsp">
497            <jsp:param name="source_type" value="<%=itemType.name()%>" />
498            <jsp:param name="source_id" value="<%=itemId%>" />
499            <jsp:param name="ID" value="<%=ID%>" />
500          </jsp:include>
501          <%
502        }
503        %>
504      </t:tab>
505      </t:tabcontrol>
506
507  </base:body>
508  </base:page>
509  <%
510}
511finally
512{
513  if (dc != null) dc.close();
514}
515
516%>
Note: See TracBrowser for help on using the repository browser.