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

Last change on this file since 5939 was 5939, checked in by Nicklas Nordborg, 11 years ago

References #1655: GUI improvements

View pages for:

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