source: trunk/www/views/experiments/view_experiment.jsp @ 5069

Last change on this file since 5069 was 5069, checked in by Nicklas Nordborg, 14 years ago

References #108: Logging the change history of an item

  • Enabled logging for experiments
  • Added "Change history" tab to experiments, plugin configuration and protocol
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 26.7 KB
Line 
1<%-- $Id: view_experiment.jsp 5069 2009-08-20 08:53:16Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson, Gregory Vincic
4  Copyright (C) 2007 Nicklas Nordborg, 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 session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
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.Experiment"
33  import="net.sf.basedb.core.RawBioAssay"
34  import="net.sf.basedb.core.AnnotationType"
35  import="net.sf.basedb.core.AnnotationSet"
36  import="net.sf.basedb.core.Annotation"
37  import="net.sf.basedb.core.Annotatable"
38  import="net.sf.basedb.core.Unit"
39  import="net.sf.basedb.core.Type"
40  import="net.sf.basedb.core.User"
41  import="net.sf.basedb.core.Group"
42  import="net.sf.basedb.core.ItemQuery"
43  import="net.sf.basedb.core.ItemResultList"
44  import="net.sf.basedb.core.ItemResultIterator"
45  import="net.sf.basedb.core.Include"
46  import="net.sf.basedb.core.MultiPermissions"
47  import="net.sf.basedb.core.PermissionDeniedException"
48  import="net.sf.basedb.core.PluginDefinition"
49  import="net.sf.basedb.core.plugin.GuiContext"
50  import="net.sf.basedb.core.plugin.Plugin"
51  import="net.sf.basedb.core.Project"
52  import="net.sf.basedb.core.query.Orders"
53  import="net.sf.basedb.core.query.Hql"
54  import="net.sf.basedb.clients.web.Base"
55  import="net.sf.basedb.clients.web.PermissionUtil"
56  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
57  import="net.sf.basedb.clients.web.util.HTML"
58  import="net.sf.basedb.util.Values"
59  import="net.sf.basedb.util.formatter.Formatter"
60  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
61  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
62  import="net.sf.basedb.clients.web.extensions.JspContext"
63  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
64  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
65  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
66  import="java.util.Collections"
67  import="java.util.Date"
68  import="java.util.Map"
69  import="java.util.HashMap"
70  import="java.util.Set"
71  import="java.util.HashSet"
72  import="java.util.List"
73  import="java.util.LinkedList"
74  import="java.util.Date"
75%>
76<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
77<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
78<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
79<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
80<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
81<%!
82  private static final Item itemType = Item.EXPERIMENT;
83  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
84%>
85<%
86final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
87final String ID = sc.getId();
88final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
89final int itemId = cc.getId();
90final String tab = Values.getString(request.getParameter("tab"), "properties");
91final float scale = Base.getScale(sc);
92final String root = request.getContextPath();
93final DbControl dc = sc.newDbControl();
94try
95{
96  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
97  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
98
99  String title = null;
100  Experiment experiment = Experiment.getById(dc, itemId);
101 
102  final boolean writePermission = experiment.hasPermission(Permission.WRITE);
103  final boolean deletePermission = experiment.hasPermission(Permission.DELETE);
104  final boolean sharePermission = experiment.hasPermission(Permission.SET_PERMISSION);
105  final boolean setOwnerPermission = experiment.hasPermission(Permission.SET_OWNER);
106  final boolean isOwner = experiment.isOwner();
107  final boolean isRemoved = experiment.isRemoved();
108  final boolean isUsed = isRemoved && experiment.isUsed();
109  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
110 
111  Map<AnnotationType, Set<Object>> usedFactorValues = 
112    new HashMap<AnnotationType, Set<Object>>();
113  Map<AnnotationType, Integer> factorValuesCount = new HashMap<AnnotationType, Integer>();
114  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, experiment);
115  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
116  %>
117  <base:page title="<%=title%>">
118  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
119    <ext:scripts context="<%=jspContext%>" />
120    <ext:stylesheets context="<%=jspContext%>" />
121    <script language="JavaScript">
122    function editItem()
123    {
124      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
125    }
126    function shareItem()
127    {
128      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareRawBioAssay', 600, 400);
129    }
130    function deleteItem()
131    {
132      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
133    }
134    function restoreItem()
135    {
136      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
137    }
138    function deleteItemPermanently()
139    {
140      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
141    }
142    function itemDeleted()
143    {
144      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
145    }
146    function showUsingItems()
147    {
148      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
149    }   
150    function setOwner()
151    {
152      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 150);
153    }
154    function runPlugin(cmd)
155    {
156      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
157    }
158    function analyzeItem()
159    {
160      location.href = '<%=root%>/analyze/index.jsp?ID=<%=ID%>&experiment_id=<%=itemId%>';
161    }
162    function viewBioAssaySets()
163    {
164      location.href = 'bioassaysets/index.jsp?ID=<%=ID%>&experiment_id=<%=itemId%>';
165    }
166    function switchTab(tabControlId, tabId)
167    {
168      if (TabControl.isActive(tabControlId, tabId)) return;
169      if ((tabId == 'overview' || tabId == 'history') && tabId != '<%=tab%>')
170      {
171        location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId;
172      }
173      else if (tabId == 'bioassaysets')
174      {
175        viewBioAssaySets();
176      }
177      else
178      {
179        TabControl.setActiveTab(tabControlId, tabId);
180      }
181    }
182    function editAnnotation(itemType, itemId, annotationTypeId)
183    {
184      var url = getRoot() + 'common/annotations/annotate.jsp?ID=<%=ID%>';
185      url += '&item_type='+itemType;
186      url += '&item_id='+itemId;
187      url += '&annotationtype_id='+annotationTypeId;
188      url += '&standalone=1';
189      Main.openPopup(url, 'EditAnnotation', 700, 460);
190    }
191    function editInheritedAnnotation(itemType, itemId, annotationTypeId)
192    {
193      var url = getRoot() + 'common/annotations/inherit.jsp?ID=<%=ID%>';
194      url += '&item_type='+itemType;
195      url += '&item_id='+itemId;
196      url += '&annotationtype_id='+annotationTypeId;
197      url += '&standalone=1';
198      Main.openPopup(url, 'EditAnnotation', 700, 460);
199    }
200    function setUsedFactorValue(annotationTypeId, values)
201    {
202      var div = document.getElementById('usedvalues.'+annotationTypeId);
203      div.innerHTML = values;
204    }
205    function showStatus(annotationTypeId, numTotal, numInherited)
206    {
207      var sss = document.getElementById('status.'+annotationTypeId);
208      var html;
209      if (numTotal == numInherited)
210      {
211        html = '<img src="../../images/ok.gif" title="All ' + numTotal +
212          ' raw bioassays have a value for this experimental factor">';
213      }
214      else
215      {
216        var numMissing = numTotal - numInherited;
217        html = '<a href="javascript:autoInherit('+annotationTypeId+')"' + 
218          ' title="Click for automatic inheritation of annotations from parents">';
219        html += '<img src="../../images/warning.gif" border="0">&nbsp;' + numMissing + ' missing</a>';
220      }
221      sss.innerHTML = html;
222    }
223    function autoInherit(annotationTypeId)
224    {
225      var url = 'index.jsp?ID=<%=ID%>&cmd=AutoInherit&item_id=<%=itemId%>&annotationtype_id=' + annotationTypeId;
226      Main.openPopup(url, 'AutoInherit', 400, 200);
227    }
228    </script>
229  </base:head>
230  <base:body onload="initUsedFactorValues()">
231    <p>
232    <p:path>
233      <p:pathelement title="Experiments" href="<%="index.jsp?ID="+ID%>" />
234      <p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" />
235    </p:path>
236   
237    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab" remember="false">
238    <t:tab id="properties" title="Properties">
239   
240    <tbl:toolbar
241      >
242      <tbl:button 
243        disabled="<%=writePermission ? false : true%>" 
244        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
245        onclick="editItem()" 
246        title="Edit&hellip;" 
247        tooltip="<%=writePermission ? "Edit this experiment" : "You do not have permission to edit this experiment"%>" 
248      />
249      <tbl:button 
250        disabled="<%=deletePermission ? false : true%>" 
251        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
252        onclick="deleteItem()" 
253        title="Delete"
254        visible="<%=!experiment.isRemoved()%>"
255        tooltip="<%=deletePermission ? "Delete this experiment" : "You do not have permission to delete this experiment"%>" 
256      />
257      <tbl:button 
258        disabled="<%=writePermission ? false : true%>" 
259        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
260        onclick="restoreItem()" 
261        title="Restore"
262        visible="<%=experiment.isRemoved()%>"
263        tooltip="<%=writePermission ? "Restore this experiment" : "You do not have permission to restore this experiment"%>" 
264      />
265      <tbl:button 
266        disabled="<%=sharePermission ? false : true%>"
267        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
268        onclick="shareItem()" 
269        title="Share&hellip;" 
270        tooltip="<%=sharePermission ? "Share this experiment to other user, groups and projects" : "You do not have permission to share this experiment"%>"
271      />
272      <tbl:button 
273        disabled="<%=setOwnerPermission ? false : true%>"
274        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
275        onclick="setOwner()" 
276        title="Set owner&hellip;"
277        tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
278      />
279      <tbl:button 
280        image="import.gif" 
281        onclick="runPlugin('ImportItem')" 
282        title="Import&hellip;" 
283        tooltip="Import data" 
284        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
285      />
286      <tbl:button 
287        image="export.gif" 
288        onclick="runPlugin('ExportItem')" 
289        title="Export&hellip;" 
290        tooltip="Export data" 
291        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
292      />
293      <tbl:button 
294        image="runplugin.gif" 
295        onclick="runPlugin('RunPlugin')" 
296        title="Run plugin&hellip;" 
297        tooltip="Run a plugin" 
298        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
299      />
300      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
301        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
302      <tbl:button
303        image="help.gif"
304        onclick="<%="Main.openHelp('" + ID +"', 'experiment.view.properties')"%>"
305        title="Help&hellip;"
306        tooltip="Get help about this page"
307      />
308      </tbl:toolbar>
309    <div class="boxedbottom">
310      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(experiment)%></i></div>
311      <%
312      if (experiment.isRemoved() || experiment.isShared())
313      {
314        %>
315        <div class="itemstatus">
316          <base:icon 
317            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
318            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
319            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
320            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
321          <base:icon image="used.gif" 
322            onclick="showUsingItems()"
323            tooltip="Show the items that are using this one"
324            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
325          <base:icon image="shared.gif" 
326            visible="<%=experiment.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
327        </div>
328        <%
329      }
330      %>
331      <table class="form" cellspacing="0">
332      <tr>
333        <td class="prompt">Name</td>
334        <td><%=HTML.encodeTags(experiment.getName())%></td>
335      </tr>
336      <tr>
337        <td class="prompt">Registered</td>
338        <td><%=dateFormatter.format(experiment.getEntryDate())%></td>
339      </tr>
340      <tr>
341        <td class="prompt">Raw data type</td>
342        <td><base:catch><%=HTML.encodeTags(experiment.getRawDataType().getName())%></base:catch></td>
343      </tr>
344      <tr>
345        <td class="prompt">Directory</td>
346        <td><base:propertyvalue item="<%=experiment%>" property="directory" /></td>
347      </tr>
348      <tr>
349        <td class="prompt">Bytes</td>
350        <td><%=Values.formatBytes(experiment.getBytes())%></td>
351      </tr>
352      <tr>
353        <td class="prompt">Owner</td>
354        <td><base:propertyvalue item="<%=experiment%>" property="owner" /></td>
355      </tr>
356      <tr>
357        <td class="prompt">Description</td>
358        <td><%=HTML.niceFormat(experiment.getDescription())%></td>
359      </tr>
360      </table>
361     
362    <base:section 
363      id="publication" 
364      title="Publication"
365      context="<%=cc%>"
366      >
367      <table class="form" cellspacing="0">
368      <tr>
369        <td class="prompt">PubMed ID</td>
370        <td>
371          <%=HTML.encodeTags(experiment.getPubMedId())%>
372          <%
373          int pubMedId = Values.getInt(experiment.getPubMedId(), -1);
374          if (pubMedId != -1)
375          {
376            %>
377            <b>Link to:</b>
378            <a href="http://www.ebi.ac.uk/citexplore/citationDetails.do?externalId=<%=pubMedId%>&dataSource=MED"
379              target="_new" title="External link to EBI Citation database"
380              >EBI Citation database</a>,
381            <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=PureSearch&db=pubmed&details_term=<%=pubMedId%>"
382              target="_new" title="External link to NCBI Entrez PubMed">NCBI Entrez PubMed</a>
383            <%
384          }
385          %>
386        </td>
387      </tr>
388      <tr>
389        <td class="prompt">Title</td>
390        <td><%=HTML.niceFormat(experiment.getTitle())%></td>
391      </tr>
392      <tr>
393        <td class="prompt">Publication date</td>
394        <td><%=dateFormatter.format(experiment.getPublicationDate())%></td>
395      </tr>
396      <tr>
397        <td class="prompt">Abstract</td>
398        <td><%=HTML.niceFormat(experiment.getAbstract())%></td>
399      </tr>
400      <tr>
401        <td class="prompt">Experiment design</td>
402        <td><%=HTML.niceFormat(experiment.getExperimentDesign())%></td>
403      </tr>
404      <tr>
405        <td class="prompt">Experiment type</td>
406        <td><%=HTML.niceFormat(experiment.getExperimentType())%></td>
407      </tr>
408      <tr>
409        <td class="prompt">Affiliations</td>
410        <td><%=HTML.niceFormat(experiment.getAffiliations())%></td>
411      </tr>
412      <tr>
413        <td class="prompt">Authors</td>
414        <td><%=HTML.niceFormat(experiment.getAuthors())%></td>
415      </tr>
416      <tr>
417        <td class="prompt">Publication</td>
418        <td><%=HTML.niceFormat(experiment.getPublication())%></td>
419      </tr>
420      </table>
421    </base:section>
422     
423      <%
424      ItemQuery<AnnotationType> efQuery = experiment.getExperimentalFactors();
425      efQuery.include(Include.ALL);
426      efQuery.order(Orders.asc(Hql.property("name")));
427      ItemResultList<AnnotationType> experimentalFactors = efQuery.list(dc);
428      if (experimentalFactors.size() == 0)
429      {
430        %>
431        <h4>Experimental factors</h4>
432        No experimental factors has been added to this experiment
433        (or, you don't have permission to view them).
434        <%
435      }
436      else
437      {
438        %>
439        <base:section 
440          id="experimentalFactors" 
441          title="<%="Experimental factors (" + experimentalFactors.size() +")"%>"
442          context="<%=cc%>">     
443        <tbl:table
444          id="experimentalFactors"
445          clazz="itemlist"
446          columns="all"
447          >
448        <tbl:columndef 
449          id="name"
450          title="Name"
451        />
452        <tbl:columndef
453          id="type"
454          title="Value type"
455        />
456        <tbl:columndef
457          id="values"
458          title="Used values"
459        />
460        <tbl:columndef 
461          id="description"
462          title="Description"
463        />
464        <tbl:columndef 
465          id="status"
466          title="Status"
467        />
468        <tbl:data>
469          <tbl:columns>
470          </tbl:columns>
471          <tbl:rows>
472          <%
473          for (AnnotationType item : experimentalFactors)
474          {
475            Type valueType = item.getValueType();
476            usedFactorValues.put(item, new HashSet<Object>());
477            factorValuesCount.put(item, 0);
478            Formatter formatter = FormatterFactory.getTypeFormatter(sc, valueType);
479            %>
480            <tbl:row>
481              <tbl:cell column="name"><base:icon 
482                  image="deleted.gif" 
483                  tooltip="This item has been scheduled for deletion" 
484                  visible="<%=item.isRemoved()%>"
485                /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
486              <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
487              <tbl:cell column="type">
488                <%=valueType%>
489                <%=item.isEnumeration() ? "(enumeration)" : ""%>
490              </tbl:cell>
491              <tbl:cell column="values">
492                <%
493                if (!item.isEnumeration() && (valueType == Type.TEXT || valueType == Type.STRING))
494                {
495                  %>
496                  N/A
497                  <%
498                }
499                else
500                {
501                  %>
502                  <div id="usedvalues.<%=item.getId()%>">Loading...</div>
503                  <%
504                }
505                %>
506              </tbl:cell>
507              <tbl:cell column="status"><div id="status.<%=item.getId()%>"></div></tbl:cell>
508            </tbl:row>
509            <%
510          }
511          %>
512          </tbl:rows>
513        </tbl:data>
514        </tbl:table>
515        <base:icon image="warning.gif" /> = Some raw bioassays are missing this factor value;
516          click to automatically try to inherit annotations from parents<br>
517        <base:icon image="ok.gif" /> = All raw bioassays have a value for this factor
518        </base:section>
519        <%
520      }
521      %>
522     
523      <%
524      ItemQuery<RawBioAssay> rbaQuery = experiment.getRawBioAssays();
525      rbaQuery.include(Include.ALL);
526      rbaQuery.order(Orders.asc(Hql.property("name")));
527      ItemResultList<RawBioAssay> rawBioAssays = rbaQuery.list(dc);
528      if (rawBioAssays.size() == 0)
529      {
530        %>
531        <h4>Raw bioassays</h4>
532        No raw bioassays has been added to this experiment
533        (or, you don't have permission to view them).
534        <%
535      }
536      else
537      {
538        %>
539        <base:section 
540          id="rawbioassays" 
541          title="<%="Raw bioassays (" + rawBioAssays.size() +")"%>"
542          context="<%=cc%>">
543        <tbl:table
544          id="rawbioassays"
545          clazz="itemlist"
546          columns="all"
547          >
548        <tbl:columndef 
549          id="name"
550          title="Name"
551        />
552        <tbl:columndef 
553          id="description"
554          title="Description"
555        />
556        <%
557        for (AnnotationType at : experimentalFactors)
558        {
559          Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
560          %>
561          <tbl:columndef
562            id="<%="at"+at.getId()%>"
563            title="<%=HTML.encodeTags(at.getName())%>"
564            formatter="<%=formatter%>"
565          />
566          <%
567        }
568        %>
569       
570        <tbl:data>
571          <tbl:columns>
572          </tbl:columns>
573          <tbl:rows>
574          <%
575          for (RawBioAssay item : rawBioAssays)
576          {
577            AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
578            %>
579            <tbl:row>
580              <tbl:cell column="name"><base:icon 
581                  image="deleted.gif" 
582                  tooltip="This item has been scheduled for deletion" 
583                  visible="<%=item.isRemoved()%>"
584                /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
585              <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
586              <%
587              for (AnnotationType at : experimentalFactors)
588              {
589                Unit unit = at.getDefaultUnit();
590                String unitSymbol = unit == null ? "" : "&nbsp;" + unit.getDisplaySymbol();
591               
592                String value = "<i>- none -</i>";
593                List<Annotation> all = as == null ? null : as.findAnnotations(dc, at, true);
594                Map<Annotatable, List> factorValues = new HashMap<Annotatable, List>();
595                if (all != null && all.size() > 0)
596                {
597                  for (Annotation a : all)
598                  {
599                    List values = a.getValues();
600                    usedFactorValues.get(at).addAll(values);
601                    factorValuesCount.put(at, factorValuesCount.get(at)+1);
602                    Annotatable aItem = null;
603                    try
604                    {
605                      aItem = a.getAnnotationSet().getItem();
606                    }
607                    catch (Throwable t)
608                    {}
609                    List toAdd = factorValues.get(aItem);
610                    if (toAdd == null)
611                    {
612                      toAdd = new LinkedList();
613                      factorValues.put(aItem, toAdd);
614                    }
615                    toAdd.addAll(values);
616                  }
617                }
618               
619                %>
620                <tbl:cell column="<%="at"+at.getId()%>"
621                  >
622                  <%
623                  for (Map.Entry<Annotatable, List> entry : factorValues.entrySet())
624                  {
625                    Annotatable aItem = entry.getKey();
626                    List values = entry.getValue();
627                    %>
628                    <tbl:cellvalue list="<%=values%>" suffix="<%=unitSymbol%>"/>
629                    <%
630                    if (aItem != null && aItem.hasPermission(Permission.WRITE))
631                    {
632                      %>: <base:icon image="edit.gif" 
633                        onclick="<%="editAnnotation('"+aItem.getType().name()+"',"+aItem.getId()+","+at.getId()+")"%>" 
634                        tooltip="Modify the values of this experimental factor" />
635                      <%
636                    }
637                  }
638                  %>
639                </tbl:cell>
640                <%
641              }
642              %>
643            </tbl:row>
644            <%
645          }
646          %>
647          </tbl:rows>
648        </tbl:data>
649        </tbl:table>
650        </base:section>
651        <%
652      }
653     
654      // Tables with users/groups/projects that this item is shared to
655      MultiPermissions mp = new MultiPermissions(Collections.singleton(experiment));
656      ItemResultIterator<User> users = mp.getUsers().iterate(dc);
657      ItemResultIterator<Group> groups = mp.getGroups().iterate(dc);
658      ItemResultIterator<Project> projects = mp.getProjects().iterate(dc);
659     
660      if (users.hasNext() || groups.hasNext() || projects.hasNext())
661      {
662        %>
663        <base:section 
664          id="sharedTo" 
665          title="Shared to"
666          context="<%=cc%>">
667        <tbl:table 
668          id="itemsSharedTo"
669          clazz="itemlist"
670          columns="all"
671        >
672          <tbl:columndef 
673            id="itemType"
674            title="Item type"
675          />
676          <tbl:columndef 
677            id="name"
678            title="Name"
679          />
680          <tbl:columndef 
681            id="permissions"
682            title="Permissions"
683          />
684          <tbl:data>
685            <tbl:columns>
686            </tbl:columns>
687            <tbl:rows>
688            <%
689            while(projects.hasNext())
690            {
691              Project project = projects.next();
692              Set<Permission> permissions = mp.getPermissions(project).values().iterator().next();
693              %>     
694              <tbl:row>
695                <tbl:cell column="itemType"><%=project.getType()%></tbl:cell>
696                <tbl:cell column="name"><base:icon 
697                  image="deleted.gif" 
698                  tooltip="This item has been scheduled for deletion" 
699                  visible="<%=project.isRemoved()%>"
700                /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell>
701                <tbl:cell column="permissions">
702                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
703                </tbl:cell>
704              </tbl:row>
705              <%
706            }
707            while(groups.hasNext())
708            {
709              Group group = groups.next();
710              Set<Permission> permissions = mp.getPermissions(group).values().iterator().next();
711              %>
712              <tbl:row>             
713                <tbl:cell column="itemType"><%=group.getType()%></tbl:cell>
714                <tbl:cell column="name"><base:icon 
715                  image="deleted.gif" 
716                  tooltip="This item has been scheduled for deletion" 
717                  visible="<%=group.isRemoved()%>"
718                /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
719                <tbl:cell column="permissions">
720                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
721                </tbl:cell>
722              </tbl:row>
723              <% 
724            }
725            while (users.hasNext())
726            {
727              User user = users.next();
728              Set<Permission> permissions = mp.getPermissions(user).values().iterator().next();
729              %>
730              <tbl:row>             
731                <tbl:cell column="itemType"><%=user.getType()%></tbl:cell>
732                <tbl:cell column="name"><base:icon 
733                  image="deleted.gif" 
734                  tooltip="This item has been scheduled for deletion" 
735                  visible="<%=user.isRemoved()%>"
736                /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
737                <tbl:cell column="permissions">
738                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
739                </tbl:cell>
740              </tbl:row>
741              <%
742            }
743            %>
744            </tbl:rows>
745          </tbl:data>
746        </tbl:table>
747        </base:section>
748        <%
749      }
750      else
751      {
752        %>
753        <h4>Shared to</h4>
754        This experiment is not shared
755        (or, you don't have permission to view the ones it is shared to).
756        <%
757      }
758      %>
759    </div>
760   
761    <script language="JavaScript">
762    function initUsedFactorValues()
763    {
764      <%
765      int numRawBioAssays = rawBioAssays.size();
766      for (Map.Entry<AnnotationType, Set<Object>> entry : usedFactorValues.entrySet())
767      {
768        AnnotationType at = entry.getKey();
769        int numRawBioAssaysWithFactor = factorValuesCount.get(at);
770        Type valueType = at.getValueType();
771        if (at.isEnumeration() || (valueType != Type.TEXT && valueType != Type.STRING))
772        {
773          Set<Object> values = entry.getValue();
774          Formatter formatter = FormatterFactory.getTypeFormatter(sc, valueType);
775          Unit unit = at.getDefaultUnit();
776          if (unit != null) formatter = unit.getFormatter(formatter);
777          String formattedValues = HTML.encodeTags(Values.getString(values, ", ", true, formatter));
778          %>
779          setUsedFactorValue(<%=at.getId()%>, '<%=HTML.javaScriptEncode(formattedValues)%>');
780          showStatus(<%=at.getId()%>, <%=numRawBioAssays%>, <%=numRawBioAssaysWithFactor%>);
781          <%
782        }
783      }
784      %>
785    }
786    </script>
787      </t:tab>
788     
789      <t:tab id="bioassaysets" title="Bioassay sets" />
790      <t:tab id="overview" title="Overview" 
791        tooltip="Display a tree overview of related items">
792        <%
793        if ("overview".equals(tab))
794        {
795          %>
796          <jsp:include page="../../common/overview/overview.jsp">
797            <jsp:param name="item_type" value="<%=itemType.name()%>" />
798            <jsp:param name="item_id" value="<%=itemId%>" />
799            <jsp:param name="ID" value="<%=ID%>" />
800          </jsp:include>
801          <%
802        }
803        %>
804      </t:tab>     
805      <t:tab id="history" title="Change history" 
806        tooltip="Displays a log of all modifications made to this item"
807        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
808        <%
809        if ("history".equals(tab))
810        {
811          %>
812          <jsp:include page="../../common/history/frameset.jsp">
813            <jsp:param name="source_type" value="<%=itemType.name()%>" />
814            <jsp:param name="source_id" value="<%=itemId%>" />
815            <jsp:param name="ID" value="<%=ID%>" />
816          </jsp:include>
817          <%
818        }
819        %>
820      </t:tab>
821      </t:tabcontrol>
822
823  </base:body>
824  </base:page>
825  <%
826}
827finally
828{
829  if (dc != null) dc.close();
830}
831
832%>
Note: See TracBrowser for help on using the repository browser.