source: branches/3.18-stable/www/views/experiments/spotdata/list_spotdata.jsp @ 7938

Last change on this file since 7938 was 7938, checked in by Nicklas Nordborg, 23 months ago

References #2246: Sticky table headers

Implemented for all items in the "View" menu.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 15.4 KB
Line 
1<%-- $Id: list_spotdata.jsp 7938 2021-05-03 11:20:19Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, 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 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.clients.web.extensions.plot.OverviewPlotAction"%>
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.Type"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.Permission"
34  import="net.sf.basedb.core.Experiment"
35  import="net.sf.basedb.core.BioAssaySet"
36  import="net.sf.basedb.core.BioAssay"
37  import="net.sf.basedb.core.RawDataType"
38  import="net.sf.basedb.core.BaseException"
39  import="net.sf.basedb.core.DynamicResultIterator"
40  import="net.sf.basedb.core.PluginDefinition"
41  import="net.sf.basedb.core.Formula"
42  import="net.sf.basedb.core.IntensityTransform"
43  import="net.sf.basedb.core.plugin.GuiContext"
44  import="net.sf.basedb.core.plugin.Plugin"
45  import="net.sf.basedb.core.query.SqlQuery"
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.util.formatter.LookupFormatter"
50  import="net.sf.basedb.clients.web.Base"
51  import="net.sf.basedb.clients.web.ModeInfo"
52  import="net.sf.basedb.clients.web.DynamicUtil"
53  import="net.sf.basedb.clients.web.WebException"
54  import="net.sf.basedb.clients.web.util.HTML"
55  import="net.sf.basedb.util.Values"
56  import="net.sf.basedb.clients.web.taglib.table.TableColumn"
57  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
58  import="net.sf.basedb.clients.web.extensions.JspContext"
59  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
60  import="net.sf.basedb.clients.web.extensions.toolbar.ButtonAction" 
61  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
62  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
63  import="java.util.Map"
64  import="java.util.HashMap"
65  import="java.util.List"
66  import="java.util.LinkedList"
67  import="java.util.ArrayList"
68  import="java.util.Set"
69  import="java.util.HashSet"
70  import="java.util.Arrays"
71  import="java.awt.Color"
72%>
73<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
74<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
75<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
76<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
77<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
78<%!
79  private static final Item itemType = Item.SPOTDATA;
80  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
81%>
82<%
83final int bioAssayId = Values.getInt(request.getParameter("bioassay_id"));
84final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id"));
85final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
86final String ID = sc.getId();
87
88final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
89final String callback = request.getParameter("callback");
90final String title = mode.generateTitle("spot data", "spot data");
91final DbControl dc = sc.newDbControl();
92DynamicResultIterator spotData = null;
93try
94{
95  final BioAssay bioAssay = bioAssayId == 0 ? null : BioAssay.getById(dc, bioAssayId);
96  final BioAssaySet bioAssaySet = bioAssay != null ? bioAssay.getBioAssaySet() : BioAssaySet.getById(dc, bioAssaySetId);
97  final Experiment experiment = bioAssaySet.getExperiment();
98  final int experimentId = experiment.getId();
99  final RawDataType rawDataType = bioAssaySet.getRawDataType();
100  final IntensityTransform transform = bioAssaySet.getIntensityTransform();
101 
102  final String subContext = rawDataType.getId();
103  final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, subContext, null, null);
104  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
105 
106  List<TableColumn> columns = new LinkedList<TableColumn>();
107  DynamicUtil.addSpotColumns(columns, dc, rawDataType.getChannels(), transform);
108  DynamicUtil.addFormulaColumns(columns, dc, rawDataType, Formula.Type.COLUMN_EXPRESSION, 
109      transform, "frm.", "[Formula] ", true);
110  DynamicUtil.addExtraColumns(columns, dc, bioAssaySet, "ev", "#", "[Xtra] ");
111  DynamicUtil.addRawDataColumns(columns, dc, rawDataType, "raw.", "$", "[Raw] ");
112  DynamicUtil.addReporterColumns(columns, dc, experiment.getVirtualDb().getReporterCloneTemplate(), "rep.", "@", "[Rep] ");
113  DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, columns, false);
114 
115  int externalIdColumn = selected.selectedIds.indexOf("rep.externalId") + 1;
116  int reporterIdColumn = selected.selectedIds.indexOf("rep.id") + 1;
117  if (reporterIdColumn <= 0 && externalIdColumn > 0)
118  {
119    // Force selecting reporter id column if external id is selected
120    selected.selectedIds.add("rep.id");
121    selected.selectedProperties.add("@id");
122    reporterIdColumn = selected.selectedIds.size();
123  }
124  if (bioAssay == null && cc.getSetting("columns").indexOf("COLUMN") >= 0) 
125  {
126    selected.selectedIds.add("COLUMN");
127    selected.selectedProperties.add("COLUMN");
128  }
129  try
130  {
131    final SqlQuery query = bioAssay != null ? bioAssay.getSpotData() : bioAssaySet.getSpotData();
132    cc.configureQuery(dc, query, selected.selectedProperties);
133    query.setFailSafe(true);
134    spotData = query.iterate(dc);
135  }
136  catch (Throwable t)
137  {
138    cc.setMessage(t.getMessage());
139    t.printStackTrace();
140  }
141
142  int numListed = 0;
143  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, 
144    guiContext, bioAssay == null ? bioAssaySet : bioAssay);
145  ExtensionsInvoker<ButtonAction> invoker = ToolbarUtil.useExtensions(jspContext);
146  ExtensionsInvoker<OverviewPlotAction> overviewPlotInvoker = bioAssay != null ? 
147    null : ExtensionsControl.useExtensions(jspContext, "net.sf.basedb.clients.web.bioassayset.overviewplots");
148  %>
149  <base:page title="<%=title%>">
150  <base:head scripts="table.js,tabcontrol-2.js,~spotdata.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
151    <ext:scripts context="<%=jspContext%>" />
152    <ext:stylesheets context="<%=jspContext%>" />
153    <style>
154    .row-index > div
155    {
156      grid-template-columns: 1fr !important;
157    }
158    .row-index .index
159    {
160      padding-right: 3px;
161    }
162    </style>
163  </base:head>
164  <base:body>
165    <p:path>
166      <p:pathelement 
167        title="Experiments" href="<%="../index.jsp?ID="+ID%>" 
168      /><p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" 
169        href="<%="../bioassaysets/index.jsp?ID="+ID+"&amp;experiment_id="+experiment.getId()%>" 
170      /><%
171      if (bioAssay == null)
172      {
173        %><p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" 
174        /><%
175      }
176      else
177      {
178        %><p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" 
179          href="<%="../bioassays/index.jsp?ID="+ID+"&amp;bioassayset_id="+bioAssaySet.getId()%>" 
180        /><p:pathelement title="<%=HTML.encodeTags(bioAssay.getName())%>" 
181        /><%
182      }
183      %></p:path>
184
185    <t:tabcontrol 
186      id="main" 
187      subclass="mastertabcontrol content"
188      active="spotdata">
189    <t:tab id="bioassayset.properties" title="Properties" visible="<%=bioAssay == null%>"/>
190    <t:tab id="bioassay.properties" title="Properties" visible="<%=bioAssay != null%>"/>
191
192    <t:tab id="bioassayset.annotations" title="Annotations" 
193        tooltip="View annotation values" visible="<%=bioAssay == null%>" />
194    <t:tab id="bioassay.annotations" title="Annotations" 
195      tooltip="View annotation values" visible="<%=bioAssay != null%>" />
196
197    <t:tab id="bioassays" visible="<%=bioAssay == null%>" title="BioAssays" />
198    <t:tab id="spotdata" title="Spot data" >
199    <tbl:table 
200      id="spotdata" 
201      columns="<%=cc.getSetting("columns")%>"
202      sortby="<%=cc.getSortProperty()%>" 
203      direction="<%=cc.getSortDirection()%>"
204      action="index.jsp"
205      sc="<%=sc%>"
206      item="<%=itemType%>"
207      subcontext="<%=subContext%>"
208      filterrows="<%=cc.getFilterRows()%>"
209      subclass="fulltable"
210      stickyheaders="rep.externalId"
211      >
212      <tbl:hidden 
213        name="mode" 
214        value="<%=mode.getName()%>" 
215      />
216      <tbl:hidden 
217        name="bioassayset_id" 
218        value="<%=String.valueOf(bioAssaySetId)%>" 
219      />
220      <tbl:hidden 
221        name="bioassay_id" 
222        value="<%=String.valueOf(bioAssayId)%>" 
223      />
224      <tbl:hidden 
225        name="callback" 
226        value="<%=callback%>" 
227        skip="<%=callback == null%>" 
228      />
229      <%
230      for (TableColumn tc : columns)
231      {
232        %>
233        <tbl:columndef
234          id="<%=tc.getId()%>"
235          property="<%=tc.getProperty()%>"
236          tooltip="<%=tc.getDescription()%>"
237          datatype="<%=tc.getDatatype().getStringValue()%>"
238          title="<%=HTML.encodeTags(tc.getTitle())%>"
239          sortable="<%=tc.getSortable()%>"
240          filterable="<%=tc.getFilterable()%>"
241          exportable="<%=tc.getExportable()%>"
242          show="<%=tc.getShow()%>"
243          formatter="<%=tc.getFormatter()%>"
244        />
245        <%
246      }
247      %>
248      <%
249      if (bioAssay == null)
250      {
251        Map<Number, String> bioAssayMap = new HashMap<Number, String>();
252        Enumeration<String, String> bioAssayEnum = new Enumeration<String, String>();
253        for (BioAssay ba : bioAssaySet.getBioAssays().list(dc))
254        {
255          short columnNo = ba.getDataCubeColumnNo();
256          String linkedBioAssay = Base.getLinkedName(ID, ba, false, true);
257          // Safety measure, since JDBC driver seems to return 'short' as 'int'
258          bioAssayMap.put(columnNo, linkedBioAssay);
259          bioAssayMap.put((int)columnNo, linkedBioAssay);
260          bioAssayEnum.add(String.valueOf(columnNo), HTML.encodeTags(ba.getName()));
261        }
262        %>
263        <tbl:columndef
264          id="COLUMN"
265          property="COLUMN"
266          datatype="int"
267          title="Bioassay"
268          sortable="true"
269          filterable="true"
270          exportable="true"
271          enumeration="<%=bioAssayEnum%>"
272          formatter="<%=new LookupFormatter<Number>(bioAssayMap)%>"
273        />
274        <%
275      }
276      %>
277      <tbl:columndef 
278        id="reporterList"
279        property="£reporterList"
280        datatype="int"
281        title="Reporter list"
282        filterable="true"
283        enumeration="<%=Base.getReporterListsEnum(dc)%>"
284        multiple="false"
285      />
286      <div class="panelgroup bg-filled-50 bottomborder">
287        <tbl:toolbar
288          subclass="bottomborder"
289          visible="<%=mode.hasToolbar()%>"
290          >
291          <tbl:button 
292            id="btnColumns"
293            image="columns.png" 
294            title="Columns&hellip;" 
295            tooltip="Show, hide and re-order columns" 
296          />
297          <tbl:button
298            id="btnNewReporterList"
299            image="add.png"
300            title="New reporter list&hellip;"
301            tooltip="Create a new reporter list from matching spots"
302            visible="<%=sc.hasPermission(Permission.CREATE, Item.REPORTERLIST)%>"
303          />
304          <tbl:button 
305            id="btnExport"
306            data-plugin-type="EXPORT"
307            image="export.png" 
308            title="Export&hellip;" 
309            tooltip="Export data" 
310            visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
311          />
312          <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
313            wrapper="<%=new PrefixSuffixRenderer<ButtonAction>(jspContext, "<td>", "</td>") %>"/>
314        </tbl:toolbar>
315        <tbl:panel>
316          <tbl:presetselector />
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:panel>
324      </div>
325      <tbl:data>
326        <tbl:headers>
327          <tbl:headerrow>
328            <tbl:header clazz="row-index bg-filled-100" />
329            <tbl:columnheaders />
330          </tbl:headerrow>
331          <%
332          int numFilters = cc.getNumPropertyFilters();
333          int numRows = cc.getFilterRows();
334          for (int filterNo = 0; filterNo < numRows; filterNo++)
335          {
336            boolean lastRow = filterNo == numRows-1;
337            %>
338            <tbl:headerrow>
339              <tbl:header subclass="row-index bg-filled-100">
340                <div class="index-<%=mode.getName()%>">
341                  <div class="icons">
342                    <base:icon
343                      subclass="link table-filter-row-action"
344                      image="add.png"
345                      tooltip="Add extra filter row"
346                      visible="<%=lastRow%>"
347                    /><base:icon
348                      subclass="link table-filter-row-action"
349                      image="remove.png"
350                      tooltip="Remove this filter row"
351                      visible="<%=numRows > 1 || numFilters > 0 %>"
352                      data-remove-row="<%=filterNo%>"
353                    />
354                  </div>
355                </div>
356              </tbl:header>
357              <tbl:propertyfilter row="<%=filterNo%>" />
358            </tbl:headerrow>
359            <%
360          }
361          %>
362          <tbl:columnsubtitles />
363        </tbl:headers>
364        <tbl:rows>
365          <%
366          if (cc.getMessage() != null)
367          {
368            %>
369            <tbl:panel subclass="bg-filled-50">
370              <div class="messagecontainer error"><%=cc.getMessage()%></div>
371            </tbl:panel>
372            <%
373            cc.setMessage(null);
374          }
375          int index = cc.getPage()*cc.getRowsPerPage();
376          int selectedItemId = cc.getId();
377          if (spotData != null)
378          {
379            boolean writeReporterPermission = sc.hasPermission(Permission.WRITE, Item.REPORTER);
380            String tooltip = "View this item" + (writeReporterPermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
381            while (spotData.hasNext())
382            {
383              SqlResult item = spotData.next();
384              index++;
385              numListed++;
386              %>
387              <tbl:row>
388                <tbl:header clazz="row-index bg-filled-100">
389                  <div class="index-<%=mode.getName()%>">
390                    <div class="index <%=index>999?"index-smaller":""%>"><%=index%></div>
391                  </div>
392                </tbl:header>
393                <%
394                int i = 1;
395                for (String columnId : selected.selectedIds)
396                {
397                  if (i == externalIdColumn)
398                  {
399                    %>
400                    <tbl:cell column="<%=columnId%>"><div 
401                      class="link auto-init"
402                      data-auto-init="item-link"
403                      data-item-id="<%=item.getInt(reporterIdColumn)%>"
404                      data-item-type="REPORTER"
405                      data-no-edit="<%=writeReporterPermission ? 0 : 1 %>" 
406                      tabindex="0"
407                      title="<%=tooltip%>"><%=HTML.encodeTags(item.getString(i++))%></div></tbl:cell>
408                    <%
409                  }
410                  else
411                  {
412                    %>
413                    <tbl:cell column="<%=columnId%>" value="<%=item.getObject(i++)%>" />
414                    <%
415                  }
416                }
417                %>
418              </tbl:row>
419              <%
420            }
421          }
422          if (numListed == 0)
423          {
424            %>
425            <tbl:panel subclass="bg-filled-50">
426              <div class="messagecontainer note">
427              <%=spotData == null || spotData.getTotalCount() == 0 ? "No spot data were found" : "No spot data on this page. Please select another page!" %>
428              </div>
429            </tbl:panel>
430            <%
431          }
432          %>
433          </tbl:rows>
434        </tbl:data>
435    </tbl:table>
436    </t:tab>
437
438    <t:tab id="bioassayset.overviewplots" title="Overview plots"
439      visible="<%=overviewPlotInvoker != null && overviewPlotInvoker.getNumExtensions() > 0%>" 
440    />
441    </t:tabcontrol>
442
443    <base:buttongroup>
444      <base:button id="btnOk" title="Ok" visible="<%=mode.hasOkButton()%>" />
445      <base:button id="close" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
446      <base:button id="close" title="Close" visible="<%=mode.hasCloseButton()%>" />
447    </base:buttongroup>
448
449  </base:body>
450  </base:page>
451  <%
452}
453finally
454{
455  if (dc != null) dc.close();
456}
457%>
Note: See TracBrowser for help on using the repository browser.