source: trunk/www/views/reporterlists/reporters/list_reporters.jsp @ 5425

Last change on this file since 5425 was 5425, checked in by Nicklas Nordborg, 13 years ago

References #1514: Fix character encoding of jsp files

I hope this fixes most of the issues, including the reporter list filtering in many places. Let's keep an eye open for more issues until it is time to release 2.16

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 17.1 KB
Line 
1<%-- $Id: list_reporters.jsp 5425 2010-09-23 13:30:07Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Johan Enell, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Johan Enell, Nicklas Nordborg
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 modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 3 of the License, or
12  (at your option) any later version.
13 
14  BASE is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  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 session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.SystemItems"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.ItemQuery"
33  import="net.sf.basedb.core.ItemResultList"
34  import="net.sf.basedb.core.ReporterList"
35  import="net.sf.basedb.core.ReporterType"
36  import="net.sf.basedb.core.ReporterScore"
37  import="net.sf.basedb.core.PluginDefinition"
38  import="net.sf.basedb.core.data.ReporterData"
39  import="net.sf.basedb.core.ReporterScoreQuery"
40  import="net.sf.basedb.core.ReporterScoreResultIterator"
41  import="net.sf.basedb.core.ExtendedProperty"
42  import="net.sf.basedb.core.ExtendedProperties"
43  import="net.sf.basedb.core.Permission"
44  import="net.sf.basedb.core.query.Orders"
45  import="net.sf.basedb.core.query.Hql"
46  import="net.sf.basedb.core.plugin.GuiContext"
47  import="net.sf.basedb.core.plugin.Plugin"
48  import="net.sf.basedb.util.Enumeration"
49  import="net.sf.basedb.clients.web.Base"
50  import="net.sf.basedb.clients.web.ModeInfo"
51  import="net.sf.basedb.clients.web.util.HTML"
52  import="net.sf.basedb.util.Values"
53  import="net.sf.basedb.util.formatter.Formatter"
54  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
55  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
56  import="net.sf.basedb.clients.web.extensions.JspContext"
57  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
58  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
59  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
60  import="java.util.Date"
61  import="java.util.Map"
62  import="java.util.List"
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<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
69<%!
70  private static final Item itemType = Item.REPORTERSCORE;
71  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
72%>
73<%
74final int reporterListId = Values.getInt(request.getParameter("reporterlist_id"));
75final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType);
76final String ID = sc.getId();
77
78final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
79
80final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
81final String callback = request.getParameter("callback");
82final String title = mode.generateTitle("reporter", "reporters");
83final DbControl dc = sc.newDbControl();
84ReporterScoreResultIterator reporters = null;
85ItemResultList<ReporterType> reporterTypes = null;
86try
87{
88  final ReporterList reporterList = ReporterList.getById(dc, reporterListId);
89  final boolean createPermission = reporterList.hasPermission(Permission.WRITE);
90  final boolean writePermission = createPermission;
91  final boolean deletePermission = createPermission;
92
93  final ReporterScoreQuery query = reporterList.getReporterScores();
94  query.join(Hql.innerJoin(null, "reporter", "rpt", true));
95  final ItemQuery<ReporterType> typeQuery = ReporterType.getQuery();
96  typeQuery.order(Orders.asc(Hql.property("name")));
97  typeQuery.setCacheResult(true);
98  List<ExtendedProperty> reporterProperties = ExtendedProperties.getProperties("ReporterData");
99  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
100
101  try
102  {
103    cc.configureQuery(dc, query, true);
104    reporters = query.iterate(dc);
105  }
106  catch (Throwable t)
107  {
108    cc.setMessage(t.getMessage());
109    t.printStackTrace();
110  }
111  int numListed = 0;
112  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
113  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
114  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, reporterList);
115  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
116  %>
117  <base:page title="<%=title%>" type="<%=mode.getPageType()%>">
118  <base:head scripts="table.js,tabcontrol.js" styles="table.css,headertabcontrol.css,path.css">
119    <ext:scripts context="<%=jspContext%>" />
120    <ext:stylesheets context="<%=jspContext%>" />
121    <script language="JavaScript">
122    var submitPage = 'index.jsp';
123    var formId = 'reporters';
124    function editItem(itemId)
125    {
126      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, true);
127    }
128    function viewItem(itemId)
129    {
130      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, false);
131    }
132    function itemOnClick(evt, itemId)
133    {
134      Table.itemOnClick(formId, evt, itemId, '<%=mode.getName()%>', viewItem, editItem, returnSelected);
135    }
136    function addItems()
137    {
138      Main.openPopup('add_reporters_frameset.jsp?ID=<%=ID%>&reporterlist_id=<%=reporterListId%>', 'AddReporters', 1000, 700);
139    }
140    function deleteItems()
141    {
142      var frm = document.forms[formId];
143      var numChecked = Forms.numChecked(frm);
144      if (numChecked == 0)
145      {
146        alert('Please select at least one item in the list');
147        return;
148      }
149      else
150      {
151        var rep = numChecked == 1 ? 'reporter' : 'reporters';
152        if (!confirm('You are about to delete '+numChecked+' '+rep+' from the reporter list. This can\'t be undone. Continue?'))
153        {
154          return;
155        }
156      }
157      frm.action = submitPage;
158      frm.cmd.value = 'DeleteItems';
159      frm.submit();
160    }
161    function configureColumns()
162    {
163      Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
164    }
165    function runPlugin(cmd)
166    {
167      Table.submitToPopup(formId, cmd, 740, 540);
168    }
169    function returnSelected()
170    {
171      Table.returnSelected(formId, <%=callback != null ? "window.opener."+callback : "null" %>);
172      window.close();
173    }
174    function presetOnChange()
175    {
176      Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
177    }
178    function switchTab(tabControlId, tabId)
179    {
180      if (tabId == 'properties')
181      {
182        location.href = '../index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=reporterListId%>&tab='+tabId;
183      }
184      else
185      {
186        TabControl.setActiveTab(tabControlId, tabId);
187      }
188    }
189    </script>
190  </base:head>
191 
192  <base:body>
193  <p>
194    <p:path>
195      <p:pathelement title="Reporter lists" href="<%="../index.jsp?ID="+ID%>" />
196      <p:pathelement title="<%=HTML.encodeTags(reporterList.getName())%>" />
197    </p:path>
198 
199    <t:tabcontrol id="main" active="reporters" switch="switchTab">
200    <t:tab id="properties" title="Properties" />
201   
202    <t:tab id="reporters" title="Reporters">
203
204    <%
205    if (cc.getMessage() != null)
206    {
207      %>
208      <div class="error"><%=cc.getMessage()%></div>
209      <%
210      cc.setMessage(null);
211    }
212    %>
213    <tbl:table 
214      id="reporters" 
215      clazz="itemlist" 
216      columns="<%=cc.getSetting("columns")%>"
217      sortby="<%=cc.getSortProperty()%>" 
218      direction="<%=cc.getSortDirection()%>"
219      title="<%=title%>"
220      action="index.jsp"
221      sc="<%=sc%>"
222      item="<%=itemType%>"
223      >
224      <tbl:hidden 
225        name="mode" 
226        value="<%=mode.getName()%>" 
227      />
228      <tbl:hidden 
229        name="callback" 
230        value="<%=callback%>" 
231        skip="<%=callback == null%>" 
232      />
233      <tbl:hidden 
234        name="reporterlist_id" 
235        value="<%=String.valueOf(reporterListId)%>" 
236      />
237      <tbl:columndef 
238        id="externalId"
239        clazz="uniquecol"
240        property="reporter.externalId"
241        datatype="string"
242        title="External ID"
243        sortable="true" 
244        filterable="true"
245        exportable="true"
246      />
247      <tbl:columndef 
248        id="name"
249        property="reporter.name"
250        datatype="string"
251        title="Name"
252        sortable="true" 
253        filterable="true"
254        exportable="true"
255        show="always" 
256      />
257      <tbl:columndef 
258        id="id"
259        clazz="uniquecol"
260        property="reporter.id"
261        datatype="int"
262        title="ID"
263        sortable="true"
264        filterable="true"
265        exportable="true"
266      />
267      <tbl:columndef 
268        id="score"
269        property="score"
270        datatype="float"
271        title="Score"
272        sortable="true" 
273        filterable="true"
274        exportable="true"
275      />
276      <tbl:columndef 
277        id="symbol"
278        property="reporter.symbol"
279        datatype="string"
280        title="Gene symbol"
281        sortable="true" 
282        filterable="true"
283        exportable="true"
284      />
285      <tbl:columndef 
286        id="description"
287        property="reporter.description"
288        datatype="string"
289        title="Description" 
290        sortable="true" 
291        filterable="true" 
292        exportable="true"
293      />
294      <tbl:columndef
295        id="reporterList"
296        property="$rpt.£reporterListScores"
297        datatype="int"
298        title="Reporter list"
299        filterable="true"
300        enumeration="<%=Base.getReporterListsEnum(dc)%>"
301        multiple="false"
302      />
303      <tbl:columndef 
304        id="entryDate"
305        property="reporter.entryDate"
306        datatype="date"
307        title="Registered"
308        sortable="true" 
309        filterable="true"
310        exportable="true"
311        formatter="<%=dateFormatter%>"
312      />
313      <tbl:columndef 
314        id="lastUpdate"
315        property="reporter.lastUpdate"
316        datatype="timestamp"
317        title="Last update" 
318        sortable="true" 
319        filterable="true" 
320        exportable="true"
321        formatter="<%=dateTimeFormatter%>"
322      />
323      <%
324      if (reporterProperties != null)
325      {
326        for (ExtendedProperty ep : reporterProperties)
327        {
328          String name = ep.getName();
329          %>
330          <tbl:columndef
331            id="<%=name%>"
332            property="<%="reporter."+name%>"
333            datatype="<%=ep.getType().getStringValue()%>"
334            title="<%=HTML.encodeTags(ep.getTitle())%>"
335            sortable="true"
336            filterable="true"
337            exportable="true"
338            formatter="<%=FormatterFactory.getExtendedPropertyFormatter(sc, ep)%>"
339          />
340          <%
341        }
342      }
343      Enumeration<String, String> types = new Enumeration<String, String>();
344      reporterTypes = typeQuery.list(dc);
345      types.add("", "- none -");
346      for (ReporterType rt : reporterTypes)
347      {
348        types.add(Integer.toString(rt.getId()), HTML.encodeTags(rt.getName()));
349      }
350      %>
351      <tbl:columndef 
352        id="reporterType"
353        property="reporter.reporterType"
354        sortproperty="reporter.reporterType.name"
355        exportproperty="reporter.reporterType.name"
356        datatype="int"
357        enumeration="<%=types%>"
358        title="Type"
359        sortable="true" 
360        filterable="true"
361        exportable="true"
362      />
363      <tbl:toolbar
364        visible="<%=mode.hasToolbar()%>"
365        >
366        <tbl:button 
367          disabled="<%=writePermission ? false : true%>" 
368          image="<%=writePermission ? "add.png" : "add_disabled.png"%>" 
369          onclick="addItems()" 
370          title="Add&hellip;" 
371          tooltip="<%=writePermission ? "Add reporters to this list" : "You do not have permission to add reporters" %>" 
372        />
373        <tbl:button 
374          disabled="<%=deletePermission ? false : true%>" 
375          image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
376          onclick="deleteItems()" 
377          title="Remove&hellip;" 
378          tooltip="<%=deletePermission ? "Remove the selected items from this list" : "You do not have permission to remove reporters" %>" 
379        />
380        <tbl:button 
381          image="columns.gif" 
382          onclick="configureColumns()" 
383          title="Columns&hellip;" 
384          tooltip="Show, hide and re-order columns" 
385        />
386        <tbl:button 
387          image="import.gif" 
388          onclick="runPlugin('ImportItems')" 
389          title="Import&hellip;" 
390          tooltip="Import data" 
391          visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
392        />
393        <tbl:button 
394          image="export.gif" 
395          onclick="runPlugin('ExportItems')" 
396          title="Export&hellip;" 
397          tooltip="Export data" 
398          visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
399        />
400        <tbl:button 
401          image="runplugin.gif" 
402          onclick="runPlugin('RunListPlugin')" 
403          title="Run plugin&hellip;" 
404          tooltip="Run a plugin" 
405          visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
406        />
407        <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
408          wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
409      </tbl:toolbar>
410      <tbl:navigator
411        page="<%=cc.getPage()%>" 
412        rowsperpage="<%=cc.getRowsPerPage()%>" 
413        totalrows="<%=reporters == null ? 0 : reporters.getTotalCount()%>" 
414        visible="<%=mode.hasNavigator()%>"
415      />
416      <tbl:data>
417        <tbl:columns>
418        <tbl:presetselector 
419          clazz="columnheader"
420          colspan="3"
421          onchange="presetOnChange()"
422        />
423        </tbl:columns>
424        <tr>
425          <tbl:header 
426            clazz="index"
427            >&nbsp;</tbl:header>
428          <tbl:header 
429            clazz="check" 
430            visible="<%=mode.hasCheck()%>"
431            ><base:icon 
432              image="check_uncheck.gif" 
433              tooltip="Check/uncheck all" 
434              onclick="Forms.checkUncheck(document.forms[formId])" style="align: left;"
435            /></tbl:header>
436          <tbl:header 
437            clazz="check" 
438            visible="<%=mode.hasRadio()%>"
439            >&nbsp;</tbl:header>
440          <tbl:header 
441            clazz="icons" 
442            visible="<%=mode.hasIcons()%>"
443            >&nbsp;</tbl:header>
444          <tbl:propertyfilter />
445        </tr>
446          <tbl:rows>
447          <%
448          int index = cc.getPage()*cc.getRowsPerPage();
449          int selectedItemId = cc.getId();
450          if (reporters != null)
451          {           
452            while (reporters.hasNext())
453            {
454              ReporterScore score = reporters.next();
455              ReporterData item = score.getReporter();
456              int itemId = item.getId();
457              String name = HTML.encodeTags(item.getName());
458              String tooltip = mode.isSelectionMode() ?
459                  "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : "");
460              index++;
461              numListed++;
462              %>
463              <tbl:row>
464                <tbl:header 
465                  clazz="index"
466                  ><%=index%></tbl:header>
467                <tbl:header 
468                  clazz="check" 
469                  visible="<%=mode.hasCheck()%>"
470                  ><input 
471                    type="checkbox" 
472                    name="<%=itemId%>" 
473                    value="<%=itemId%>" 
474                    title="<%=name%>" 
475                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
476                  ></tbl:header>
477                <tbl:header 
478                  clazz="check" 
479                  visible="<%=mode.hasRadio()%>"
480                  ><input 
481                    type="radio" 
482                    name="item_id" 
483                    value="<%=itemId%>" 
484                    title="<%=name%>" 
485                    <%=selectedItemId == itemId ? "checked" : ""%>
486                  ></tbl:header>
487                <tbl:header 
488                  clazz="icons" 
489                  visible="<%=mode.hasIcons()%>"
490                  >&nbsp;</tbl:header>
491                <tbl:cell column="name"><div class="link" 
492                  onclick="itemOnClick(<%=writePermission ? "event" : null%>, <%=itemId%>)" 
493                  title="<%=tooltip%>"><%=name%></div></tbl:cell>
494                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
495                <tbl:cell column="externalId"><%=HTML.encodeTags(item.getExternalId())%></tbl:cell>
496                <tbl:cell column="score"><%=Values.formatNumber(score.getScore(), 2)%></tbl:cell>
497                <tbl:cell column="symbol"><%=HTML.encodeTags(item.getSymbol())%></tbl:cell>
498                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
499                <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" />
500                <tbl:cell column="lastUpdate" value="<%=item.getLastUpdate()%>" />
501                <tbl:cell column="reporterType"><base:propertyvalue dbcontrol="<%=dc%>" item="<%=item%>" property="reporterType.name" /></tbl:cell>
502                <%
503                if (reporterProperties != null)
504                {
505                  for (ExtendedProperty ep : reporterProperties)
506                  {
507                    name = ep.getName();
508                    %>
509                    <tbl:cell column="<%=name%>"><tbl:cellvalue value="<%=item.getExtended(name)%>" /></tbl:cell>
510                    <%
511                  }
512                }
513                %>
514              </tbl:row>
515              <%
516            }
517          }
518          %>
519          </tbl:rows>
520      </tbl:data>
521      <%
522      if (numListed == 0)
523      {
524        %>
525        <tbl:panel><%=reporters == null || reporters.getTotalCount() == 0 ? "No reporters were found" : "No reporters on this page. Please select another page!" %></tbl:panel>
526        <%
527      }
528      else
529      {
530        %>
531        <tbl:navigator
532          page="<%=cc.getPage()%>" 
533          rowsperpage="<%=cc.getRowsPerPage()%>" 
534          totalrows="<%=reporters == null ? 0 : reporters.getTotalCount()%>" 
535          visible="<%=mode.hasNavigator()%>"
536          locked="true"
537        />
538        <%
539      }
540      %>
541    </tbl:table>
542    <base:buttongroup align="center" clazz="fixedatbottom">
543      <base:button onclick="returnSelected();" title="Ok" visible="<%=mode.hasOkButton()%>" />
544      <base:button onclick="window.close();" title="Cancel" visible="<%=mode.hasCancelButton()%>" />
545      <base:button onclick="window.close();" title="Close" visible="<%=mode.hasCloseButton()%>" />
546    </base:buttongroup>
547
548    </t:tab>
549    </t:tabcontrol>
550
551  </base:body>
552  </base:page>
553  <%
554}
555finally
556{
557  if (reporters != null) reporters.close();
558  if (dc != null) dc.close();
559}
560%>
Note: See TracBrowser for help on using the repository browser.