source: trunk/www/views/experiments/explorer/search/list.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: 10.0 KB
Line 
1<%-- $Id: list.jsp 4302 2008-05-19 12:07:25Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Johan Enell, 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.ItemContext"
33  import="net.sf.basedb.core.BioAssaySet"
34  import="net.sf.basedb.core.Experiment"
35  import="net.sf.basedb.core.RawDataType"
36  import="net.sf.basedb.core.ExtendedProperties"
37  import="net.sf.basedb.core.ExtendedProperty"
38  import="net.sf.basedb.core.DynamicSpotQuery"
39  import="net.sf.basedb.core.DynamicResultIterator"
40  import="net.sf.basedb.core.VirtualColumn"
41  import="net.sf.basedb.core.data.ReporterData"
42  import="net.sf.basedb.core.query.Restrictions"
43  import="net.sf.basedb.core.query.Expressions"
44  import="net.sf.basedb.core.query.Dynamic"
45  import="net.sf.basedb.core.query.Orders"
46  import="net.sf.basedb.core.query.Selects"
47  import="net.sf.basedb.core.query.Aggregations"
48  import="net.sf.basedb.core.query.JoinType"
49  import="net.sf.basedb.core.query.SqlResult"
50  import="net.sf.basedb.clients.web.Base"
51  import="net.sf.basedb.clients.web.DynamicUtil"
52  import="net.sf.basedb.clients.web.ExperimentExplorer"
53  import="net.sf.basedb.clients.web.WebException"
54  import="net.sf.basedb.util.Values"
55  import="net.sf.basedb.clients.web.util.HTML"
56  import="net.sf.basedb.clients.web.taglib.table.TableColumn"
57  import="java.util.Date"
58  import="java.util.Map"
59  import="java.util.HashMap"
60  import="java.util.List"
61  import="java.util.LinkedList"
62%>
63<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
64<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
65<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
66<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
67<%!
68  private static final Item itemType = Item.REPORTER;
69%>
70
71<%
72final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
73final String ID = sc.getId();
74final float scale = Base.getScale(sc);
75final String root = request.getContextPath();
76
77final int bioAssaySetId = Values.getInt(request.getParameter("bioassayset_id"));
78final DbControl dc = sc.newDbControl();
79DynamicResultIterator reporters = null;
80try
81{
82  String title = null;
83  final BioAssaySet bioAssaySet = BioAssaySet.getById(dc, bioAssaySetId);
84  final Experiment experiment = bioAssaySet.getExperiment();
85  final RawDataType rawDataType = experiment.getRawDataType();
86 
87  final ExperimentExplorer explorer = ExperimentExplorer.getExplorer(bioAssaySet);
88  final ItemContext cc = explorer.getAndSetReporterContext(sc, null);
89  final String subContext = cc.getSubContext();
90
91  List<TableColumn> columns = new LinkedList<TableColumn>();
92  DynamicUtil.addReporterColumns(columns, dc, "", "@", "");
93 
94  DynamicUtil.SelectedInfo selected = DynamicUtil.getSelectedColumns(cc, columns, false);
95  Map<String, Integer> selectedIndex = new HashMap<String, Integer>();
96  for (int i = 0; i < selected.selectedIds.size(); ++i)
97  {
98    selectedIndex.put(selected.selectedIds.get(i), i+2);
99  }
100 
101  try
102  {
103    DynamicSpotQuery reporterQuery = explorer.getReporterQuery(dc, selected.selectedProperties);
104    reporters = reporterQuery.iterate(dc);
105  }
106  catch (Throwable t)
107  {
108    cc.setMessage(t.getMessage());
109  }
110  int numListed = 0;
111  %>
112
113  <base:page title="<%=title%>">
114  <base:head scripts="table.js,tabcontrol.js,newjoust.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css,newjoust.css">
115  <script language="JavaScript">
116    var submitPage = 'index.jsp';
117    var formId = 'reporters';
118    function editItem(itemId)
119    {
120      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, true);
121    }
122    function viewItem(itemId)
123    {
124      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, false);
125    }
126    function itemOnClick(evt, itemId)
127    {
128      Table.itemOnClick(formId, evt, itemId, 'DEFAULT', viewItem, editItem, null);
129    }   
130    function configureColumns()
131    {
132      Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>');
133    }
134    function presetOnChange()
135    {
136      Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>', '<%=subContext%>');
137    }
138    function viewReporter(index)
139    {
140      var url = '../view/index.jsp?ID=<%=ID%>&bioassayset_id=<%=bioAssaySetId%>';
141      if (index >= 0)
142      {
143        url += '&cmd=SetReporterIndex&reporterIndex='+index;
144      }
145      location.href = url;
146    }
147
148    function switchTab(tabControlId, tabId)
149    {
150      if (tabId == 'view')
151      {
152        viewReporter(-1);
153      }
154      else
155      {
156        TabControl.setActiveTab(tabControlId, tabId);
157      }
158    }
159  </script>
160  </base:head>
161  <base:body>
162    <p>
163    <p:path>
164      <p:pathelement title="Experiments" href="<%="../../index.jsp?ID="+ID%>" />
165      <p:pathelement title="<%=HTML.encodeTags(experiment.getName())%>" 
166        href="<%="../../bioassaysets/index.jsp?ID="+ID+"&experiment_id="+experiment.getId()%>" />
167      <p:pathelement title="<%=HTML.encodeTags(bioAssaySet.getName())%>" 
168        href="<%="../../bioassaysets/index.jsp?ID="+ID+"&cmd=ViewItem&item_id="+bioAssaySetId%>" />
169      <p:pathelement title="Explorer" />
170    </p:path>
171   
172    <t:tabcontrol id="explorer" switch="switchTab" remember="false" active="search">
173    <t:tab id="search" title="Reporter search">
174    <%
175    if (cc.getMessage() != null)
176    {
177      %>
178      <div class="error"><%=cc.getMessage()%></div>
179      <%
180      cc.setMessage(null);
181    }
182    %>
183    <tbl:table 
184      id="reporters" 
185      clazz="itemlist" 
186      columns="<%=cc.getSetting("columns")%>"
187      sortby="<%=cc.getSortProperty()%>" 
188      direction="<%=cc.getSortDirection()%>"
189      title="<%=title%>"
190      action="index.jsp"
191      sc="<%=sc%>"
192      item="<%=itemType%>"
193      subcontext="<%=subContext%>"
194      >
195      <tbl:hidden 
196        name="bioassayset_id" 
197        value="<%=String.valueOf(bioAssaySetId)%>" 
198      />
199      <tbl:columndef 
200        id="reporterList"
201        property="£reporterList"
202        datatype="int"
203        title="Reporter list"
204        filterable="true"
205        enumeration="<%=Base.getReporterListsEnum(dc)%>"
206        multiple="false"
207      />     
208      <%
209      for (TableColumn tc : columns)
210      {
211        %>
212        <tbl:columndef
213          id="<%=tc.getId()%>"
214          property="<%=tc.getProperty()%>"
215          datatype="<%=tc.getDatatype().getStringValue()%>"
216          title="<%=tc.getTitle()%>"
217          sortable="<%=tc.getSortable()%>"
218          filterable="<%=tc.getFilterable()%>"
219          exportable="<%=tc.getExportable()%>"
220          show="<%=tc.getShow()%>"
221          formatter="<%=tc.getFormatter()%>"
222        />
223        <%
224      }
225      %>
226       
227      <tbl:toolbar>
228        <tbl:button 
229          image="columns.gif" 
230          onclick="configureColumns()" 
231          title="Columns&hellip;" 
232          tooltip="Show, hide and re-order columns" 
233        />
234      </tbl:toolbar>
235      <tbl:navigator
236        page="<%=cc.getPage()%>" 
237        rowsperpage="<%=cc.getRowsPerPage()%>" 
238        totalrows="<%=reporters == null ? 0 : reporters.getTotalCount()%>" 
239      />
240      <tbl:data>
241        <tbl:columns>
242        <tbl:presetselector 
243          clazz="columnheader"
244          colspan="1"
245          onchange="presetOnChange()"
246        />
247        </tbl:columns>
248        <tr>
249          <tbl:header 
250            clazz="icons"
251            >&nbsp;</tbl:header>
252          <tbl:propertyfilter />
253        </tr>
254        <tbl:rows>
255       
256      <%
257      int index = cc.getPage()*cc.getRowsPerPage();
258      if (reporters != null)
259      {
260        while (reporters.hasNext())
261        {
262          SqlResult item = reporters.next();
263          int itemId = item.getInt(1);
264          index++;
265          numListed++;
266          %>
267          <tbl:row>
268            <tbl:header 
269              clazz="icons"
270              ><a href="javascript:viewReporter(<%=index-1%>)"><%=index%></a></tbl:header>
271            <tbl:cell column="name"><div class="link" onclick="itemOnClick(event, <%=itemId%>)" 
272              title="View this item (use CTRL, ALT or SHIFT to edit)"><%=HTML.encodeTags(item.getString(selectedIndex.get("name")))%></div></tbl:cell>
273            <tbl:cell column="externalId"><tbl:cellvalue value="<%=item.getString(selectedIndex.get("externalId"))%>"/></tbl:cell>
274            <tbl:cell column="symbol"><tbl:cellvalue value="<%=item.getString(selectedIndex.get("symbol"))%>"/></tbl:cell>
275            <tbl:cell column="description"><tbl:cellvalue value="<%=item.getString(selectedIndex.get("description"))%>"/></tbl:cell>
276            <tbl:cell column="lastUpdate"><tbl:cellvalue value="<%=item.getObject(selectedIndex.get("lastUpdate"))%>"/></tbl:cell>
277            <%
278            List<ExtendedProperty> reporterProperties = ExtendedProperties.getProperties("ReporterData");
279            if (reporterProperties != null)
280            {
281              for (ExtendedProperty ep : reporterProperties)
282              {
283                String name = ep.getName();
284                %>
285                <tbl:cell column="<%=name%>"><tbl:cellvalue value="<%=item.getObject(selectedIndex.get(name))%>" /></tbl:cell>
286              <%
287              }
288            }
289            %>
290          </tbl:row>
291          <%
292        }
293      }
294      %>
295      </tbl:rows>
296      </tbl:data>
297      <%
298      if (numListed == 0)
299      {
300        %>
301        <tbl:panel><%=reporters == null || reporters.getTotalCount() == 0 ? "No reporters were found" : "No reporters on this page. Please select another page!" %></tbl:panel>
302        <%
303      }
304      else
305      {
306        %>
307        <tbl:navigator
308          page="<%=cc.getPage()%>" 
309          rowsperpage="<%=cc.getRowsPerPage()%>" 
310          totalrows="<%=reporters == null ? 0 : reporters.getTotalCount()%>"
311          locked="true"
312        />
313        <%
314      }
315      %>
316      </tbl:table>
317    </t:tab>
318
319    <t:tab id="view" title="Reporter view" />
320    </t:tabcontrol>
321
322  </base:body>
323  </base:page>
324  <%
325}
326finally
327{
328  if (reporters != null) reporters.close();
329  if (dc != null) dc.close();
330}
331
332%>
Note: See TracBrowser for help on using the repository browser.