2107 |
24 Mar 06 |
nicklas |
1 |
<%-- $Id$ |
2107 |
24 Mar 06 |
nicklas |
2 |
------------------------------------------------------------------ |
5425 |
23 Sep 10 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2007 Nicklas Nordborg |
2107 |
24 Mar 06 |
nicklas |
5 |
|
2304 |
22 May 06 |
jari |
6 |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
7 |
Available at http://base.thep.lu.se/ |
2107 |
24 Mar 06 |
nicklas |
8 |
|
2107 |
24 Mar 06 |
nicklas |
9 |
BASE is free software; you can redistribute it and/or |
2107 |
24 Mar 06 |
nicklas |
10 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
11 |
as published by the Free Software Foundation; either version 3 |
2107 |
24 Mar 06 |
nicklas |
12 |
of the License, or (at your option) any later version. |
2107 |
24 Mar 06 |
nicklas |
13 |
|
2107 |
24 Mar 06 |
nicklas |
14 |
BASE is distributed in the hope that it will be useful, |
2107 |
24 Mar 06 |
nicklas |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2107 |
24 Mar 06 |
nicklas |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2107 |
24 Mar 06 |
nicklas |
17 |
GNU General Public License for more details. |
2107 |
24 Mar 06 |
nicklas |
18 |
|
2107 |
24 Mar 06 |
nicklas |
19 |
You should have received a copy of the GNU General Public License |
4511 |
11 Sep 08 |
jari |
20 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
2107 |
24 Mar 06 |
nicklas |
21 |
------------------------------------------------------------------ |
2107 |
24 Mar 06 |
nicklas |
22 |
|
2107 |
24 Mar 06 |
nicklas |
23 |
@author Nicklas |
2107 |
24 Mar 06 |
nicklas |
24 |
@version 2.0 |
2107 |
24 Mar 06 |
nicklas |
25 |
--%> |
5426 |
24 Sep 10 |
nicklas |
26 |
<%@ page pageEncoding="UTF-8" session="false" |
2107 |
24 Mar 06 |
nicklas |
27 |
import="net.sf.basedb.core.SessionControl" |
2107 |
24 Mar 06 |
nicklas |
28 |
import="net.sf.basedb.core.DbControl" |
2107 |
24 Mar 06 |
nicklas |
29 |
import="net.sf.basedb.core.Item" |
5208 |
08 Jan 10 |
nicklas |
30 |
import="net.sf.basedb.core.Type" |
2107 |
24 Mar 06 |
nicklas |
31 |
import="net.sf.basedb.core.Include" |
2107 |
24 Mar 06 |
nicklas |
32 |
import="net.sf.basedb.core.Formula" |
4918 |
04 May 09 |
nicklas |
33 |
import="net.sf.basedb.core.IntensityTransform" |
2733 |
16 Oct 06 |
nicklas |
34 |
import="net.sf.basedb.core.Coloring" |
2107 |
24 Mar 06 |
nicklas |
35 |
import="net.sf.basedb.core.ItemQuery" |
2107 |
24 Mar 06 |
nicklas |
36 |
import="net.sf.basedb.core.Permission" |
2107 |
24 Mar 06 |
nicklas |
37 |
import="net.sf.basedb.core.ItemContext" |
2107 |
24 Mar 06 |
nicklas |
38 |
import="net.sf.basedb.core.ItemQuery" |
2107 |
24 Mar 06 |
nicklas |
39 |
import="net.sf.basedb.core.MultiPermissions" |
4587 |
15 Oct 08 |
martin |
40 |
import="net.sf.basedb.core.OwnedItem" |
2107 |
24 Mar 06 |
nicklas |
41 |
import="net.sf.basedb.core.PermissionDeniedException" |
2107 |
24 Mar 06 |
nicklas |
42 |
import="net.sf.basedb.core.ItemAlreadyExistsException" |
2107 |
24 Mar 06 |
nicklas |
43 |
import="net.sf.basedb.core.RawDataTypes" |
2597 |
25 Aug 06 |
nicklas |
44 |
import="net.sf.basedb.core.RawDataType" |
2107 |
24 Mar 06 |
nicklas |
45 |
import="net.sf.basedb.util.RemovableUtil" |
2107 |
24 Mar 06 |
nicklas |
46 |
import="net.sf.basedb.util.ShareableUtil" |
2918 |
15 Nov 06 |
nicklas |
47 |
import="net.sf.basedb.util.OwnableUtil" |
2107 |
24 Mar 06 |
nicklas |
48 |
import="net.sf.basedb.clients.web.Base" |
2107 |
24 Mar 06 |
nicklas |
49 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
50 |
import="net.sf.basedb.util.Values" |
2107 |
24 Mar 06 |
nicklas |
51 |
import="net.sf.basedb.clients.web.util.HTML" |
5501 |
18 Nov 10 |
nicklas |
52 |
import="net.sf.basedb.core.plugin.GuiContext" |
5501 |
18 Nov 10 |
nicklas |
53 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
5501 |
18 Nov 10 |
nicklas |
54 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5501 |
18 Nov 10 |
nicklas |
55 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5501 |
18 Nov 10 |
nicklas |
56 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
57 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction" |
5501 |
18 Nov 10 |
nicklas |
58 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
6040 |
30 Mar 12 |
nicklas |
59 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
7604 |
25 Feb 19 |
nicklas |
60 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
6040 |
30 Mar 12 |
nicklas |
61 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
2107 |
24 Mar 06 |
nicklas |
62 |
import="java.util.Enumeration" |
2107 |
24 Mar 06 |
nicklas |
63 |
import="java.util.Set" |
2107 |
24 Mar 06 |
nicklas |
64 |
import="java.util.HashSet" |
2107 |
24 Mar 06 |
nicklas |
65 |
import="java.util.List" |
2107 |
24 Mar 06 |
nicklas |
66 |
import="java.util.ArrayList" |
2107 |
24 Mar 06 |
nicklas |
67 |
import="java.util.Collections" |
2107 |
24 Mar 06 |
nicklas |
68 |
import="java.util.Arrays" |
2107 |
24 Mar 06 |
nicklas |
69 |
%> |
2107 |
24 Mar 06 |
nicklas |
70 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
2107 |
24 Mar 06 |
nicklas |
71 |
<%! |
2107 |
24 Mar 06 |
nicklas |
72 |
private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,type,rawDataType,channels,description"); |
2107 |
24 Mar 06 |
nicklas |
73 |
private static final Item itemType = Item.FORMULA; |
2107 |
24 Mar 06 |
nicklas |
74 |
%> |
2107 |
24 Mar 06 |
nicklas |
75 |
<% |
2107 |
24 Mar 06 |
nicklas |
76 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
2107 |
24 Mar 06 |
nicklas |
77 |
final String ID = sc.getId(); |
2107 |
24 Mar 06 |
nicklas |
78 |
final String cmd = request.getParameter("cmd"); |
2107 |
24 Mar 06 |
nicklas |
79 |
final String root = request.getContextPath()+"/"; |
2107 |
24 Mar 06 |
nicklas |
80 |
final String mode = request.getParameter("mode"); |
2107 |
24 Mar 06 |
nicklas |
81 |
final String callback = request.getParameter("callback"); |
2107 |
24 Mar 06 |
nicklas |
82 |
final String itemId = request.getParameter("item_id"); |
2107 |
24 Mar 06 |
nicklas |
83 |
final String listPage = "list_formulas.jsp?ID="+ID |
2107 |
24 Mar 06 |
nicklas |
84 |
+(mode == null ? "" : "&mode="+mode) |
2107 |
24 Mar 06 |
nicklas |
85 |
+(callback == null ? "" : "&callback="+callback) |
2107 |
24 Mar 06 |
nicklas |
86 |
+(itemId == null ? "" : "&item_id="+itemId); |
2107 |
24 Mar 06 |
nicklas |
87 |
final String viewPage = "view_formula.jsp?ID="+ID; |
2107 |
24 Mar 06 |
nicklas |
88 |
final String editPage = "edit_formula.jsp?ID="+ID; |
2107 |
24 Mar 06 |
nicklas |
89 |
|
2107 |
24 Mar 06 |
nicklas |
90 |
String forward = null; |
2107 |
24 Mar 06 |
nicklas |
91 |
String redirect = null; |
2107 |
24 Mar 06 |
nicklas |
92 |
String message = null; |
2107 |
24 Mar 06 |
nicklas |
93 |
DbControl dc = null; |
2107 |
24 Mar 06 |
nicklas |
94 |
|
2107 |
24 Mar 06 |
nicklas |
95 |
try |
2107 |
24 Mar 06 |
nicklas |
96 |
{ |
2107 |
24 Mar 06 |
nicklas |
97 |
if (cmd == null || "List".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
98 |
{ |
2107 |
24 Mar 06 |
nicklas |
99 |
// Display the list page without updatinging the current context |
2811 |
26 Oct 06 |
nicklas |
100 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
2107 |
24 Mar 06 |
nicklas |
101 |
redirect = listPage; |
2107 |
24 Mar 06 |
nicklas |
102 |
} |
2107 |
24 Mar 06 |
nicklas |
103 |
else if ("UpdateContext".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
104 |
{ |
2107 |
24 Mar 06 |
nicklas |
105 |
// Display the list page after updating the current context from the request parameters |
2107 |
24 Mar 06 |
nicklas |
106 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
107 |
redirect = listPage; |
2107 |
24 Mar 06 |
nicklas |
108 |
} |
2107 |
24 Mar 06 |
nicklas |
109 |
else if ("LoadContext".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
110 |
{ |
2107 |
24 Mar 06 |
nicklas |
111 |
// Display the list page after loading a saved context |
2107 |
24 Mar 06 |
nicklas |
112 |
int contextId = Values.getInt(request.getParameter("context")); |
2107 |
24 Mar 06 |
nicklas |
113 |
Base.loadContext(sc, contextId, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
114 |
redirect = listPage; |
2107 |
24 Mar 06 |
nicklas |
115 |
} |
2107 |
24 Mar 06 |
nicklas |
116 |
|
2107 |
24 Mar 06 |
nicklas |
117 |
else if ("ViewItem".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
118 |
{ |
2107 |
24 Mar 06 |
nicklas |
119 |
// Display the view page for a single item |
2107 |
24 Mar 06 |
nicklas |
120 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
121 |
forward = viewPage; |
2107 |
24 Mar 06 |
nicklas |
122 |
} |
2107 |
24 Mar 06 |
nicklas |
123 |
else if ("EditItem".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
124 |
{ |
2107 |
24 Mar 06 |
nicklas |
125 |
// Display the edit page for a single item (should be opened in a popup) |
2107 |
24 Mar 06 |
nicklas |
126 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
127 |
redirect = editPage; |
2107 |
24 Mar 06 |
nicklas |
128 |
} |
2107 |
24 Mar 06 |
nicklas |
129 |
else if ("NewItem".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
130 |
{ |
2107 |
24 Mar 06 |
nicklas |
131 |
// Display the edit page for a new item (should be opened in a popup) |
2107 |
24 Mar 06 |
nicklas |
132 |
if (!sc.hasPermission(Permission.CREATE, itemType)) |
2107 |
24 Mar 06 |
nicklas |
133 |
{ |
2107 |
24 Mar 06 |
nicklas |
134 |
throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
2107 |
24 Mar 06 |
nicklas |
135 |
} |
2107 |
24 Mar 06 |
nicklas |
136 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
137 |
cc.setId(0); |
2107 |
24 Mar 06 |
nicklas |
138 |
redirect = editPage; |
2107 |
24 Mar 06 |
nicklas |
139 |
} |
2107 |
24 Mar 06 |
nicklas |
140 |
else if ("UpdateItem".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
141 |
{ |
2107 |
24 Mar 06 |
nicklas |
142 |
// Update the properties on an item (will close the popup) |
2107 |
24 Mar 06 |
nicklas |
143 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
2597 |
25 Aug 06 |
nicklas |
144 |
final int maxRecent = Base.getMaxRecent(sc); |
7954 |
12 May 21 |
nicklas |
145 |
dc = sc.newDbControl(":Edit "+itemType); |
7605 |
26 Feb 19 |
nicklas |
146 |
Formula formula = cc.getObject("item"); |
2107 |
24 Mar 06 |
nicklas |
147 |
if (formula == null) |
2107 |
24 Mar 06 |
nicklas |
148 |
{ |
2107 |
24 Mar 06 |
nicklas |
149 |
formula = Formula.getNew(dc); |
2107 |
24 Mar 06 |
nicklas |
150 |
message = "Formula created"; |
2107 |
24 Mar 06 |
nicklas |
151 |
dc.saveItem(formula); |
2107 |
24 Mar 06 |
nicklas |
152 |
} |
2107 |
24 Mar 06 |
nicklas |
153 |
else |
2107 |
24 Mar 06 |
nicklas |
154 |
{ |
5060 |
19 Aug 09 |
nicklas |
155 |
dc.reattachItem(formula, false); |
2107 |
24 Mar 06 |
nicklas |
156 |
message = "Formula updated"; |
2107 |
24 Mar 06 |
nicklas |
157 |
} |
5501 |
18 Nov 10 |
nicklas |
158 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.FORMULA), formula); |
7604 |
25 Feb 19 |
nicklas |
159 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
5501 |
18 Nov 10 |
nicklas |
160 |
try |
5501 |
18 Nov 10 |
nicklas |
161 |
{ |
5501 |
18 Nov 10 |
nicklas |
162 |
formula.setName(Values.getStringOrNull(request.getParameter("name"))); |
5501 |
18 Nov 10 |
nicklas |
163 |
formula.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
5501 |
18 Nov 10 |
nicklas |
164 |
formula.setParser(Formula.Parser.valueOf(request.getParameter("parser"))); |
5501 |
18 Nov 10 |
nicklas |
165 |
formula.setAverageMethod(Formula.AverageMethod.valueOf(Values.getString(request.getParameter("averageMethod"), "NONE"))); |
5501 |
18 Nov 10 |
nicklas |
166 |
String sourceTransform = Values.getStringOrNull(request.getParameter("sourceIntensityTransform")); |
5501 |
18 Nov 10 |
nicklas |
167 |
String resultTransform = Values.getStringOrNull(request.getParameter("resultIntensityTransform")); |
5501 |
18 Nov 10 |
nicklas |
168 |
formula.setSourceIntensityTransform(sourceTransform == null ? null : IntensityTransform.valueOf(sourceTransform)); |
5501 |
18 Nov 10 |
nicklas |
169 |
formula.setResultIntensityTransform(resultTransform == null ? null : IntensityTransform.valueOf(resultTransform)); |
5501 |
18 Nov 10 |
nicklas |
170 |
Formula.Type formulaType = Formula.Type.valueOf(request.getParameter("type")); |
5501 |
18 Nov 10 |
nicklas |
171 |
formula.setFormulaType(formulaType); |
5501 |
18 Nov 10 |
nicklas |
172 |
cc.setRecent("FormulaType", formulaType.name(), maxRecent); |
5501 |
18 Nov 10 |
nicklas |
173 |
String valueType = Values.getStringOrNull(request.getParameter("valueType")); |
5501 |
18 Nov 10 |
nicklas |
174 |
formula.setValueType(valueType == null ? null : Type.valueOf(valueType)); |
5501 |
18 Nov 10 |
nicklas |
175 |
RawDataType rdt = RawDataTypes.getRawDataType(Values.getStringOrNull(request.getParameter("rawdatatype"))); |
5501 |
18 Nov 10 |
nicklas |
176 |
formula.setRawDataType(rdt); |
7703 |
11 Apr 19 |
nicklas |
177 |
cc.setRecent("RawDataType", rdt==null?"":rdt.getId(), maxRecent); |
5501 |
18 Nov 10 |
nicklas |
178 |
formula.setChannels(Values.getInt(request.getParameter("channels"))); |
5501 |
18 Nov 10 |
nicklas |
179 |
String[] formulas = request.getParameterValues("formulas"); |
5501 |
18 Nov 10 |
nicklas |
180 |
if (formulas != null) formula.setFormulas(Arrays.asList(formulas)); |
5501 |
18 Nov 10 |
nicklas |
181 |
|
5501 |
18 Nov 10 |
nicklas |
182 |
Coloring coloring = formula.getColoring(); |
5501 |
18 Nov 10 |
nicklas |
183 |
coloring.setUsingColors(Values.getBoolean(request.getParameter("use_colors"))); |
5501 |
18 Nov 10 |
nicklas |
184 |
coloring.setLogarithmic(Values.getBoolean(request.getParameter("logarithmic"))); |
5501 |
18 Nov 10 |
nicklas |
185 |
coloring.setMinValue(Values.getFloat(request.getParameter("min_value"), null)); |
5501 |
18 Nov 10 |
nicklas |
186 |
coloring.setMidValue(Values.getFloat(request.getParameter("mid_value"), null)); |
5501 |
18 Nov 10 |
nicklas |
187 |
coloring.setMaxValue(Values.getFloat(request.getParameter("max_value"), null)); |
5501 |
18 Nov 10 |
nicklas |
188 |
|
5501 |
18 Nov 10 |
nicklas |
189 |
// OnSave extensions |
5501 |
18 Nov 10 |
nicklas |
190 |
invoker.render(OnSaveRenderer.ON_SAVE); |
5501 |
18 Nov 10 |
nicklas |
191 |
dc.commit(); |
5501 |
18 Nov 10 |
nicklas |
192 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
5501 |
18 Nov 10 |
nicklas |
193 |
} |
5501 |
18 Nov 10 |
nicklas |
194 |
catch (Exception ex) |
5501 |
18 Nov 10 |
nicklas |
195 |
{ |
5501 |
18 Nov 10 |
nicklas |
196 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
5501 |
18 Nov 10 |
nicklas |
197 |
throw ex; |
5501 |
18 Nov 10 |
nicklas |
198 |
} |
5501 |
18 Nov 10 |
nicklas |
199 |
finally |
5501 |
18 Nov 10 |
nicklas |
200 |
{ |
5501 |
18 Nov 10 |
nicklas |
201 |
cc.removeObject("item"); |
5501 |
18 Nov 10 |
nicklas |
202 |
} |
2107 |
24 Mar 06 |
nicklas |
203 |
} |
2107 |
24 Mar 06 |
nicklas |
204 |
else if ("DeleteItem".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
205 |
{ |
2107 |
24 Mar 06 |
nicklas |
206 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
207 |
dc = sc.newDbControl(":Delete "+itemType); |
2107 |
24 Mar 06 |
nicklas |
208 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
209 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true); |
2107 |
24 Mar 06 |
nicklas |
210 |
dc.commit(); |
2107 |
24 Mar 06 |
nicklas |
211 |
redirect = viewPage; |
2107 |
24 Mar 06 |
nicklas |
212 |
} |
2107 |
24 Mar 06 |
nicklas |
213 |
else if ("DeleteItems".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
214 |
{ |
2107 |
24 Mar 06 |
nicklas |
215 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
216 |
dc = sc.newDbControl(":Delete "+itemType); |
2107 |
24 Mar 06 |
nicklas |
217 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
218 |
int numTotal = cc.getSelected().size(); |
2107 |
24 Mar 06 |
nicklas |
219 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
2107 |
24 Mar 06 |
nicklas |
220 |
dc.commit(); |
2107 |
24 Mar 06 |
nicklas |
221 |
if (numTotal != numRemoved) |
2107 |
24 Mar 06 |
nicklas |
222 |
{ |
2107 |
24 Mar 06 |
nicklas |
223 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
2107 |
24 Mar 06 |
nicklas |
224 |
} |
6192 |
31 Oct 12 |
nicklas |
225 |
redirect = listPage; |
2107 |
24 Mar 06 |
nicklas |
226 |
} |
2107 |
24 Mar 06 |
nicklas |
227 |
else if ("RestoreItem".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
228 |
{ |
2107 |
24 Mar 06 |
nicklas |
229 |
// Restore a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
230 |
dc = sc.newDbControl(":Restore "+itemType); |
2107 |
24 Mar 06 |
nicklas |
231 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
232 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false); |
2107 |
24 Mar 06 |
nicklas |
233 |
dc.commit(); |
2107 |
24 Mar 06 |
nicklas |
234 |
redirect = viewPage; |
2107 |
24 Mar 06 |
nicklas |
235 |
} |
2107 |
24 Mar 06 |
nicklas |
236 |
else if ("RestoreItems".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
237 |
{ |
2107 |
24 Mar 06 |
nicklas |
238 |
// Restore all selected items on the list page |
7954 |
12 May 21 |
nicklas |
239 |
dc = sc.newDbControl(":Restore "+itemType); |
2107 |
24 Mar 06 |
nicklas |
240 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
241 |
int numTotal = cc.getSelected().size(); |
2107 |
24 Mar 06 |
nicklas |
242 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
2107 |
24 Mar 06 |
nicklas |
243 |
dc.commit(); |
2107 |
24 Mar 06 |
nicklas |
244 |
if (numTotal != numRemoved) |
2107 |
24 Mar 06 |
nicklas |
245 |
{ |
2528 |
15 Aug 06 |
martin |
246 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
2107 |
24 Mar 06 |
nicklas |
247 |
} |
6192 |
31 Oct 12 |
nicklas |
248 |
redirect = listPage; |
2107 |
24 Mar 06 |
nicklas |
249 |
} |
2107 |
24 Mar 06 |
nicklas |
250 |
else if ("ShareItem".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
251 |
{ |
2107 |
24 Mar 06 |
nicklas |
252 |
// Display a popup window for sharing a single item |
7954 |
12 May 21 |
nicklas |
253 |
dc = sc.newDbControl(":Share "+itemType); |
2107 |
24 Mar 06 |
nicklas |
254 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
255 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId())); |
2107 |
24 Mar 06 |
nicklas |
256 |
dc.close(); |
2107 |
24 Mar 06 |
nicklas |
257 |
cc.setObject("MultiPermissions", permissions); |
2107 |
24 Mar 06 |
nicklas |
258 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
2107 |
24 Mar 06 |
nicklas |
259 |
} |
2107 |
24 Mar 06 |
nicklas |
260 |
else if ("ShareItems".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
261 |
{ |
2107 |
24 Mar 06 |
nicklas |
262 |
// Display a popup window for sharing all selected items on the list page |
7954 |
12 May 21 |
nicklas |
263 |
dc = sc.newDbControl(":Share "+itemType); |
2107 |
24 Mar 06 |
nicklas |
264 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
265 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected()); |
2107 |
24 Mar 06 |
nicklas |
266 |
dc.close(); |
2107 |
24 Mar 06 |
nicklas |
267 |
cc.setObject("MultiPermissions", permissions); |
2107 |
24 Mar 06 |
nicklas |
268 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
2107 |
24 Mar 06 |
nicklas |
269 |
} |
4578 |
13 Oct 08 |
martin |
270 |
else if ("SetOwnerOfItem".equals(cmd)) |
2918 |
15 Nov 06 |
nicklas |
271 |
{ |
4578 |
13 Oct 08 |
martin |
272 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
273 |
dc = sc.newDbControl(":Set owner of "+itemType); |
2918 |
15 Nov 06 |
nicklas |
274 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4587 |
15 Oct 08 |
martin |
275 |
OwnedItem item = (OwnedItem)itemType.getById(dc, cc.getId()); |
4587 |
15 Oct 08 |
martin |
276 |
cc.setObject("OwnedItems", Collections.singleton(item)); |
4578 |
13 Oct 08 |
martin |
277 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
2918 |
15 Nov 06 |
nicklas |
278 |
} |
4578 |
13 Oct 08 |
martin |
279 |
else if ("SetOwnerOfItems".equals(cmd)) |
2918 |
15 Nov 06 |
nicklas |
280 |
{ |
4578 |
13 Oct 08 |
martin |
281 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
282 |
dc = sc.newDbControl(":Set owner of "+itemType); |
2918 |
15 Nov 06 |
nicklas |
283 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4587 |
15 Oct 08 |
martin |
284 |
Set<OwnedItem> items = new HashSet<OwnedItem>(); |
4587 |
15 Oct 08 |
martin |
285 |
for (Integer id : cc.getSelected()) |
4587 |
15 Oct 08 |
martin |
286 |
{ |
4587 |
15 Oct 08 |
martin |
287 |
if (id != null) items.add((OwnedItem)itemType.getById(dc, id)); |
4587 |
15 Oct 08 |
martin |
288 |
} |
4587 |
15 Oct 08 |
martin |
289 |
dc.close(); |
4587 |
15 Oct 08 |
martin |
290 |
cc.setObject("OwnedItems", items); |
4578 |
13 Oct 08 |
martin |
291 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
2918 |
15 Nov 06 |
nicklas |
292 |
} |
2107 |
24 Mar 06 |
nicklas |
293 |
else if ("ExportItems".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
294 |
{ |
2107 |
24 Mar 06 |
nicklas |
295 |
// Run an export plugin in a list context |
2107 |
24 Mar 06 |
nicklas |
296 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
297 |
final ItemQuery<Formula> query = Formula.getQuery(); |
7954 |
12 May 21 |
nicklas |
298 |
dc = sc.newDbControl(":Export "+itemType); |
7914 |
23 Feb 21 |
nicklas |
299 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
300 |
cc.configureQuery(dc, query, jspContext, true); |
6040 |
30 Mar 12 |
nicklas |
301 |
cc.setQuery(query); |
7604 |
25 Feb 19 |
nicklas |
302 |
ExtensionsInvoker<ListColumnAction<Formula,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
303 |
listInvoker.render(new ListColumnExportRenderer<Formula>(cc)); |
5590 |
16 Mar 11 |
nicklas |
304 |
dc.close(); |
2107 |
24 Mar 06 |
nicklas |
305 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+formulas"; |
2107 |
24 Mar 06 |
nicklas |
306 |
} |
2107 |
24 Mar 06 |
nicklas |
307 |
else if ("ExportItem".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
308 |
{ |
2107 |
24 Mar 06 |
nicklas |
309 |
// Run an export plugin in single-item context |
2107 |
24 Mar 06 |
nicklas |
310 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
311 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+formula"; |
2107 |
24 Mar 06 |
nicklas |
312 |
} |
2107 |
24 Mar 06 |
nicklas |
313 |
else if ("ImportItems".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
314 |
{ |
2107 |
24 Mar 06 |
nicklas |
315 |
// Run an import plugin in a list context |
2107 |
24 Mar 06 |
nicklas |
316 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
317 |
final ItemQuery<Formula> query = Formula.getQuery(); |
7954 |
12 May 21 |
nicklas |
318 |
dc = sc.newDbControl(":Import "+itemType); |
7914 |
23 Feb 21 |
nicklas |
319 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
320 |
cc.configureQuery(dc, query, jspContext, false); |
5590 |
16 Mar 11 |
nicklas |
321 |
dc.close(); |
2107 |
24 Mar 06 |
nicklas |
322 |
cc.setQuery(query); |
2107 |
24 Mar 06 |
nicklas |
323 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+formulas"; |
2107 |
24 Mar 06 |
nicklas |
324 |
} |
2107 |
24 Mar 06 |
nicklas |
325 |
else if ("ImportItem".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
326 |
{ |
2107 |
24 Mar 06 |
nicklas |
327 |
// Run an import plugin in single-item context |
2107 |
24 Mar 06 |
nicklas |
328 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
329 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+formula"; |
2107 |
24 Mar 06 |
nicklas |
330 |
} |
2107 |
24 Mar 06 |
nicklas |
331 |
else if ("RunListPlugin".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
332 |
{ |
2107 |
24 Mar 06 |
nicklas |
333 |
// Run another plugin in a list context |
2107 |
24 Mar 06 |
nicklas |
334 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
335 |
final ItemQuery<Formula> query = Formula.getQuery(); |
7954 |
12 May 21 |
nicklas |
336 |
dc = sc.newDbControl(":Run plugin "+itemType); |
7914 |
23 Feb 21 |
nicklas |
337 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
338 |
cc.configureQuery(dc, query, jspContext, false); |
5590 |
16 Mar 11 |
nicklas |
339 |
dc.close(); |
2107 |
24 Mar 06 |
nicklas |
340 |
cc.setQuery(query); |
2107 |
24 Mar 06 |
nicklas |
341 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
2107 |
24 Mar 06 |
nicklas |
342 |
} |
2107 |
24 Mar 06 |
nicklas |
343 |
else if ("RunPlugin".equals(cmd)) |
2107 |
24 Mar 06 |
nicklas |
344 |
{ |
2107 |
24 Mar 06 |
nicklas |
345 |
// Run another plugin in single-item context |
2107 |
24 Mar 06 |
nicklas |
346 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2107 |
24 Mar 06 |
nicklas |
347 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
2107 |
24 Mar 06 |
nicklas |
348 |
} |
2107 |
24 Mar 06 |
nicklas |
349 |
else |
2107 |
24 Mar 06 |
nicklas |
350 |
{ |
2107 |
24 Mar 06 |
nicklas |
351 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
2107 |
24 Mar 06 |
nicklas |
352 |
} |
2107 |
24 Mar 06 |
nicklas |
353 |
} |
2107 |
24 Mar 06 |
nicklas |
354 |
finally |
2107 |
24 Mar 06 |
nicklas |
355 |
{ |
2107 |
24 Mar 06 |
nicklas |
356 |
if (dc != null) dc.close(); |
2107 |
24 Mar 06 |
nicklas |
357 |
} |
2107 |
24 Mar 06 |
nicklas |
358 |
|
2107 |
24 Mar 06 |
nicklas |
359 |
if (forward != null) |
2107 |
24 Mar 06 |
nicklas |
360 |
{ |
6192 |
31 Oct 12 |
nicklas |
361 |
sc.setSessionSetting("alert-message", message); |
2107 |
24 Mar 06 |
nicklas |
362 |
pageContext.forward(forward); |
2107 |
24 Mar 06 |
nicklas |
363 |
} |
2107 |
24 Mar 06 |
nicklas |
364 |
else if (redirect != null) |
2107 |
24 Mar 06 |
nicklas |
365 |
{ |
6192 |
31 Oct 12 |
nicklas |
366 |
sc.setSessionSetting("alert-message", message); |
2107 |
24 Mar 06 |
nicklas |
367 |
response.sendRedirect(redirect); |
2107 |
24 Mar 06 |
nicklas |
368 |
} |
2107 |
24 Mar 06 |
nicklas |
369 |
else if (message == null) |
2107 |
24 Mar 06 |
nicklas |
370 |
{ |
2107 |
24 Mar 06 |
nicklas |
371 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
2107 |
24 Mar 06 |
nicklas |
372 |
} |
2107 |
24 Mar 06 |
nicklas |
373 |
else |
2107 |
24 Mar 06 |
nicklas |
374 |
{ |
2107 |
24 Mar 06 |
nicklas |
375 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
2107 |
24 Mar 06 |
nicklas |
376 |
} |
2107 |
24 Mar 06 |
nicklas |
377 |
%> |
2107 |
24 Mar 06 |
nicklas |
378 |
|