source: trunk/www/biomaterials/bioplates/events/view_event.jsp @ 6261

Last change on this file since 6261 was 6261, checked in by Nicklas Nordborg, 10 years ago

References #1729 and #1730. Fixed for all biomaterial view pages.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 16.3 KB
Line 
1<%-- $Id: view_event.jsp 6261 2013-03-27 12:25:00Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2010 Nicklas Nordborg
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--%>
24<%@ page pageEncoding="UTF-8" session="false"
25  import="net.sf.basedb.core.SessionControl"
26  import="net.sf.basedb.core.DbControl"
27  import="net.sf.basedb.core.SystemItems"
28  import="net.sf.basedb.core.Item"
29  import="net.sf.basedb.core.ItemContext"
30  import="net.sf.basedb.core.Permission"
31  import="net.sf.basedb.core.CommonItem"
32  import="net.sf.basedb.core.BioPlate"
33  import="net.sf.basedb.core.BioPlateEvent"
34  import="net.sf.basedb.core.BioPlateEventParticipant"
35  import="net.sf.basedb.core.BioMaterialEvent"
36  import="net.sf.basedb.core.MeasuredBioMaterial"
37  import="net.sf.basedb.core.PhysicalBioAssay"
38  import="net.sf.basedb.core.Protocol"
39  import="net.sf.basedb.core.Hardware"
40  import="net.sf.basedb.core.PermissionDeniedException"
41  import="net.sf.basedb.core.ItemQuery"
42  import="net.sf.basedb.core.ItemResultList"
43  import="net.sf.basedb.core.Include"
44  import="net.sf.basedb.core.PluginDefinition"
45  import="net.sf.basedb.core.query.Orders"
46  import="net.sf.basedb.core.query.Hql"
47  import="net.sf.basedb.core.plugin.GuiContext"
48  import="net.sf.basedb.core.plugin.Plugin"
49  import="net.sf.basedb.clients.web.Base"
50  import="net.sf.basedb.clients.web.PermissionUtil"
51  import="net.sf.basedb.clients.web.util.HTML"
52  import="net.sf.basedb.util.Values"
53  import="net.sf.basedb.util.formatter.Formatter"
54  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
55  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
56  import="net.sf.basedb.clients.web.extensions.JspContext"
57  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
58  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
59  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
60  import="java.util.Date"
61  import="java.util.Map"
62  import="java.util.Set"
63%>
64<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
65<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
66<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
67<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
68<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
69<%!
70  private static final Item itemType = Item.BIOPLATEEVENT;
71  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
72%>
73<%
74int bioPlateId = Values.getInt(request.getParameter("bioplate_id"));
75final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
76final String ID = sc.getId();
77final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
78final int itemId = cc.getId();
79final String tab = Values.getStringOrNull(request.getParameter("tab"));
80final float scale = Base.getScale(sc);
81final DbControl dc = sc.newDbControl();
82try
83{
84  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
85  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
86
87  String title = null;
88  BioPlateEvent event = BioPlateEvent.getById(dc, itemId);
89 
90  // Load bioplates participating in this event
91  ItemQuery<BioPlateEventParticipant> participantQuery = event.getParticipants();
92  participantQuery.join(Hql.innerJoin(null, "bioPlate", "bpl", true));
93  participantQuery.include(Include.ALL);
94  participantQuery.order(Orders.asc(Hql.property("role")));
95  participantQuery.order(Orders.asc(Hql.property("index")));
96  participantQuery.order(Orders.asc(Hql.property("bpl", "name")));
97  ItemResultList<BioPlateEventParticipant> participants = participantQuery.list(dc);
98 
99  if (bioPlateId == 0)
100  {
101    for (BioPlateEventParticipant participant : participants)
102    {
103      try
104      {
105        bioPlateId = participant.getBioPlate().getId();
106        break;
107      }
108      catch (RuntimeException ex)
109      {}
110    }
111  }
112  BioPlate bioPlate = bioPlateId == 0 ? null : BioPlate.getById(dc, bioPlateId);
113 
114  final boolean usePermission = event.hasPermission(Permission.USE);
115  final boolean writePermission = event.hasPermission(Permission.WRITE);
116  final boolean deletePermission = event.hasPermission(Permission.DELETE);
117  final boolean sharePermission = event.hasPermission(Permission.SET_PERMISSION);
118  final boolean setOwnerPermission = event.hasPermission(Permission.SET_OWNER);
119  final boolean isRemoved = event.isRemoved();
120  final boolean isUsed = isRemoved && event.isUsed();
121  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
122  final boolean isOwner = event.isOwner();
123  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, event);
124  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
125  %>
126  <base:page title="<%=title%>" id="view-page">
127  <base:head scripts="table.js,tabcontrol-2.js,~events.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
128    <ext:scripts context="<%=jspContext%>" />
129    <ext:stylesheets context="<%=jspContext%>" />
130    <script>
131    function editItem()
132    {
133      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
134    }
135    function shareItem()
136    {
137      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareEvent', 600, 400);
138    }
139    function deleteItem()
140    {
141      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>&bioplate_id=<%=bioPlateId%>');
142    }
143    function restoreItem()
144    {
145      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>&bioplate_id=<%=bioPlateId%>');
146    }
147    function deleteItemPermanently()
148    {
149      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
150    }
151    function itemDeleted()
152    {
153      Main.listItems('<%=ID%>', '<%=itemType.name()%>', '&bioplate_id=<%=bioPlateId%>');
154    }
155    function showUsingItems()
156    {
157      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
158    }
159    function setOwner()
160    {
161      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
162    }
163    function runPlugin(cmd)
164    {
165      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
166    }
167    </script>
168  </base:head>
169  <base:body>
170    <%
171    if (bioPlate != null)
172    {
173      %>
174      <p:path><p:pathelement 
175        title="Bioplates" href="<%="../index.jsp?ID="+ID%>" /><p:pathelement 
176        title="<%=HTML.encodeTags(bioPlate.getName())%>" 
177          href="<%="index.jsp?ID="+ID+"&amp;bioplate_id="+bioPlateId%>" /><p:pathelement 
178        title="<%=HTML.encodeTags(event.getName())%>" /></p:path>
179      <%
180    }
181    else
182    {
183      %>
184      <p:path><p:pathelement 
185        title="Bioplate events" /><p:pathelement 
186        title="<%=HTML.encodeTags(event.getName())%>" /></p:path>
187      <%
188    }
189    %>
190    <div id="page-data" data-item-id="<%=itemId%>"></div>
191   
192    <t:tabcontrol id="main"
193      subclass="content mastertabcontrol"
194      active="<%=tab %>">
195    <t:tab id="properties" title="Properties">
196      <div>
197      <table class="fullform bottomborder">
198      <tr>
199        <th class="itemstatus">
200          <base:icon 
201            image="shared.png" 
202            visible="<%=event.isShared()%>"
203            tooltip="This item is shared to other users, groups and/or projects"
204          />
205          <base:icon 
206            id="btnDeletePermanently"
207            data-extra-url="<%="&bioplate_id=" + bioPlateId%>"
208            image="deleted.png"
209            tooltip="This item has been flagged for deletion. Click to delete it now."
210            enabled="<%=deletePermanentlyPermission %>"
211            visible="<%=isRemoved%>" 
212          />
213          <base:icon 
214            id="btnUsingItems"
215            image="used.png" 
216            onclick="showUsingItems()"
217            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
218            visible="<%=isRemoved && isUsed%>" />
219        </th>
220        <td style="padding: 0px;">
221          <tbl:toolbar subclass="bottomborder">
222            <tbl:button 
223              id="btnEdit"
224              disabled="<%=!writePermission%>" 
225              image="edit.png" 
226              title="Edit&hellip;" 
227              tooltip="<%=writePermission ? "Edit this event" : "You do not have permission to edit this event"%>" 
228            />
229            <tbl:button 
230              id="btnDelete"
231              data-extra-url="<%="&bioplate_id=" + bioPlateId%>"
232              disabled="<%=!deletePermission%>" 
233              image="delete.png" 
234              title="Delete"
235              visible="<%=!event.isRemoved()%>"
236              tooltip="<%=deletePermission ? "Delete this event" : "You do not have permission to delete this event"%>" 
237            />
238            <tbl:button 
239              id="btnRestore"
240              data-extra-url="<%="&bioplate_id=" + bioPlateId%>"
241              disabled="<%=!writePermission%>" 
242              image="restore.png" 
243              title="Restore"
244              visible="<%=event.isRemoved()%>"
245              tooltip="<%=writePermission ? "Restore this event" : "You do not have permission to restore this event"%>" 
246            />
247            <tbl:button 
248              id="btnShare"
249              disabled="<%=!sharePermission%>"
250              image="share.png"
251              title="Share&hellip;" 
252              tooltip="<%=sharePermission ? "Share this event to other user, groups and projects" : "You do not have permission to share this event"%>"
253            />
254            <tbl:button 
255              id="btnSetOwner"
256              disabled="<%=!setOwnerPermission%>"
257              image="take_ownership.png"
258              title="Set owner&hellip;"
259              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
260            />
261            <tbl:button 
262              id="btnImport"
263              image="import.png" 
264              data-plugin-type="IMPORT" 
265              title="Import&hellip;" 
266              tooltip="Import data" 
267              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
268            />
269            <tbl:button 
270              id="btnExport"
271              image="export.png"
272              data-plugin-type="EXPORT" 
273              title="Export&hellip;" 
274              tooltip="Export data" 
275              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
276            />
277            <tbl:button 
278              id="btnRunPlugin"
279              image="runplugin.png" 
280              data-plugin-type="OTHER" 
281              title="Run plugin&hellip;" 
282              tooltip="Run a plugin" 
283              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
284            />
285            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
286              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
287          </tbl:toolbar>
288        </td>
289      </tr>
290      <tr>
291        <th>Name</th>
292        <td><%=HTML.encodeTags(event.getName())%></td>
293      </tr>
294      <tr>
295        <th>Event date</th>
296        <td><%=dateFormatter.format(event.getEventDate())%></td>
297      </tr>
298      <tr>
299        <th>Registration date</th>
300        <td><%=dateFormatter.format(event.getEntryDate())%></td>
301      </tr>
302      <tr>
303        <th>Event type</th>
304        <td><base:propertyvalue item="<%=event%>" property="eventType" /></td>
305      </tr>
306      <tr>
307        <th>Protocol</th>
308        <td><base:propertyvalue item="<%=event%>" property="protocol"/></td>
309      </tr>
310      <tr>
311        <th>Hardware</th>
312        <td><base:propertyvalue item="<%=event%>" property="hardware"/></td>
313      </tr>
314      <tr>
315        <th>Owner</th>
316        <td><base:propertyvalue item="<%=event%>" property="owner" /></td>
317      </tr>
318      <tr>
319        <th>Description</th>
320        <td><%=HTML.niceFormat(event.getDescription())%></td>
321      </tr>
322      </table>
323      </div>
324     
325      <base:section 
326        id="participantSection" 
327        title="<%="Participating plates (" + participants.size() + ")"%>"
328        context="<%=cc%>"
329        >
330        <%
331        if (participants.size() == 0)
332        {
333          %>
334          <div class="messagecontainer note">
335          No plates are participating in this event
336          (or, you don't have permission to view them).
337          </div>
338          <%
339        }
340        else
341        {
342          %>
343          <tbl:table
344            id="participants"
345            columns="all"
346            >
347            <tbl:columndef
348              id="bioplate"
349              title="Bioplate"
350            />
351            <tbl:columndef 
352              id="role"
353              title="Role"
354            />
355            <tbl:columndef
356              id="description"
357              title="Description"
358            />
359            <tbl:data>
360              <tbl:headers>
361                <tbl:headerrow>
362                  <tbl:columnheaders />
363                </tbl:headerrow>
364              </tbl:headers>
365              <tbl:rows>
366                <%
367                for (BioPlateEventParticipant participant : participants)
368                {
369                  BioPlate plate = null;
370                  try
371                  {
372                    plate = participant.getBioPlate();
373                  }
374                  catch (PermissionDeniedException ex)
375                  {}
376                  %>
377                  <tbl:row>
378                    <tbl:cell column="bioplate"><base:icon 
379                      image="deleted.png" 
380                      tooltip="This item has been scheduled for deletion" 
381                      visible="<%=plate != null && plate.isRemoved()%>"
382                    /><%=Base.getLinkedName(ID, plate, true, true)%></tbl:cell>
383                    <tbl:cell column="role"><%=HTML.encodeTags(participant.getRole())%> [<%=participant.getIndex()%>]</tbl:cell>
384                    <tbl:cell column="description"><%=plate == null ? "" : HTML.encodeTags(plate.getDescription())%></tbl:cell>
385                  </tbl:row>
386                  <%
387                }
388                %>
389              </tbl:rows>
390            </tbl:data>
391          </tbl:table>
392          <%
393        }
394        %>
395      </base:section>
396      <%
397      // Biomaterial events linked with this event
398      ItemQuery<BioMaterialEvent> eventQuery = event.getBioMaterialEvents();
399      eventQuery.join(Hql.leftJoin("bioMaterial", "bm"));
400      eventQuery.join(Hql.leftJoin("physicalBioAssay", "pba"));
401      eventQuery.include(Include.ALL);
402      eventQuery.order(Orders.asc(Hql.property("bm", "name")));
403      eventQuery.order(Orders.asc(Hql.property("pba", "name")));
404      ItemResultList<BioMaterialEvent> events = eventQuery.list(dc);
405      %>
406      <base:section 
407        id="eventsSection" 
408        title="<%="Related biomaterial events (" + events.size() + ")"%>"
409        context="<%=cc%>"
410        >
411        <%
412        if (events.size() == 0)
413        {
414          %>
415          <div class="messagecontainer note">
416          No biomaterial events are linked to this event
417          (or, you don't have permission to view them).
418          </div>
419          <%
420        }
421        else
422        {
423          %>
424          <tbl:table
425            id="events"
426            columns="all"
427            >
428            <tbl:columndef
429              id="item"
430              title="Biomaterial/Bioassay"
431            />
432            <tbl:columndef
433              id="bioplate"
434              title="Bioplate"
435            />
436            <tbl:columndef
437              id="eventType"
438              title="Event type"
439            />
440            <tbl:columndef
441              id="comment"
442              title="Comment"
443            />
444            <tbl:data>
445              <tbl:headers>
446                <tbl:headerrow>
447                  <tbl:columnheaders />
448                </tbl:headerrow>
449              </tbl:headers>
450              <tbl:rows>
451                <%
452                for (BioMaterialEvent bmEvent : events)
453                {
454                  BioMaterialEvent.Type eventType = bmEvent.getEventType();
455                  CommonItem item = null;
456                  try
457                  {
458                    if (eventType == BioMaterialEvent.Type.BIOASSAY)
459                    {
460                      item = bmEvent.getPhysicalBioAssay();
461                    }
462                    else
463                    {
464                      item = bmEvent.getBioMaterial();
465                    }
466                  }
467                  catch (PermissionDeniedException ex)
468                  {}     
469                  %>
470                  <tbl:row>
471                    <tbl:cell column="item"><base:icon 
472                      image="deleted.png" 
473                      tooltip="This item has been scheduled for deletion" 
474                      visible="<%=item != null && item.isRemoved()%>"
475                    /><%=Base.getLinkedName(ID, item, true, true)%><%=item != null ? " (" +item.getType().toString() + ")" : "" %></tbl:cell>
476                    <tbl:cell column="bioplate"><base:propertyvalue item="<%=bmEvent%>" property="bioPlateEventParticipant.bioPlate" /></tbl:cell>
477                    <tbl:cell column="eventType"><%=eventType%></tbl:cell>
478                    <tbl:cell column="comment"><%=HTML.encodeTags(bmEvent.getComment())%></tbl:cell>
479                  </tbl:row>
480                  <%
481                }
482                %>
483              </tbl:rows>
484            </tbl:data>
485          </tbl:table>
486          <%
487        }
488        %>
489      </base:section>
490      <jsp:include page="../../../common/anytoany/list_anytoany.jsp">
491        <jsp:param name="ID" value="<%=ID%>" />
492        <jsp:param name="item_type" value="<%=itemType.name()%>" />
493        <jsp:param name="item_id" value="<%=itemId%>" />
494        <jsp:param name="title" value="Other items related to this event" />
495      </jsp:include>
496      </t:tab>
497      </t:tabcontrol>
498
499  </base:body>
500  </base:page>
501  <%
502}
503finally
504{
505  if (dc != null) dc.close();
506}
507
508%>
Note: See TracBrowser for help on using the repository browser.