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

Last change on this file since 6728 was 6728, checked in by Nicklas Nordborg, 7 years ago

References #1910: Disable annotation inheritance for annotation types

Added AnnotationType.getDisableInheritance() which is a flag that if set will disable the inheritance. Schema version is updated and all existing annotation types are set to FALSE.

A permission check when calling AnnotationSet.inheritAnnotation has been implemented and setting the flag with AnnotationType.setDisableInheritance() will trigger a removal of existing inherited annotations.

This should complete the core part of the functionality but we also need some supporting functionality (mainly in the gui).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 13.4 KB
Line 
1<%-- $Id: view_annotationtype.jsp 6728 2015-02-13 08:00:01Z 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<%
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"));
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%>" id="view-page">
104  <base:head scripts="tabcontrol-2.js,table.js,~annotationtypes.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
105    <ext:scripts context="<%=jspContext%>" />
106    <ext:stylesheets context="<%=jspContext%>" />
107  </base:head>
108  <base:body>
109    <p:path><p:pathelement 
110      title="Annotation types" href="<%="index.jsp?ID="+ID%>" 
111      /><p:pathelement title="<%=HTML.encodeTags(annotationType.getName())%>" 
112      /></p:path>
113    <div id="page-data" data-item-id="<%=itemId%>"></div>
114   
115    <t:tabcontrol 
116      id="main" 
117      subclass="content mastertabcontrol" 
118      active="<%=tab%>">
119    <t:tab id="properties" title="Properties">
120      <div>
121      <table class="fullform bottomborder">
122      <tr>
123        <th class="itemstatus">
124          <base:icon 
125            image="shared.png" 
126            visible="<%=annotationType.isShared()%>"
127            tooltip="This item is shared to other users, groups and/or projects"
128          />
129          <base:icon 
130            id="btnDeletePermanently"
131            image="deleted.png"
132            tooltip="This item has been flagged for deletion. Click to delete it now."
133            enabled="<%=deletePermanentlyPermission %>"
134            visible="<%=isRemoved%>" 
135          />
136          <base:icon
137            id="btnUsingItems"
138            image="used.png" 
139            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
140            visible="<%=isRemoved && isUsed%>" />
141        </th>
142        <td style="padding: 0px;">
143          <tbl:toolbar subclass="bottomborder bg-filled-50">
144            <tbl:button 
145              id="btnEdit"
146              disabled="<%=!writePermission%>" 
147              image="edit.png" 
148              title="Edit&hellip;" 
149              tooltip="<%=writePermission ? "Edit this annotation type" : "You do not have permission to edit this annotation type"%>" 
150            />
151            <tbl:button 
152              id="btnDelete"
153              disabled="<%=!deletePermission%>" 
154              image="delete.png" 
155              title="Delete"
156              visible="<%=!annotationType.isRemoved()%>"
157              tooltip="<%=deletePermission ? "Delete this annotation type" : "You do not have permission to delete this annotation type"%>" 
158            />
159            <tbl:button 
160              id="btnRestore"
161              disabled="<%=!writePermission%>" 
162              image="restore.png" 
163              title="Restore"
164              visible="<%=annotationType.isRemoved()%>"
165              tooltip="<%=writePermission ? "Restore this annotation type" : "You do not have permission to restore this annotation type"%>" 
166            />
167            <tbl:button 
168              id="btnShare"
169              disabled="<%=!sharePermission%>"
170              image="share.png"
171              title="Share&hellip;" 
172              tooltip="<%=sharePermission ? "Share this annotation type to other user, groups and projects" : "You do not have permission to share this annotation type"%>"
173            />
174            <tbl:button 
175              id="btnSetOwner"
176              disabled="<%=!setOwnerPermission%>"
177              image="take_ownership.png"
178              title="Set ownership&hellip;"
179              tooltip="<%=setOwnerPermission ? "Set owner of this item" : "You do not have permission to change ownership of this item"%>"
180            />
181            <tbl:button 
182              id="btnImport"
183              image="import.png" 
184              data-plugin-type="IMPORT" 
185              title="Import&hellip;" 
186              tooltip="Import data" 
187              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
188            />
189            <tbl:button 
190              id="btnExport"
191              image="export.png"
192              data-plugin-type="EXPORT" 
193              title="Export&hellip;" 
194              tooltip="Export data" 
195              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
196            />
197            <tbl:button 
198              id="btnRunPlugin"
199              image="runplugin.png" 
200              data-plugin-type="OTHER" 
201              title="Run plugin&hellip;" 
202              tooltip="Run a plugin" 
203              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
204            />
205            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
206              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
207            <tbl:button
208              image="help.png"
209              subclass="auto-init"
210              data-auto-init="help"
211              data-help-id="annotationtype.view.properties"
212              title="Help&hellip;"
213              tooltip="Get help about this page"
214            />
215          </tbl:toolbar>
216        </td>
217      </tr>
218      <tr>
219        <th>Name</th>
220        <td><%=HTML.encodeTags(annotationType.getName())%></td>
221      </tr>
222      <tr>
223        <th>Registered</th>
224        <td><%=dateFormatter.format(annotationType.getEntryDate())%></td>
225      </tr>
226      <tr>
227        <th>External ID</th>
228        <td><%=HTML.encodeTags(annotationType.getExternalId())%></td>
229      </tr>
230      <tr>
231        <th>Value type</th>
232        <td><%=annotationType.getValueType()%></td>
233      </tr>
234      <tr>
235        <th>Default unit</th>
236        <td>
237          <%
238          if (annotationType.supportUnits())
239          {
240            %>
241            <base:propertyvalue item="<%=annotationType%>" property="quantity" />
242            ›
243            <base:propertyvalue item="<%=annotationType%>" property="defaultUnit"  />
244            <%
245          }
246          else
247          {
248            %>
249            <i>- none -</i>
250            <%
251          }
252          %>
253        </td>
254      </tr>
255      <tr>
256        <th>Enumeration</th>
257        <td><%=annotationType.isEnumeration() ? 
258          HTML.encodeTags(Values.getString((List)annotationType.getValues(), ", ", true, 
259            (Formatter)FormatterFactory.getTypeFormatter(sc, annotationType.getValueType()))) : "no"%></td>
260      </tr>
261      <tr>
262        <th>Default value</th>
263        <td><%=HTML.encodeTags(annotationType.getDefaultValue())%></td>
264      </tr>
265      <tr>
266        <th>Multiplicity</th>
267        <td><%=annotationType.getMultiplicity() == 0 ? "<i>- unlimited -</i>" : annotationType.getMultiplicity()%></td>
268      </tr>
269      <tr>
270        <th>Required by MIAME</th>
271        <td><%=annotationType.isRequiredForMiame() ? "yes" : "no"%></td>
272      </tr>
273      <tr>
274        <th>Protocol parameter</th>
275        <td><%=annotationType.isProtocolParameter() ? "yes" : "no"%></td>
276      </tr>
277      <tr>
278        <th>Disable change log</th>
279        <td><%=annotationType.getDisableLogOfValues() ? "yes" : "no"%></td>
280      </tr>
281      <tr>
282        <th>Disable inheritance</th>
283        <td><%=annotationType.getDisableInheritance() ? "yes" : "no"%></td>
284      </tr>
285      <tr>
286        <th>Items</th>
287        <td><%=Values.getString(annotationType.getEnabledItems(), ", ", true)%></td>
288      </tr>
289      <tr>
290        <th>Owner</th>
291        <td><base:propertyvalue item="<%=annotationType%>" property="owner" /></td>
292      </tr>
293      <tr>
294        <th>Permissions</th>
295        <td><%=PermissionUtil.getFullPermissionNames(annotationType)%></td>
296      </tr>
297      <tr >
298        <th>Description</th>
299        <td><%=HTML.niceFormat(annotationType.getDescription())%></td>
300      </tr>
301      </table>
302      </div>
303      <%
304      ItemQuery<AnnotationTypeCategory> categoryQuery = 
305        annotationType.getCategories();
306      categoryQuery.include(Include.ALL);
307      categoryQuery.order(Orders.asc(Hql.property("name")));
308      ItemResultList<AnnotationTypeCategory> categories = categoryQuery.list(dc);
309      %>
310      <base:section 
311        id="categories" 
312        title="<%="Categories (" + categories.size() + ")"%>"
313        context="<%=cc%>"
314        >
315        <%
316        if (categories.size() == 0)
317        {
318          %>
319          <div class="messagecontainer note">
320          This annotation type isn't a member of any category (or, you don't have permission to view them).
321          </div>
322          <%
323        }
324        else
325        {
326          %>
327          <tbl:table
328            id="members"
329            columns="all"
330            >
331          <tbl:columndef 
332            id="name"
333            title="Name"
334          />
335          <tbl:columndef 
336            id="description"
337            title="Description"
338          />
339          <tbl:data>
340            <tbl:headers>
341              <tbl:headerrow>
342                <tbl:columnheaders />
343              </tbl:headerrow>
344            </tbl:headers>
345            <tbl:rows>
346            <%
347            for (AnnotationTypeCategory category : categories)
348            {
349              %>
350              <tbl:row>
351                <tbl:cell column="name"><base:icon 
352                    image="deleted.png" 
353                    tooltip="This item has been scheduled for deletion" 
354                    visible="<%=category.isRemoved()%>"
355                  /><%=Base.getLinkedName(ID, category, false, true)%></tbl:cell>
356                <tbl:cell column="description"><%=HTML.encodeTags(category.getDescription())%></tbl:cell>
357              </tbl:row>
358              <%
359            }
360            %>
361            </tbl:rows>
362          </tbl:data>
363          </tbl:table>
364          <%
365        }
366        %>
367      </base:section>
368      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
369        <jsp:param name="ID" value="<%=ID%>" />
370        <jsp:param name="item_type" value="<%=itemType.name()%>" />
371        <jsp:param name="item_id" value="<%=itemId%>" />
372        <jsp:param name="title" value="Other items related to this annotation type" />
373      </jsp:include>
374      <jsp:include page="../../common/share/list_share.jsp">
375        <jsp:param name="ID" value="<%=ID%>" />
376        <jsp:param name="item_type" value="<%=itemType.name()%>" />
377        <jsp:param name="item_id" value="<%=itemId%>" />
378        <jsp:param name="title" value="Shared to" />
379      </jsp:include>
380      </t:tab>
381      <t:tab id="history" title="Change history" 
382        tooltip="Displays a log of all modifications made to this item"
383        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
384        <jsp:include page="../../common/history/frameset.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      </t:tab>
390      </t:tabcontrol>
391
392  </base:body>
393  </base:page>
394  <%
395}
396finally
397{
398  if (dc != null) dc.close();
399}
400
401%>
Note: See TracBrowser for help on using the repository browser.