source: branches/filedb/www/admin/datafiletypes/view_filetype.jsp @ 3798

Last change on this file since 3798 was 3798, checked in by Nicklas Nordborg, 15 years ago

References #721: Changed systemId to externalId in JSP as well

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 8.7 KB
Line 
1<%-- $Id: view_filetype.jsp 3798 2007-09-28 06:45:09Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Hakkinen, 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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.SystemItems"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.Permission"
34  import="net.sf.basedb.core.DataFileType"
35  import="net.sf.basedb.core.Platform"
36  import="net.sf.basedb.core.PlatformVariant"
37  import="net.sf.basedb.core.ItemQuery"
38  import="net.sf.basedb.core.ItemResultList"
39  import="net.sf.basedb.core.PermissionDeniedException"
40  import="net.sf.basedb.core.PluginDefinition"
41  import="net.sf.basedb.core.plugin.GuiContext"
42  import="net.sf.basedb.core.plugin.Plugin"
43  import="net.sf.basedb.core.query.Orders"
44  import="net.sf.basedb.core.query.Hql"
45  import="net.sf.basedb.clients.web.Base"
46  import="net.sf.basedb.clients.web.PermissionUtil"
47  import="net.sf.basedb.clients.web.util.HTML"
48  import="net.sf.basedb.util.formatter.Formatter"
49  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
50  import="net.sf.basedb.util.Values"
51  import="java.util.Map"
52  import="java.util.Date"
53%>
54<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
55<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
56<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
57<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
58<%!
59  private static final Item itemType = Item.DATAFILETYPE;
60  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
61%>
62<%
63final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
64final String ID = sc.getId();
65final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
66final int itemId = cc.getId();
67final float scale = Base.getScale(sc);
68final DbControl dc = sc.newDbControl();
69try
70{
71  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
72
73  String title = null;
74  DataFileType fileType = DataFileType.getById(dc, itemId);
75 
76  final boolean writePermission = fileType.hasPermission(Permission.WRITE);
77  final boolean deletePermission = fileType.hasPermission(Permission.DELETE);
78  %>
79
80  <%@page import="net.sf.basedb.core.PlatformFileType"%>
81<base:page title="<%=title%>">
82  <base:head scripts="tabcontrol.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css">
83    <script language="JavaScript">
84    function editItem()
85    {
86      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
87    }
88    function deleteItem()
89    {
90      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
91    }
92    function restoreItem()
93    {
94      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
95    }
96    function runPlugin(cmd)
97    {
98      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
99    }
100    </script>
101  </base:head>
102  <base:body>
103    <p>
104    <p:path>
105      <p:pathelement title="Data file types" href="<%="index.jsp?ID="+ID%>" />
106      <p:pathelement title="<%=HTML.encodeTags(fileType.getName())%>" />
107    </p:path>
108   
109    <t:tabcontrol id="main" active="properties">
110    <t:tab id="properties" title="Properties">
111   
112    <tbl:toolbar
113      >
114      <tbl:button 
115        disabled="<%=writePermission ? false : true%>" 
116        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
117        onclick="editItem()" 
118        title="Edit&hellip;" 
119        tooltip="<%=writePermission ? "Edit this data file type" : "You do not have permission to edit this data file type"%>" 
120      />
121      <tbl:button 
122        disabled="<%=deletePermission ? false : true%>" 
123        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
124        onclick="deleteItem()" 
125        title="Delete"
126        visible="<%=!fileType.isRemoved()%>"
127        tooltip="<%=deletePermission ? "Delete this data file type" : "You do not have permission to delete this data file type"%>" 
128      />
129      <tbl:button 
130        disabled="<%=writePermission ? false : true%>" 
131        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
132        onclick="restoreItem()" 
133        title="Restore"
134        visible="<%=fileType.isRemoved()%>"
135        tooltip="<%=writePermission ? "Restore this data file type" : "You do not have permission to restore this data file type"%>" 
136      />
137      <tbl:button 
138        image="import.gif" 
139        onclick="runPlugin('ImportItem')" 
140        title="Import&hellip;" 
141        tooltip="Import data" 
142        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
143      />
144      <tbl:button 
145        image="export.gif" 
146        onclick="runPlugin('ExportItem')" 
147        title="Export&hellip;" 
148        tooltip="Export data" 
149        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
150      />
151      <tbl:button 
152        image="runplugin.gif" 
153        onclick="runPlugin('RunPlugin')" 
154        title="Run plugin&hellip;" 
155        tooltip="Run a plugin" 
156        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
157      />
158      <tbl:button
159        image="help.gif"
160        onclick="<%="Main.openHelp('" + ID +"', 'platform.view.properties')"%>"
161        title="Help&hellip;"
162        tooltip="Get help about this page"
163      />
164      </tbl:toolbar>
165    <div class="boxedbottom">
166      <div class="itemstatus">
167        Permissions on this item:
168        <i><%=PermissionUtil.getFullPermissionNames(fileType)%></i>
169      </div>
170      <%
171      if (fileType.isRemoved())
172      {
173        %>
174        <div class="itemstatus">
175          <base:icon image="deleted.gif" 
176            visible="<%=fileType.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
177        </div>
178        <%
179      }
180      %>
181      <table class="form" cellspacing=0>
182      <tr>
183        <td class="prompt">Name</td>
184        <td><%=HTML.encodeTags(fileType.getName())%></td>
185      </tr>
186      <tr>
187        <td class="prompt">External ID</td>
188        <td><%=HTML.encodeTags(fileType.getExternalId())%></td>
189      </tr>
190      <tr>
191        <td class="prompt">Item type</td>
192        <td><%=fileType.getItemType()%></td>
193      </tr>
194      <tr>
195        <td class="prompt">File extension</td>
196        <td><%=HTML.encodeTags(fileType.getExtension())%></td>
197      </tr>
198      <tr>
199        <td class="prompt">Generic file type</td>
200        <td><base:propertyvalue item="<%=fileType%>" property="genericType" /></td>
201      </tr>
202      <tr>
203        <td class="prompt">Validator</td>
204        <td><%=HTML.encodeTags(fileType.getValidatorClass())%></td>
205      </tr>
206      <tr>
207        <td class="prompt">Meta data reader</td>
208        <td><%=HTML.encodeTags(fileType.getMetadataReaderClass())%></td>
209      </tr>
210      <tr valign="baseline">
211        <td class="prompt">Description</td>
212        <td><%=HTML.niceFormat(fileType.getDescription())%></td>
213      </tr>
214      </table>
215     
216    </div>
217      </t:tab>
218      </t:tabcontrol>
219     
220      <%
221      ItemQuery<PlatformFileType> platformQuery = fileType.getPlatforms();
222      platformQuery.order(Orders.asc(Hql.property("platform.name")));
223      ItemResultList<PlatformFileType> platforms = platformQuery.list(dc);
224      if (platforms.size() == 0)
225      {
226        %>
227        <h4>Platforms</h4>
228        This file type is not used by any platforms or variants
229        (or, you don't have permission to view them).
230        <%
231      }
232      else
233      {
234        %>
235        <h4 class="docked">Used on platforms</h4>
236        <tbl:table
237          id="platforms"
238          clazz="itemlist"
239          columns="all"
240          >
241        <tbl:columndef 
242          id="platform"
243          title="Platform"
244        />
245        <tbl:columndef 
246          id="variant"
247          title="Variant"
248        />
249        <tbl:columndef 
250          id="required"
251          title="Required"
252        />
253        <tbl:data>
254          <tbl:columns>
255          </tbl:columns>
256          <tbl:rows>
257          <%
258          for (PlatformFileType item : platforms)
259          {
260            Platform p = item.getPlatform();
261            PlatformVariant v = item.getVariant();
262            %>
263            <tbl:row>
264              <tbl:cell column="platform"><%=Base.getLinkedName(ID, p, false, true)%></tbl:cell>
265              <tbl:cell column="variant"><%=Base.getLinkedName(ID, v, false, true)%></tbl:cell>
266              <tbl:cell column="required"><%=item.isRequired() ? "yes" : "no"%></tbl:cell>
267            </tbl:row>
268            <%
269          }
270          %>
271          </tbl:rows>
272        </tbl:data>
273        </tbl:table>
274        <%
275      }
276      %>
277  </base:body>
278  </base:page>
279  <%
280}
281finally
282{
283  if (dc != null) dc.close();
284}
285
286%>
Note: See TracBrowser for help on using the repository browser.