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

Last change on this file since 6604 was 6604, checked in by Nicklas Nordborg, 9 years ago

References #1890: Improve skinnability of BASE

Updated table listings with some new css classes to make it easier to modify background color.

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