source: trunk/www/common/history/list_history.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: 12.4 KB
Line 
1<%-- $Id: list_history.jsp 5425 2010-09-23 13:30:07Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 3
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  @author Nicklas
23  @version 2.0
24--%>
25<%@ page session="false"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.DbControl"
28  import="net.sf.basedb.core.Item"
29  import="net.sf.basedb.core.BasicItem"
30  import="net.sf.basedb.core.ChangeHistory"
31  import="net.sf.basedb.core.Permission"
32  import="net.sf.basedb.core.Nameable"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.ItemQuery"
35  import="net.sf.basedb.core.ItemResultIterator"
36  import="net.sf.basedb.core.PermissionDeniedException"
37  import="net.sf.basedb.core.PluginDefinition"
38  import="net.sf.basedb.core.query.Orders"
39  import="net.sf.basedb.core.query.Hql"
40  import="net.sf.basedb.core.plugin.GuiContext"
41  import="net.sf.basedb.core.plugin.Plugin"
42  import="net.sf.basedb.core.log.ChangeType"
43  import="net.sf.basedb.util.Values"
44  import="net.sf.basedb.util.Enumeration"
45  import="net.sf.basedb.util.formatter.Formatter"
46  import="net.sf.basedb.clients.web.Base"
47  import="net.sf.basedb.clients.web.ModeInfo"
48  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
49  import="net.sf.basedb.clients.web.util.HTML"
50  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
51  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
52  import="net.sf.basedb.clients.web.extensions.JspContext"
53  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
54  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
55  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
56  import="java.util.List"
57  import="java.util.Date"
58  import="java.util.Map"
59%>
60<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
61<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
62<%!
63  private static final Item itemType = Item.CHANGEHISTORY;
64  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST);
65%>
66<%
67final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
68final String ID = sc.getId();
69final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
70
71final Item sourceType = Item.valueOf(request.getParameter("source_type"));
72final int sourceId = Values.getInt(request.getParameter("source_id"));
73final float scale = Base.getScale(sc);
74final ModeInfo mode = ModeInfo.get(request.getParameter("mode"));
75final String callback = request.getParameter("callback");
76final String title = mode.generateTitle("history entry", "history entries");
77final DbControl dc = sc.newDbControl();
78ItemResultIterator<ChangeHistory> history = null;
79
80try
81{
82  final BasicItem source = sourceType.getById(dc, sourceId); 
83  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
84  try
85  {
86    final ItemQuery<ChangeHistory> query = 
87      Base.getConfiguredQuery(dc, cc, true, ChangeHistory.getHistoryOf(source), mode);
88    query.order(cc.getSortDirection().sortBy(Hql.property("id")));
89    history = query.iterate(dc);
90    //cc.setMessage(query.toString());
91  }
92  catch (Throwable t)
93  {
94    cc.setMessage(t.getMessage());
95    t.printStackTrace();
96  }
97  Formatter<Date> dateFormatter = FormatterFactory.getDateTimeFormatter(sc);
98  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null);
99  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
100  int numListed = 0;
101  %>
102  <base:page type="popup">
103  <base:head scripts="table.js" styles="table.css">
104  </base:head>
105  <base:body style="padding: 0px; background: #E0E0E0">
106    <script language="JavaScript">
107    var submitPage = 'index.jsp';
108    var formId = 'history';
109    function viewItem(itemId)
110    {
111      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, false, '&source_id=<%=sourceId%>&source_type=<%=sourceType.name()%>');
112    }
113    function itemOnClick(evt, itemId)
114    {
115      viewItem(itemId);
116    }
117
118    function configureColumns()
119    {
120      Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
121    }
122    function presetOnChange()
123    {
124      Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>');
125    }
126    function returnSelected()
127    {
128      Table.returnSelected(formId, <%=callback != null ? "window.opener."+callback : "null" %>);
129      window.close();
130    }
131    function runPlugin(cmd)
132    {
133      Table.submitToPopup(formId, cmd, 740, 540);
134    }
135    </script>
136    <%
137    if (cc.getMessage() != null)
138    {
139      %>
140      <div class="error"><%=cc.getMessage()%></div>
141      <%
142      cc.setMessage(null);
143    }
144    %>
145    <tbl:table 
146      id="history" 
147      clazz="itemlist" 
148      columns="<%=cc.getSetting("columns")%>"
149      sortby="<%=cc.getSortProperty()%>" 
150      direction="<%=cc.getSortDirection()%>"
151      title="<%=title%>"
152      action="index.jsp"
153      sc="<%=sc%>"
154      item="<%=itemType%>"
155      >
156      <tbl:hidden 
157        name="source_id"
158        value="<%=String.valueOf(sourceId)%>" 
159      />
160      <tbl:hidden 
161        name="source_type" 
162        value="<%=sourceType.name()%>" 
163      />
164      <tbl:columndef 
165         id="id"
166        clazz="uniquecol"
167         property="id"
168         datatype="int"
169         title="ID"
170         sortable="true" 
171         filterable="true"
172         exportable="true"
173      />
174      <tbl:columndef 
175        id="time"
176        property="$hst.time"
177        exportproperty="changeHistory.time"
178        datatype="timestamp"
179        title="Time"
180        sortable="true" 
181        filterable="true"
182        exportable="true"
183        show="always" 
184      />
185      <%
186      Enumeration<String, String> types = new Enumeration<String, String>();
187      for (ChangeType ct : ChangeType.values())
188      {
189        types.add(Integer.toString(ct.getValue()), ct.toString());
190      }
191      %>
192      <tbl:columndef 
193        id="changeType"
194        property="changeType"
195        datatype="int"
196        title="Type"
197        sortable="true" 
198        filterable="true"
199        exportable="true"
200        enumeration="<%=types%>"
201      />
202      <tbl:columndef 
203        id="user"
204        property="$hst.user.name"
205        exportproperty="changeHistory.user.name"
206        datatype="string"
207        title="User"
208        sortable="true" 
209        filterable="true"
210        exportable="true"
211      />
212      <tbl:columndef 
213        id="session"
214        property="$hst.session.loginTime"
215        exportproperty="changeHistory.session.loginTime"
216        datatype="date"
217        title="Session"
218        sortable="true" 
219        filterable="true"
220        exportable="true"
221      />
222      <tbl:columndef 
223        id="client"
224        property="$hst.client.name"
225        exportproperty="changeHistory.client.name"
226        datatype="string"
227        title="Client"
228        sortable="true" 
229        filterable="true"
230        exportable="true"
231      />
232      <tbl:columndef 
233        id="project"
234        property="$hst.project.name"
235        exportproperty="changeHistory.project.name"
236        datatype="string"
237        title="Project"
238        sortable="true" 
239        filterable="true"
240        exportable="true"
241      />
242      <tbl:columndef 
243        id="plugin"
244        property="$hst.plugin.name"
245        exportproperty="changeHistory.plugin.name"
246        datatype="string"
247        title="Plugin"
248        sortable="true"
249        filterable="true"
250        exportable="true"
251      />
252      <tbl:columndef 
253        id="job"
254        property="$hst.job.name"
255        exportproperty="changeHistory.job.name"
256        datatype="string"
257        title="Job"
258        sortable="true" 
259        filterable="true"
260        exportable="true"
261      />
262      <tbl:columndef 
263        id="changeInfo"
264        property="changeInfo"
265        datatype="string"
266        title="Change info" 
267        sortable="true" 
268        filterable="true" 
269        exportable="true"
270      />
271      <tbl:toolbar
272        visible="<%=mode.hasToolbar()%>"
273        >
274        <tbl:button 
275          image="columns.gif" 
276          onclick="configureColumns()" 
277          title="Columns&hellip;" 
278          tooltip="Show, hide and re-order columns" 
279        />
280        <tbl:button 
281          image="export.gif" 
282          onclick="runPlugin('ExportItems')" 
283          title="Export&hellip;" 
284          tooltip="Export data" 
285          visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
286        />
287        <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
288          wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
289      </tbl:toolbar>
290      <tbl:navigator
291        page="<%=cc.getPage()%>" 
292        rowsperpage="<%=cc.getRowsPerPage()%>" 
293        totalrows="<%=history == null ? 0 : history.getTotalCount()%>" 
294        visible="<%=mode.hasNavigator()%>"
295      />
296      <tbl:data>
297        <tbl:columns>
298        <tbl:presetselector 
299          clazz="columnheader"
300          colspan="3"
301          onchange="presetOnChange()"
302        />
303        </tbl:columns>
304
305        <tr>
306          <tbl:header 
307            clazz="index"
308            >&nbsp;</tbl:header>
309          <tbl:header 
310            clazz="check" 
311            visible="<%=mode.hasCheck()%>"
312            ><base:icon 
313              image="check_uncheck.gif" 
314              tooltip="Check/uncheck all" 
315              onclick="Forms.checkUncheck(document.forms[formId])" style="align: left;"
316            /></tbl:header>
317          <tbl:header 
318            clazz="check" 
319            visible="<%=mode.hasRadio()%>"
320            >&nbsp;</tbl:header>
321          <tbl:header 
322            clazz="icons" 
323            visible="<%=mode.hasIcons()%>"
324            >&nbsp;</tbl:header>
325          <tbl:propertyfilter />
326        </tr>
327         
328          <tbl:rows>
329          <%
330          int index = cc.getPage()*cc.getRowsPerPage();
331          int selectedItemId = cc.getId();
332          if (history != null)
333          {           
334            while (history.hasNext())
335            {
336              ChangeHistory item = history.next();
337              int itemId = item.getId();
338              String tooltip = mode.isSelectionMode() ? 
339                  "Select this item" : "View this item";
340              index++;
341              numListed++;
342              %>
343              <tbl:row>
344                <tbl:header 
345                  clazz="index"
346                  ><%=index%></tbl:header>
347                <tbl:header 
348                  clazz="check" 
349                  visible="<%=mode.hasCheck()%>"
350                  ><input 
351                    type="checkbox" 
352                    name="<%=itemId%>" 
353                    value="<%=itemId%>" 
354                    <%=cc.getSelected().contains(itemId) ? "checked" : ""%> 
355                  ></tbl:header>
356                <tbl:header 
357                  clazz="check" 
358                  visible="<%=mode.hasRadio()%>"
359                  ><input 
360                    type="radio" 
361                    name="item_id" 
362                    value="<%=itemId%>" 
363                    <%=selectedItemId == itemId ? "checked" : ""%>
364                  ></tbl:header>
365                <tbl:header 
366                  clazz="icons" 
367                  visible="<%=mode.hasIcons()%>"
368                  >&nbsp;</tbl:header>
369                <tbl:cell column="time"><div class="link" 
370                  onclick="itemOnClick(null, <%=itemId%>)" 
371                  title="<%=tooltip%>"><%=dateFormatter.format(item.getTime())%></div></tbl:cell>
372                <tbl:cell column="id"><%=item.getId()%></tbl:cell>
373                <tbl:cell column="changeType"><%=item.getChangeType()%></tbl:cell>
374                <tbl:cell column="changeInfo"><%=HTML.niceFormat(item.getChangeInfo())%></tbl:cell>
375                <tbl:cell column="user"><%=ChangeHistoryUtil.getUser(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
376                <tbl:cell column="session"><%=ChangeHistoryUtil.getSession(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
377                <tbl:cell column="client"><%=ChangeHistoryUtil.getClient(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
378                <tbl:cell column="project"><%=ChangeHistoryUtil.getProject(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
379                <tbl:cell column="plugin"><%=ChangeHistoryUtil.getPlugin(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
380                <tbl:cell column="job"><%=ChangeHistoryUtil.getJob(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell>
381              </tbl:row>
382              <%
383              }
384            }
385          %>
386          </tbl:rows>
387      </tbl:data>
388      <%
389      if (numListed == 0)
390      {
391        %>
392        <tbl:panel><%=history == null || history.getTotalCount() == 0 ? "No history entries were found" : "No history entries on this page. Please select another page!" %></tbl:panel>
393        <%
394      }
395      else
396      {
397        %>
398        <tbl:navigator
399          page="<%=cc.getPage()%>" 
400          rowsperpage="<%=cc.getRowsPerPage()%>" 
401          totalrows="<%=history == null ? 0 : history.getTotalCount()%>" 
402          visible="<%=mode.hasNavigator()%>"
403          locked="true"
404        />
405        <%
406      }
407      %>
408    </tbl:table>
409     
410     
411  </base:body>
412  </base:page>
413  <%
414}
415finally
416{
417  if (dc != null) dc.close();
418}
419
420%>
Note: See TracBrowser for help on using the repository browser.