source: trunk/www/views/experiments/explorer/search/list.jsp @ 4306

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

References #1015: Add reporter list from tables that list reporters/reporter info

It is now working from dynamic queries as well.

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