source: trunk/www/views/experiments/spotdata/list_spotdata.jsp @ 4302

Last change on this file since 4302 was 4302, checked in by Nicklas Nordborg, 15 years ago

References #1016: Filter table using a reporter list

I think this should now be working, but I may have missed a list somewhere. Please test.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 13.4 KB
Line 
1<%-- $Id: list_spotdata.jsp 4302 2008-05-19 12:07:25Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Hakkinen, Nicklas Nordborg
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.Type"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.Experiment"
36  import="net.sf.basedb.core.BioAssaySet"
37  import="net.sf.basedb.core.BioAssay"
38  import="net.sf.basedb.core.RawDataType"
39  import="net.sf.basedb.core.BaseException"
40  import="net.sf.basedb.core.DynamicSpotQuery"
41  import="net.sf.basedb.core.DynamicResultIterator"
42  import="net.sf.basedb.core.PluginDefinition"
43  import="net.sf.basedb.core.Formula"
44  import="net.sf.basedb.core.plugin.GuiContext"
45  import="net.sf.basedb.core.plugin.Plugin"
46  import="net.sf.basedb.core.query.SqlResult"
47  import="net.sf.basedb.util.Enumeration"
48  import="net.sf.basedb.util.ColorGenerator"
49  import="net.sf.basedb.clients.web.Base"
50  import="net.sf.basedb.clients.web.ModeInfo"
51  import="net.sf.basedb.clients.web.DynamicUtil"
52  import="net.sf.basedb.clients.web.WebException"
53  import="net.sf.basedb.clients.web.util.HTML"
54  import="net.sf.basedb.util.Values"
55  import="net.sf.basedb.clients.web.taglib.table.TableColumn"
56  import="java.util.Map"
57  import="java.util.HashMap"
58  import="java.util.List"
59  import="java.util.LinkedList"
60  import="java.util.ArrayList"
61  import="java.util.Set"
62  import="java.util.HashSet"
63  import="java.util.Arrays"
64  import="java.awt.Color"
65%>
66<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
67<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
68<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
69<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
70<%!
71  private static final Item itemType = Item.SPOTDATA;
72  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
73%>
74<%
75final int bioAssayId = Values.getInt(request.getParameter("bioassay_id"));
76final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id"));
77final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
78final String ID = sc.getId();
79
80final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
81final String callback = request.getParameter("callback");
82final String title = mode.generateTitle("spot data", "spot data");
83final DbControl dc = sc.newDbControl();
84DynamicResultIterator spotData = null;
85try
86{
87  final BioAssay bioAssay = bioAssayId == 0 ? null : BioAssay.getById(dc, bioAssayId);
88  final BioAssaySet bioAssaySet = bioAssay != null ? bioAssay.getBioAssaySet() : BioAssaySet.getById(dc, bioAssaySetId);
89  final Experiment experiment = bioAssaySet.getExperiment();
90  final int experimentId = experiment.getId();
91  final RawDataType rawDataType = bioAssaySet.getRawDataType();
92  Map<Short, String> bioAssayMap = null;
93 
94  final String subContext = rawDataType.getId();
95  final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, subContext, null, null);
96  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
97 
98  List<TableColumn> columns = new LinkedList<TableColumn>();
99  DynamicUtil.addSpotColumns(columns, dc, rawDataType.getChannels());
100  DynamicUtil.addFormulaColumns(columns, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION, "frm.", "", true);
101  DynamicUtil.addExtraColumns(columns, dc, bioAssaySet, "ev", "#", "[Xtra] ");
102  DynamicUtil.addRawDataColumns(columns, dc, rawDataType, "raw.", "$", "[Raw] ");
103  DynamicUtil.addReporterColumns(columns, dc, "rep.", "@", "[Rep] ");
104  DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, columns, false);
105  if (bioAssay == null && cc.getSetting("columns").indexOf("COLUMN") >= 0) 
106  {
107    selected.selectedIds.add("COLUMN");
108    selected.selectedProperties.add("COLUMN");
109  }
110  try
111  {
112    final DynamicSpotQuery query = bioAssay != null ? bioAssay.getSpotData() : bioAssaySet.getSpotData();
113    cc.configureQuery(dc, query, selected.selectedProperties);
114    spotData = query.iterate(dc);
115  }
116  catch (Throwable t)
117  {
118    cc.setMessage(t.getMessage());
119  }
120
121  int numListed = 0;
122  %>
123  <base:page title="<%=title%>">
124  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
125    <script language="JavaScript">
126    var submitPage = 'index.jsp';
127    var formId = 'spotdata';
128    function configureColumns()
129    {
130      Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>');
131    }
132    function presetOnChange()
133    {
134      Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>');
135    }
136    function runPlugin(cmd)
137    {
138      Table.submitToPopup(formId, cmd, 800, 500);
139    }
140    function switchTab(tabControlId, tabId)
141    {
142      if (tabId == 'properties.bioassay')
143      {
144        location.href = '../bioassays/index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=bioAssayId%>&tab=properties';
145      }
146      else if (tabId == 'annotations.bioassay')
147      {
148        location.href = '../bioassays/index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=bioAssayId%>&tab=annotations';
149      }
150      else if (tabId == 'properties.bioassayset')
151      {
152        location.href = '../bioassaysets/index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=bioAssaySetId%>&tab=properties';
153      }
154      else if (tabId == 'annotations.bioassayset')
155      {
156        location.href = '../bioassaysets/index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=bioAssaySetId%>&tab=annotations';
157      }
158      else if (tabId == 'overviewplots' || tabId == 'cfplots')
159      {
160        location.href = '../bioassaysets/index.jsp?ID=<%=ID%>&cmd=ViewItem&experiment_id=<%=experimentId%>&item_id=<%=bioAssaySetId%>&tab='+tabId;
161      }
162      else if (tabId == 'bioassays')
163      {
164        location.href = '../bioassays/index.jsp?ID=<%=ID%>&experiment_id=<%=experimentId%>&bioassayset_id=<%=bioAssaySetId%>&tab='+tabId;
165      }
166      else
167      {
168        TabControl.setActiveTab(tabControlId, tabId);
169      }
170    }
171    </script>
172  </base:head>
173  <base:body>
174    <p>
175    <p:path>
176      <p:pathelement title="Experiments" href="<%="../index.jsp?ID="+ID%>" />
177      <p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" 
178        href="<%="../bioassaysets/index.jsp?ID="+ID+"&experiment_id="+experiment.getId()%>" />
179       
180      <%
181      if (bioAssay == null)
182      {
183        %>
184        <p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" />
185        <%
186      }
187      else
188      {
189        %>
190        <p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" 
191          href="<%="../bioassays/index.jsp?ID="+ID+"&bioassayset_id="+bioAssaySet.getId()%>" />
192        <p:pathelement title="<%=HTML.encodeTags(bioAssay.getName())%>" />
193        <%
194      }
195      %>
196    </p:path>
197
198    <t:tabcontrol id="main" active="spotdata" switch="switchTab">
199    <t:tab id="properties.bioassay" title="Properties" visible="<%=bioAssay != null%>"/>
200    <t:tab id="properties.bioassayset" title="Properties" visible="<%=bioAssay == null%>"/>
201
202    <t:tab id="annotations.bioassay" title="Annotations" 
203      tooltip="View annotation values" visible="<%=bioAssay != null%>" />
204    <t:tab id="annotations.bioassayset" title="Annotations" 
205        tooltip="View annotation values" visible="<%=bioAssay == null%>" />
206
207    <t:tab id="bioassays" visible="<%=bioAssay == null%>" title="BioAssays" />
208    <t:tab id="spotdata" title="Spot data" >
209    <%
210    if (cc.getMessage() != null)
211    {
212      %>
213      <div class="error"><%=cc.getMessage()%></div>
214      <%
215      cc.setMessage(null);
216    }
217    %>
218    <tbl:table 
219      id="spotdata" 
220      clazz="itemlist" 
221      columns="<%=cc.getSetting("columns")%>"
222      sortby="<%=cc.getSortProperty()%>" 
223      direction="<%=cc.getSortDirection()%>"
224      title="<%=title%>"
225      action="index.jsp"
226      sc="<%=sc%>"
227      item="<%=itemType%>"
228      subcontext="<%=subContext%>"
229      >
230      <tbl:hidden 
231        name="mode" 
232        value="<%=mode.getName()%>" 
233      />
234      <tbl:hidden 
235        name="bioassayset_id" 
236        value="<%=String.valueOf(bioAssaySetId)%>" 
237      />
238      <tbl:hidden 
239        name="bioassay_id" 
240        value="<%=String.valueOf(bioAssayId)%>" 
241      />
242      <tbl:hidden 
243        name="callback" 
244        value="<%=callback%>" 
245        skip="<%=callback == null%>" 
246      />
247
248      <%
249      for (TableColumn tc : columns)
250      {
251        %>
252        <tbl:columndef
253          id="<%=tc.getId()%>"
254          property="<%=tc.getProperty()%>"
255          datatype="<%=tc.getDatatype().getStringValue()%>"
256          title="<%=tc.getTitle()%>"
257          sortable="<%=tc.getSortable()%>"
258          filterable="<%=tc.getFilterable()%>"
259          exportable="<%=tc.getExportable()%>"
260          show="<%=tc.getShow()%>"
261          formatter="<%=tc.getFormatter()%>"
262        />
263        <%
264      }
265      %>
266      <%
267      if (bioAssay == null)
268      {
269        bioAssayMap = new HashMap<Short, String>();
270        Enumeration<String, String> bioAssayEnum = new Enumeration<String, String>();
271        for (BioAssay ba : bioAssaySet.getBioAssays().list(dc))
272        {
273          short columnNo = ba.getDataCubeColumnNo(); 
274          bioAssayMap.put(columnNo, Base.getLinkedName(ID, ba, false, true));
275          bioAssayEnum.add(String.valueOf(columnNo), HTML.encodeTags(ba.getName()));
276        }
277        %>
278        <tbl:columndef
279          id="COLUMN"
280          property="COLUMN"
281          datatype="int"
282          title="Bioassay"
283          sortable="true"
284          filterable="true"
285          exportable="true"
286          enumeration="<%=bioAssayEnum%>"
287        />
288        <%
289      }
290      %>
291      <tbl:columndef 
292        id="reporterList"
293        property="£reporterList"
294        datatype="int"
295        title="Reporter list"
296        filterable="true"
297        enumeration="<%=Base.getReporterListsEnum(dc)%>"
298        multiple="false"
299      />
300      <tbl:toolbar
301        visible="<%=mode.hasToolbar()%>"
302        >
303        <tbl:button 
304          image="columns.gif" 
305          onclick="configureColumns()" 
306          title="Columns&hellip;" 
307          tooltip="Show, hide and re-order columns" 
308        />
309        <tbl:button 
310          image="export.gif" 
311          onclick="runPlugin('ExportItems')" 
312          title="Export&hellip;" 
313          tooltip="Export data" 
314          visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
315        />
316      </tbl:toolbar>
317      <tbl:navigator
318        page="<%=cc.getPage()%>" 
319        rowsperpage="<%=cc.getRowsPerPage()%>" 
320        totalrows="<%=spotData == null ? 0 : spotData.getTotalCount()%>" 
321        visible="<%=mode.hasNavigator()%>"
322      />
323      <tbl:data>
324        <tbl:columns>
325        <tbl:presetselector 
326          clazz="columnheader"
327          colspan="2"
328          onchange="presetOnChange()"
329        />
330        </tbl:columns>
331        <tr>
332          <tbl:header 
333            clazz="index"
334            >&nbsp;</tbl:header>
335          <tbl:header 
336            clazz="icons" 
337            visible="<%=mode.hasIcons()%>"
338            >&nbsp;</tbl:header>
339          <tbl:propertyfilter />
340        </tr>
341   
342          <tbl:rows>
343          <%
344          int index = cc.getPage()*cc.getRowsPerPage();
345          int selectedItemId = cc.getId();
346          if (spotData != null)
347          {
348            while (spotData.hasNext())
349            {
350              SqlResult item = spotData.next();
351              index++;
352              numListed++;
353              %>
354              <tbl:row>
355                <tbl:header 
356                  clazz="index"
357                  ><%=index%></tbl:header>
358                <tbl:header 
359                  clazz="icons" 
360                  visible="<%=mode.hasIcons()%>"
361                  >&nbsp;</tbl:header>
362                <%
363                int i = 1;
364                for (String columnId : selected.selectedIds)
365                {
366                  Object value = item.getObject(i++);
367                  if ("COLUMN".equals(columnId))
368                  {
369                    short columnNo = ((Number)value).shortValue();
370                    value= bioAssayMap.get(columnNo);
371                  }
372                  %>
373                  <tbl:cell column="<%=columnId%>" value="<%=value%>" />
374                  <%
375                }
376                %>
377              </tbl:row>
378              <%
379            }
380          }
381          %>
382          </tbl:rows>
383        </tbl:data>
384      <%
385      if (numListed == 0)
386      {
387        %>
388        <tbl:panel><%=spotData == null || spotData.getTotalCount() == 0 ? "No spot data were found" : "No spot data on this page. Please select another page!" %></tbl:panel>
389        <%
390      }
391      else
392      {
393        %>
394        <tbl:navigator
395          page="<%=cc.getPage()%>" 
396          rowsperpage="<%=cc.getRowsPerPage()%>" 
397          totalrows="<%=spotData == null ? 0 : spotData.getTotalCount()%>" 
398          visible="<%=mode.hasNavigator()%>"
399          locked="true"
400        />
401        <%
402      }
403      %>
404    </tbl:table>
405    <base:buttongroup align="center">
406      <base:button onclick="returnSelected();" title="Ok" visible="<%=mode.hasOkButton()%>" />
407      <base:button onclick="window.close();" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
408      <base:button onclick="window.close();" title="Close" visible="<%=mode.hasCloseButton()%>" />
409    </base:buttongroup>
410    </t:tab>
411
412    <t:tab id="overviewplots" 
413      visible="<%=bioAssay == null && rawDataType.getChannels() == 2%>" 
414      title="Overview plots" 
415      tooltip="MA-plots of each bioassay in this bioassay set"
416    />
417    <t:tab id="cfplots" 
418      title="Correction factor plots" 
419      visible="<%=bioAssay == null && rawDataType.getChannels() == 2 && bioAssaySet.getTransformation().getSource() != null %>" 
420    />
421
422    </t:tabcontrol>
423
424  </base:body>
425  </base:page>
426  <%
427}
428finally
429{
430  if (dc != null) dc.close();
431}
432%>
Note: See TracBrowser for help on using the repository browser.