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

Last change on this file since 5426 was 5426, checked in by Nicklas Nordborg, 11 years ago

References #1514: Fix character encoding of jsp files

  • Add pageEncoding="UTF-8" to all JSP files.
  • Add @charset="UTF-8"; to all CSS files.
  • Add charset="UTF-8" to all <script> tags

This should at least make Eclipse happy and hopefully allow other editors to automatically select the correct encoding.

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