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

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

References #1655: GUI improvements

  • More changes to table and section taglibs. Simple item lists should now display ok (after using a different set of tags for the header row)
  • Hidable sections have been re-designed and should now look a bit better. However, in many of the places we use a section it is only used when there is data to list. The section should be used in all cases so we need to move the conditional test inside.
  • The code for listing "Shared to" information for items have been moved to an "include" page and the old code has been replaced in a lot of pages (may still be missing some).
  • The "Annotations & parameter" tab have been fixed with the new design.
  • The biosource, sample, extract and tag view pages have also been fixed.


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