source: trunk/www/views/experiments/bioassays/list_bioassays.jsp @ 4093

Last change on this file since 4093 was 4093, checked in by Johan Enell, 15 years ago

Reverted to revision r4089

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 18.6 KB
Line 
1<%-- $Id: list_bioassays.jsp 4093 2008-01-18 15:05:29Z enell $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Hakkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Johan Enell
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 2
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 this program; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place - Suite 330,
22  Boston, MA  02111-1307, USA.
23  ------------------------------------------------------------------
24
25  @author Nicklas
26  @version 2.0
27--%>
28<%@ page session="false"
29  import="net.sf.basedb.core.SessionControl"
30  import="net.sf.basedb.core.DbControl"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.Experiment"
34  import="net.sf.basedb.core.BioAssaySet"
35  import="net.sf.basedb.core.BioAssay"
36  import="net.sf.basedb.core.RawBioAssay"
37  import="net.sf.basedb.core.AnnotationSet"
38  import="net.sf.basedb.core.AnnotationType"
39  import="net.sf.basedb.core.ItemQuery"
40  import="net.sf.basedb.core.ItemResultIterator"
41  import="net.sf.basedb.core.ItemResultList"
42  import="net.sf.basedb.core.Permission"
43  import="net.sf.basedb.core.PluginDefinition"
44  import="net.sf.basedb.core.PermissionDeniedException"
45  import="net.sf.basedb.core.RawDataType"
46  import="net.sf.basedb.core.Type"
47  import="net.sf.basedb.core.Include"
48  import="net.sf.basedb.core.query.Restrictions"
49  import="net.sf.basedb.core.query.Expressions"
50  import="net.sf.basedb.core.query.Orders"
51  import="net.sf.basedb.core.query.Hql"
52  import="net.sf.basedb.core.plugin.GuiContext"
53  import="net.sf.basedb.core.plugin.Plugin"
54  import="net.sf.basedb.util.Tree"
55  import="net.sf.basedb.util.Enumeration"
56  import="net.sf.basedb.clients.web.Base"
57  import="net.sf.basedb.clients.web.ModeInfo"
58  import="net.sf.basedb.clients.web.PermissionUtil"
59  import="net.sf.basedb.clients.web.util.HTML"
60  import="net.sf.basedb.util.Values"
61  import="net.sf.basedb.util.formatter.Formatter"
62  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
63  import="java.util.List"
64  import="java.util.LinkedList"
65  import="java.util.Map"
66  import="java.util.HashMap"
67  import="java.util.Iterator"
68  import="java.util.Collection"
69%>
70<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
71<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
72<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
73<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
74<%!
75  private static final Item itemType = Item.BIOASSAY;
76  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
77%>
78<%
79final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id"));
80final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
81final String ID = sc.getId();
82final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
83
84final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
85final String callback = request.getParameter("callback");
86final String title = mode.generateTitle("bioassay", "bioassays");
87final DbControl dc = sc.newDbControl();
88ItemResultIterator<BioAssay> bioAssays = null;
89ItemResultList<AnnotationType> annotationTypes = null;
90ItemResultList<AnnotationType> experimentalFactors = null;
91try
92{
93  final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
94  final BioAssaySet bioAssaySet = BioAssaySet.getById(dc, bioAssaySetId);
95  final Experiment experiment = bioAssaySet.getExperiment();
96  final ItemQuery<AnnotationType> experimentalFactorQuery = experiment.getExperimentalFactors();
97  experimentalFactorQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
98  final int experimentId = experiment.getId();
99  final RawDataType rawDataType = experiment.getRawDataType();
100  final boolean createPermission = experiment.hasPermission(Permission.WRITE);
101  final boolean deletePermission = createPermission;
102  final boolean writePermission = createPermission;
103
104  // Query for raw bioassays related to the current bioassay
105  final ItemQuery<RawBioAssay> rawQuery = RawBioAssay.getQuery();
106  rawQuery.include(Include.MINE, Include.SHARED, Include.IN_PROJECT, Include.OTHERS);
107  rawQuery.join(Hql.innerJoin("bioAssays", "bas"));
108  rawQuery.restrict(Restrictions.eq(Hql.alias("bas"), Expressions.parameter("bioAssay"))); 
109  rawQuery.order(Orders.asc(Hql.property("name"))); 
110 
111  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
112  annotationTypes = annotationTypeQuery.list(dc);
113  experimentalFactors = experimentalFactorQuery.list(dc);
114  try
115  {
116    final ItemQuery<BioAssay> query = Base.getConfiguredQuery(cc, true, bioAssaySet.getBioAssays(), mode);
117    query.join(Hql.leftJoin("rawParents", "rba"));
118    bioAssays = query.iterate(dc);
119  }
120  catch (Throwable t)
121  {
122    t.printStackTrace();
123    cc.setMessage(t.getMessage());
124  }
125  int numListed = 0;
126  %>
127  <%@page import="net.sf.basedb.util.BioAssaySetUtil"%>
128<base:page title="<%=title%>" type="<%=mode.getPageType()%>">
129  <base:head scripts="table.js,tabcontrol.js" styles="table.css,headertabcontrol.css,path.css">
130    <script language="JavaScript">
131    var submitPage = 'index.jsp';
132    var formId = 'bioAssaySets';
133    function editItem(itemId)
134    {
135      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, true);
136    }
137    function viewItem(itemId)
138    {
139      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, false);
140    }
141    function itemOnClick(evt, itemId)
142    {
143      Table.itemOnClick(formId, evt, itemId, '<%=mode.getName()%>', viewItem, editItem, returnSelected);
144    }
145    function configureColumns()
146    {
147      Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
148    }
149    function runPlugin(cmd)
150    {
151      Table.submitToPopup(formId, cmd, 740, 540);
152    }
153    function returnSelected()
154    {
155      Table.returnSelected(formId, <%=callback != null ? "window.opener."+callback : "null" %>);
156      window.close();
157    }
158    function presetOnChange()
159    {
160      Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
161    }
162    function switchTab(tabControlId, tabId)
163    {
164      if (tabId == 'properties' || tabId == 'overviewplots' || tabId == 'cfplots' || tabId == 'annotations')
165      {
166        location.href = '../bioassaysets/index.jsp?ID=<%=ID%>&cmd=ViewItem&experiment_id=<%=experiment.getId()%>&item_id=<%=bioAssaySetId%>&tab='+tabId;
167      }
168      else if (tabId == 'spotdata')
169      {
170        location.href = '../spotdata/index.jsp?ID=<%=ID%>&experiment_id=<%=experimentId%>&bioassayset_id=<%=bioAssaySetId%>';
171      }
172      else
173      {
174        TabControl.setActiveTab(tabControlId, tabId);
175      }
176    }
177    function openPlotTool(bioAssayId)
178    {
179      Main.openPopup('../plotter/index.jsp?ID=<%=ID%>&bioassay_id='+bioAssayId, 'Plotter', 1000, 700);
180    }
181    function viewSpotData(bioAssayId)
182    {
183      location.href = '../spotdata/index.jsp?ID=<%=ID%>&bioassay_id='+bioAssayId;
184    }
185    </script>
186  </base:head>
187 
188  <base:body>
189    <p>
190    <%
191    if (!mode.isSelectionMode())
192    {
193      %>
194      <p:path>
195        <p:pathelement title="Experiments" href="<%="../index.jsp?ID="+ID%>" />
196        <p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" 
197          href="<%="../bioassaysets/index.jsp?ID="+ID+"&experiment_id="+experiment.getId()%>" />
198        <p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" />
199      </p:path>
200      <%
201    }
202    %>
203
204    <t:tabcontrol id="main" active="bioassays" switch="switchTab" notabs="<%=mode.isSelectionMode()%>">
205    <t:tab id="properties" title="Properties" />
206   
207    <t:tab id="annotations" title="Annotations" 
208        tooltip="View annotation values" />
209   
210    <t:tab id="bioassays" title="Bioassays">
211    <%
212    if (cc.getMessage() != null)
213    {
214      %>
215      <div class="error"><%=cc.getMessage()%></div>
216      <%
217      cc.setMessage(null);
218    }
219    %>
220    <tbl:table 
221      id="bioAssaySets" 
222      clazz="itemlist" 
223      columns="<%=cc.getSetting("columns")%>"
224      sortby="<%=cc.getSortProperty()%>" 
225      direction="<%=cc.getSortDirection()%>"
226      title="<%=title%>"
227      action="index.jsp"
228      sc="<%=sc%>"
229      item="<%=itemType%>"
230      >
231      <tbl:hidden 
232        name="mode" 
233        value="<%=mode.getName()%>" 
234      />
235      <tbl:hidden 
236        name="bioassayset_id" 
237        value="<%=String.valueOf(bioAssaySetId)%>" 
238      />
239      <tbl:hidden 
240        name="callback" 
241        value="<%=callback%>" 
242        skip="<%=callback == null%>" 
243      />
244      <tbl:columndef 
245        id="name"
246        property="name"
247        datatype="string"
248        title="Name"
249        sortable="true" 
250        filterable="true"
251        exportable="true"
252        show="always" 
253      />
254      <tbl:columndef 
255        id="spots"
256        property="numSpots"
257        datatype="int"
258        title="Spots"
259        sortable="true" 
260        filterable="true"
261        exportable="true"
262      />
263      <tbl:columndef
264        id="rawBioAssays"
265        title="Raw bioassays"
266      />
267      <tbl:columndef 
268        id="description"
269        property="description"
270        datatype="string"
271        title="Description" 
272        sortable="true" 
273        filterable="true" 
274        exportable="true"
275      />
276      <tbl:columndef 
277        id="tools"
278        title="Tools" 
279        show="<%=mode.isSelectionMode() ? "never" : "auto"%>"
280      />
281      <%
282      for (AnnotationType at : annotationTypes)
283      {
284        Enumeration<String, String> annotationEnum = null;
285        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
286        if (at.isEnumeration())
287        {
288          annotationEnum = new Enumeration<String, String>();
289          List<?> values = at.getValues();
290          for (Object value : values)
291          {
292            String encoded = formatter.format(value);
293            annotationEnum.add(encoded, encoded);
294          }
295        }
296        %>
297        <tbl:columndef 
298          id="<%="at"+at.getId()%>"
299          title="<%=HTML.encodeTags(at.getName())+" [A]"%>" 
300          property="<%="#"+at.getId()%>"
301          annotation="true"
302          datatype="<%=at.getValueType().getStringValue()%>"
303          enumeration="<%=annotationEnum%>"
304          sortable="false" 
305          filterable="true" 
306          exportable="true"
307          formatter="<%=formatter%>"
308        />
309        <%
310      }
311      %>
312      <%
313      for (AnnotationType at : experimentalFactors)
314      {
315        Enumeration<String, String> annotationEnum = null;
316        Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
317        if (at.isEnumeration())
318        {
319          annotationEnum = new Enumeration<String, String>();
320          List<?> values = at.getValues();
321          for (Object value : values)
322          {
323            String encoded = formatter.format(value);
324            annotationEnum.add(encoded, encoded);
325          }
326        }
327        %>
328        <tbl:columndef 
329          id="<%="ef"+at.getId()%>"
330          title="<%=HTML.encodeTags(at.getName())+" [EF]"%>" 
331          property="<%="$rba.##"+at.getId()%>"
332          annotation="true"
333          datatype="<%=at.getValueType().getStringValue()%>"
334          enumeration="<%=annotationEnum%>"
335          sortable="false" 
336          filterable="true" 
337          exportable="true"
338          formatter="<%=formatter%>"
339        />
340        <%
341      }
342      %>
343      <tbl:toolbar
344        visible="<%=mode.hasToolbar()%>"
345        >
346        <tbl:button 
347          image="columns.gif" 
348          onclick="configureColumns()" 
349          title="Columns&hellip;" 
350          tooltip="Show, hide and re-order columns" 
351        />
352        <tbl:button 
353          image="import.gif" 
354          onclick="runPlugin('ImportItems')" 
355          title="Import&hellip;" 
356          tooltip="Import data" 
357          visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
358        />
359        <tbl:button 
360          image="export.gif" 
361          onclick="runPlugin('ExportItems')" 
362          title="Export&hellip;" 
363          tooltip="Export data" 
364          visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
365        />
366        <tbl:button
367          disabled="<%=!createPermission%>"
368          image="<%=createPermission ? "filter.gif" : "filter_disabled.gif"%>"
369          onclick="<%="runPlugin('NewFilteredBioAssaySet')"%>"
370          title="Filter bioassay set&hellip;"
371          tooltip="<%=createPermission ? 
372            "Create a new bioassay set by filtering this bioassayset" :
373            "You do not have permission analyze this experiment"%>"
374          visible="<%=!mode.isSelectionMode()%>"
375        />
376        <tbl:button 
377          image="runplugin.gif" 
378          onclick="runPlugin('RunListPlugin')" 
379          title="Run plugin&hellip;" 
380          tooltip="Run a plugin" 
381          visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER) && !mode.isSelectionMode()%>"
382        />
383        <tbl:button 
384          disabled="<%=!createPermission%>"
385          image="<%=createPermission ? "runplugin.gif" : "runplugin_disabled.gif"%>" 
386          onclick="<%="runPlugin('RunListAnalysisPlugin')"%>"
387          title="Run analysis&hellip;" 
388          tooltip="<%=createPermission ? "Run an analysis plugin" : 
389            "You do not have permission to analyze this experiment"%>"
390          visible="<%=pluginCount.containsKey(Plugin.MainType.ANALYZE) && !mode.isSelectionMode()%>"
391        />
392      </tbl:toolbar>
393      <tbl:navigator
394        page="<%=cc.getPage()%>" 
395        rowsperpage="<%=cc.getRowsPerPage()%>" 
396        totalrows="<%=bioAssays == null ? 0 : bioAssays.getTotalCount()%>" 
397        visible="<%=mode.hasNavigator()%>"
398      />
399      <tbl:data>
400        <tbl:columns>
401        <tbl:presetselector 
402          clazz="columnheader"
403          colspan="3"
404          onchange="presetOnChange()"
405        />
406        </tbl:columns>
407        <tr>
408          <tbl:header 
409            clazz="index"
410            >&nbsp;</tbl:header>
411          <tbl:header 
412            clazz="check" 
413            visible="<%=mode.hasCheck()%>"
414            ><base:icon 
415              image="check_uncheck.gif" 
416              tooltip="Check/uncheck all" 
417              onclick="Forms.checkUncheck(document.forms[formId])" style="align: left;"
418            /></tbl:header>
419          <tbl:header 
420            clazz="check" 
421            visible="<%=mode.hasRadio()%>"
422            />
423          <tbl:header 
424            clazz="icons" 
425            visible="<%=mode.hasIcons()%>"
426            >&nbsp;</tbl:header>
427          <tbl:propertyfilter />
428        </tr>
429   
430          <tbl:rows>
431          <%
432          int index = cc.getPage()*cc.getRowsPerPage();
433          int selectedItemId = cc.getId();
434          if (bioAssays != null)
435          {           
436            while (bioAssays.hasNext())
437            {
438              BioAssay item = bioAssays.next();
439              int itemId = item.getId();
440              String name = HTML.encodeTags(item.getName());
441              String tooltip = mode.isSelectionMode() ?
442                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
443              index++;
444              numListed++;         
445              %>
446              <tbl:row>
447                <tbl:header 
448                  clazz="index"
449                  ><%=index%></tbl:header>
450                <tbl:header 
451                  clazz="check" 
452                  visible="<%=mode.hasCheck()%>"
453                  ><input 
454                      type="checkbox" 
455                      name="<%=itemId%>" 
456                      value="<%=itemId%>" 
457                      title="<%=name%>" 
458                      <%=cc.getSelected().contains(itemId) ? "checked" : ""%>
459                    ></tbl:header>
460                <tbl:header 
461                  clazz="check" 
462                  visible="<%=mode.hasRadio()%>"
463                  ><input 
464                      type="radio" 
465                      name="item_id" 
466                      value="<%=itemId%>" 
467                      title="<%=name%>" 
468                      <%=selectedItemId == itemId ? "checked" : ""%>
469                    ></tbl:header>
470                <tbl:header 
471                  clazz="icons" 
472                  visible="<%=mode.hasIcons()%>"
473                  >&nbsp;</tbl:header>
474                <tbl:cell column="name"><div class="link" 
475                  onclick="itemOnClick(<%=writePermission ? "event" : null%>, <%=itemId%>)" 
476                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
477                <tbl:cell column="spots"><%=item.getNumSpots()%></tbl:cell>
478                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
479                <tbl:cell column="rawBioAssays">
480                  <%
481                  rawQuery.setParameter("bioAssay", itemId, Type.INT);
482                  try
483                  {
484                    String separator = "";
485                    for (RawBioAssay rba : rawQuery.list(dc))
486                    {
487                      out.write(separator);
488                      if (mode.hasPropertyLink())
489                      {
490                        out.write(Base.getLinkedName(ID, rba, false, mode.hasEditLink()));
491                      }
492                      else
493                      {
494                        out.write(HTML.encodeTags(rba.getName()));
495                      }
496                      separator = ", ";
497                    }
498                  }
499                  catch (Throwable t)
500                  {
501                    %>
502                    <div class="error"><%=t.getMessage()%></div>
503                    <%
504                  }
505                  %>
506                </tbl:cell>
507                <%
508                AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null;
509                if (as != null)
510                {
511                  for (AnnotationType at : annotationTypes)
512                  {
513                    if (as.hasAnnotation(at))
514                    {
515                      %>
516                      <tbl:cell column="<%="at"+at.getId()%>"
517                        ><tbl:cellvalue 
518                        list="<%=as.getAnnotation(at).getValues()%>" 
519                      /></tbl:cell>
520                      <%
521                    }
522                  }
523                }
524                for (AnnotationType at : experimentalFactors)
525                {
526                  %>
527                  <tbl:cell column="<%="ef"+at.getId()%>"
528                    ><tbl:cellvalue
529                    list="<%=BioAssaySetUtil.getAnnotationValues(dc, item, at)%>"
530                  /></tbl:cell>
531                  <%
532                }               
533                %>
534                <tbl:cell column="tools">
535                  <nobr>
536                  <a href="javascript:openPlotTool(<%=itemId%>)" 
537                    title="A simple plot tool"><img 
538                    src="../../../images/plotter.gif" border="0"></a>
539                  <a href="javascript:viewSpotData(<%=itemId%>)"
540                    title="View spot data as a table"><img 
541                    src="../../../images/table.gif" border="0"></a>
542                  </nobr>
543                </tbl:cell>
544              </tbl:row>
545              <%
546            }
547          }
548          %>
549          </tbl:rows>
550        </tbl:data>
551      <%
552      if (numListed == 0)
553      {
554        %>
555        <tbl:panel><%=bioAssays == null || bioAssays.getTotalCount() == 0 ? "No bioassays were found" : "No bioassays on this page. Please select another page!" %></tbl:panel>
556        <%
557      }
558      else
559      {
560        %>
561        <tbl:navigator
562          page="<%=cc.getPage()%>" 
563          rowsperpage="<%=cc.getRowsPerPage()%>" 
564          totalrows="<%=bioAssays == null ? 0 : bioAssays.getTotalCount()%>" 
565          visible="<%=mode.hasNavigator()%>"
566          locked="true"
567        />
568        <%
569      }
570      %>
571
572    </tbl:table>
573    <base:buttongroup align="center" clazz="fixedatbottom">
574      <base:button onclick="returnSelected();" title="Ok" visible="<%=mode.hasOkButton()%>" />
575      <base:button onclick="window.close();" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
576      <base:button onclick="window.close();" title="Close" visible="<%=mode.hasCloseButton()%>" />
577    </base:buttongroup>
578    </t:tab>
579   
580    <t:tab id="spotdata" title="Spot data" />
581   
582    <t:tab id="overviewplots" title="Overview plots" 
583      visible="<%=rawDataType.getChannels() == 2%>" />
584     
585    <t:tab id="cfplots" title="Correction factor plots" 
586      visible="<%=rawDataType.getChannels() == 2 && bioAssaySet.getTransformation().getSource() != null %>" />
587   
588    </t:tabcontrol>
589
590  </base:body>
591  </base:page>
592  <%
593}
594finally
595{
596  if (bioAssays != null) bioAssays.close();
597  if (dc != null) dc.close();
598}
599%>
Note: See TracBrowser for help on using the repository browser.