1 | <%-- $Id: list_history.jsp 6707 2015-02-02 13:20:03Z 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 pageEncoding="UTF-8" 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.clients.web.extensions.list.ListColumnUtil" |
---|
56 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
57 | import="java.util.List" |
---|
58 | import="java.util.Date" |
---|
59 | import="java.util.Map" |
---|
60 | %> |
---|
61 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
62 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
63 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
64 | <%! |
---|
65 | private static final Item itemType = Item.CHANGEHISTORY; |
---|
66 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST); |
---|
67 | %> |
---|
68 | <% |
---|
69 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
70 | final String ID = sc.getId(); |
---|
71 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
72 | |
---|
73 | final Item sourceType = Item.valueOf(request.getParameter("source_type")); |
---|
74 | final int sourceId = Values.getInt(request.getParameter("source_id")); |
---|
75 | final float scale = Base.getScale(sc); |
---|
76 | final ModeInfo mode = ModeInfo.get(request.getParameter("mode")); |
---|
77 | final String callback = request.getParameter("callback"); |
---|
78 | final String title = mode.generateTitle("history entry", "history entries"); |
---|
79 | final DbControl dc = sc.newDbControl(); |
---|
80 | ItemResultIterator<ChangeHistory> history = null; |
---|
81 | |
---|
82 | try |
---|
83 | { |
---|
84 | final BasicItem source = sourceType.getById(dc, sourceId); |
---|
85 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
86 | try |
---|
87 | { |
---|
88 | final ItemQuery<ChangeHistory> query = |
---|
89 | Base.getConfiguredQuery(dc, cc, true, ChangeHistory.getHistoryOf(source), mode); |
---|
90 | query.order(cc.getSortDirection().sortBy(Hql.property("id"))); |
---|
91 | history = query.iterate(dc); |
---|
92 | //cc.setMessage(query.toString()); |
---|
93 | } |
---|
94 | catch (Throwable t) |
---|
95 | { |
---|
96 | cc.setMessage(t.getMessage()); |
---|
97 | t.printStackTrace(); |
---|
98 | } |
---|
99 | Formatter<Date> dateFormatter = FormatterFactory.getDateTimeFormatter(sc); |
---|
100 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null); |
---|
101 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
102 | ExtensionsInvoker columnsInvoker = ListColumnUtil.useExtensions(jspContext); |
---|
103 | int numListed = 0; |
---|
104 | %> |
---|
105 | <base:page type="iframe" id="list-history"> |
---|
106 | <base:head scripts="table.js,~history.js" styles="table.css,toolbar.css"> |
---|
107 | <ext:scripts context="<%=jspContext%>" /> |
---|
108 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
109 | </base:head> |
---|
110 | <base:body> |
---|
111 | <tbl:table |
---|
112 | id="history" |
---|
113 | columns="<%=cc.getSetting("columns")%>" |
---|
114 | sortby="<%=cc.getSortProperty()%>" |
---|
115 | direction="<%=cc.getSortDirection()%>" |
---|
116 | action="index.jsp" |
---|
117 | sc="<%=sc%>" |
---|
118 | item="<%=itemType%>" |
---|
119 | filterrows="<%=cc.getFilterRows()%>" |
---|
120 | subclass="fulltable" |
---|
121 | > |
---|
122 | <tbl:hidden |
---|
123 | name="source_id" |
---|
124 | value="<%=String.valueOf(sourceId)%>" |
---|
125 | /> |
---|
126 | <tbl:hidden |
---|
127 | name="source_type" |
---|
128 | value="<%=sourceType.name()%>" |
---|
129 | /> |
---|
130 | <tbl:columndef |
---|
131 | id="id" |
---|
132 | clazz="uniquecol" |
---|
133 | property="id" |
---|
134 | datatype="int" |
---|
135 | title="ID" |
---|
136 | sortable="true" |
---|
137 | filterable="true" |
---|
138 | exportable="true" |
---|
139 | /> |
---|
140 | <tbl:columndef |
---|
141 | id="time" |
---|
142 | property="$hst.time" |
---|
143 | exportproperty="changeHistory.time" |
---|
144 | datatype="timestamp" |
---|
145 | title="Time" |
---|
146 | sortable="true" |
---|
147 | filterable="true" |
---|
148 | exportable="true" |
---|
149 | show="always" |
---|
150 | /> |
---|
151 | <% |
---|
152 | Enumeration<String, String> types = new Enumeration<String, String>(); |
---|
153 | for (ChangeType ct : ChangeType.values()) |
---|
154 | { |
---|
155 | types.add(Integer.toString(ct.getValue()), ct.toString()); |
---|
156 | } |
---|
157 | %> |
---|
158 | <tbl:columndef |
---|
159 | id="changeType" |
---|
160 | property="changeType" |
---|
161 | datatype="int" |
---|
162 | title="Type" |
---|
163 | sortable="true" |
---|
164 | filterable="true" |
---|
165 | exportable="true" |
---|
166 | enumeration="<%=types%>" |
---|
167 | /> |
---|
168 | <tbl:columndef |
---|
169 | id="user" |
---|
170 | property="$hst.user.name" |
---|
171 | exportproperty="changeHistory.user.name" |
---|
172 | datatype="string" |
---|
173 | title="User" |
---|
174 | sortable="true" |
---|
175 | filterable="true" |
---|
176 | exportable="true" |
---|
177 | /> |
---|
178 | <tbl:columndef |
---|
179 | id="session" |
---|
180 | property="$hst.session.loginTime" |
---|
181 | exportproperty="changeHistory.session.loginTime" |
---|
182 | datatype="date" |
---|
183 | title="Session" |
---|
184 | sortable="true" |
---|
185 | filterable="true" |
---|
186 | exportable="true" |
---|
187 | /> |
---|
188 | <tbl:columndef |
---|
189 | id="client" |
---|
190 | property="$hst.client.name" |
---|
191 | exportproperty="changeHistory.client.name" |
---|
192 | datatype="string" |
---|
193 | title="Client" |
---|
194 | sortable="true" |
---|
195 | filterable="true" |
---|
196 | exportable="true" |
---|
197 | /> |
---|
198 | <tbl:columndef |
---|
199 | id="project" |
---|
200 | property="$hst.project.name" |
---|
201 | exportproperty="changeHistory.project.name" |
---|
202 | datatype="string" |
---|
203 | title="Project" |
---|
204 | sortable="true" |
---|
205 | filterable="true" |
---|
206 | exportable="true" |
---|
207 | /> |
---|
208 | <tbl:columndef |
---|
209 | id="plugin" |
---|
210 | property="$hst.plugin.name" |
---|
211 | exportproperty="changeHistory.plugin.name" |
---|
212 | datatype="string" |
---|
213 | title="Plugin" |
---|
214 | sortable="true" |
---|
215 | filterable="true" |
---|
216 | exportable="true" |
---|
217 | /> |
---|
218 | <tbl:columndef |
---|
219 | id="job" |
---|
220 | property="$hst.job.name" |
---|
221 | exportproperty="changeHistory.job.name" |
---|
222 | datatype="string" |
---|
223 | title="Job" |
---|
224 | sortable="true" |
---|
225 | filterable="true" |
---|
226 | exportable="true" |
---|
227 | /> |
---|
228 | <tbl:columndef |
---|
229 | id="changeInfo" |
---|
230 | property="changeInfo" |
---|
231 | datatype="string" |
---|
232 | title="Change info" |
---|
233 | sortable="true" |
---|
234 | filterable="true" |
---|
235 | exportable="true" |
---|
236 | /> |
---|
237 | <% |
---|
238 | if (sc.hasPermission(Permission.READ, Item.CHANGEHISTORY_VALUES)) |
---|
239 | { |
---|
240 | %> |
---|
241 | <tbl:columndef |
---|
242 | id="oldValue" |
---|
243 | property="oldValue" |
---|
244 | datatype="string" |
---|
245 | title="Old value" |
---|
246 | sortable="true" |
---|
247 | filterable="true" |
---|
248 | exportable="true" |
---|
249 | /> |
---|
250 | <tbl:columndef |
---|
251 | id="newValue" |
---|
252 | property="newValue" |
---|
253 | datatype="string" |
---|
254 | title="New value" |
---|
255 | sortable="true" |
---|
256 | filterable="true" |
---|
257 | exportable="true" |
---|
258 | /> |
---|
259 | <% |
---|
260 | } |
---|
261 | %> |
---|
262 | <tbl:columndef |
---|
263 | id="xt-columns" |
---|
264 | extensions="<%=columnsInvoker%>" |
---|
265 | jspcontext="<%=jspContext%>" |
---|
266 | /> |
---|
267 | <div class="panelgroup bg-filled-50 bottomborder"> |
---|
268 | <tbl:toolbar |
---|
269 | visible="<%=mode.hasToolbar()%>" |
---|
270 | subclass="bottomborder" |
---|
271 | > |
---|
272 | <tbl:button |
---|
273 | id="btnColumns" |
---|
274 | image="columns.png" |
---|
275 | title="Columns…" |
---|
276 | tooltip="Show, hide and re-order columns" |
---|
277 | /> |
---|
278 | <tbl:button |
---|
279 | id="btnExport" |
---|
280 | data-plugin-type="EXPORT" |
---|
281 | image="export.png" |
---|
282 | title="Export…" |
---|
283 | tooltip="Export data" |
---|
284 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
285 | /> |
---|
286 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
287 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
288 | </tbl:toolbar> |
---|
289 | <tbl:panel> |
---|
290 | <tbl:presetselector /> |
---|
291 | <tbl:navigator |
---|
292 | page="<%=cc.getPage()%>" |
---|
293 | rowsperpage="<%=cc.getRowsPerPage()%>" |
---|
294 | totalrows="<%=history == null ? 0 : history.getTotalCount()%>" |
---|
295 | visible="<%=mode.hasNavigator()%>" |
---|
296 | /> |
---|
297 | </tbl:panel> |
---|
298 | </div> |
---|
299 | <tbl:data> |
---|
300 | <tbl:headers> |
---|
301 | <tbl:headerrow> |
---|
302 | <tbl:header colspan="3" /> |
---|
303 | <tbl:columnheaders /> |
---|
304 | </tbl:headerrow> |
---|
305 | <% |
---|
306 | int numFilters = cc.getNumPropertyFilters(); |
---|
307 | int numRows = cc.getFilterRows(); |
---|
308 | for (int filterNo = 0; filterNo < numRows; filterNo++) |
---|
309 | { |
---|
310 | boolean lastRow = filterNo == numRows-1; |
---|
311 | %> |
---|
312 | <tbl:headerrow> |
---|
313 | <tbl:header subclass="index" /> |
---|
314 | <tbl:header |
---|
315 | subclass="check" |
---|
316 | visible="<%=mode.hasCheck()%>" |
---|
317 | ><base:icon |
---|
318 | id="check.uncheck" |
---|
319 | image="check_uncheck.png" |
---|
320 | tooltip="Check/uncheck all" |
---|
321 | visible="<%=lastRow%>" |
---|
322 | /></tbl:header> |
---|
323 | <tbl:header |
---|
324 | subclass="check" |
---|
325 | visible="<%=mode.hasRadio()%>" |
---|
326 | /> |
---|
327 | <tbl:header |
---|
328 | subclass="icons" |
---|
329 | visible="<%=mode.hasIcons()%>" |
---|
330 | > |
---|
331 | <base:icon |
---|
332 | subclass="link table-filter-row-action" |
---|
333 | image="add.png" |
---|
334 | tooltip="Add extra filter row" |
---|
335 | visible="<%=lastRow%>" |
---|
336 | /><base:icon |
---|
337 | subclass="link table-filter-row-action" |
---|
338 | image="remove.png" |
---|
339 | tooltip="Remove this filter row" |
---|
340 | visible="<%=numRows > 1 || numFilters > 0 %>" |
---|
341 | data-remove-row="<%=filterNo%>" |
---|
342 | /> |
---|
343 | </tbl:header> |
---|
344 | <tbl:propertyfilter row="<%=filterNo%>" /> |
---|
345 | </tbl:headerrow> |
---|
346 | <% |
---|
347 | } |
---|
348 | %> |
---|
349 | </tbl:headers> |
---|
350 | <tbl:rows> |
---|
351 | <% |
---|
352 | if (cc.getMessage() != null) |
---|
353 | { |
---|
354 | %> |
---|
355 | <tbl:panel subclass="bg-filled-50"> |
---|
356 | <div class="messagecontainer error"><%=cc.getMessage()%></div> |
---|
357 | </tbl:panel> |
---|
358 | <% |
---|
359 | cc.setMessage(null); |
---|
360 | } |
---|
361 | int index = cc.getPage()*cc.getRowsPerPage(); |
---|
362 | int selectedItemId = cc.getId(); |
---|
363 | if (history != null) |
---|
364 | { |
---|
365 | while (history.hasNext()) |
---|
366 | { |
---|
367 | ChangeHistory item = history.next(); |
---|
368 | int itemId = item.getId(); |
---|
369 | String tooltip = mode.isSelectionMode() ? |
---|
370 | "Select this item" : "View this item"; |
---|
371 | index++; |
---|
372 | numListed++; |
---|
373 | %> |
---|
374 | <tbl:row> |
---|
375 | <tbl:header |
---|
376 | clazz="index" |
---|
377 | ><%=index%></tbl:header> |
---|
378 | <tbl:header |
---|
379 | clazz="check" |
---|
380 | visible="<%=mode.hasCheck()%>" |
---|
381 | ><input |
---|
382 | type="checkbox" |
---|
383 | name="<%=itemId%>" |
---|
384 | value="<%=itemId%>" |
---|
385 | <%=cc.getSelected().contains(itemId) ? "checked" : ""%> |
---|
386 | ></tbl:header> |
---|
387 | <tbl:header |
---|
388 | clazz="check" |
---|
389 | visible="<%=mode.hasRadio()%>" |
---|
390 | ><input |
---|
391 | type="radio" |
---|
392 | name="item_id" |
---|
393 | value="<%=itemId%>" |
---|
394 | <%=selectedItemId == itemId ? "checked" : ""%> |
---|
395 | ></tbl:header> |
---|
396 | <tbl:header |
---|
397 | clazz="icons" |
---|
398 | visible="<%=mode.hasIcons()%>" |
---|
399 | > </tbl:header> |
---|
400 | <tbl:cell column="time"><div |
---|
401 | class="link table-item" |
---|
402 | data-item-id="<%=itemId%>" |
---|
403 | data-no-edit="1" tabindex="0" |
---|
404 | title="<%=tooltip%>"><%=dateFormatter.format(item.getTime())%></div> |
---|
405 | </tbl:cell> |
---|
406 | <tbl:cell column="id"><%=item.getId()%></tbl:cell> |
---|
407 | <tbl:cell column="changeType"><%=item.getChangeType()%></tbl:cell> |
---|
408 | <tbl:cell column="changeInfo"><%=HTML.niceFormat(item.getChangeInfo())%></tbl:cell> |
---|
409 | <tbl:cell column="oldValue"><%=HTML.niceFormat(item.getOldValue())%></tbl:cell> |
---|
410 | <tbl:cell column="newValue"><%=HTML.niceFormat(item.getNewValue())%></tbl:cell> |
---|
411 | <tbl:cell column="user"><%=ChangeHistoryUtil.getUser(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell> |
---|
412 | <tbl:cell column="session"><%=ChangeHistoryUtil.getSession(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell> |
---|
413 | <tbl:cell column="client"><%=ChangeHistoryUtil.getClient(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell> |
---|
414 | <tbl:cell column="project"><%=ChangeHistoryUtil.getProject(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell> |
---|
415 | <tbl:cell column="plugin"><%=ChangeHistoryUtil.getPlugin(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell> |
---|
416 | <tbl:cell column="job"><%=ChangeHistoryUtil.getJob(dc, item, mode.hasPropertyLink(), mode.hasEditLink())%></tbl:cell> |
---|
417 | <tbl:xt-cells dc="<%=dc%>" item="<%=item%>"> |
---|
418 | <tbl:cell column="xt-columns" /> |
---|
419 | </tbl:xt-cells> |
---|
420 | </tbl:row> |
---|
421 | <% |
---|
422 | } |
---|
423 | } |
---|
424 | if (numListed == 0) |
---|
425 | { |
---|
426 | %> |
---|
427 | <tbl:panel subclass="bg-filled-50"> |
---|
428 | <div class="messagecontainer note"> |
---|
429 | <%=history == null || history.getTotalCount() == 0 ? "No history entries were found" : "No history entries on this page. Please select another page!" %> |
---|
430 | </div> |
---|
431 | </tbl:panel> |
---|
432 | <% |
---|
433 | } |
---|
434 | %> |
---|
435 | </tbl:rows> |
---|
436 | </tbl:data> |
---|
437 | </tbl:table> |
---|
438 | |
---|
439 | |
---|
440 | </base:body> |
---|
441 | </base:page> |
---|
442 | <% |
---|
443 | } |
---|
444 | finally |
---|
445 | { |
---|
446 | if (dc != null) dc.close(); |
---|
447 | } |
---|
448 | |
---|
449 | %> |
---|