1862 |
30 Jan 06 |
nicklas |
1 |
<%-- $Id$ |
1862 |
30 Jan 06 |
nicklas |
2 |
------------------------------------------------------------------ |
5425 |
23 Sep 10 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
1862 |
30 Jan 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/ |
1862 |
30 Jan 06 |
nicklas |
7 |
|
1862 |
30 Jan 06 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
1862 |
30 Jan 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 |
1862 |
30 Jan 06 |
nicklas |
11 |
of the License, or (at your option) any later version. |
1862 |
30 Jan 06 |
nicklas |
12 |
|
1862 |
30 Jan 06 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
1862 |
30 Jan 06 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1862 |
30 Jan 06 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1862 |
30 Jan 06 |
nicklas |
16 |
GNU General Public License for more details. |
1862 |
30 Jan 06 |
nicklas |
17 |
|
1862 |
30 Jan 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/>. |
1862 |
30 Jan 06 |
nicklas |
20 |
------------------------------------------------------------------ |
1862 |
30 Jan 06 |
nicklas |
21 |
|
1862 |
30 Jan 06 |
nicklas |
22 |
@author Nicklas |
1862 |
30 Jan 06 |
nicklas |
23 |
@version 2.0 |
1862 |
30 Jan 06 |
nicklas |
24 |
--%> |
5426 |
24 Sep 10 |
nicklas |
25 |
<%@ page pageEncoding="UTF-8" session="false" |
1862 |
30 Jan 06 |
nicklas |
26 |
import="net.sf.basedb.core.SessionControl" |
1862 |
30 Jan 06 |
nicklas |
27 |
import="net.sf.basedb.core.DbControl" |
2486 |
03 Aug 06 |
martin |
28 |
import="net.sf.basedb.core.Hardware" |
1862 |
30 Jan 06 |
nicklas |
29 |
import="net.sf.basedb.core.Item" |
1862 |
30 Jan 06 |
nicklas |
30 |
import="net.sf.basedb.core.ItemContext" |
1862 |
30 Jan 06 |
nicklas |
31 |
import="net.sf.basedb.core.Plate" |
1862 |
30 Jan 06 |
nicklas |
32 |
import="net.sf.basedb.core.PlateEvent" |
1862 |
30 Jan 06 |
nicklas |
33 |
import="net.sf.basedb.core.PlateEventType" |
1862 |
30 Jan 06 |
nicklas |
34 |
import="net.sf.basedb.core.Protocol" |
1862 |
30 Jan 06 |
nicklas |
35 |
import="net.sf.basedb.core.ItemQuery" |
1862 |
30 Jan 06 |
nicklas |
36 |
import="net.sf.basedb.core.Permission" |
1862 |
30 Jan 06 |
nicklas |
37 |
import="net.sf.basedb.core.PermissionDeniedException" |
1862 |
30 Jan 06 |
nicklas |
38 |
import="net.sf.basedb.util.RemovableUtil" |
1862 |
30 Jan 06 |
nicklas |
39 |
import="net.sf.basedb.clients.web.Base" |
1862 |
30 Jan 06 |
nicklas |
40 |
import="net.sf.basedb.clients.web.WebException" |
1862 |
30 Jan 06 |
nicklas |
41 |
import="net.sf.basedb.clients.web.util.HTML" |
2942 |
22 Nov 06 |
nicklas |
42 |
import="net.sf.basedb.util.formatter.Formatter" |
2942 |
22 Nov 06 |
nicklas |
43 |
import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
2753 |
20 Oct 06 |
nicklas |
44 |
import="net.sf.basedb.util.Values" |
5498 |
17 Nov 10 |
nicklas |
45 |
import="net.sf.basedb.core.plugin.GuiContext" |
5498 |
17 Nov 10 |
nicklas |
46 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
5498 |
17 Nov 10 |
nicklas |
47 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5498 |
17 Nov 10 |
nicklas |
48 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5498 |
17 Nov 10 |
nicklas |
49 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
50 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction" |
5498 |
17 Nov 10 |
nicklas |
51 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
6039 |
29 Mar 12 |
nicklas |
52 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
7604 |
25 Feb 19 |
nicklas |
53 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
6039 |
29 Mar 12 |
nicklas |
54 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
1862 |
30 Jan 06 |
nicklas |
55 |
import="java.util.List" |
1862 |
30 Jan 06 |
nicklas |
56 |
import="java.util.Collections" |
2942 |
22 Nov 06 |
nicklas |
57 |
import="java.util.Date" |
1862 |
30 Jan 06 |
nicklas |
58 |
%> |
1862 |
30 Jan 06 |
nicklas |
59 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
1862 |
30 Jan 06 |
nicklas |
60 |
<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
1862 |
30 Jan 06 |
nicklas |
61 |
<%! |
7982 |
14 Jun 21 |
nicklas |
62 |
private static final ItemContext defaultContext = Base.createDefaultContext("plateEventType.ordinal", "eventType,ordinal,entryDate,eventDate,protocol,comment", "eventType"); |
1862 |
30 Jan 06 |
nicklas |
63 |
private static final Item itemType = Item.PLATEEVENT; |
1862 |
30 Jan 06 |
nicklas |
64 |
%> |
1862 |
30 Jan 06 |
nicklas |
65 |
<% |
1862 |
30 Jan 06 |
nicklas |
66 |
final int plateId = Values.getInt(request.getParameter("plate_id")); |
1862 |
30 Jan 06 |
nicklas |
67 |
|
1862 |
30 Jan 06 |
nicklas |
68 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
1862 |
30 Jan 06 |
nicklas |
69 |
final String ID = sc.getId(); |
1862 |
30 Jan 06 |
nicklas |
70 |
final String cmd = request.getParameter("cmd"); |
1862 |
30 Jan 06 |
nicklas |
71 |
final String root = request.getContextPath()+"/"; |
1862 |
30 Jan 06 |
nicklas |
72 |
final String mode = request.getParameter("mode"); |
1862 |
30 Jan 06 |
nicklas |
73 |
final String callback = request.getParameter("callback"); |
1862 |
30 Jan 06 |
nicklas |
74 |
final String itemId = request.getParameter("item_id"); |
1862 |
30 Jan 06 |
nicklas |
75 |
final String listPage = "list_events.jsp?ID="+ID |
1862 |
30 Jan 06 |
nicklas |
76 |
+"&plate_id="+plateId |
1862 |
30 Jan 06 |
nicklas |
77 |
+(mode == null ? "" : "&mode="+mode) |
1862 |
30 Jan 06 |
nicklas |
78 |
+(callback == null ? "" : "&callback="+callback) |
1862 |
30 Jan 06 |
nicklas |
79 |
+(itemId == null ? "" : "&item_id="+itemId); |
1862 |
30 Jan 06 |
nicklas |
80 |
final String viewPage = "view_event.jsp?ID="+ID+"&plate_id="+plateId; |
1862 |
30 Jan 06 |
nicklas |
81 |
final String editPage = "edit_event.jsp?ID="+ID+"&plate_id="+plateId; |
1862 |
30 Jan 06 |
nicklas |
82 |
|
1862 |
30 Jan 06 |
nicklas |
83 |
String forward = null; |
1862 |
30 Jan 06 |
nicklas |
84 |
String redirect = null; |
1862 |
30 Jan 06 |
nicklas |
85 |
String message = null; |
1862 |
30 Jan 06 |
nicklas |
86 |
DbControl dc = null; |
1862 |
30 Jan 06 |
nicklas |
87 |
|
1862 |
30 Jan 06 |
nicklas |
88 |
try |
1862 |
30 Jan 06 |
nicklas |
89 |
{ |
1862 |
30 Jan 06 |
nicklas |
90 |
if (cmd == null || "List".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
91 |
{ |
1862 |
30 Jan 06 |
nicklas |
92 |
// Display the list page without updatinging the current context |
2811 |
26 Oct 06 |
nicklas |
93 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
1862 |
30 Jan 06 |
nicklas |
94 |
redirect = listPage; |
1862 |
30 Jan 06 |
nicklas |
95 |
} |
1862 |
30 Jan 06 |
nicklas |
96 |
else if ("UpdateContext".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
97 |
{ |
1862 |
30 Jan 06 |
nicklas |
98 |
// Display the list page after updating the current context from the request parameters |
1862 |
30 Jan 06 |
nicklas |
99 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1862 |
30 Jan 06 |
nicklas |
100 |
redirect = listPage; |
1862 |
30 Jan 06 |
nicklas |
101 |
} |
1862 |
30 Jan 06 |
nicklas |
102 |
else if ("LoadContext".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
103 |
{ |
1862 |
30 Jan 06 |
nicklas |
104 |
// Display the list page after loading a saved context |
1862 |
30 Jan 06 |
nicklas |
105 |
int contextId = Values.getInt(request.getParameter("context")); |
1862 |
30 Jan 06 |
nicklas |
106 |
Base.loadContext(sc, contextId, defaultContext); |
1862 |
30 Jan 06 |
nicklas |
107 |
redirect = listPage; |
1862 |
30 Jan 06 |
nicklas |
108 |
} |
1862 |
30 Jan 06 |
nicklas |
109 |
else if ("ViewItem".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
110 |
{ |
1862 |
30 Jan 06 |
nicklas |
111 |
// Display the view page for a single item |
1862 |
30 Jan 06 |
nicklas |
112 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1862 |
30 Jan 06 |
nicklas |
113 |
forward = viewPage; |
1862 |
30 Jan 06 |
nicklas |
114 |
} |
1862 |
30 Jan 06 |
nicklas |
115 |
else if ("EditItem".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
116 |
{ |
1862 |
30 Jan 06 |
nicklas |
117 |
// Display the edit page for a single item (should be opened in a popup) |
1862 |
30 Jan 06 |
nicklas |
118 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1862 |
30 Jan 06 |
nicklas |
119 |
redirect = editPage; |
1862 |
30 Jan 06 |
nicklas |
120 |
} |
1862 |
30 Jan 06 |
nicklas |
121 |
else if ("NewItem".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
122 |
{ |
1862 |
30 Jan 06 |
nicklas |
123 |
// Display the edit page for a new item (should be opened in a popup) |
1862 |
30 Jan 06 |
nicklas |
124 |
if (!sc.hasPermission(Permission.CREATE, itemType)) |
1862 |
30 Jan 06 |
nicklas |
125 |
{ |
1862 |
30 Jan 06 |
nicklas |
126 |
throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
1862 |
30 Jan 06 |
nicklas |
127 |
} |
1862 |
30 Jan 06 |
nicklas |
128 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1862 |
30 Jan 06 |
nicklas |
129 |
cc.setId(0); |
1862 |
30 Jan 06 |
nicklas |
130 |
redirect = editPage; |
1862 |
30 Jan 06 |
nicklas |
131 |
} |
1862 |
30 Jan 06 |
nicklas |
132 |
else if ("UpdateItem".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
133 |
{ |
1862 |
30 Jan 06 |
nicklas |
134 |
// Update the properties on an item (will close the popup) |
1862 |
30 Jan 06 |
nicklas |
135 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
2598 |
28 Aug 06 |
nicklas |
136 |
final int maxRecent = Base.getMaxRecent(sc); |
7954 |
12 May 21 |
nicklas |
137 |
dc = sc.newDbControl(":Edit "+itemType); |
7605 |
26 Feb 19 |
nicklas |
138 |
PlateEvent event = cc.getObject("item"); |
1862 |
30 Jan 06 |
nicklas |
139 |
if (event == null) |
1862 |
30 Jan 06 |
nicklas |
140 |
{ |
1862 |
30 Jan 06 |
nicklas |
141 |
Plate plate = Plate.getById(dc, plateId); |
1862 |
30 Jan 06 |
nicklas |
142 |
int eventTypeId = Values.getInt(request.getParameter("plateeventtype_id")); |
1862 |
30 Jan 06 |
nicklas |
143 |
PlateEventType eventType = PlateEventType.getById(dc, eventTypeId); |
1862 |
30 Jan 06 |
nicklas |
144 |
event = plate.getEvent(eventType); |
1862 |
30 Jan 06 |
nicklas |
145 |
message = "Event created"; |
1862 |
30 Jan 06 |
nicklas |
146 |
dc.saveItem(event); |
1862 |
30 Jan 06 |
nicklas |
147 |
} |
1862 |
30 Jan 06 |
nicklas |
148 |
else |
1862 |
30 Jan 06 |
nicklas |
149 |
{ |
5060 |
19 Aug 09 |
nicklas |
150 |
dc.reattachItem(event, false); |
1862 |
30 Jan 06 |
nicklas |
151 |
message = "Event updated"; |
1862 |
30 Jan 06 |
nicklas |
152 |
} |
5498 |
17 Nov 10 |
nicklas |
153 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.PLATEEVENT), event); |
7604 |
25 Feb 19 |
nicklas |
154 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
5498 |
17 Nov 10 |
nicklas |
155 |
try |
1862 |
30 Jan 06 |
nicklas |
156 |
{ |
5498 |
17 Nov 10 |
nicklas |
157 |
Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
5498 |
17 Nov 10 |
nicklas |
158 |
event.setComment(Values.getStringOrNull(request.getParameter("comment"))); |
5498 |
17 Nov 10 |
nicklas |
159 |
event.setEventDate(dateFormatter.parseString(Values.getStringOrNull(request.getParameter("event_date")))); |
5498 |
17 Nov 10 |
nicklas |
160 |
int protocolId = Values.getInt(request.getParameter("protocol_id"), -1); |
5498 |
17 Nov 10 |
nicklas |
161 |
if (protocolId >= 0) // < 0 = denied or unchanged |
5498 |
17 Nov 10 |
nicklas |
162 |
{ |
5498 |
17 Nov 10 |
nicklas |
163 |
Protocol pt = protocolId == 0 ? null : Protocol.getById(dc, protocolId); |
5498 |
17 Nov 10 |
nicklas |
164 |
event.setProtocol(pt); |
7703 |
11 Apr 19 |
nicklas |
165 |
cc.setRecent(Item.PROTOCOL, pt, maxRecent); |
5498 |
17 Nov 10 |
nicklas |
166 |
} |
5498 |
17 Nov 10 |
nicklas |
167 |
int hardwareId = Values.getInt(request.getParameter("hardware_id"), -1); |
5498 |
17 Nov 10 |
nicklas |
168 |
if (hardwareId >= 0) // < 0 = denied or unchanged |
5498 |
17 Nov 10 |
nicklas |
169 |
{ |
5498 |
17 Nov 10 |
nicklas |
170 |
Hardware hw = hardwareId == 0 ? null : Hardware.getById(dc, hardwareId); |
5498 |
17 Nov 10 |
nicklas |
171 |
event.setHardware(hw); |
7703 |
11 Apr 19 |
nicklas |
172 |
cc.setRecent(Item.HARDWARE, hw, maxRecent); |
5498 |
17 Nov 10 |
nicklas |
173 |
} |
5498 |
17 Nov 10 |
nicklas |
174 |
|
5498 |
17 Nov 10 |
nicklas |
175 |
// OnSave extensions |
5498 |
17 Nov 10 |
nicklas |
176 |
invoker.render(OnSaveRenderer.ON_SAVE); |
5498 |
17 Nov 10 |
nicklas |
177 |
dc.commit(); |
5498 |
17 Nov 10 |
nicklas |
178 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
1862 |
30 Jan 06 |
nicklas |
179 |
} |
5498 |
17 Nov 10 |
nicklas |
180 |
catch (Exception ex) |
2486 |
03 Aug 06 |
martin |
181 |
{ |
5498 |
17 Nov 10 |
nicklas |
182 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
5498 |
17 Nov 10 |
nicklas |
183 |
throw ex; |
2486 |
03 Aug 06 |
martin |
184 |
} |
5498 |
17 Nov 10 |
nicklas |
185 |
finally |
5498 |
17 Nov 10 |
nicklas |
186 |
{ |
5498 |
17 Nov 10 |
nicklas |
187 |
cc.removeObject("item"); |
5498 |
17 Nov 10 |
nicklas |
188 |
} |
1862 |
30 Jan 06 |
nicklas |
189 |
} |
1862 |
30 Jan 06 |
nicklas |
190 |
else if ("DeleteItem".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
191 |
{ |
1862 |
30 Jan 06 |
nicklas |
192 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
193 |
dc = sc.newDbControl(":Delete "+itemType); |
1862 |
30 Jan 06 |
nicklas |
194 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1862 |
30 Jan 06 |
nicklas |
195 |
RemovableUtil.delete(dc, itemType, Collections.singleton(cc.getId())); |
1862 |
30 Jan 06 |
nicklas |
196 |
dc.commit(); |
1862 |
30 Jan 06 |
nicklas |
197 |
redirect = listPage; |
1862 |
30 Jan 06 |
nicklas |
198 |
} |
1862 |
30 Jan 06 |
nicklas |
199 |
else if ("DeleteItems".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
200 |
{ |
1862 |
30 Jan 06 |
nicklas |
201 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
202 |
dc = sc.newDbControl(":Delete "+itemType); |
1862 |
30 Jan 06 |
nicklas |
203 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1862 |
30 Jan 06 |
nicklas |
204 |
int numTotal = cc.getSelected().size(); |
1862 |
30 Jan 06 |
nicklas |
205 |
int numDeleted = RemovableUtil.delete(dc, itemType, cc.getSelected()); |
1862 |
30 Jan 06 |
nicklas |
206 |
dc.commit(); |
1862 |
30 Jan 06 |
nicklas |
207 |
if (numTotal != numDeleted) |
1862 |
30 Jan 06 |
nicklas |
208 |
{ |
1862 |
30 Jan 06 |
nicklas |
209 |
message = (numDeleted == 0 ? "No" : "Only "+numDeleted+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
1862 |
30 Jan 06 |
nicklas |
210 |
} |
6192 |
31 Oct 12 |
nicklas |
211 |
redirect = listPage; |
1862 |
30 Jan 06 |
nicklas |
212 |
} |
1862 |
30 Jan 06 |
nicklas |
213 |
else if ("ExportItems".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
214 |
{ |
1862 |
30 Jan 06 |
nicklas |
215 |
// Run an export plugin in a list context |
1862 |
30 Jan 06 |
nicklas |
216 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
7954 |
12 May 21 |
nicklas |
217 |
dc = sc.newDbControl(":Export "+itemType); |
1862 |
30 Jan 06 |
nicklas |
218 |
final Plate plate = Plate.getById(dc, plateId); |
5590 |
16 Mar 11 |
nicklas |
219 |
final ItemQuery<PlateEvent> query = plate.getEvents(); |
7914 |
23 Feb 21 |
nicklas |
220 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
221 |
cc.configureQuery(dc, query, jspContext, true); |
6039 |
29 Mar 12 |
nicklas |
222 |
cc.setQuery(query); |
7604 |
25 Feb 19 |
nicklas |
223 |
ExtensionsInvoker<ListColumnAction<PlateEvent,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
224 |
listInvoker.render(new ListColumnExportRenderer<PlateEvent>(cc)); |
1862 |
30 Jan 06 |
nicklas |
225 |
dc.close(); |
6039 |
29 Mar 12 |
nicklas |
226 |
redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+event+types"; |
1862 |
30 Jan 06 |
nicklas |
227 |
} |
1862 |
30 Jan 06 |
nicklas |
228 |
else if ("ExportItem".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
229 |
{ |
1862 |
30 Jan 06 |
nicklas |
230 |
// Run an export plugin in single-item context |
1862 |
30 Jan 06 |
nicklas |
231 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
6039 |
29 Mar 12 |
nicklas |
232 |
redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+event+type"; |
1862 |
30 Jan 06 |
nicklas |
233 |
} |
1862 |
30 Jan 06 |
nicklas |
234 |
else if ("ImportItems".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
235 |
{ |
1862 |
30 Jan 06 |
nicklas |
236 |
// Run an import plugin in a list context |
1862 |
30 Jan 06 |
nicklas |
237 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
7954 |
12 May 21 |
nicklas |
238 |
dc = sc.newDbControl(":Import "+itemType); |
1862 |
30 Jan 06 |
nicklas |
239 |
final Plate plate = Plate.getById(dc, plateId); |
5590 |
16 Mar 11 |
nicklas |
240 |
final ItemQuery<PlateEvent> query = plate.getEvents(); |
7914 |
23 Feb 21 |
nicklas |
241 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
242 |
cc.configureQuery(dc, query, jspContext, true); |
1862 |
30 Jan 06 |
nicklas |
243 |
dc.close(); |
1862 |
30 Jan 06 |
nicklas |
244 |
cc.setQuery(query); |
6039 |
29 Mar 12 |
nicklas |
245 |
redirect = "../../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+event+types"; |
1862 |
30 Jan 06 |
nicklas |
246 |
} |
1862 |
30 Jan 06 |
nicklas |
247 |
else if ("ImportItem".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
248 |
{ |
1862 |
30 Jan 06 |
nicklas |
249 |
// Run an import plugin in single-item context |
1862 |
30 Jan 06 |
nicklas |
250 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
6039 |
29 Mar 12 |
nicklas |
251 |
redirect = "../../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+event+type"; |
1862 |
30 Jan 06 |
nicklas |
252 |
} |
1862 |
30 Jan 06 |
nicklas |
253 |
else if ("RunListPlugin".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
254 |
{ |
1862 |
30 Jan 06 |
nicklas |
255 |
// Run another plugin in a list context |
1862 |
30 Jan 06 |
nicklas |
256 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
7954 |
12 May 21 |
nicklas |
257 |
dc = sc.newDbControl(":Run plugin "+itemType); |
1862 |
30 Jan 06 |
nicklas |
258 |
final Plate plate = Plate.getById(dc, plateId); |
5590 |
16 Mar 11 |
nicklas |
259 |
final ItemQuery<PlateEvent> query = plate.getEvents(); |
7914 |
23 Feb 21 |
nicklas |
260 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
261 |
cc.configureQuery(dc, query, jspContext, true); |
1862 |
30 Jan 06 |
nicklas |
262 |
dc.close(); |
1862 |
30 Jan 06 |
nicklas |
263 |
cc.setQuery(query); |
6039 |
29 Mar 12 |
nicklas |
264 |
redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
1862 |
30 Jan 06 |
nicklas |
265 |
} |
1862 |
30 Jan 06 |
nicklas |
266 |
else if ("RunPlugin".equals(cmd)) |
1862 |
30 Jan 06 |
nicklas |
267 |
{ |
1862 |
30 Jan 06 |
nicklas |
268 |
// Run another plugin in single-item context |
1862 |
30 Jan 06 |
nicklas |
269 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
6039 |
29 Mar 12 |
nicklas |
270 |
redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
1862 |
30 Jan 06 |
nicklas |
271 |
} |
1862 |
30 Jan 06 |
nicklas |
272 |
else |
1862 |
30 Jan 06 |
nicklas |
273 |
{ |
1862 |
30 Jan 06 |
nicklas |
274 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
1862 |
30 Jan 06 |
nicklas |
275 |
} |
1862 |
30 Jan 06 |
nicklas |
276 |
|
1862 |
30 Jan 06 |
nicklas |
277 |
} |
1862 |
30 Jan 06 |
nicklas |
278 |
finally |
1862 |
30 Jan 06 |
nicklas |
279 |
{ |
1862 |
30 Jan 06 |
nicklas |
280 |
if (dc != null) dc.close(); |
1862 |
30 Jan 06 |
nicklas |
281 |
} |
1862 |
30 Jan 06 |
nicklas |
282 |
if (forward != null) |
1862 |
30 Jan 06 |
nicklas |
283 |
{ |
6192 |
31 Oct 12 |
nicklas |
284 |
sc.setSessionSetting("alert-message", message); |
1862 |
30 Jan 06 |
nicklas |
285 |
pageContext.forward(forward); |
1862 |
30 Jan 06 |
nicklas |
286 |
} |
1862 |
30 Jan 06 |
nicklas |
287 |
else if (redirect != null) |
1862 |
30 Jan 06 |
nicklas |
288 |
{ |
6192 |
31 Oct 12 |
nicklas |
289 |
sc.setSessionSetting("alert-message", message); |
1862 |
30 Jan 06 |
nicklas |
290 |
response.sendRedirect(redirect); |
1862 |
30 Jan 06 |
nicklas |
291 |
} |
1862 |
30 Jan 06 |
nicklas |
292 |
else if (message == null) |
1862 |
30 Jan 06 |
nicklas |
293 |
{ |
1862 |
30 Jan 06 |
nicklas |
294 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
1862 |
30 Jan 06 |
nicklas |
295 |
} |
1862 |
30 Jan 06 |
nicklas |
296 |
else |
1862 |
30 Jan 06 |
nicklas |
297 |
{ |
1862 |
30 Jan 06 |
nicklas |
298 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
1862 |
30 Jan 06 |
nicklas |
299 |
} |
1862 |
30 Jan 06 |
nicklas |
300 |
|
3675 |
16 Aug 07 |
jari |
301 |
%> |