2210 |
03 May 06 |
nicklas |
1 |
<%-- $Id$ |
2210 |
03 May 06 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2006 Nicklas Nordborg, Martin Svensson |
2210 |
03 May 06 |
nicklas |
4 |
|
2210 |
03 May 06 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
2210 |
03 May 06 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
2210 |
03 May 06 |
nicklas |
7 |
|
2210 |
03 May 06 |
nicklas |
8 |
This file is part of BASE. |
2210 |
03 May 06 |
nicklas |
9 |
|
2210 |
03 May 06 |
nicklas |
10 |
BASE is free software; you can redistribute it and/or |
2210 |
03 May 06 |
nicklas |
11 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
12 |
as published by the Free Software Foundation; either version 3 |
2210 |
03 May 06 |
nicklas |
13 |
of the License, or (at your option) any later version. |
2210 |
03 May 06 |
nicklas |
14 |
|
2210 |
03 May 06 |
nicklas |
15 |
BASE is distributed in the hope that it will be useful, |
2210 |
03 May 06 |
nicklas |
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2210 |
03 May 06 |
nicklas |
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2210 |
03 May 06 |
nicklas |
18 |
GNU General Public License for more details. |
2210 |
03 May 06 |
nicklas |
19 |
|
2210 |
03 May 06 |
nicklas |
20 |
You should have received a copy of the GNU General Public License |
4511 |
11 Sep 08 |
jari |
21 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
2210 |
03 May 06 |
nicklas |
22 |
------------------------------------------------------------------ |
2210 |
03 May 06 |
nicklas |
23 |
|
2210 |
03 May 06 |
nicklas |
24 |
@author Nicklas |
2210 |
03 May 06 |
nicklas |
25 |
@version 2.0 |
2210 |
03 May 06 |
nicklas |
26 |
--%> |
5426 |
24 Sep 10 |
nicklas |
27 |
<%@ page pageEncoding="UTF-8" session="false" |
2210 |
03 May 06 |
nicklas |
28 |
import="net.sf.basedb.core.SessionControl" |
2210 |
03 May 06 |
nicklas |
29 |
import="net.sf.basedb.core.DbControl" |
2210 |
03 May 06 |
nicklas |
30 |
import="net.sf.basedb.core.Item" |
2210 |
03 May 06 |
nicklas |
31 |
import="net.sf.basedb.core.Include" |
2210 |
03 May 06 |
nicklas |
32 |
import="net.sf.basedb.core.Experiment" |
2210 |
03 May 06 |
nicklas |
33 |
import="net.sf.basedb.core.Transformation" |
2210 |
03 May 06 |
nicklas |
34 |
import="net.sf.basedb.core.Job" |
2210 |
03 May 06 |
nicklas |
35 |
import="net.sf.basedb.core.RawBioAssay" |
2210 |
03 May 06 |
nicklas |
36 |
import="net.sf.basedb.core.StringParameterType" |
2210 |
03 May 06 |
nicklas |
37 |
import="net.sf.basedb.core.IntegerParameterType" |
2210 |
03 May 06 |
nicklas |
38 |
import="net.sf.basedb.core.ItemParameterType" |
2210 |
03 May 06 |
nicklas |
39 |
import="net.sf.basedb.core.User" |
2210 |
03 May 06 |
nicklas |
40 |
import="net.sf.basedb.core.Path" |
2210 |
03 May 06 |
nicklas |
41 |
import="net.sf.basedb.core.ItemQuery" |
2210 |
03 May 06 |
nicklas |
42 |
import="net.sf.basedb.core.ItemResultIterator" |
2210 |
03 May 06 |
nicklas |
43 |
import="net.sf.basedb.core.Permission" |
2210 |
03 May 06 |
nicklas |
44 |
import="net.sf.basedb.core.PluginDefinition" |
2210 |
03 May 06 |
nicklas |
45 |
import="net.sf.basedb.core.ItemContext" |
2210 |
03 May 06 |
nicklas |
46 |
import="net.sf.basedb.core.MultiPermissions" |
2210 |
03 May 06 |
nicklas |
47 |
import="net.sf.basedb.core.PermissionDeniedException" |
2210 |
03 May 06 |
nicklas |
48 |
import="net.sf.basedb.core.ItemAlreadyExistsException" |
2210 |
03 May 06 |
nicklas |
49 |
import="net.sf.basedb.core.query.Restriction" |
2210 |
03 May 06 |
nicklas |
50 |
import="net.sf.basedb.util.RemovableUtil" |
2210 |
03 May 06 |
nicklas |
51 |
import="net.sf.basedb.util.ShareableUtil" |
2210 |
03 May 06 |
nicklas |
52 |
import="net.sf.basedb.util.BioAssaySetFilterUtil" |
2210 |
03 May 06 |
nicklas |
53 |
import="net.sf.basedb.util.DynamicFilter" |
2210 |
03 May 06 |
nicklas |
54 |
import="net.sf.basedb.util.IncludeExcludeFilter" |
2210 |
03 May 06 |
nicklas |
55 |
import="net.sf.basedb.clients.web.Base" |
2210 |
03 May 06 |
nicklas |
56 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
57 |
import="net.sf.basedb.util.Values" |
2210 |
03 May 06 |
nicklas |
58 |
import="net.sf.basedb.clients.web.util.HTML" |
5503 |
18 Nov 10 |
nicklas |
59 |
import="net.sf.basedb.core.plugin.GuiContext" |
5503 |
18 Nov 10 |
nicklas |
60 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
5503 |
18 Nov 10 |
nicklas |
61 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5503 |
18 Nov 10 |
nicklas |
62 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5503 |
18 Nov 10 |
nicklas |
63 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
64 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction" |
5503 |
18 Nov 10 |
nicklas |
65 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
2210 |
03 May 06 |
nicklas |
66 |
import="java.util.Enumeration" |
2210 |
03 May 06 |
nicklas |
67 |
import="java.util.Set" |
2210 |
03 May 06 |
nicklas |
68 |
import="java.util.HashSet" |
2210 |
03 May 06 |
nicklas |
69 |
import="java.util.List" |
2210 |
03 May 06 |
nicklas |
70 |
import="java.util.LinkedList" |
2210 |
03 May 06 |
nicklas |
71 |
import="java.util.Collections" |
2210 |
03 May 06 |
nicklas |
72 |
import="java.util.Arrays" |
2210 |
03 May 06 |
nicklas |
73 |
%> |
2210 |
03 May 06 |
nicklas |
74 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
2210 |
03 May 06 |
nicklas |
75 |
<%! |
2210 |
03 May 06 |
nicklas |
76 |
private static final Item itemType = Item.TRANSFORMATION; |
2210 |
03 May 06 |
nicklas |
77 |
%> |
2210 |
03 May 06 |
nicklas |
78 |
<% |
2210 |
03 May 06 |
nicklas |
79 |
final int experimentId = Values.getInt(request.getParameter("experiment_id")); |
2210 |
03 May 06 |
nicklas |
80 |
|
2210 |
03 May 06 |
nicklas |
81 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
2210 |
03 May 06 |
nicklas |
82 |
final String ID = sc.getId(); |
2210 |
03 May 06 |
nicklas |
83 |
final String cmd = request.getParameter("cmd"); |
2210 |
03 May 06 |
nicklas |
84 |
final String root = request.getContextPath()+"/"; |
2210 |
03 May 06 |
nicklas |
85 |
final String itemId = request.getParameter("item_id"); |
2210 |
03 May 06 |
nicklas |
86 |
|
2210 |
03 May 06 |
nicklas |
87 |
final String viewPage = "view_transformation.jsp?ID="+ID+"&experiment_id="+experimentId; |
2210 |
03 May 06 |
nicklas |
88 |
final String editPage = "edit_transformation.jsp?ID="+ID+"&experiment_id="+experimentId; |
2210 |
03 May 06 |
nicklas |
89 |
|
2210 |
03 May 06 |
nicklas |
90 |
sc.getCurrentContext(Item.EXPERIMENT).setId(experimentId); |
2210 |
03 May 06 |
nicklas |
91 |
|
2210 |
03 May 06 |
nicklas |
92 |
String forward = null; |
2210 |
03 May 06 |
nicklas |
93 |
String redirect = null; |
2210 |
03 May 06 |
nicklas |
94 |
String message = null; |
2210 |
03 May 06 |
nicklas |
95 |
DbControl dc = null; |
2210 |
03 May 06 |
nicklas |
96 |
|
2210 |
03 May 06 |
nicklas |
97 |
try |
2210 |
03 May 06 |
nicklas |
98 |
{ |
6315 |
06 Sep 13 |
nicklas |
99 |
if ("List".equals(cmd)) |
2210 |
03 May 06 |
nicklas |
100 |
{ |
6315 |
06 Sep 13 |
nicklas |
101 |
redirect = "../bioassaysets/index.jsp?ID="+ID+"&experiment_id="+experimentId; |
6315 |
06 Sep 13 |
nicklas |
102 |
} |
6315 |
06 Sep 13 |
nicklas |
103 |
else if ("ViewItem".equals(cmd)) |
6315 |
06 Sep 13 |
nicklas |
104 |
{ |
2210 |
03 May 06 |
nicklas |
105 |
// Display the view page for a single item |
2210 |
03 May 06 |
nicklas |
106 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, null); |
2210 |
03 May 06 |
nicklas |
107 |
forward = viewPage; |
2210 |
03 May 06 |
nicklas |
108 |
} |
2210 |
03 May 06 |
nicklas |
109 |
else if ("EditItem".equals(cmd)) |
2210 |
03 May 06 |
nicklas |
110 |
{ |
2210 |
03 May 06 |
nicklas |
111 |
// Display the edit page for a single item (should be opened in a popup) |
2210 |
03 May 06 |
nicklas |
112 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, null); |
2210 |
03 May 06 |
nicklas |
113 |
redirect = editPage; |
2210 |
03 May 06 |
nicklas |
114 |
} |
2210 |
03 May 06 |
nicklas |
115 |
else if ("UpdateItem".equals(cmd)) |
2210 |
03 May 06 |
nicklas |
116 |
{ |
2210 |
03 May 06 |
nicklas |
117 |
// Update the properties on an item (will close the popup) |
2210 |
03 May 06 |
nicklas |
118 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
7605 |
26 Feb 19 |
nicklas |
119 |
Transformation t = cc.getObject("item"); |
2210 |
03 May 06 |
nicklas |
120 |
if (t != null) |
2210 |
03 May 06 |
nicklas |
121 |
{ |
7954 |
12 May 21 |
nicklas |
122 |
dc = sc.newDbControl(":Edit "+itemType); |
5060 |
19 Aug 09 |
nicklas |
123 |
dc.reattachItem(t, false); |
2210 |
03 May 06 |
nicklas |
124 |
message = "Transformation updated"; |
5503 |
18 Nov 10 |
nicklas |
125 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.TRANSFORMATION), t); |
7604 |
25 Feb 19 |
nicklas |
126 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
5503 |
18 Nov 10 |
nicklas |
127 |
try |
5503 |
18 Nov 10 |
nicklas |
128 |
{ |
5503 |
18 Nov 10 |
nicklas |
129 |
t.setName(Values.getStringOrNull(request.getParameter("name"))); |
5503 |
18 Nov 10 |
nicklas |
130 |
t.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
5503 |
18 Nov 10 |
nicklas |
131 |
|
5503 |
18 Nov 10 |
nicklas |
132 |
// OnSave extensions |
5503 |
18 Nov 10 |
nicklas |
133 |
invoker.render(OnSaveRenderer.ON_SAVE); |
5503 |
18 Nov 10 |
nicklas |
134 |
dc.commit(); |
5503 |
18 Nov 10 |
nicklas |
135 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
5503 |
18 Nov 10 |
nicklas |
136 |
} |
5503 |
18 Nov 10 |
nicklas |
137 |
catch (Exception ex) |
5503 |
18 Nov 10 |
nicklas |
138 |
{ |
5503 |
18 Nov 10 |
nicklas |
139 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
5503 |
18 Nov 10 |
nicklas |
140 |
throw ex; |
5503 |
18 Nov 10 |
nicklas |
141 |
} |
5503 |
18 Nov 10 |
nicklas |
142 |
finally |
5503 |
18 Nov 10 |
nicklas |
143 |
{ |
5503 |
18 Nov 10 |
nicklas |
144 |
cc.removeObject("item"); |
5503 |
18 Nov 10 |
nicklas |
145 |
} |
2210 |
03 May 06 |
nicklas |
146 |
} |
2210 |
03 May 06 |
nicklas |
147 |
} |
2210 |
03 May 06 |
nicklas |
148 |
else if ("DeleteItem".equals(cmd)) |
2210 |
03 May 06 |
nicklas |
149 |
{ |
2210 |
03 May 06 |
nicklas |
150 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
151 |
dc = sc.newDbControl(":Delete "+itemType); |
2210 |
03 May 06 |
nicklas |
152 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, null); |
2526 |
15 Aug 06 |
martin |
153 |
RemovableUtil.removeRecursively(dc, itemType, Collections.singleton(cc.getId()), true); |
2210 |
03 May 06 |
nicklas |
154 |
dc.commit(); |
2210 |
03 May 06 |
nicklas |
155 |
redirect = viewPage; |
2210 |
03 May 06 |
nicklas |
156 |
} |
2210 |
03 May 06 |
nicklas |
157 |
else if ("RestoreItem".equals(cmd)) |
2210 |
03 May 06 |
nicklas |
158 |
{ |
2210 |
03 May 06 |
nicklas |
159 |
// Restore a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
160 |
dc = sc.newDbControl(":Restore "+itemType); |
2210 |
03 May 06 |
nicklas |
161 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, null); |
2526 |
15 Aug 06 |
martin |
162 |
RemovableUtil.removeRecursively(dc, itemType, Collections.singleton(cc.getId()), false); |
2210 |
03 May 06 |
nicklas |
163 |
dc.commit(); |
2210 |
03 May 06 |
nicklas |
164 |
redirect = viewPage; |
2210 |
03 May 06 |
nicklas |
165 |
} |
2210 |
03 May 06 |
nicklas |
166 |
else if ("ExportItem".equals(cmd)) |
2210 |
03 May 06 |
nicklas |
167 |
{ |
2210 |
03 May 06 |
nicklas |
168 |
// Run an export plugin in single-item context |
2210 |
03 May 06 |
nicklas |
169 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, null); |
2210 |
03 May 06 |
nicklas |
170 |
redirect = "../../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+bioassay+set"; |
2210 |
03 May 06 |
nicklas |
171 |
} |
2210 |
03 May 06 |
nicklas |
172 |
else if ("ImportItem".equals(cmd)) |
2210 |
03 May 06 |
nicklas |
173 |
{ |
2210 |
03 May 06 |
nicklas |
174 |
// Run an import plugin in single-item context |
2210 |
03 May 06 |
nicklas |
175 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, null); |
2210 |
03 May 06 |
nicklas |
176 |
redirect = "../../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+bioassay+set"; |
2210 |
03 May 06 |
nicklas |
177 |
} |
2210 |
03 May 06 |
nicklas |
178 |
else if ("RunPlugin".equals(cmd)) |
2210 |
03 May 06 |
nicklas |
179 |
{ |
2210 |
03 May 06 |
nicklas |
180 |
// Run a plugin in single-item context |
2210 |
03 May 06 |
nicklas |
181 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, null); |
2210 |
03 May 06 |
nicklas |
182 |
redirect = "../../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
2210 |
03 May 06 |
nicklas |
183 |
} |
2210 |
03 May 06 |
nicklas |
184 |
else |
2210 |
03 May 06 |
nicklas |
185 |
{ |
2210 |
03 May 06 |
nicklas |
186 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
2210 |
03 May 06 |
nicklas |
187 |
} |
2210 |
03 May 06 |
nicklas |
188 |
} |
2210 |
03 May 06 |
nicklas |
189 |
finally |
2210 |
03 May 06 |
nicklas |
190 |
{ |
2210 |
03 May 06 |
nicklas |
191 |
if (dc != null) dc.close(); |
2210 |
03 May 06 |
nicklas |
192 |
} |
2210 |
03 May 06 |
nicklas |
193 |
|
2210 |
03 May 06 |
nicklas |
194 |
if (forward != null) |
2210 |
03 May 06 |
nicklas |
195 |
{ |
6192 |
31 Oct 12 |
nicklas |
196 |
sc.setSessionSetting("alert-message", message); |
2210 |
03 May 06 |
nicklas |
197 |
pageContext.forward(forward); |
2210 |
03 May 06 |
nicklas |
198 |
} |
2210 |
03 May 06 |
nicklas |
199 |
else if (redirect != null) |
2210 |
03 May 06 |
nicklas |
200 |
{ |
6192 |
31 Oct 12 |
nicklas |
201 |
sc.setSessionSetting("alert-message", message); |
2210 |
03 May 06 |
nicklas |
202 |
response.sendRedirect(redirect); |
2210 |
03 May 06 |
nicklas |
203 |
} |
2210 |
03 May 06 |
nicklas |
204 |
else if (message == null) |
2210 |
03 May 06 |
nicklas |
205 |
{ |
2210 |
03 May 06 |
nicklas |
206 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
2210 |
03 May 06 |
nicklas |
207 |
} |
2210 |
03 May 06 |
nicklas |
208 |
else |
2210 |
03 May 06 |
nicklas |
209 |
{ |
2210 |
03 May 06 |
nicklas |
210 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
2210 |
03 May 06 |
nicklas |
211 |
} |
2210 |
03 May 06 |
nicklas |
212 |
%> |
2210 |
03 May 06 |
nicklas |
213 |
|