2150 |
05 Apr 06 |
nicklas |
1 |
<%-- $Id$ |
2150 |
05 Apr 06 |
nicklas |
2 |
------------------------------------------------------------------ |
5425 |
23 Sep 10 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg |
2150 |
05 Apr 06 |
nicklas |
4 |
|
2304 |
22 May 06 |
jari |
5 |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
6 |
Available at http://base.thep.lu.se/ |
2150 |
05 Apr 06 |
nicklas |
7 |
|
2150 |
05 Apr 06 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
2150 |
05 Apr 06 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
10 |
as published by the Free Software Foundation; either version 3 |
2150 |
05 Apr 06 |
nicklas |
11 |
of the License, or (at your option) any later version. |
2150 |
05 Apr 06 |
nicklas |
12 |
|
2150 |
05 Apr 06 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
2150 |
05 Apr 06 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2150 |
05 Apr 06 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2150 |
05 Apr 06 |
nicklas |
16 |
GNU General Public License for more details. |
2150 |
05 Apr 06 |
nicklas |
17 |
|
2150 |
05 Apr 06 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
4511 |
11 Sep 08 |
jari |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
2150 |
05 Apr 06 |
nicklas |
20 |
------------------------------------------------------------------ |
2150 |
05 Apr 06 |
nicklas |
21 |
|
2150 |
05 Apr 06 |
nicklas |
22 |
@author Nicklas |
2150 |
05 Apr 06 |
nicklas |
23 |
@version 2.0 |
2150 |
05 Apr 06 |
nicklas |
24 |
--%> |
7604 |
25 Feb 19 |
nicklas |
25 |
<%@page import="net.sf.basedb.core.ReporterScore"%> |
5426 |
24 Sep 10 |
nicklas |
26 |
<%@ page pageEncoding="UTF-8" session="false" |
2150 |
05 Apr 06 |
nicklas |
27 |
import="net.sf.basedb.core.SessionControl" |
2150 |
05 Apr 06 |
nicklas |
28 |
import="net.sf.basedb.core.DbControl" |
2150 |
05 Apr 06 |
nicklas |
29 |
import="net.sf.basedb.core.Item" |
2150 |
05 Apr 06 |
nicklas |
30 |
import="net.sf.basedb.core.ItemContext" |
2428 |
27 Jun 06 |
nicklas |
31 |
import="net.sf.basedb.core.Type" |
2150 |
05 Apr 06 |
nicklas |
32 |
import="net.sf.basedb.core.Reporter" |
2150 |
05 Apr 06 |
nicklas |
33 |
import="net.sf.basedb.core.ReporterList" |
2150 |
05 Apr 06 |
nicklas |
34 |
import="net.sf.basedb.core.ReporterScoreQuery" |
2428 |
27 Jun 06 |
nicklas |
35 |
import="net.sf.basedb.core.DataQuery" |
2428 |
27 Jun 06 |
nicklas |
36 |
import="net.sf.basedb.core.DataResultIterator" |
2150 |
05 Apr 06 |
nicklas |
37 |
import="net.sf.basedb.core.data.ReporterData" |
2428 |
27 Jun 06 |
nicklas |
38 |
import="net.sf.basedb.core.query.Restrictions" |
2428 |
27 Jun 06 |
nicklas |
39 |
import="net.sf.basedb.core.query.Expressions" |
2428 |
27 Jun 06 |
nicklas |
40 |
import="net.sf.basedb.core.query.Hql" |
2150 |
05 Apr 06 |
nicklas |
41 |
import="net.sf.basedb.core.Permission" |
2150 |
05 Apr 06 |
nicklas |
42 |
import="net.sf.basedb.core.PermissionDeniedException" |
2150 |
05 Apr 06 |
nicklas |
43 |
import="net.sf.basedb.clients.web.Base" |
2150 |
05 Apr 06 |
nicklas |
44 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
45 |
import="net.sf.basedb.util.Values" |
2150 |
05 Apr 06 |
nicklas |
46 |
import="net.sf.basedb.clients.web.util.HTML" |
6040 |
30 Mar 12 |
nicklas |
47 |
import="net.sf.basedb.core.plugin.GuiContext" |
6040 |
30 Mar 12 |
nicklas |
48 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
6040 |
30 Mar 12 |
nicklas |
49 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
6040 |
30 Mar 12 |
nicklas |
50 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
6040 |
30 Mar 12 |
nicklas |
51 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
7604 |
25 Feb 19 |
nicklas |
52 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
6040 |
30 Mar 12 |
nicklas |
53 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
2428 |
27 Jun 06 |
nicklas |
54 |
import="java.util.Arrays" |
2150 |
05 Apr 06 |
nicklas |
55 |
%> |
2150 |
05 Apr 06 |
nicklas |
56 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
2150 |
05 Apr 06 |
nicklas |
57 |
<%! |
2150 |
05 Apr 06 |
nicklas |
58 |
private static final ItemContext defaultContext = Base.createDefaultContext("score", "name,score,externalId,symbol,description"); |
2150 |
05 Apr 06 |
nicklas |
59 |
private static final Item itemType = Item.REPORTERSCORE; |
2150 |
05 Apr 06 |
nicklas |
60 |
static |
2150 |
05 Apr 06 |
nicklas |
61 |
{ |
2150 |
05 Apr 06 |
nicklas |
62 |
defaultContext.setSortDirection(ItemContext.SortDirection.DESC); |
2150 |
05 Apr 06 |
nicklas |
63 |
} |
2150 |
05 Apr 06 |
nicklas |
64 |
%> |
2150 |
05 Apr 06 |
nicklas |
65 |
<% |
2150 |
05 Apr 06 |
nicklas |
66 |
final int reporterListId = Values.getInt(request.getParameter("reporterlist_id")); |
2150 |
05 Apr 06 |
nicklas |
67 |
|
2150 |
05 Apr 06 |
nicklas |
68 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
2150 |
05 Apr 06 |
nicklas |
69 |
final String ID = sc.getId(); |
2150 |
05 Apr 06 |
nicklas |
70 |
final String cmd = request.getParameter("cmd"); |
2150 |
05 Apr 06 |
nicklas |
71 |
final String root = request.getContextPath()+"/"; |
2150 |
05 Apr 06 |
nicklas |
72 |
final String mode = request.getParameter("mode"); |
2150 |
05 Apr 06 |
nicklas |
73 |
final String callback = request.getParameter("callback"); |
2150 |
05 Apr 06 |
nicklas |
74 |
final String itemId = request.getParameter("item_id"); |
2150 |
05 Apr 06 |
nicklas |
75 |
final String listPage = "list_reporters.jsp?ID="+ID |
2150 |
05 Apr 06 |
nicklas |
76 |
+"&reporterlist_id="+reporterListId |
2150 |
05 Apr 06 |
nicklas |
77 |
+(mode == null ? "" : "&mode="+mode) |
2150 |
05 Apr 06 |
nicklas |
78 |
+(callback == null ? "" : "&callback="+callback) |
2150 |
05 Apr 06 |
nicklas |
79 |
+(itemId == null ? "" : "&item_id="+itemId); |
2150 |
05 Apr 06 |
nicklas |
80 |
final String viewPage = "view_reporter.jsp?ID="+ID+"&reporterlist_id="+reporterListId; |
2150 |
05 Apr 06 |
nicklas |
81 |
final String editPage = "edit_reporter.jsp?ID="+ID+"&reporterlist_id="+reporterListId; |
2150 |
05 Apr 06 |
nicklas |
82 |
|
2150 |
05 Apr 06 |
nicklas |
83 |
String forward = null; |
2150 |
05 Apr 06 |
nicklas |
84 |
String redirect = null; |
2150 |
05 Apr 06 |
nicklas |
85 |
String message = null; |
2150 |
05 Apr 06 |
nicklas |
86 |
DbControl dc = null; |
2150 |
05 Apr 06 |
nicklas |
87 |
try |
2150 |
05 Apr 06 |
nicklas |
88 |
{ |
2150 |
05 Apr 06 |
nicklas |
89 |
if (cmd == null || "List".equals(cmd)) |
2150 |
05 Apr 06 |
nicklas |
90 |
{ |
2150 |
05 Apr 06 |
nicklas |
91 |
// Display the list page without updatinging the current context |
2811 |
26 Oct 06 |
nicklas |
92 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
2150 |
05 Apr 06 |
nicklas |
93 |
redirect = listPage; |
2150 |
05 Apr 06 |
nicklas |
94 |
} |
2150 |
05 Apr 06 |
nicklas |
95 |
else if ("UpdateContext".equals(cmd)) |
2150 |
05 Apr 06 |
nicklas |
96 |
{ |
2150 |
05 Apr 06 |
nicklas |
97 |
// Display the list page after updating the current context from the request parameters |
2150 |
05 Apr 06 |
nicklas |
98 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2150 |
05 Apr 06 |
nicklas |
99 |
redirect = listPage; |
2150 |
05 Apr 06 |
nicklas |
100 |
} |
2150 |
05 Apr 06 |
nicklas |
101 |
else if ("LoadContext".equals(cmd)) |
2150 |
05 Apr 06 |
nicklas |
102 |
{ |
2150 |
05 Apr 06 |
nicklas |
103 |
// Display the list page after loading a saved context |
2150 |
05 Apr 06 |
nicklas |
104 |
int contextId = Values.getInt(request.getParameter("context")); |
2150 |
05 Apr 06 |
nicklas |
105 |
Base.loadContext(sc, contextId, defaultContext); |
2150 |
05 Apr 06 |
nicklas |
106 |
redirect = listPage; |
2150 |
05 Apr 06 |
nicklas |
107 |
} |
2150 |
05 Apr 06 |
nicklas |
108 |
|
2150 |
05 Apr 06 |
nicklas |
109 |
else if ("DeleteItems".equals(cmd)) |
2150 |
05 Apr 06 |
nicklas |
110 |
{ |
2150 |
05 Apr 06 |
nicklas |
111 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
112 |
dc = sc.newDbControl(":Delete "+itemType); |
2150 |
05 Apr 06 |
nicklas |
113 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2150 |
05 Apr 06 |
nicklas |
114 |
ReporterList reporterList = ReporterList.getById(dc, reporterListId); |
2150 |
05 Apr 06 |
nicklas |
115 |
for (int reporterId : cc.getSelected()) |
2150 |
05 Apr 06 |
nicklas |
116 |
{ |
2150 |
05 Apr 06 |
nicklas |
117 |
reporterList.removeReporter(Reporter.getById(dc, reporterId)); |
2150 |
05 Apr 06 |
nicklas |
118 |
} |
2150 |
05 Apr 06 |
nicklas |
119 |
dc.commit(); |
2150 |
05 Apr 06 |
nicklas |
120 |
redirect = listPage; |
2150 |
05 Apr 06 |
nicklas |
121 |
} |
2150 |
05 Apr 06 |
nicklas |
122 |
else if ("ExportItems".equals(cmd)) |
2150 |
05 Apr 06 |
nicklas |
123 |
{ |
2150 |
05 Apr 06 |
nicklas |
124 |
// Run an export plugin in a list context |
2150 |
05 Apr 06 |
nicklas |
125 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
7954 |
12 May 21 |
nicklas |
126 |
dc = sc.newDbControl(":Export "+itemType); |
2150 |
05 Apr 06 |
nicklas |
127 |
ReporterList reporterList = ReporterList.getById(dc, reporterListId); |
2150 |
05 Apr 06 |
nicklas |
128 |
final ReporterScoreQuery query = reporterList.getReporterScores(); |
5319 |
20 Apr 10 |
nicklas |
129 |
query.join(Hql.innerJoin(null, "reporter", "rpt", true)); |
7914 |
23 Feb 21 |
nicklas |
130 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
131 |
cc.configureQuery(dc, query, jspContext, true); |
2150 |
05 Apr 06 |
nicklas |
132 |
cc.setQuery(query); |
7604 |
25 Feb 19 |
nicklas |
133 |
ExtensionsInvoker<ListColumnAction<ReporterScore,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
134 |
listInvoker.render(new ListColumnExportRenderer<ReporterScore>(cc)); |
6040 |
30 Mar 12 |
nicklas |
135 |
dc.close(); |
2150 |
05 Apr 06 |
nicklas |
136 |
redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+reporters"; |
2150 |
05 Apr 06 |
nicklas |
137 |
} |
2150 |
05 Apr 06 |
nicklas |
138 |
else if ("ImportItems".equals(cmd)) |
2150 |
05 Apr 06 |
nicklas |
139 |
{ |
2150 |
05 Apr 06 |
nicklas |
140 |
// Run an import plugin in a list context |
2150 |
05 Apr 06 |
nicklas |
141 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
7954 |
12 May 21 |
nicklas |
142 |
dc = sc.newDbControl(":Import "+itemType); |
2150 |
05 Apr 06 |
nicklas |
143 |
ReporterList reporterList = ReporterList.getById(dc, reporterListId); |
2150 |
05 Apr 06 |
nicklas |
144 |
final ReporterScoreQuery query = reporterList.getReporterScores(); |
5319 |
20 Apr 10 |
nicklas |
145 |
query.join(Hql.innerJoin(null, "reporter", "rpt", true)); |
7914 |
23 Feb 21 |
nicklas |
146 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
147 |
cc.configureQuery(dc, query, jspContext, true); |
2150 |
05 Apr 06 |
nicklas |
148 |
dc.close(); |
2150 |
05 Apr 06 |
nicklas |
149 |
cc.setQuery(query); |
2150 |
05 Apr 06 |
nicklas |
150 |
redirect = "../../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+reporters"; |
2150 |
05 Apr 06 |
nicklas |
151 |
} |
2150 |
05 Apr 06 |
nicklas |
152 |
else if ("RunListPlugin".equals(cmd)) |
2150 |
05 Apr 06 |
nicklas |
153 |
{ |
2150 |
05 Apr 06 |
nicklas |
154 |
// Run another plugin in a list context |
2150 |
05 Apr 06 |
nicklas |
155 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
7954 |
12 May 21 |
nicklas |
156 |
dc = sc.newDbControl(":Run plugin "+itemType); |
2150 |
05 Apr 06 |
nicklas |
157 |
ReporterList reporterList = ReporterList.getById(dc, reporterListId); |
2150 |
05 Apr 06 |
nicklas |
158 |
final ReporterScoreQuery query = reporterList.getReporterScores(); |
5319 |
20 Apr 10 |
nicklas |
159 |
query.join(Hql.innerJoin(null, "reporter", "rpt", true)); |
7914 |
23 Feb 21 |
nicklas |
160 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
161 |
cc.configureQuery(dc, query, jspContext, true); |
2150 |
05 Apr 06 |
nicklas |
162 |
dc.close(); |
2150 |
05 Apr 06 |
nicklas |
163 |
cc.setQuery(query); |
2150 |
05 Apr 06 |
nicklas |
164 |
redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
2150 |
05 Apr 06 |
nicklas |
165 |
} |
2428 |
27 Jun 06 |
nicklas |
166 |
else if ("AddReporters".equals(cmd)) |
2428 |
27 Jun 06 |
nicklas |
167 |
{ |
7954 |
12 May 21 |
nicklas |
168 |
dc = sc.newDbControl("Add reporters to reporter list"); |
2428 |
27 Jun 06 |
nicklas |
169 |
ReporterList reporterList = ReporterList.getById(dc, reporterListId); |
2428 |
27 Jun 06 |
nicklas |
170 |
ItemContext reporterContext = sc.getCurrentContext(Item.REPORTER); |
2428 |
27 Jun 06 |
nicklas |
171 |
final DataQuery<ReporterData> query = Reporter.getQuery(); |
5590 |
16 Mar 11 |
nicklas |
172 |
reporterContext.configureQuery(dc, query, true); |
2428 |
27 Jun 06 |
nicklas |
173 |
String which = request.getParameter("which"); |
2428 |
27 Jun 06 |
nicklas |
174 |
if ("selected".equals(which)) |
2428 |
27 Jun 06 |
nicklas |
175 |
{ |
2428 |
27 Jun 06 |
nicklas |
176 |
query.setFirstResult(0); |
2428 |
27 Jun 06 |
nicklas |
177 |
query.setMaxResults(-1); |
2428 |
27 Jun 06 |
nicklas |
178 |
Integer[] itemIds = Values.getInt(request.getParameter("items").split(",")); |
2428 |
27 Jun 06 |
nicklas |
179 |
query.restrict( |
2428 |
27 Jun 06 |
nicklas |
180 |
Restrictions.in( |
2428 |
27 Jun 06 |
nicklas |
181 |
Hql.property("id"), |
2428 |
27 Jun 06 |
nicklas |
182 |
Expressions.parameter("_selected_") |
2428 |
27 Jun 06 |
nicklas |
183 |
) |
2428 |
27 Jun 06 |
nicklas |
184 |
); |
2428 |
27 Jun 06 |
nicklas |
185 |
query.setParameter("_selected_", Arrays.asList(itemIds), Type.INT); |
2428 |
27 Jun 06 |
nicklas |
186 |
} |
2428 |
27 Jun 06 |
nicklas |
187 |
else if ("all".equals(which)) |
2428 |
27 Jun 06 |
nicklas |
188 |
{ |
2428 |
27 Jun 06 |
nicklas |
189 |
query.setFirstResult(0); |
2428 |
27 Jun 06 |
nicklas |
190 |
query.setMaxResults(-1); |
2428 |
27 Jun 06 |
nicklas |
191 |
} |
2428 |
27 Jun 06 |
nicklas |
192 |
DataResultIterator<ReporterData> result = query.iterate(dc); |
2428 |
27 Jun 06 |
nicklas |
193 |
int count = 0; |
5952 |
10 Feb 12 |
nicklas |
194 |
int total = 0; |
2428 |
27 Jun 06 |
nicklas |
195 |
while (result.hasNext()) |
2428 |
27 Jun 06 |
nicklas |
196 |
{ |
2428 |
27 Jun 06 |
nicklas |
197 |
if (reporterList.addReporter(result.next(), null)) count++; |
5952 |
10 Feb 12 |
nicklas |
198 |
total++; |
2428 |
27 Jun 06 |
nicklas |
199 |
} |
2428 |
27 Jun 06 |
nicklas |
200 |
dc.commit(); |
5952 |
10 Feb 12 |
nicklas |
201 |
message = count + " of " + total + " reporters added"; |
2428 |
27 Jun 06 |
nicklas |
202 |
} |
2150 |
05 Apr 06 |
nicklas |
203 |
else |
2150 |
05 Apr 06 |
nicklas |
204 |
{ |
2150 |
05 Apr 06 |
nicklas |
205 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
2150 |
05 Apr 06 |
nicklas |
206 |
} |
2150 |
05 Apr 06 |
nicklas |
207 |
} |
2150 |
05 Apr 06 |
nicklas |
208 |
finally |
2150 |
05 Apr 06 |
nicklas |
209 |
{ |
2150 |
05 Apr 06 |
nicklas |
210 |
if (dc != null) dc.close(); |
2150 |
05 Apr 06 |
nicklas |
211 |
} |
2150 |
05 Apr 06 |
nicklas |
212 |
|
2150 |
05 Apr 06 |
nicklas |
213 |
if (forward != null) |
2150 |
05 Apr 06 |
nicklas |
214 |
{ |
6192 |
31 Oct 12 |
nicklas |
215 |
sc.setSessionSetting("alert-message", message); |
2150 |
05 Apr 06 |
nicklas |
216 |
pageContext.forward(forward); |
2150 |
05 Apr 06 |
nicklas |
217 |
} |
2150 |
05 Apr 06 |
nicklas |
218 |
else if (redirect != null) |
2150 |
05 Apr 06 |
nicklas |
219 |
{ |
6192 |
31 Oct 12 |
nicklas |
220 |
sc.setSessionSetting("alert-message", message); |
2150 |
05 Apr 06 |
nicklas |
221 |
response.sendRedirect(redirect); |
2150 |
05 Apr 06 |
nicklas |
222 |
} |
2150 |
05 Apr 06 |
nicklas |
223 |
else if (message == null) |
2150 |
05 Apr 06 |
nicklas |
224 |
{ |
2150 |
05 Apr 06 |
nicklas |
225 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
2150 |
05 Apr 06 |
nicklas |
226 |
} |
2150 |
05 Apr 06 |
nicklas |
227 |
else |
2150 |
05 Apr 06 |
nicklas |
228 |
{ |
2150 |
05 Apr 06 |
nicklas |
229 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
2150 |
05 Apr 06 |
nicklas |
230 |
} |
2150 |
05 Apr 06 |
nicklas |
231 |
%> |
2150 |
05 Apr 06 |
nicklas |
232 |
|