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

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

References #1290: Change source files to UTF-8

Changed 'Hakkinen' to 'Häkkinen'.

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