source: trunk/www/admin/platforms/variants/view_variant.jsp @ 4889

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

References #1290: Change source files to UTF-8

Changed 'Hakkinen' to 'Häkkinen'.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 11.5 KB
Line 
1<%-- $Id: view_variant.jsp 4889 2009-04-06 12:52:39Z 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 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.Include"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.Permission"
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.DataFileType"
37  import="net.sf.basedb.core.RawDataType"
38  import="net.sf.basedb.core.PermissionDeniedException"
39  import="net.sf.basedb.core.PluginDefinition"
40  import="net.sf.basedb.core.ItemQuery"
41  import="net.sf.basedb.core.ItemResultList"
42  import="net.sf.basedb.core.query.Orders"
43  import="net.sf.basedb.core.query.Hql"
44  import="net.sf.basedb.core.plugin.GuiContext"
45  import="net.sf.basedb.core.plugin.Plugin"
46  import="net.sf.basedb.clients.web.Base"
47  import="net.sf.basedb.clients.web.PermissionUtil"
48  import="net.sf.basedb.clients.web.util.HTML"
49  import="net.sf.basedb.util.Values"
50  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
51  import="net.sf.basedb.clients.web.extensions.JspContext"
52  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
53  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
54  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
55  import="java.util.Date"
56  import="java.util.Map"
57  import="java.util.Set"
58%>
59<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
60<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
61<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
62<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
63<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
64<%!
65  private static final Item itemType = Item.PLATFORMVARIANT;
66  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
67%>
68<%
69final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
70final String ID = sc.getId();
71final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
72final int itemId = cc.getId();
73final float scale = Base.getScale(sc);
74final DbControl dc = sc.newDbControl();
75try
76{
77  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
78
79  String title = null;
80  final PlatformVariant variant = PlatformVariant.getById(dc, itemId);
81  final Platform platform = variant.getPlatform();
82  final int platformId = platform.getId();
83
84  final boolean writePermission = variant.hasPermission(Permission.WRITE);
85  final boolean deletePermission = variant.hasPermission(Permission.DELETE);
86  final boolean isRemoved = variant.isRemoved();
87  final boolean isUsed = isRemoved && variant.isUsed();
88  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
89  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, variant);
90  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
91  %>
92  <base:page title="<%=title%>">
93  <base:head scripts="table.js,tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
94    <ext:scripts context="<%=jspContext%>" />
95    <ext:stylesheets context="<%=jspContext%>" />
96    <script language="JavaScript">
97    function editItem()
98    {
99      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
100    }
101    function deleteItem()
102    {
103      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&platform_id=<%=platformId%>&item_id=<%=itemId%>');
104    }
105    function restoreItem()
106    {
107      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&platform_id=<%=platformId%>&item_id=<%=itemId%>');
108    }
109    function deleteItemPermanently()
110    {
111      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
112    }
113    function itemDeleted()
114    {
115      Main.listItems('<%=ID%>', '<%=itemType.name()%>', '&platform_id=<%=platformId%>');
116    }
117    function showUsingItems()
118    {
119      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
120    }
121    function runPlugin(cmd)
122    {
123      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&platform_id=<%=platformId%>&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
124    }
125    </script>
126  </base:head>
127  <base:body>
128    <p>
129    <p:path>
130      <p:pathelement title="Platforms" href="<%="../index.jsp?ID="+ID%>" />
131      <p:pathelement 
132        title="<%=HTML.encodeTags(platform.getName())%>" 
133        href="<%="index.jsp?ID="+ID+"&platform_id="+platformId%>" />
134      <p:pathelement title="<%=HTML.encodeTags(variant.getName())%>" />
135    </p:path>
136   
137    <t:tabcontrol id="main" active="properties">
138    <t:tab id="properties" title="Properties">
139
140    <tbl:toolbar
141      >
142      <tbl:button 
143        disabled="<%=writePermission ? false : true%>" 
144        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
145        onclick="editItem()" 
146        title="Edit&hellip;" 
147        tooltip="<%=writePermission ? "Edit this platform variant" : "You do not have permission to edit this variant"%>" 
148      />
149      <tbl:button 
150        disabled="<%=deletePermission ? false : true%>" 
151        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
152        onclick="deleteItem()" 
153        title="Delete"
154        visible="<%=!variant.isRemoved()%>"
155        tooltip="<%=deletePermission ? "Delete this platform variant" : "You do not have permission to delete this platform variant"%>" 
156      />
157      <tbl:button 
158        disabled="<%=writePermission ? false : true%>" 
159        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
160        onclick="restoreItem()" 
161        title="Restore"
162        visible="<%=variant.isRemoved()%>"
163        tooltip="<%=writePermission ? "Restore this platform" : "You do not have permission to restore this platform variant"%>" 
164      />
165      <tbl:button 
166        image="import.gif" 
167        onclick="runPlugin('ImportItem')" 
168        title="Import&hellip;" 
169        tooltip="Import data" 
170        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
171      />
172      <tbl:button 
173        image="export.gif" 
174        onclick="runPlugin('ExportItem')" 
175        title="Export&hellip;" 
176        tooltip="Export data" 
177        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
178      />
179      <tbl:button 
180        image="runplugin.gif" 
181        onclick="runPlugin('RunPlugin')" 
182        title="Run plugin&hellip;" 
183        tooltip="Run a plugin" 
184        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
185      />
186      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
187        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
188      <tbl:button
189        image="help.gif"
190        onclick="<%="Main.openHelp('" + ID +"', 'platformvariant.view.properties')"%>"
191        title="Help&hellip;"
192        tooltip="Get help about this page"
193      />
194      </tbl:toolbar>
195    <div class="boxedbottom">
196      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(platform)%></i></div>
197      <%
198      if (variant.isRemoved())
199      {
200        %>
201        <div class="itemstatus">
202          <base:icon 
203            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
204            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
205            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
206            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
207          <base:icon image="used.gif" 
208            onclick="showUsingItems()"
209            tooltip="Show the items that are using this one"
210            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
211        </div>
212        <%
213      }
214      %>
215      <table class="form" cellspacing=0>
216      <tr>
217        <td class="prompt">Name</td>
218        <td><%=HTML.encodeTags(variant.getName())%></td>
219      </tr>
220      <tr>
221        <td class="prompt">External ID</td>
222        <td><%=HTML.encodeTags(variant.getExternalId())%></td>
223      </tr>
224      <tr>
225        <td class="prompt">File-only</td>
226        <td><%=variant.isFileOnly() ? "yes" : "no"%></td>
227      </tr>
228      <%
229      RawDataType rdt = variant.getRawDataType();
230      if (!variant.isFileOnly())
231      {
232        %>
233        <tr>
234          <td class="prompt">Raw data type</td>
235          <td><%=rdt == null ? "<i>- any -</i>" : rdt.getName()%></td>
236        </tr>
237        <%
238      }
239      else
240      {
241        %>
242        <tr>
243          <td class="prompt">Channels</td>
244          <td><%=rdt.getChannels()%></td>
245        </tr>
246        <%
247      }
248      %>
249      <tr valign="baseline">
250        <td class="prompt">Description</td>
251        <td><%=HTML.niceFormat(variant.getDescription())%></td>
252      </tr>
253      </table>
254    </div>
255      </t:tab>
256      </t:tabcontrol>
257
258      <% 
259      ItemQuery<PlatformFileType> fileTypeQuery = platform.getFileTypes(variant, false);
260      fileTypeQuery.include(Include.ALL);
261      fileTypeQuery.join(Hql.leftJoin("variant", "var"));
262      fileTypeQuery.order(Orders.asc(Hql.property("var", "name")));
263      fileTypeQuery.order(Orders.asc(Hql.property("dataFileType.name")));
264      ItemResultList<PlatformFileType> fileTypes = fileTypeQuery.list(dc);
265     
266      if (fileTypes.size() == 0)
267      {
268        %>
269        <h4>Data file types</h4>
270        This platform variant has no associated data file types (or, you don't have permission to view them).
271        <%
272      }
273      else
274      {
275        %>
276        <h4 class="docked">Data file types</h4>
277        <tbl:table
278          id="fileTypes"
279          clazz="itemlist"
280          columns="all"
281          >
282        <tbl:columndef 
283          id="name"
284          title="Name"
285        />
286        <tbl:columndef 
287          id="variant"
288          title="Variant"
289        />
290        <tbl:columndef 
291          id="required"
292          title="Required"
293        />
294        <tbl:columndef 
295          id="genericType"
296          title="Generic type"
297        />
298        <tbl:columndef 
299          id="description"
300          title="Description"
301        />
302        <tbl:data>
303          <tbl:columns>
304          </tbl:columns>
305          <tbl:rows>
306          <%
307          for (PlatformFileType fileType : fileTypes)
308          {
309            DataFileType dft = fileType.getDataFileType();
310            PlatformVariant thisVariant = fileType.getVariant();
311            %>
312            <tbl:row>
313              <tbl:cell column="variant"><base:icon 
314                  image="deleted.gif" 
315                  tooltip="This item has been scheduled for deletion" 
316                  visible="<%=thisVariant != null && thisVariant.isRemoved()%>"
317                /><%=thisVariant == null ? "<i>- all -</i>" : Base.getLinkedName(ID, thisVariant, false, true)%></tbl:cell>
318              <tbl:cell column="name"><base:icon 
319                  image="deleted.gif" 
320                  tooltip="This item has been scheduled for deletion" 
321                  visible="<%=dft != null && dft.isRemoved()%>"
322                /><%=Base.getLinkedName(ID, dft, false, true)%></tbl:cell>
323              <tbl:cell column="required"><%=fileType.isRequired() ? "yes" : "no"%></tbl:cell>
324              <tbl:cell column="genericType"><base:propertyvalue item="<%=dft%>" property="genericType" /></tbl:cell>
325              <tbl:cell column="description"><%=HTML.niceFormat(dft.getDescription())%></tbl:cell>
326            </tbl:row>
327            <%
328          }
329          %>
330          </tbl:rows>
331        </tbl:data>
332        </tbl:table>
333        <%
334      }
335      %>
336
337  </base:body>
338  </base:page>
339  <%
340}
341finally
342{
343  if (dc != null) dc.close();
344}
345
346%>
Note: See TracBrowser for help on using the repository browser.