source: trunk/www/biomaterials/biosources/view_biosource.jsp @ 7604

Last change on this file since 7604 was 7604, checked in by Nicklas Nordborg, 3 years ago

References #2151: Pre-compile all JSP pages before releases

Getting rid of rawtypes warnings. Most of them are relatively simple by adding a type parameter.

Utility functions that are used with generics are typically a bit harder.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 13.1 KB
Line 
1<%-- $Id: view_biosource.jsp 7604 2019-02-25 12:19:50Z 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.Group"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.Nameable"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.MultiPermissions"
36  import="net.sf.basedb.core.BioSource"
37  import="net.sf.basedb.core.Sample"
38  import="net.sf.basedb.core.User"
39  import="net.sf.basedb.core.Include"
40  import="net.sf.basedb.core.ItemQuery"
41  import="net.sf.basedb.core.ItemResultList"
42  import="net.sf.basedb.core.PermissionDeniedException"
43  import="net.sf.basedb.core.PluginDefinition"
44  import="net.sf.basedb.core.plugin.GuiContext"
45  import="net.sf.basedb.core.Project"
46  import="net.sf.basedb.core.query.Orders"
47  import="net.sf.basedb.core.query.Hql"
48  import="net.sf.basedb.core.plugin.Plugin"
49  import="net.sf.basedb.core.SharedItem"
50  import="net.sf.basedb.clients.web.Base"
51  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
52  import="net.sf.basedb.clients.web.PermissionUtil"
53  import="net.sf.basedb.clients.web.util.HTML"
54  import="net.sf.basedb.util.Values"
55  import="net.sf.basedb.util.ShareableUtil"
56  import="net.sf.basedb.clients.web.PermissionUtil"
57  import="net.sf.basedb.util.formatter.Formatter"
58  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
59  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
60  import="net.sf.basedb.clients.web.extensions.JspContext"
61  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
62  import="net.sf.basedb.clients.web.extensions.toolbar.ButtonAction" 
63  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
64  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
65  import="java.util.Collections"
66  import="java.util.Date"
67  import="java.util.Map"
68  import="java.util.Set"
69  import="java.util.List"
70%>
71<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
72<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
73<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
74<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
75<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
76<%!
77  private static final Item itemType = Item.BIOSOURCE;
78  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
79%>
80<%
81final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
82final String ID = sc.getId();
83final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
84final int itemId = cc.getId();
85final String tab = Values.getStringOrNull(request.getParameter("tab"));
86final float scale = Base.getScale(sc);
87final DbControl dc = sc.newDbControl();
88try
89{
90  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
91  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
92
93  String title = null;
94  BioSource bioSource = BioSource.getById(dc, itemId);
95 
96  final boolean usePermission = bioSource.hasPermission(Permission.USE);
97  final boolean writePermission = bioSource.hasPermission(Permission.WRITE);
98  final boolean deletePermission = bioSource.hasPermission(Permission.DELETE);
99  final boolean sharePermission = bioSource.hasPermission(Permission.SET_PERMISSION);
100  final boolean setOwnerPermission = bioSource.hasPermission(Permission.SET_OWNER);
101  final boolean isRemoved = bioSource.isRemoved();
102  final boolean isUsed = isRemoved && bioSource.isUsed();
103  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
104  final boolean isOwner = bioSource.isOwner();
105  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, bioSource);
106  ExtensionsInvoker<ButtonAction> invoker = ToolbarUtil.useExtensions(jspContext);
107  %>
108  <base:page title="<%=title%>" id="view-page">
109  <base:head scripts="table.js,tabcontrol-2.js,~biosources.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
110    <ext:scripts context="<%=jspContext%>" />
111    <ext:stylesheets context="<%=jspContext%>" />
112  </base:head>
113  <base:body>
114    <p:path><p:pathelement 
115      title="Biosources" href="<%="index.jsp?ID="+ID%>" /><p:pathelement 
116      title="<%=HTML.encodeTags(bioSource.getName())%>" /></p:path>
117    <div id="page-data" data-item-id="<%=itemId%>"></div>
118   
119    <t:tabcontrol id="main" subclass="content mastertabcontrol" active="<%=tab%>">
120    <t:tab id="properties" title="Properties">
121
122      <div>
123      <table class="fullform bottomborder">
124      <tr>
125        <th class="itemstatus">
126          <base:icon 
127            image="shared.png" 
128            visible="<%=bioSource.isShared()%>"
129            tooltip="This item is shared to other users, groups and/or projects"
130          />
131          <base:icon 
132            id="btnDeletePermanently"
133            image="deleted.png"
134            tooltip="This item has been flagged for deletion. Click to delete it now."
135            enabled="<%=deletePermanentlyPermission %>"
136            visible="<%=isRemoved%>" 
137          />
138          <base:icon 
139            id="btnUsingItems"
140            image="used.png" 
141            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
142            visible="<%=isRemoved && isUsed%>" />
143        </th>
144        <td style="padding: 0px;">
145          <tbl:toolbar subclass="bottomborder bg-filled-50">
146            <tbl:button 
147              id="btnEdit"
148              disabled="<%=!writePermission%>" 
149              image="edit.png" 
150              title="Edit&hellip;" 
151              tooltip="<%=writePermission ? "Edit this biosource" : "You do not have permission to edit this biosource"%>" 
152            />
153            <tbl:button 
154              id="btnDelete"
155              disabled="<%=!deletePermission%>" 
156              image="delete.png" 
157              title="Delete"
158              visible="<%=!bioSource.isRemoved()%>"
159              tooltip="<%=deletePermission ? "Delete this biosource" : "You do not have permission to delete this biosource"%>" 
160            />
161            <tbl:button 
162              id="btnRestore"
163              disabled="<%=!writePermission%>" 
164              image="restore.png" 
165              title="Restore"
166              visible="<%=bioSource.isRemoved()%>"
167              tooltip="<%=writePermission ? "Restore this biosource" : "You do not have permission to restore this biosource"%>" 
168            />
169            <tbl:button 
170              id="btnShare"
171              disabled="<%=!sharePermission%>"
172              image="share.png"
173              title="Share&hellip;" 
174              tooltip="<%=sharePermission ? "Share this biosource to other user, groups and projects" : "You do not have permission to share this biosource"%>"
175            />
176            <tbl:button 
177              id="btnSetOwner"
178              disabled="<%=!setOwnerPermission%>"
179              image="take_ownership.png"
180              title="Set owner&hellip;"
181              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
182            />
183            <tbl:button
184              id="btnNewSample"
185              image="add.png"
186              title="New sample&hellip;"
187              tooltip="Create a new sample from this biosource"
188              visible="<%=sc.hasPermission(Permission.CREATE, Item.SAMPLE) && usePermission%>"
189            />
190            <tbl:button 
191              id="btnImport"
192              image="import.png" 
193              data-plugin-type="IMPORT" 
194              title="Import&hellip;" 
195              tooltip="Import data" 
196              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
197            />
198            <tbl:button 
199              id="btnExport"
200              image="export.png"
201              data-plugin-type="EXPORT" 
202              title="Export&hellip;" 
203              tooltip="Export data" 
204              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
205            />
206            <tbl:button 
207              id="btnRunPlugin"
208              image="runplugin.png" 
209              data-plugin-type="OTHER" 
210              title="Run plugin&hellip;" 
211              tooltip="Run a plugin" 
212              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
213            />
214            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
215              wrapper="<%=new PrefixSuffixRenderer<ButtonAction>(jspContext, "<td>", "</td>") %>"/>
216            <tbl:button
217              image="help.png"
218              subclass="auto-init"
219              data-auto-init="help"
220              data-help-id="biosource.view.properties"
221              title="Help&hellip;"
222              tooltip="Get help about this page"
223              />
224            </tbl:toolbar>
225        </td>
226      </tr>
227      <tr>
228        <th>Name</th>
229        <td><%=HTML.encodeTags(bioSource.getName())%></td>
230      </tr>
231      <tr>
232        <th>Type</th>
233        <td><base:propertyvalue item="<%=bioSource%>" property="itemSubtype" /></td>
234      </tr>
235      <tr>
236        <th>Registered</th>
237        <td><%=dateFormatter.format(bioSource.getEntryDate())%></td>
238      </tr>
239      <tr>
240        <th>External ID</th>
241        <td><%=HTML.encodeTags(bioSource.getExternalId())%></td>
242      </tr>
243      <tr>
244        <th>Owner</th>
245        <td><base:propertyvalue item="<%=bioSource%>" property="owner" /></td>
246      </tr>
247      <tr>
248        <th>Permissions</th>
249        <td><%=PermissionUtil.getFullPermissionNames(bioSource)%></td>
250      </tr>
251      <tr>
252        <th>Description</th>
253        <td><%=HTML.niceFormat(bioSource.getDescription())%></td>
254      </tr>
255      </table>
256      </div>
257      <%
258      ItemQuery<Sample> sampleQuery = bioSource.getSamples();
259      sampleQuery.include(Include.ALL);
260      sampleQuery.order(Orders.asc(Hql.property("name")));
261      ItemResultList<Sample> samples = sampleQuery.list(dc);
262      %>
263      <base:section 
264        id="sampleSection" 
265        title="<%="Child samples (" + samples.size() + ")"%>"
266        context="<%=cc%>"
267        >
268        <%
269        if (samples.size() == 0)
270        {
271          %>
272          <div class="messagecontainer note">
273          No samples have been created from this biosource
274          (or, you don't have permission to view them).
275          </div>
276          <%
277        }
278        else
279        {
280          %>
281          <tbl:table
282            id="samples"
283           
284            columns="all"
285            >
286          <tbl:columndef 
287            id="name"
288            title="Name"
289          />
290          <tbl:columndef 
291            id="type"
292            title="Type"
293          />
294          <tbl:columndef 
295            id="description"
296            title="Description"
297          />
298          <tbl:data>
299            <tbl:headers>
300              <tbl:headerrow>
301                <tbl:columnheaders />
302              </tbl:headerrow>
303            </tbl:headers>
304            <tbl:rows>
305            <%
306            for (Sample item : samples)
307            {
308              %>
309              <tbl:row>
310                <tbl:cell column="name"><base:icon 
311                    image="deleted.png" 
312                    tooltip="This item has been scheduled for deletion" 
313                    visible="<%=item.isRemoved()%>"
314                  /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
315                  <tbl:cell column="type"><base:propertyvalue item="<%=item%>" property="itemSubtype" /></tbl:cell>
316                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
317              </tbl:row>
318              <%
319            }
320            %>
321            </tbl:rows>
322          </tbl:data>
323          </tbl:table>
324          <%
325        }     
326        %>
327      </base:section>
328      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
329        <jsp:param name="ID" value="<%=ID%>" />
330        <jsp:param name="item_type" value="<%=itemType.name()%>" />
331        <jsp:param name="item_id" value="<%=itemId%>" />
332        <jsp:param name="title" value="Other items related to this biosource" />
333      </jsp:include>
334     
335      <jsp:include page="../../common/share/list_share.jsp">
336        <jsp:param name="ID" value="<%=ID%>" />
337        <jsp:param name="item_type" value="<%=itemType.name()%>" />
338        <jsp:param name="item_id" value="<%=itemId%>" />
339        <jsp:param name="title" value="Shared to" />
340      </jsp:include>
341      </t:tab>
342     
343      <t:tab id="annotations" title="Annotations" 
344        tooltip="View annotation values" clazz="white">
345        <jsp:include page="../../common/annotations/list_frameset.jsp">
346          <jsp:param name="item_type" value="<%=itemType.name()%>" />
347          <jsp:param name="item_id" value="<%=itemId%>" />
348          <jsp:param name="ID" value="<%=ID%>" />
349        </jsp:include>
350      </t:tab>
351      <t:tab id="overview" title="Overview" 
352        tooltip="Display a tree overview of related items">
353        <jsp:include page="../../common/overview/overview.jsp">
354          <jsp:param name="item_type" value="<%=itemType.name()%>" />
355          <jsp:param name="item_id" value="<%=itemId%>" />
356          <jsp:param name="ID" value="<%=ID%>" />
357        </jsp:include>
358      </t:tab>     
359      <t:tab id="history" title="History"
360        tooltip="Displays a log with the history of this item"
361        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
362        <jsp:include page="../../common/history/frameset.jsp">
363          <jsp:param name="item_type" value="<%=itemType.name()%>" />
364          <jsp:param name="item_id" value="<%=itemId%>" />
365          <jsp:param name="ID" value="<%=ID%>" />
366        </jsp:include>
367      </t:tab>     
368      </t:tabcontrol>
369  </base:body>
370  </base:page>
371  <%
372}
373finally
374{
375  if (dc != null) dc.close();
376}
377
378%>
Note: See TracBrowser for help on using the repository browser.