source: trunk/www/admin/datafiletypes/view_filetype.jsp @ 7311

Last change on this file since 7311 was 7311, checked in by Nicklas Nordborg, 6 years ago

Fixes #2066: Display item subtypes that are referencing a data file type

Also added a column in the list page.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 12.4 KB
Line 
1<%-- $Id:view_filetype.jsp 3820 2007-10-12 10:03:18Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 3
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  @author Nicklas
23  @version 2.0
24--%>
25<%@ page pageEncoding="UTF-8" session="false"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.DbControl"
28  import="net.sf.basedb.core.SystemItems"
29  import="net.sf.basedb.core.Item"
30  import="net.sf.basedb.core.ItemContext"
31  import="net.sf.basedb.core.Permission"
32  import="net.sf.basedb.core.DataFileType"
33  import="net.sf.basedb.core.Platform"
34  import="net.sf.basedb.core.PlatformVariant"
35  import="net.sf.basedb.core.PlatformFileType"
36  import="net.sf.basedb.core.ItemSubtypeFileType"
37  import="net.sf.basedb.core.ItemSubtype"
38  import="net.sf.basedb.core.Include"
39  import="net.sf.basedb.core.ItemQuery"
40  import="net.sf.basedb.core.ItemResultList"
41  import="net.sf.basedb.core.PermissionDeniedException"
42  import="net.sf.basedb.core.PluginDefinition"
43  import="net.sf.basedb.core.plugin.GuiContext"
44  import="net.sf.basedb.core.plugin.Plugin"
45  import="net.sf.basedb.core.query.Orders"
46  import="net.sf.basedb.core.query.Hql"
47  import="net.sf.basedb.clients.web.Base"
48  import="net.sf.basedb.clients.web.PermissionUtil"
49  import="net.sf.basedb.clients.web.util.HTML"
50  import="net.sf.basedb.util.formatter.Formatter"
51  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
52  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
53  import="net.sf.basedb.clients.web.extensions.JspContext"
54  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
55  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
56  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
57  import="net.sf.basedb.util.Values"
58  import="java.util.Map"
59  import="java.util.Date"
60%>
61<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
62<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
63<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
64<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
65<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
66<%!
67  private static final Item itemType = Item.DATAFILETYPE;
68  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
69%>
70<%
71final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
72final String ID = sc.getId();
73final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
74final int itemId = cc.getId();
75final String tab = Values.getStringOrNull(request.getParameter("tab"));
76final float scale = Base.getScale(sc);
77final DbControl dc = sc.newDbControl();
78try
79{
80  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
81
82  String title = null;
83  DataFileType fileType = DataFileType.getById(dc, itemId);
84 
85  final boolean writePermission = fileType.hasPermission(Permission.WRITE);
86  final boolean deletePermission = fileType.hasPermission(Permission.DELETE);
87  final boolean isRemoved = fileType.isRemoved();
88  final boolean isUsed = isRemoved && fileType.isUsed();
89  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
90  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, fileType);
91  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
92  %>
93  <base:page title="<%=title%>" id="view-page">
94  <base:head scripts="tabcontrol-2.js,~filetypes.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css">
95    <ext:scripts context="<%=jspContext%>" />
96    <ext:stylesheets context="<%=jspContext%>" />
97  </base:head>
98  <base:body>
99    <p:path><p:pathelement 
100      title="Data file types" href="<%="index.jsp?ID="+ID%>" 
101      /><p:pathelement title="<%=HTML.encodeTags(fileType.getName())%>" 
102      /></p:path>
103    <div id="page-data" data-item-id="<%=itemId%>"></div>
104   
105    <t:tabcontrol 
106      id="main" 
107      subclass="content mastertabcontrol" 
108      active="<%=tab%>">
109    <t:tab id="properties" title="Properties">
110      <div>
111      <table class="fullform bottomborder">
112      <tr>
113        <th class="itemstatus">
114          <base:icon 
115            id="btnDeletePermanently"
116            image="deleted.png"
117            tooltip="This item has been flagged for deletion. Click to delete it now."
118            enabled="<%=deletePermanentlyPermission %>"
119            visible="<%=isRemoved%>" 
120          />
121          <base:icon 
122            id="btnUsingItems"
123            image="used.png" 
124            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
125            visible="<%=isRemoved && isUsed%>" />
126        </th>
127        <td style="padding: 0px;">
128          <tbl:toolbar subclass="bottomborder bg-filled-50">
129            <tbl:button 
130              id="btnEdit"
131              disabled="<%=!writePermission%>" 
132              image="edit.png" 
133              title="Edit&hellip;" 
134              tooltip="<%=writePermission ? "Edit this data file type" : "You do not have permission to edit this data file type"%>" 
135            />
136            <tbl:button 
137              id="btnDelete"
138              disabled="<%=!deletePermission%>" 
139              image="delete.png" 
140              title="Delete"
141              visible="<%=!fileType.isRemoved()%>"
142              tooltip="<%=deletePermission ? "Delete this data file type" : "You do not have permission to delete this data file type"%>" 
143            />
144            <tbl:button 
145              id="btnRestore"
146              disabled="<%=!writePermission%>" 
147              image="restore.png" 
148              title="Restore"
149              visible="<%=fileType.isRemoved()%>"
150              tooltip="<%=writePermission ? "Restore this data file type" : "You do not have permission to restore this data file type"%>" 
151            />
152            <tbl:button 
153              id="btnImport"
154              image="import.png" 
155              data-plugin-type="IMPORT" 
156              title="Import&hellip;" 
157              tooltip="Import data" 
158              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
159            />
160            <tbl:button 
161              id="btnExport"
162              image="export.png"
163              data-plugin-type="EXPORT" 
164              title="Export&hellip;" 
165              tooltip="Export data" 
166              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
167            />
168            <tbl:button 
169              id="btnRunPlugin"
170              image="runplugin.png" 
171              data-plugin-type="OTHER" 
172              title="Run plugin&hellip;" 
173              tooltip="Run a plugin" 
174              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
175            />
176            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
177              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
178            <tbl:button
179              image="help.png"
180              subclass="auto-init"
181              data-auto-init="help"
182              data-help-id="datafiletype.view.properties"
183              title="Help&hellip;"
184              tooltip="Get help about this page"
185            />
186          </tbl:toolbar>
187        </td>
188      </tr>
189      <tr>
190        <th>Name</th>
191        <td><%=HTML.encodeTags(fileType.getName())%></td>
192      </tr>
193      <tr>
194        <th>External ID</th>
195        <td><%=HTML.encodeTags(fileType.getExternalId())%></td>
196      </tr>
197      <tr>
198        <th>Item type</th>
199        <td><%=fileType.getItemType()%></td>
200      </tr>
201      <tr>
202        <th>File extension</th>
203        <td><%=HTML.encodeTags(fileType.getExtension())%></td>
204      </tr>
205      <tr>
206        <th>Generic file type</th>
207        <td><base:propertyvalue item="<%=fileType%>" property="genericType" /></td>
208      </tr>
209      <tr>
210        <th>Permissions</th>
211        <td><%=PermissionUtil.getFullPermissionNames(fileType)%></td>
212      </tr>
213      <tr >
214        <th>Description</th>
215        <td><%=HTML.niceFormat(fileType.getDescription())%></td>
216      </tr>
217      </table>
218      </div>
219      <%
220      ItemQuery<PlatformFileType> platformQuery = fileType.getPlatforms();
221      platformQuery.include(Include.ALL);
222      platformQuery.order(Orders.asc(Hql.property("platform.name")));
223      ItemResultList<PlatformFileType> platforms = platformQuery.list(dc);
224      %>
225      <base:section 
226        id="platforms"
227        title="<%="Used on platforms (" + platforms.size() + ")"%>"
228        context="<%=cc%>"
229        >
230        <%
231        if (platforms.size() == 0)
232        {
233          %>
234          <div class="messagecontainer note">
235          This file type is not used by any platforms or variants
236          (or, you don't have permission to view them).
237          </div>
238          <%
239        }
240        else
241        {
242          %>
243          <tbl:table
244            id="tbl.platforms"
245            columns="all"
246            >
247            <tbl:columndef 
248              id="platform"
249              title="Platform"
250            />
251            <tbl:columndef 
252              id="variant"
253              title="Variant"
254            />
255            <tbl:columndef 
256              id="required"
257              title="Required"
258            />
259            <tbl:columndef 
260              id="multiple"
261              title="Multiple files"
262            />
263            <tbl:data>
264              <tbl:headers>
265                <tbl:headerrow>
266                  <tbl:columnheaders />
267                </tbl:headerrow>
268              </tbl:headers>
269              <tbl:rows>
270              <%
271              for (PlatformFileType item : platforms)
272              {
273                Platform p = item.getPlatform();
274                PlatformVariant v = item.getVariant();
275                %>
276                <tbl:row>
277                  <tbl:cell column="platform"><base:icon 
278                      image="deleted.png" 
279                      tooltip="This item has been scheduled for deletion" 
280                      visible="<%=p.isRemoved()%>"
281                    /><%=Base.getLinkedName(ID, p, false, true)%></tbl:cell>
282                  <tbl:cell column="variant"><base:icon 
283                      image="deleted.png" 
284                      tooltip="This item has been scheduled for deletion" 
285                      visible="<%=v!= null && v.isRemoved()%>"
286                    /><%=v == null ? "<i>- all -</i>" : Base.getLinkedName(ID, v, false, true)%></tbl:cell>
287                  <tbl:cell column="required"><%=item.isRequired() ? "yes" : "no"%></tbl:cell>
288                  <tbl:cell column="multiple"><%=item.getAllowMultiple() ? "yes" : "no"%></tbl:cell>
289                </tbl:row>
290                <%
291              }
292              %>
293              </tbl:rows>
294            </tbl:data>
295          </tbl:table>
296          <%
297        }
298        %>
299      </base:section>
300      <%
301      ItemQuery<ItemSubtypeFileType> subtypeQuery = ItemSubtypeFileType.getQuery(fileType);
302      subtypeQuery.include(Include.ALL);
303      subtypeQuery.order(Orders.asc(Hql.property("itemSubtype.name")));
304      ItemResultList<ItemSubtypeFileType> subtypes = subtypeQuery.list(dc);
305      %>
306      <base:section 
307        id="subtypes"
308        title="<%="Used by item subtypes (" + subtypes.size() + ")"%>"
309        context="<%=cc%>"
310        >
311        <%
312        if (subtypes.size() == 0)
313        {
314          %>
315          <div class="messagecontainer note">
316          This file type is not used by any item subtypes
317          (or, you don't have permission to view them).
318          </div>
319          <%
320        }
321        else
322        {
323          %>
324          <tbl:table
325            id="tbl.subtypes"
326            columns="all"
327            >
328            <tbl:columndef 
329              id="subtype"
330              title="Item subtype"
331            />
332            <tbl:columndef 
333              id="required"
334              title="Required"
335            />
336            <tbl:columndef 
337              id="multiple"
338              title="Multiple files"
339            />
340            <tbl:data>
341              <tbl:headers>
342                <tbl:headerrow>
343                  <tbl:columnheaders />
344                </tbl:headerrow>
345              </tbl:headers>
346              <tbl:rows>
347              <%
348              for (ItemSubtypeFileType item : subtypes)
349              {
350                ItemSubtype st = item.getItemSubtype();
351                %>
352                <tbl:row>
353                  <tbl:cell column="subtype"><base:icon 
354                      image="deleted.png" 
355                      tooltip="This item has been scheduled for deletion" 
356                      visible="<%=st.isRemoved()%>"
357                    /><%=Base.getLinkedName(ID, st, false, true)%></tbl:cell>
358                  <tbl:cell column="required"><%=item.isRequired() ? "yes" : "no"%></tbl:cell>
359                  <tbl:cell column="multiple"><%=item.getAllowMultiple() ? "yes" : "no"%></tbl:cell>
360                </tbl:row>
361                <%
362              }
363              %>
364              </tbl:rows>
365            </tbl:data>
366          </tbl:table>
367          <%
368        }
369        %>
370      </base:section>
371      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
372        <jsp:param name="ID" value="<%=ID%>" />
373        <jsp:param name="item_type" value="<%=itemType.name()%>" />
374        <jsp:param name="item_id" value="<%=itemId%>" />
375        <jsp:param name="title" value="Other items related to this file type" />
376      </jsp:include>
377     
378      </t:tab>
379      </t:tabcontrol>
380  </base:body>
381  </base:page>
382  <%
383}
384finally
385{
386  if (dc != null) dc.close();
387}
388
389%>
Note: See TracBrowser for help on using the repository browser.