1 | <%-- $Id: view_event.jsp 5937 2012-01-27 11:00:26Z 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.Plate" |
---|
33 | import="net.sf.basedb.core.BioMaterial" |
---|
34 | import="net.sf.basedb.core.BioMaterialEvent" |
---|
35 | import="net.sf.basedb.core.BioMaterialEventSource" |
---|
36 | import="net.sf.basedb.core.BioPlateEventParticipant" |
---|
37 | import="net.sf.basedb.core.BioPlateEvent" |
---|
38 | import="net.sf.basedb.core.BioPlate" |
---|
39 | import="net.sf.basedb.core.MeasuredBioMaterial" |
---|
40 | import="net.sf.basedb.core.PhysicalBioAssay" |
---|
41 | import="net.sf.basedb.core.Protocol" |
---|
42 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
43 | import="net.sf.basedb.core.ItemQuery" |
---|
44 | import="net.sf.basedb.core.SpecialQuery" |
---|
45 | import="net.sf.basedb.core.ItemResultList" |
---|
46 | import="net.sf.basedb.core.Include" |
---|
47 | import="net.sf.basedb.core.PluginDefinition" |
---|
48 | import="net.sf.basedb.core.query.Orders" |
---|
49 | import="net.sf.basedb.core.query.Hql" |
---|
50 | import="net.sf.basedb.core.query.ResultList" |
---|
51 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
52 | import="net.sf.basedb.core.plugin.Plugin" |
---|
53 | import="net.sf.basedb.clients.web.Base" |
---|
54 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
55 | import="net.sf.basedb.clients.web.util.HTML" |
---|
56 | import="net.sf.basedb.util.Values" |
---|
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.ToolbarUtil" |
---|
63 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
64 | import="java.util.Date" |
---|
65 | import="java.util.Map" |
---|
66 | import="java.util.Set" |
---|
67 | %> |
---|
68 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
69 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
70 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
71 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
72 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
73 | <%! |
---|
74 | private static final Item itemType = Item.BIOMATERIALEVENT; |
---|
75 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
76 | %> |
---|
77 | <% |
---|
78 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
79 | final String ID = sc.getId(); |
---|
80 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
81 | final int itemId = cc.getId(); |
---|
82 | final Item bioMaterialType = Item.valueOf(request.getParameter("biomaterial_type")); |
---|
83 | final int bioMaterialId = Values.getInt(request.getParameter("biomaterial_id")); |
---|
84 | final float scale = Base.getScale(sc); |
---|
85 | final DbControl dc = sc.newDbControl(); |
---|
86 | try |
---|
87 | { |
---|
88 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
89 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
90 | |
---|
91 | String title = null; |
---|
92 | BioMaterialEvent event = BioMaterialEvent.getById(dc, itemId); |
---|
93 | MeasuredBioMaterial bioMaterial = (MeasuredBioMaterial)bioMaterialType.getById(dc, bioMaterialId); |
---|
94 | BioMaterialEvent.Type eventType = event.getEventType(); |
---|
95 | boolean isPlateEvent = event.isPlateEvent(); |
---|
96 | |
---|
97 | BioPlateEventParticipant participant = null; |
---|
98 | BioPlateEvent plateEvent = null; |
---|
99 | BioPlate plate = null; |
---|
100 | if (isPlateEvent) |
---|
101 | { |
---|
102 | try |
---|
103 | { |
---|
104 | participant = event.getBioPlateEventParticipant(); |
---|
105 | plateEvent = participant.getEvent(); |
---|
106 | plate = participant.getBioPlate(); |
---|
107 | } |
---|
108 | catch (RuntimeException ex) |
---|
109 | {} |
---|
110 | } |
---|
111 | |
---|
112 | String viewPage = null; |
---|
113 | String listName = null; |
---|
114 | if (bioMaterialType == Item.SAMPLE) |
---|
115 | { |
---|
116 | listName = "Samples"; |
---|
117 | viewPage = "../samples/index.jsp"; |
---|
118 | } |
---|
119 | else if (bioMaterialType == Item.EXTRACT) |
---|
120 | { |
---|
121 | listName = "Extracts"; |
---|
122 | viewPage = "../extracts/index.jsp"; |
---|
123 | } |
---|
124 | |
---|
125 | final boolean writePermission = event.hasPermission(Permission.WRITE) && eventType == BioMaterialEvent.Type.OTHER; |
---|
126 | final boolean deletePermission = event.hasPermission(Permission.DELETE); |
---|
127 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, event); |
---|
128 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
129 | %> |
---|
130 | <base:page title="<%=title%>"> |
---|
131 | <base:head scripts="table.js,tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css"> |
---|
132 | <ext:scripts context="<%=jspContext%>" /> |
---|
133 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
134 | <script language="JavaScript"> |
---|
135 | function editItem() |
---|
136 | { |
---|
137 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true, '&biomaterial_type=<%=bioMaterialType.name()%>&biomaterial_id=<%=bioMaterial.getId()%>'); |
---|
138 | } |
---|
139 | function deleteItem() |
---|
140 | { |
---|
141 | if (confirm('This can\'t be undone. Continue?')) |
---|
142 | { |
---|
143 | location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&&biomaterial_id=<%=bioMaterialId%>&biomaterial_type=<%=bioMaterialType.name()%>&item_id=<%=itemId%>'); |
---|
144 | } |
---|
145 | } |
---|
146 | function runPlugin(cmd) |
---|
147 | { |
---|
148 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&biomaterial_id=<%=bioMaterialId%>&biomaterial_type=<%=bioMaterialType.name()%>&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500); |
---|
149 | } |
---|
150 | </script> |
---|
151 | </base:head> |
---|
152 | <base:body> |
---|
153 | <p:path><p:pathelement |
---|
154 | title="<%=listName%>" href="<%=viewPage+"?ID="+ID%>" /><p:pathelement |
---|
155 | title="<%=HTML.encodeTags(bioMaterial.getName())%>" |
---|
156 | href="<%="index.jsp?ID="+ID+"&biomaterial_id="+bioMaterialId+"&biomaterial_type="+bioMaterialType.name()%>" |
---|
157 | /><p:pathelement title="Event" /></p:path> |
---|
158 | |
---|
159 | <t:tabcontrol id="main" |
---|
160 | subclass="content mastertabcontrol" |
---|
161 | active="properties" switch="switchTab"> |
---|
162 | <t:tab id="properties" title="Properties"> |
---|
163 | <div> |
---|
164 | <table class="fullform bottomborder"> |
---|
165 | <tr> |
---|
166 | <th class="itemstatus"></th> |
---|
167 | <td style="padding: 0px;" colspan="2"> |
---|
168 | <tbl:toolbar subclass="bottomborder"> |
---|
169 | <tbl:button |
---|
170 | disabled="<%=writePermission ? false : true%>" |
---|
171 | image="edit.gif" |
---|
172 | onclick="editItem()" |
---|
173 | title="Edit…" |
---|
174 | tooltip="<%=writePermission ? "Edit this event" : "You do not have permission to edit this event"%>" |
---|
175 | /> |
---|
176 | <tbl:button |
---|
177 | disabled="<%=deletePermission ? false : true%>" |
---|
178 | image="delete.gif" |
---|
179 | onclick="deleteItem()" |
---|
180 | title="Delete" |
---|
181 | tooltip="<%=deletePermission ? "Delete this event" : "You do not have permission to event this event"%>" |
---|
182 | /> |
---|
183 | <tbl:button |
---|
184 | image="import.gif" |
---|
185 | onclick="runPlugin('ImportItem')" |
---|
186 | title="Import…" |
---|
187 | tooltip="Import data" |
---|
188 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
189 | /> |
---|
190 | <tbl:button |
---|
191 | image="export.gif" |
---|
192 | onclick="runPlugin('ExportItem')" |
---|
193 | title="Export…" |
---|
194 | tooltip="Export data" |
---|
195 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
196 | /> |
---|
197 | <tbl:button |
---|
198 | image="runplugin.gif" |
---|
199 | onclick="runPlugin('RunPlugin')" |
---|
200 | title="Run plugin…" |
---|
201 | tooltip="Run a plugin" |
---|
202 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
203 | /> |
---|
204 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
205 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
206 | </tbl:toolbar> |
---|
207 | </td> |
---|
208 | </tr> |
---|
209 | <% |
---|
210 | if (isPlateEvent) |
---|
211 | { |
---|
212 | %> |
---|
213 | <tr> |
---|
214 | <th>Releated plate event</th> |
---|
215 | <td><%=Base.getLinkedName(ID, plateEvent, plateEvent == null, true) %></td> |
---|
216 | </tr> |
---|
217 | <tr> |
---|
218 | <th class="subprompt">- bioplate</th> |
---|
219 | <td><%=Base.getLinkedName(ID, plate, plate == null, true)%> |
---|
220 | <% |
---|
221 | if (participant != null) |
---|
222 | { |
---|
223 | %> |
---|
224 | (<%=HTML.encodeTags(participant.getRole())%>) |
---|
225 | <% |
---|
226 | } |
---|
227 | %> |
---|
228 | </td> |
---|
229 | </tr> |
---|
230 | <tr> |
---|
231 | <th class="subprompt">- event type</th> |
---|
232 | <td><% |
---|
233 | if (plateEvent != null) |
---|
234 | { |
---|
235 | %> |
---|
236 | <base:propertyvalue item="<%=plateEvent%>" property="eventType" /> |
---|
237 | <% |
---|
238 | } |
---|
239 | %> |
---|
240 | </td> |
---|
241 | </tr> |
---|
242 | <% |
---|
243 | } |
---|
244 | %> |
---|
245 | <tr> |
---|
246 | <th>Event date</th> |
---|
247 | <td><%=dateFormatter.format(event.getEventDate())%></td> |
---|
248 | </tr> |
---|
249 | <tr> |
---|
250 | <th>Registration date</th> |
---|
251 | <td><%=dateFormatter.format(event.getEntryDate())%></td> |
---|
252 | </tr> |
---|
253 | <tr> |
---|
254 | <th>Used quantity</th> |
---|
255 | <td><%=Values.formatNumber(event.getUsedQuantity(bioMaterial), 2, " µg")%></td> |
---|
256 | </tr> |
---|
257 | <tr> |
---|
258 | <th>Event type</th> |
---|
259 | <td><%=eventType%></td> |
---|
260 | </tr> |
---|
261 | <% |
---|
262 | if (eventType != BioMaterialEvent.Type.OTHER) |
---|
263 | { |
---|
264 | if (eventType == BioMaterialEvent.Type.CREATION) |
---|
265 | { |
---|
266 | %> |
---|
267 | <tr> |
---|
268 | <th>Product</th> |
---|
269 | <td><base:propertyvalue item="<%=event%>" property="bioMaterial"/></td> |
---|
270 | </tr> |
---|
271 | <% |
---|
272 | } |
---|
273 | else if (eventType == BioMaterialEvent.Type.BIOASSAY) |
---|
274 | { |
---|
275 | %> |
---|
276 | <tr> |
---|
277 | <th>Physical bioassay</th> |
---|
278 | <td><base:propertyvalue item="<%=event%>" property="physicalBioAssay"/></td> |
---|
279 | </tr> |
---|
280 | <% |
---|
281 | } |
---|
282 | SpecialQuery<BioMaterialEventSource> sourcesQuery = event.getEventSources(); |
---|
283 | sourcesQuery.order(Orders.asc(Hql.property("bioMaterial.name"))); |
---|
284 | ResultList<BioMaterialEventSource> sources = sourcesQuery.list(dc); |
---|
285 | %> |
---|
286 | <tr class="big"> |
---|
287 | <th>Sources</th> |
---|
288 | <td> |
---|
289 | <% |
---|
290 | for (BioMaterialEventSource evtSrc : sources) |
---|
291 | { |
---|
292 | BioMaterial source = null; |
---|
293 | Item sourceType = null; |
---|
294 | try |
---|
295 | { |
---|
296 | source = evtSrc.getBioMaterial(); |
---|
297 | sourceType = source.getType(); |
---|
298 | } |
---|
299 | catch (PermissionDeniedException ex) |
---|
300 | {} |
---|
301 | %> |
---|
302 | <%=Base.getLinkedName(ID, source, source == null, true)%> |
---|
303 | <%=sourceType != null ? "(" + sourceType + ")" : "" %> |
---|
304 | <%=Values.formatNumber(evtSrc.getUsedQuantity(), 2, " µg")%> |
---|
305 | <br> |
---|
306 | <% |
---|
307 | } |
---|
308 | %> |
---|
309 | </td> |
---|
310 | </tr> |
---|
311 | <% |
---|
312 | } |
---|
313 | %> |
---|
314 | <tr> |
---|
315 | <th>Protocol</th> |
---|
316 | <td><base:propertyvalue item="<%=event%>" property="protocol"/></td> |
---|
317 | </tr> |
---|
318 | <tr> |
---|
319 | <th>User</th> |
---|
320 | <td><base:propertyvalue item="<%=event%>" property="user"/></td> |
---|
321 | </tr> |
---|
322 | <tr> |
---|
323 | <th>Permissions</th> |
---|
324 | <td><%=PermissionUtil.getFullPermissionNames(event)%></td> |
---|
325 | </tr> |
---|
326 | <tr> |
---|
327 | <th>Comment</th> |
---|
328 | <td><%=HTML.niceFormat(event.getComment())%></td> |
---|
329 | </tr> |
---|
330 | </table> |
---|
331 | |
---|
332 | <jsp:include page="../../common/anytoany/list_anytoany.jsp"> |
---|
333 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
334 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
335 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
336 | <jsp:param name="title" value="Other items related to this event" /> |
---|
337 | </jsp:include> |
---|
338 | |
---|
339 | </t:tab> |
---|
340 | </t:tabcontrol> |
---|
341 | |
---|
342 | </base:body> |
---|
343 | </base:page> |
---|
344 | <% |
---|
345 | } |
---|
346 | finally |
---|
347 | { |
---|
348 | if (dc != null) dc.close(); |
---|
349 | } |
---|
350 | |
---|
351 | %> |
---|