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