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

Last change on this file since 2978 was 2978, checked in by Nicklas Nordborg, 17 years ago

Added session="false" to all jsp pages so we no longer generate unneeded cookies

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 14.5 KB
Line 
1<%-- $Id: view_experiment.jsp 2978 2006-11-30 07:27:42Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 2
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page 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.RawBioAssay"
35  import="net.sf.basedb.core.AnnotationType"
36  import="net.sf.basedb.core.AnnotationSet"
37  import="net.sf.basedb.core.Annotation"
38  import="net.sf.basedb.core.User"
39  import="net.sf.basedb.core.ItemQuery"
40  import="net.sf.basedb.core.ItemResultList"
41  import="net.sf.basedb.core.Include"
42  import="net.sf.basedb.core.PermissionDeniedException"
43  import="net.sf.basedb.core.PluginDefinition"
44  import="net.sf.basedb.core.plugin.GuiContext"
45  import="net.sf.basedb.core.plugin.Plugin"
46  import="net.sf.basedb.core.query.Orders"
47  import="net.sf.basedb.core.query.Hql"
48  import="net.sf.basedb.clients.web.Base"
49  import="net.sf.basedb.clients.web.PermissionUtil"
50  import="net.sf.basedb.clients.web.util.HTML"
51  import="net.sf.basedb.util.Values"
52  import="net.sf.basedb.util.formatter.Formatter"
53  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
54  import="java.util.Date"
55  import="java.util.Map"
56  import="java.util.Set"
57  import="java.util.Date"
58%>
59<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
60<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
61<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
62<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
63<%!
64  private static final Item itemType = Item.EXPERIMENT;
65  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
66%>
67<%
68final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
69final String ID = sc.getId();
70final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
71final int itemId = cc.getId();
72final float scale = Base.getScale(sc);
73final String root = request.getContextPath();
74final DbControl dc = sc.newDbControl();
75try
76{
77  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
78  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
79
80  String title = null;
81  Experiment experiment = Experiment.getById(dc, itemId);
82 
83  final boolean writePermission = experiment.hasPermission(Permission.WRITE);
84  final boolean deletePermission = experiment.hasPermission(Permission.DELETE);
85  final boolean sharePermission = experiment.hasPermission(Permission.SET_PERMISSION);
86  final boolean setOwnerPermission = experiment.hasPermission(Permission.SET_OWNER);
87  final boolean isOwner = experiment.isOwner();
88  %>
89
90  <base:page title="<%=title%>">
91  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
92    <script language="JavaScript">
93    function editItem()
94    {
95      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
96    }
97    function shareItem()
98    {
99      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareRawBioAssay', 500, 400);
100    }
101    function deleteItem()
102    {
103      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
104    }
105    function restoreItem()
106    {
107      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
108    }
109    function takeOwnership()
110    {
111      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
112      {
113        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
114      }
115    }
116    function runPlugin(cmd)
117    {
118      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
119    }
120    function analyzeItem()
121    {
122      location.href = '<%=root%>/analyze/index.jsp?ID=<%=ID%>&experiment_id=<%=itemId%>';
123    }
124    function viewBioAssaySets()
125    {
126      location.href = 'bioassaysets/index.jsp?ID=<%=ID%>&experiment_id=<%=itemId%>';
127    }
128    function switchTab(tabControlId, tabId)
129    {
130      if (tabId == 'bioassaysets')
131      {
132        viewBioAssaySets();
133      }
134      else
135      {
136        TabControl.setActiveTab(tabControlId, tabId);
137      }
138    }
139    </script>
140  </base:head>
141  <base:body>
142    <p>
143    <p:path>
144      <p:pathelement title="Experiments" href="<%="index.jsp?ID="+ID%>" />
145      <p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" />
146    </p:path>
147   
148    <t:tabcontrol id="main" active="properties" switch="switchTab">
149    <t:tab id="properties" title="Properties">
150   
151    <tbl:toolbar
152      >
153      <tbl:button 
154        disabled="<%=writePermission ? false : true%>" 
155        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
156        onclick="editItem()" 
157        title="Edit&hellip;" 
158        tooltip="<%=writePermission ? "Edit this experiment" : "You do not have permission to edit this experiment"%>" 
159      />
160      <tbl:button 
161        disabled="<%=deletePermission ? false : true%>" 
162        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
163        onclick="deleteItem()" 
164        title="Delete"
165        visible="<%=!experiment.isRemoved()%>"
166        tooltip="<%=deletePermission ? "Delete this experiment" : "You do not have permission to delete this experiment"%>" 
167      />
168      <tbl:button 
169        disabled="<%=writePermission ? false : true%>" 
170        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
171        onclick="restoreItem()" 
172        title="Restore"
173        visible="<%=experiment.isRemoved()%>"
174        tooltip="<%=writePermission ? "Restore this experiment" : "You do not have permission to restore this experiment"%>" 
175      />
176      <tbl:button 
177        disabled="<%=sharePermission ? false : true%>"
178        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
179        onclick="shareItem()" 
180        title="Share&hellip;" 
181        tooltip="<%=sharePermission ? "Share this experiment to other user, groups and projects" : "You do not have permission to share this experiment"%>"
182      />
183      <tbl:button 
184        disabled="<%=setOwnerPermission ? false : true%>"
185        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
186        onclick="takeOwnership()" 
187        title="Take ownership&hellip;"
188        visible="<%=!isOwner%>"
189        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
190      />
191      <tbl:button 
192        image="import.gif" 
193        onclick="runPlugin('ImportItem')" 
194        title="Import&hellip;" 
195        tooltip="Import data" 
196        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
197      />
198      <tbl:button 
199        image="export.gif" 
200        onclick="runPlugin('ExportItem')" 
201        title="Export&hellip;" 
202        tooltip="Export data" 
203        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
204      />
205      <tbl:button 
206        image="runplugin.gif" 
207        onclick="runPlugin('RunPlugin')" 
208        title="Run plugin&hellip;" 
209        tooltip="Run a plugin" 
210        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
211      />
212      <tbl:button
213        image="help.gif"
214        onclick="<%="Main.openHelp('" + ID +"', 'experiment.view.properties')"%>"
215        title="Help&hellip;"
216        tooltip="Get help about this page"
217      />
218      </tbl:toolbar>
219    <div class="boxedbottom">
220      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(experiment)%></i></div>
221      <%
222      if (experiment.isRemoved() || experiment.isShared())
223      {
224        %>
225        <div class="itemstatus">
226          <base:icon image="deleted.gif" 
227            visible="<%=experiment.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
228          <base:icon image="shared.gif" 
229            visible="<%=experiment.isShared()%>"> This item is shared to other user, groups and/or projects</base:icon>
230        </div>
231        <%
232      }
233      %>
234      <table class="form" cellspacing=0>
235      <tr>
236        <td class="prompt">Name</td>
237        <td><%=HTML.encodeTags(experiment.getName())%></td>
238      </tr>
239      <tr>
240        <td class="prompt">Raw data type</td>
241        <td><%=HTML.encodeTags(experiment.getRawDataType().getName())%></td>
242      </tr>
243      <tr>
244        <td class="prompt">Directory</td>
245        <td><base:propertyvalue item="<%=experiment%>" property="directory" /></td>
246      </tr>
247      <tr>
248        <td class="prompt">Bytes</td>
249        <td><%=Values.formatBytes(experiment.getBytes())%></td>
250      </tr>
251      <tr>
252        <td class="prompt">Owner</td>
253        <td><base:propertyvalue item="<%=experiment%>" property="owner" /></td>
254      </tr>
255      <tr>
256        <td class="prompt">Description</td>
257        <td><%=HTML.niceFormat(experiment.getDescription())%></td>
258      </tr>
259      </table>
260     
261      <h4>Publication</h4>
262      <table class="form" cellspacing=0>
263      <tr>
264        <td class="prompt">PubMed ID</td>
265        <td>
266          <%=HTML.encodeTags(experiment.getPubMedId())%>
267          <%
268          int pubMedId = Values.getInt(experiment.getPubMedId(), -1);
269          if (pubMedId != -1)
270          {
271            %>
272            <b>Link to:</b>
273            <a href="http://www.ebi.ac.uk/citexplore/citationDetails.do?externalId=<%=pubMedId%>&dataSource=MED"
274              target="_new" title="External link to EBI Citation database"
275              >EBI Citation database</a>,
276            <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=PureSearch&db=pubmed&details_term=<%=pubMedId%>"
277              target="_new" title="External link to NCBI Entrez PubMed">NCBI Entrez PubMed</a>
278            <%
279          }
280          %>
281        </td>
282      </tr>
283      <tr>
284        <td class="prompt">Title</td>
285        <td><%=HTML.niceFormat(experiment.getTitle())%></td>
286      </tr>
287      <tr>
288        <td class="prompt">Publication date</td>
289        <td><%=dateFormatter.format(experiment.getPublicationDate())%></td>
290      </tr>
291      <tr>
292        <td class="prompt">Abstract</td>
293        <td><%=HTML.niceFormat(experiment.getAbstract())%></td>
294      </tr>
295      <tr>
296        <td class="prompt">Experiment design</td>
297        <td><%=HTML.niceFormat(experiment.getExperimentDesign())%></td>
298      </tr>
299      <tr>
300        <td class="prompt">Experiment type</td>
301        <td><%=HTML.niceFormat(experiment.getExperimentType())%></td>
302      </tr>
303      <tr>
304        <td class="prompt">Affiliations</td>
305        <td><%=HTML.niceFormat(experiment.getAffiliations())%></td>
306      </tr>
307      <tr>
308        <td class="prompt">Authors</td>
309        <td><%=HTML.niceFormat(experiment.getAuthors())%></td>
310      </tr>
311      <tr>
312        <td class="prompt">Publication</td>
313        <td><%=HTML.niceFormat(experiment.getPublication())%></td>
314      </tr>
315      </table>
316     
317      <%
318      ItemQuery<AnnotationType> efQuery = experiment.getExperimentalFactors();
319      efQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
320      efQuery.order(Orders.asc(Hql.property("name")));
321      ItemResultList<AnnotationType> experimentalFactors = efQuery.list(dc);
322      if (experimentalFactors.size() == 0)
323      {
324        %>
325        <h4>Experimental factors</h4>
326        No experimental factors has been added to this experiment
327        (or, you don't have permission to view them).
328        <%
329      }
330      else
331      {
332        %>
333        <h4 class="docked">Experimental factors</h4>
334        <tbl:table
335          id="experimentalFactors"
336          clazz="itemlist"
337          columns="all"
338          >
339        <tbl:columndef 
340          id="name"
341          title="Name"
342        />
343        <tbl:columndef
344          id="values"
345          title="Values"
346        />
347        <tbl:columndef 
348          id="description"
349          title="Description"
350        />
351        <tbl:data>
352          <tbl:columns>
353          </tbl:columns>
354          <tbl:rows>
355          <%
356          for (AnnotationType item : experimentalFactors)
357          {
358            Formatter formatter = FormatterFactory.getTypeFormatter(sc, item.getValueType());
359            %>
360            <tbl:row>
361              <tbl:cell column="name"><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
362              <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
363              <tbl:cell column="values">
364              <%=item.isEnumeration() ? 
365                "Enumeration: " + Values.getString(item.getValues(), ", ", true, formatter) :
366                item.getValueType()%>
367              </tbl:cell>
368            </tbl:row>
369            <%
370          }
371          %>
372          </tbl:rows>
373        </tbl:data>
374        </tbl:table>
375        <%
376      }
377      %>
378     
379      <%
380      ItemQuery<RawBioAssay> rbaQuery = experiment.getRawBioAssays();
381      rbaQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
382      rbaQuery.order(Orders.asc(Hql.property("name")));
383      ItemResultList<RawBioAssay> rawBioAssays = rbaQuery.list(dc);
384      if (rawBioAssays.size() == 0)
385      {
386        %>
387        <h4>Raw bioassays</h4>
388        No raw bioassays has been added to this experiment
389        (or, you don't have permission to view them).
390        <%
391      }
392      else
393      {
394        %>
395        <h4 class="docked">Raw bioassays</h4>
396        <tbl:table
397          id="rawbioassays"
398          clazz="itemlist"
399          columns="all"
400          >
401        <tbl:columndef 
402          id="name"
403          title="Name"
404        />
405        <tbl:columndef 
406          id="description"
407          title="Description"
408        />
409        <%
410        for (AnnotationType at : experimentalFactors)
411        {
412          Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
413          %>
414          <tbl:columndef
415            id="<%="at"+at.getId()%>"
416            title="<%=HTML.encodeTags(at.getName())+" [EF]"%>"
417            formatter="<%=formatter%>"
418          />
419          <%
420        }
421        %>
422       
423        <tbl:data>
424          <tbl:columns>
425          </tbl:columns>
426          <tbl:rows>
427          <%
428          for (RawBioAssay item : rawBioAssays)
429          {
430            AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
431            %>
432            <tbl:row>
433              <tbl:cell column="name"><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
434              <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
435              <%
436              for (AnnotationType at : experimentalFactors)
437              {
438                String value = "<i>- none -</i>";
439                Annotation a = as == null ? null : as.findAnnotation(at);
440                %>
441                <tbl:cell column="<%="at"+at.getId()%>"
442                  ><tbl:cellvalue list="<%=a == null ? null : a.getValues()%>" 
443                /></tbl:cell>
444                <%
445              }
446              %>
447            </tbl:row>
448            <%
449          }
450          %>
451          </tbl:rows>
452        </tbl:data>
453        </tbl:table>
454        <%
455      }
456      %>
457    </div>
458      </t:tab>
459     
460      <t:tab id="bioassaysets" title="Bioassay sets" />
461     
462      </t:tabcontrol>
463
464
465  </base:body>
466  </base:page>
467  <%
468}
469finally
470{
471  if (dc != null) dc.close();
472}
473
474%>
Note: See TracBrowser for help on using the repository browser.