source: trunk/www/biomaterials/events/view_event.jsp @ 4882

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

References #1271: Add extension points to all toolbars

Added code for displaying extensions to all biomaterial pages.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 9.5 KB
Line 
1<%-- $Id: view_event.jsp 4882 2009-04-03 10:53:42Z 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 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.ItemContext"
31  import="net.sf.basedb.core.Permission"
32  import="net.sf.basedb.core.Plate"
33  import="net.sf.basedb.core.BioMaterialEvent"
34  import="net.sf.basedb.core.MeasuredBioMaterial"
35  import="net.sf.basedb.core.Hybridization"
36  import="net.sf.basedb.core.Protocol"
37  import="net.sf.basedb.core.PermissionDeniedException"
38  import="net.sf.basedb.core.ItemQuery"
39  import="net.sf.basedb.core.ItemResultList"
40  import="net.sf.basedb.core.Include"
41  import="net.sf.basedb.core.PluginDefinition"
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.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="java.util.Date"
58  import="java.util.Map"
59  import="java.util.Set"
60%>
61<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
62<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
63<%@ taglib prefix="tbl" uri="/WEB-INF/table.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.BIOMATERIALEVENT;
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 Item bioMaterialType = Item.valueOf(request.getParameter("biomaterial_type"));
76final int bioMaterialId = Values.getInt(request.getParameter("biomaterial_id"));
77final float scale = Base.getScale(sc);
78final DbControl dc = sc.newDbControl();
79try
80{
81  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
82  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
83
84  String title = null;
85  BioMaterialEvent event = BioMaterialEvent.getById(dc, itemId);
86  MeasuredBioMaterial bioMaterial = (MeasuredBioMaterial)bioMaterialType.getById(dc, bioMaterialId);
87  BioMaterialEvent.Type eventType = event.getEventType();
88 
89  String viewPage = null;
90  String listName = null;
91  if (bioMaterialType == Item.SAMPLE)
92  {
93    listName = "Samples";
94    viewPage = "../samples/index.jsp";
95  }
96  else if (bioMaterialType == Item.EXTRACT)
97  {
98    listName = "Extracts";
99    viewPage = "../extracts/index.jsp";
100  }
101  else if (bioMaterialType == Item.LABELEDEXTRACT)
102  {
103    listName = "Labeled extracts";
104    viewPage = "../labeledextracts/index.jsp";
105  }
106
107  final boolean writePermission = event.hasPermission(Permission.WRITE) && eventType == BioMaterialEvent.Type.OTHER;
108  final boolean deletePermission = event.hasPermission(Permission.DELETE);
109  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, event);
110  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
111  %>
112  <base:page title="<%=title%>">
113  <base:head scripts="table.js,tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
114    <ext:scripts context="<%=jspContext%>" />
115    <ext:stylesheets context="<%=jspContext%>" />
116    <script language="JavaScript">
117    function editItem()
118    {
119      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true, '&biomaterial_type=<%=bioMaterialType.name()%>&biomaterial_id=<%=bioMaterial.getId()%>');
120    }
121    function deleteItem()
122    {
123      if (confirm('This can\'t be undone. Continue?'))
124      {
125        location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&&biomaterial_id=<%=bioMaterialId%>&biomaterial_type=<%=bioMaterialType.name()%>&item_id=<%=itemId%>');
126      }
127    }
128    function runPlugin(cmd)
129    {
130      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&biomaterial_id=<%=bioMaterialId%>&biomaterial_type=<%=bioMaterialType.name()%>&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
131    }
132    </script>
133  </base:head>
134  <base:body>
135    <p>
136    <p:path>
137      <p:pathelement title="<%=listName%>" href="<%=viewPage+"?ID="+ID%>" />
138      <p:pathelement 
139        title="<%=HTML.encodeTags(bioMaterial.getName())%>" 
140        href="<%="index.jsp?ID="+ID+"&biomaterial_id="+bioMaterialId+"&biomaterial_type="+bioMaterialType.name()%>" />
141      <p:pathelement title="Event" />
142    </p:path>
143   
144    <t:tabcontrol id="main" active="properties" switch="switchTab">
145    <t:tab id="properties" title="Properties">
146
147    <tbl:toolbar
148      >
149      <tbl:button 
150        disabled="<%=writePermission ? false : true%>" 
151        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
152        onclick="editItem()" 
153        title="Edit&hellip;" 
154        tooltip="<%=writePermission ? "Edit this event" : "You do not have permission to edit this event"%>" 
155      />
156      <tbl:button 
157        disabled="<%=deletePermission ? false : true%>" 
158        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
159        onclick="deleteItem()" 
160        title="Delete"
161        tooltip="<%=deletePermission ? "Delete this event" : "You do not have permission to event this event"%>" 
162      />
163      <tbl:button 
164        image="import.gif" 
165        onclick="runPlugin('ImportItem')" 
166        title="Import&hellip;" 
167        tooltip="Import data" 
168        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
169      />
170      <tbl:button 
171        image="export.gif" 
172        onclick="runPlugin('ExportItem')" 
173        title="Export&hellip;" 
174        tooltip="Export data" 
175        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
176      />
177      <tbl:button 
178        image="runplugin.gif" 
179        onclick="runPlugin('RunPlugin')" 
180        title="Run plugin&hellip;" 
181        tooltip="Run a plugin" 
182        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
183      />
184      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
185        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
186      </tbl:toolbar>
187     
188    <div class="boxedbottom">
189      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(event)%></i></div>
190      <table class="form" cellspacing=0>
191      <tr>
192        <td class="prompt">Event date</td>
193        <td><%=dateFormatter.format(event.getEventDate())%></td>
194      </tr>
195      <tr>
196        <td class="prompt">Registration date</td>
197        <td><%=dateFormatter.format(event.getEntryDate())%></td>
198      </tr>
199      <tr>
200        <td class="prompt">Used quantity</td>
201        <td><%=Values.formatNumber(event.getUsedQuantity(bioMaterial), 2, " µg")%></td>
202      </tr>
203      <tr>
204        <td class="prompt">Event type</td>
205        <td><%=eventType%></td>
206      </tr>
207      <%
208      if (eventType != BioMaterialEvent.Type.OTHER)
209      {
210     
211        if (eventType == BioMaterialEvent.Type.CREATION)
212        {         
213          %>
214          <tr>
215            <td class="prompt">Product</td>
216            <td><base:propertyvalue item="<%=event%>" property="bioMaterial"/>
217            </td>
218          </tr>
219          <%
220        }
221        else if (eventType == BioMaterialEvent.Type.HYBRIDIZATION)
222        {         
223          %>
224          <tr>
225            <td class="prompt">Hybridization</td>
226            <td><base:propertyvalue item="<%=event%>" property="hybridization"/>
227            </td>
228          </tr>
229          <tr>
230            <td class="prompt">Labeled extracts</td>
231            <td>
232            </td>
233          </tr>
234          <%
235        }
236        ItemQuery<? extends MeasuredBioMaterial> sourcesQuery = event.getSources();
237        sourcesQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
238        sourcesQuery.order(Orders.asc(Hql.property("name")));
239        ItemResultList<? extends MeasuredBioMaterial> sources = sourcesQuery.list(dc);
240        %>
241        <tr>
242          <td class="prompt">Sources</td>
243          <td>
244          <%
245          for (MeasuredBioMaterial s : sources)
246          {
247            Item sourceType = s.getType();
248            %>
249            <%=HTML.encodeTags(s.getName())%> (<%=sourceType%>),
250            <%=Values.formatNumber(event.getUsedQuantity(s), 2, " µg")%>
251            <br>
252            <%
253          }
254          %>
255          </td>
256        </tr>
257        <%
258      }
259      %>
260      <tr>
261        <td class="prompt">Protocol</td>
262        <td><base:propertyvalue item="<%=event%>" property="protocol"/></td>
263      </tr>
264      <tr>
265        <td class="prompt">Comment</td>
266        <td><%=HTML.niceFormat(event.getComment())%></td>
267      </tr>
268      </table>
269    </div>
270      </t:tab>
271      </t:tabcontrol>
272
273  </base:body>
274  </base:page>
275  <%
276}
277finally
278{
279  if (dc != null) dc.close();
280}
281
282%>
Note: See TracBrowser for help on using the repository browser.