919 |
12 Jul 05 |
nicklas |
1 |
<%-- $Id$ |
919 |
12 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 |
919 |
12 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/ |
919 |
12 Jul 05 |
nicklas |
8 |
|
919 |
12 Jul 05 |
nicklas |
9 |
BASE is free software; you can redistribute it and/or |
919 |
12 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 |
919 |
12 Jul 05 |
nicklas |
12 |
of the License, or (at your option) any later version. |
919 |
12 Jul 05 |
nicklas |
13 |
|
919 |
12 Jul 05 |
nicklas |
14 |
BASE is distributed in the hope that it will be useful, |
919 |
12 Jul 05 |
nicklas |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
919 |
12 Jul 05 |
nicklas |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
919 |
12 Jul 05 |
nicklas |
17 |
GNU General Public License for more details. |
919 |
12 Jul 05 |
nicklas |
18 |
|
919 |
12 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/>. |
919 |
12 Jul 05 |
nicklas |
21 |
------------------------------------------------------------------ |
919 |
12 Jul 05 |
nicklas |
22 |
|
919 |
12 Jul 05 |
nicklas |
23 |
@author Nicklas |
919 |
12 Jul 05 |
nicklas |
24 |
@version 2.0 |
919 |
12 Jul 05 |
nicklas |
25 |
--%> |
5426 |
24 Sep 10 |
nicklas |
26 |
<%@ page pageEncoding="UTF-8" session="false" |
919 |
12 Jul 05 |
nicklas |
27 |
import="net.sf.basedb.core.SessionControl" |
919 |
12 Jul 05 |
nicklas |
28 |
import="net.sf.basedb.core.DbControl" |
919 |
12 Jul 05 |
nicklas |
29 |
import="net.sf.basedb.core.Item" |
1872 |
31 Jan 06 |
nicklas |
30 |
import="net.sf.basedb.core.Include" |
919 |
12 Jul 05 |
nicklas |
31 |
import="net.sf.basedb.core.Sample" |
1872 |
31 Jan 06 |
nicklas |
32 |
import="net.sf.basedb.core.BioSource" |
927 |
13 Jul 05 |
nicklas |
33 |
import="net.sf.basedb.core.BioMaterialEvent" |
5536 |
21 Dec 10 |
nicklas |
34 |
import="net.sf.basedb.core.BioPlateEventType" |
4729 |
14 Jan 09 |
martin |
35 |
import="net.sf.basedb.core.BioWell" |
5645 |
27 May 11 |
nicklas |
36 |
import="net.sf.basedb.core.ItemSubtype" |
4901 |
23 Apr 09 |
martin |
37 |
import="net.sf.basedb.core.Extract" |
6993 |
03 Nov 15 |
nicklas |
38 |
import="net.sf.basedb.core.Kit" |
1872 |
31 Jan 06 |
nicklas |
39 |
import="net.sf.basedb.core.Protocol" |
1418 |
07 Oct 05 |
nicklas |
40 |
import="net.sf.basedb.core.ItemQuery" |
1418 |
07 Oct 05 |
nicklas |
41 |
import="net.sf.basedb.core.ItemResultIterator" |
919 |
12 Jul 05 |
nicklas |
42 |
import="net.sf.basedb.core.Permission" |
1872 |
31 Jan 06 |
nicklas |
43 |
import="net.sf.basedb.core.ItemContext" |
1872 |
31 Jan 06 |
nicklas |
44 |
import="net.sf.basedb.core.MultiPermissions" |
4587 |
15 Oct 08 |
martin |
45 |
import="net.sf.basedb.core.OwnedItem" |
6695 |
28 Jan 15 |
nicklas |
46 |
import="net.sf.basedb.core.AnnotatedItem" |
1872 |
31 Jan 06 |
nicklas |
47 |
import="net.sf.basedb.core.PermissionDeniedException" |
1872 |
31 Jan 06 |
nicklas |
48 |
import="net.sf.basedb.core.ItemAlreadyExistsException" |
4901 |
23 Apr 09 |
martin |
49 |
import="net.sf.basedb.core.query.Hql" |
4901 |
23 Apr 09 |
martin |
50 |
import="net.sf.basedb.core.query.Orders" |
4901 |
23 Apr 09 |
martin |
51 |
import="net.sf.basedb.core.query.Restrictions" |
4901 |
23 Apr 09 |
martin |
52 |
import="net.sf.basedb.core.query.Expressions" |
1872 |
31 Jan 06 |
nicklas |
53 |
import="net.sf.basedb.util.RemovableUtil" |
1872 |
31 Jan 06 |
nicklas |
54 |
import="net.sf.basedb.util.ShareableUtil" |
2917 |
15 Nov 06 |
nicklas |
55 |
import="net.sf.basedb.util.OwnableUtil" |
919 |
12 Jul 05 |
nicklas |
56 |
import="net.sf.basedb.clients.web.Base" |
1872 |
31 Jan 06 |
nicklas |
57 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
58 |
import="net.sf.basedb.util.Values" |
4901 |
23 Apr 09 |
martin |
59 |
import="net.sf.basedb.clients.web.plugins.ParentBioMaterialLoader" |
5963 |
15 Feb 12 |
nicklas |
60 |
import="net.sf.basedb.clients.web.plugins.BioMaterialEventSourceFormatter" |
5963 |
15 Feb 12 |
nicklas |
61 |
import="net.sf.basedb.clients.web.plugins.ParentBioMaterialEventSourceLoader" |
4901 |
23 Apr 09 |
martin |
62 |
import="net.sf.basedb.clients.web.plugins.ItemQueryLoader" |
919 |
12 Jul 05 |
nicklas |
63 |
import="net.sf.basedb.clients.web.util.HTML" |
2942 |
22 Nov 06 |
nicklas |
64 |
import="net.sf.basedb.util.formatter.Formatter" |
4869 |
31 Mar 09 |
martin |
65 |
import="net.sf.basedb.util.formatter.WellCoordinateFormatter" |
4901 |
23 Apr 09 |
martin |
66 |
import="net.sf.basedb.util.formatter.NameableFormatter" |
5664 |
23 Jun 11 |
nicklas |
67 |
import="net.sf.basedb.util.formatter.ItemTypeFormatter" |
2942 |
22 Nov 06 |
nicklas |
68 |
import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
5490 |
15 Nov 10 |
nicklas |
69 |
|
5490 |
15 Nov 10 |
nicklas |
70 |
import="net.sf.basedb.core.plugin.GuiContext" |
5490 |
15 Nov 10 |
nicklas |
71 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
5490 |
15 Nov 10 |
nicklas |
72 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5490 |
15 Nov 10 |
nicklas |
73 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5490 |
15 Nov 10 |
nicklas |
74 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
75 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction" |
5490 |
15 Nov 10 |
nicklas |
76 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
6029 |
27 Mar 12 |
nicklas |
77 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
7604 |
25 Feb 19 |
nicklas |
78 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
6029 |
27 Mar 12 |
nicklas |
79 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
1872 |
31 Jan 06 |
nicklas |
80 |
import="java.util.Enumeration" |
1872 |
31 Jan 06 |
nicklas |
81 |
import="java.util.Set" |
1872 |
31 Jan 06 |
nicklas |
82 |
import="java.util.HashSet" |
951 |
18 Jul 05 |
nicklas |
83 |
import="java.util.List" |
1872 |
31 Jan 06 |
nicklas |
84 |
import="java.util.ArrayList" |
1872 |
31 Jan 06 |
nicklas |
85 |
import="java.util.Collections" |
2942 |
22 Nov 06 |
nicklas |
86 |
import="java.util.Date" |
919 |
12 Jul 05 |
nicklas |
87 |
%> |
919 |
12 Jul 05 |
nicklas |
88 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
919 |
12 Jul 05 |
nicklas |
89 |
<%! |
5645 |
27 May 11 |
nicklas |
90 |
private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,itemSubtype,originalQuantity,remainingQuantity,extracts,description"); |
1872 |
31 Jan 06 |
nicklas |
91 |
private static final Item itemType = Item.SAMPLE; |
4869 |
31 Mar 09 |
martin |
92 |
|
4901 |
23 Apr 09 |
martin |
93 |
private static void registerExportUtils(ItemContext cc) |
4869 |
31 Mar 09 |
martin |
94 |
{ |
4901 |
23 Apr 09 |
martin |
95 |
// Register formatters |
4869 |
31 Mar 09 |
martin |
96 |
cc.setObject("export.formatter.bioWell.row", new WellCoordinateFormatter(true)); |
4869 |
31 Mar 09 |
martin |
97 |
cc.setObject("export.formatter.bioWell.column", new WellCoordinateFormatter(false)); |
5963 |
15 Feb 12 |
nicklas |
98 |
cc.setObject("export.formatter.&creationEvent.sources(bioMaterial.name)", new BioMaterialEventSourceFormatter()); |
5663 |
22 Jun 11 |
nicklas |
99 |
cc.setObject("export.formatter.&childCreationEvents(event.bioMaterial.name)", new NameableFormatter()); |
4901 |
23 Apr 09 |
martin |
100 |
cc.setObject("export.formatter.&children(name)", new NameableFormatter()); |
5664 |
23 Jun 11 |
nicklas |
101 |
cc.setObject("export.formatter.parentType", new ItemTypeFormatter()); |
4901 |
23 Apr 09 |
martin |
102 |
|
4901 |
23 Apr 09 |
martin |
103 |
// Register dataloaders |
5567 |
10 Feb 11 |
nicklas |
104 |
String sampleParameter = "sample"; |
5567 |
10 Feb 11 |
nicklas |
105 |
|
5567 |
10 Feb 11 |
nicklas |
106 |
// Child extracts |
4901 |
23 Apr 09 |
martin |
107 |
ItemQuery<Extract> extractQuery = Extract.getQuery(); |
4901 |
23 Apr 09 |
martin |
108 |
extractQuery.include(cc.getInclude()); |
4901 |
23 Apr 09 |
martin |
109 |
extractQuery.restrict(Restrictions.eq(Hql.property("parent"), Expressions.parameter(sampleParameter))); |
4901 |
23 Apr 09 |
martin |
110 |
extractQuery.order(Orders.asc(Hql.property("name"))); |
7604 |
25 Feb 19 |
nicklas |
111 |
cc.setObject("export.dataloader.&children(name)", new ItemQueryLoader<Sample>(extractQuery, sampleParameter)); |
5567 |
10 Feb 11 |
nicklas |
112 |
|
5567 |
10 Feb 11 |
nicklas |
113 |
// Child samples |
5567 |
10 Feb 11 |
nicklas |
114 |
ItemQuery<Sample> childSamplesQuery = Sample.getQuery(); |
5567 |
10 Feb 11 |
nicklas |
115 |
childSamplesQuery.join(Hql.innerJoin("creationEvent", "ce")); |
5567 |
10 Feb 11 |
nicklas |
116 |
childSamplesQuery.join(Hql.innerJoin("ce", "sources", "src")); |
5663 |
22 Jun 11 |
nicklas |
117 |
childSamplesQuery.restrict(Restrictions.eq(Hql.property("src", "bioMaterial"), Expressions.parameter(sampleParameter))); |
5567 |
10 Feb 11 |
nicklas |
118 |
childSamplesQuery.order(Orders.asc(Hql.property("name"))); |
5567 |
10 Feb 11 |
nicklas |
119 |
childSamplesQuery.include(cc.getInclude()); |
7604 |
25 Feb 19 |
nicklas |
120 |
cc.setObject("export.dataloader.&childCreationEvents(event.bioMaterial.name)", new ItemQueryLoader<Sample>(childSamplesQuery, sampleParameter)); |
5567 |
10 Feb 11 |
nicklas |
121 |
|
5567 |
10 Feb 11 |
nicklas |
122 |
// Parent samples |
5963 |
15 Feb 12 |
nicklas |
123 |
cc.setObject("export.dataloader.&creationEvent.sources(bioMaterial.name)", new ParentBioMaterialEventSourceLoader()); |
4869 |
31 Mar 09 |
martin |
124 |
} |
919 |
12 Jul 05 |
nicklas |
125 |
%> |
919 |
12 Jul 05 |
nicklas |
126 |
<% |
1872 |
31 Jan 06 |
nicklas |
127 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
919 |
12 Jul 05 |
nicklas |
128 |
final String ID = sc.getId(); |
1872 |
31 Jan 06 |
nicklas |
129 |
final String cmd = request.getParameter("cmd"); |
1872 |
31 Jan 06 |
nicklas |
130 |
final String root = request.getContextPath()+"/"; |
1872 |
31 Jan 06 |
nicklas |
131 |
final String mode = request.getParameter("mode"); |
1872 |
31 Jan 06 |
nicklas |
132 |
final String callback = request.getParameter("callback"); |
1872 |
31 Jan 06 |
nicklas |
133 |
final String itemId = request.getParameter("item_id"); |
1872 |
31 Jan 06 |
nicklas |
134 |
final String listPage = "list_samples.jsp?ID="+ID |
1872 |
31 Jan 06 |
nicklas |
135 |
+(mode == null ? "" : "&mode="+mode) |
1872 |
31 Jan 06 |
nicklas |
136 |
+(callback == null ? "" : "&callback="+callback) |
1872 |
31 Jan 06 |
nicklas |
137 |
+(itemId == null ? "" : "&item_id="+itemId); |
1872 |
31 Jan 06 |
nicklas |
138 |
final String viewPage = "view_sample.jsp?ID="+ID; |
1872 |
31 Jan 06 |
nicklas |
139 |
final String editPage = "edit_sample.jsp?ID="+ID; |
919 |
12 Jul 05 |
nicklas |
140 |
|
1872 |
31 Jan 06 |
nicklas |
141 |
String forward = null; |
1872 |
31 Jan 06 |
nicklas |
142 |
String redirect = null; |
1872 |
31 Jan 06 |
nicklas |
143 |
String message = null; |
1872 |
31 Jan 06 |
nicklas |
144 |
DbControl dc = null; |
1872 |
31 Jan 06 |
nicklas |
145 |
|
919 |
12 Jul 05 |
nicklas |
146 |
try |
919 |
12 Jul 05 |
nicklas |
147 |
{ |
1872 |
31 Jan 06 |
nicklas |
148 |
if (cmd == null || "List".equals(cmd)) |
941 |
15 Jul 05 |
nicklas |
149 |
{ |
1872 |
31 Jan 06 |
nicklas |
150 |
// Display the list page without updatinging the current context |
2811 |
26 Oct 06 |
nicklas |
151 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
1872 |
31 Jan 06 |
nicklas |
152 |
redirect = listPage; |
941 |
15 Jul 05 |
nicklas |
153 |
} |
1872 |
31 Jan 06 |
nicklas |
154 |
else if ("UpdateContext".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
155 |
{ |
1872 |
31 Jan 06 |
nicklas |
156 |
// Display the list page after updating the current context from the request parameters |
1872 |
31 Jan 06 |
nicklas |
157 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
158 |
redirect = listPage; |
1872 |
31 Jan 06 |
nicklas |
159 |
} |
1872 |
31 Jan 06 |
nicklas |
160 |
else if ("LoadContext".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
161 |
{ |
1872 |
31 Jan 06 |
nicklas |
162 |
// Display the list page after loading a saved context |
1872 |
31 Jan 06 |
nicklas |
163 |
int contextId = Values.getInt(request.getParameter("context")); |
1872 |
31 Jan 06 |
nicklas |
164 |
Base.loadContext(sc, contextId, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
165 |
redirect = listPage; |
1872 |
31 Jan 06 |
nicklas |
166 |
} |
941 |
15 Jul 05 |
nicklas |
167 |
|
1872 |
31 Jan 06 |
nicklas |
168 |
else if ("ViewItem".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
169 |
{ |
1872 |
31 Jan 06 |
nicklas |
170 |
// Display the view page for a single item |
1872 |
31 Jan 06 |
nicklas |
171 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
172 |
forward = viewPage; |
1872 |
31 Jan 06 |
nicklas |
173 |
} |
1872 |
31 Jan 06 |
nicklas |
174 |
else if ("EditItem".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
175 |
{ |
1872 |
31 Jan 06 |
nicklas |
176 |
// Display the edit page for a single item (should be opened in a popup) |
1872 |
31 Jan 06 |
nicklas |
177 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
178 |
redirect = editPage; |
1872 |
31 Jan 06 |
nicklas |
179 |
} |
1872 |
31 Jan 06 |
nicklas |
180 |
else if ("NewItem".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
181 |
{ |
1872 |
31 Jan 06 |
nicklas |
182 |
// Display the edit page for a new item (should be opened in a popup) |
1872 |
31 Jan 06 |
nicklas |
183 |
if (!sc.hasPermission(Permission.CREATE, itemType)) |
919 |
12 Jul 05 |
nicklas |
184 |
{ |
1872 |
31 Jan 06 |
nicklas |
185 |
throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
919 |
12 Jul 05 |
nicklas |
186 |
} |
1872 |
31 Jan 06 |
nicklas |
187 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
188 |
cc.setId(0); |
2404 |
21 Jun 06 |
nicklas |
189 |
forward = editPage; |
1872 |
31 Jan 06 |
nicklas |
190 |
} |
2472 |
31 Jul 06 |
martin |
191 |
else if ("NewPooledItem".equals(cmd)) |
2472 |
31 Jul 06 |
martin |
192 |
{ |
2472 |
31 Jul 06 |
martin |
193 |
// Display the edit page for a new pooled item (should be opened in a popup) |
2472 |
31 Jul 06 |
martin |
194 |
if (!sc.hasPermission(Permission.CREATE, itemType)) |
2472 |
31 Jul 06 |
martin |
195 |
{ |
2472 |
31 Jul 06 |
martin |
196 |
throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
2472 |
31 Jul 06 |
martin |
197 |
} |
2472 |
31 Jul 06 |
martin |
198 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
2472 |
31 Jul 06 |
martin |
199 |
cc.setId(0); |
2472 |
31 Jul 06 |
martin |
200 |
forward = editPage+"&pooled="+true; |
2472 |
31 Jul 06 |
martin |
201 |
} |
1872 |
31 Jan 06 |
nicklas |
202 |
else if ("UpdateItem".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
203 |
{ |
1872 |
31 Jan 06 |
nicklas |
204 |
// Update the properties on an item (will close the popup) |
1872 |
31 Jan 06 |
nicklas |
205 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
2597 |
25 Aug 06 |
nicklas |
206 |
final int maxRecent = Base.getMaxRecent(sc); |
7954 |
12 May 21 |
nicklas |
207 |
dc = sc.newDbControl(":Edit "+itemType); |
7605 |
26 Feb 19 |
nicklas |
208 |
Sample sample = cc.getObject("item"); |
1872 |
31 Jan 06 |
nicklas |
209 |
if (sample == null) |
919 |
12 Jul 05 |
nicklas |
210 |
{ |
1872 |
31 Jan 06 |
nicklas |
211 |
sample = Sample.getNew(dc); |
1872 |
31 Jan 06 |
nicklas |
212 |
message = "Sample created"; |
1872 |
31 Jan 06 |
nicklas |
213 |
dc.saveItem(sample); |
919 |
12 Jul 05 |
nicklas |
214 |
} |
1872 |
31 Jan 06 |
nicklas |
215 |
else |
919 |
12 Jul 05 |
nicklas |
216 |
{ |
5060 |
19 Aug 09 |
nicklas |
217 |
dc.reattachItem(sample, false); |
5060 |
19 Aug 09 |
nicklas |
218 |
dc.reattachItem(sample.getCreationEvent(), false); |
1872 |
31 Jan 06 |
nicklas |
219 |
message = "Sample updated"; |
919 |
12 Jul 05 |
nicklas |
220 |
} |
5490 |
15 Nov 10 |
nicklas |
221 |
|
5490 |
15 Nov 10 |
nicklas |
222 |
// Create extension context |
5490 |
15 Nov 10 |
nicklas |
223 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.SAMPLE), sample); |
7604 |
25 Feb 19 |
nicklas |
224 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
5490 |
15 Nov 10 |
nicklas |
225 |
try |
919 |
12 Jul 05 |
nicklas |
226 |
{ |
5490 |
15 Nov 10 |
nicklas |
227 |
sample.setName(Values.getStringOrNull(request.getParameter("name"))); |
5490 |
15 Nov 10 |
nicklas |
228 |
sample.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
5490 |
15 Nov 10 |
nicklas |
229 |
sample.setExternalId(Values.getStringOrNull(request.getParameter("external_id"))); |
5490 |
15 Nov 10 |
nicklas |
230 |
sample.setOriginalQuantity(Values.getFloat(request.getParameter("original_quantity"), null)); |
5686 |
05 Aug 11 |
nicklas |
231 |
|
5686 |
05 Aug 11 |
nicklas |
232 |
int subtypeId = Values.getInt(request.getParameter("subtype_id"), -1); |
5686 |
05 Aug 11 |
nicklas |
233 |
ItemSubtype subtype = null; |
5686 |
05 Aug 11 |
nicklas |
234 |
if (subtypeId >= 0) // < 0 = denied or unchanged |
5686 |
05 Aug 11 |
nicklas |
235 |
{ |
5686 |
05 Aug 11 |
nicklas |
236 |
if (subtypeId > 0) subtype = ItemSubtype.getById(dc, subtypeId); |
5686 |
05 Aug 11 |
nicklas |
237 |
sample.setItemSubtype(subtype); |
7703 |
11 Apr 19 |
nicklas |
238 |
cc.setRecent(Item.ITEMSUBTYPE, subtype, maxRecent); |
5686 |
05 Aug 11 |
nicklas |
239 |
} |
5490 |
15 Nov 10 |
nicklas |
240 |
|
5490 |
15 Nov 10 |
nicklas |
241 |
BioMaterialEvent creationEvent = sample.getCreationEvent(); |
5490 |
15 Nov 10 |
nicklas |
242 |
if (creationEvent.hasPermission(Permission.WRITE)) |
5383 |
10 Aug 10 |
nicklas |
243 |
{ |
5490 |
15 Nov 10 |
nicklas |
244 |
Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
5490 |
15 Nov 10 |
nicklas |
245 |
creationEvent.setEventDate(dateFormatter.parseString(Values.getStringOrNull(request.getParameter("event_date")))); |
5490 |
15 Nov 10 |
nicklas |
246 |
int protocolId = Values.getInt(request.getParameter("protocol_id"), -1); |
5490 |
15 Nov 10 |
nicklas |
247 |
if (protocolId >= 0) // < 0 = denied or unchanged |
5490 |
15 Nov 10 |
nicklas |
248 |
{ |
5490 |
15 Nov 10 |
nicklas |
249 |
Protocol pt = protocolId == 0 ? null : Protocol.getById(dc, protocolId); |
5490 |
15 Nov 10 |
nicklas |
250 |
creationEvent.setProtocol(pt); |
7703 |
11 Apr 19 |
nicklas |
251 |
cc.setRecent(Item.PROTOCOL, pt, subtype, maxRecent); |
5490 |
15 Nov 10 |
nicklas |
252 |
} |
6993 |
03 Nov 15 |
nicklas |
253 |
int kitId = Values.getInt(request.getParameter("kit_id"), -1); |
6993 |
03 Nov 15 |
nicklas |
254 |
if (kitId >= 0) // < 0 = denied or unchanged |
6993 |
03 Nov 15 |
nicklas |
255 |
{ |
6993 |
03 Nov 15 |
nicklas |
256 |
Kit kit = kitId == 0 ? null : Kit.getById(dc, kitId); |
6993 |
03 Nov 15 |
nicklas |
257 |
creationEvent.setKit(kit); |
7703 |
11 Apr 19 |
nicklas |
258 |
cc.setRecent(Item.KIT, kit, subtype, maxRecent); |
6993 |
03 Nov 15 |
nicklas |
259 |
} |
5383 |
10 Aug 10 |
nicklas |
260 |
} |
5686 |
05 Aug 11 |
nicklas |
261 |
|
5490 |
15 Nov 10 |
nicklas |
262 |
int biowellId = Values.getInt(request.getParameter("biowell_id"), -1); |
5490 |
15 Nov 10 |
nicklas |
263 |
if (biowellId >= 0) // < 0 = denied or unchanged |
4730 |
15 Jan 09 |
martin |
264 |
{ |
5490 |
15 Nov 10 |
nicklas |
265 |
BioWell bw = biowellId == 0 ? null : BioWell.getById(dc, biowellId); |
5490 |
15 Nov 10 |
nicklas |
266 |
if (bw != null && bw.getBioMaterial() != null) |
5490 |
15 Nov 10 |
nicklas |
267 |
{ |
5490 |
15 Nov 10 |
nicklas |
268 |
throw new WebException("popup", "Biowell can not be used", |
5490 |
15 Nov 10 |
nicklas |
269 |
"The biowell [{1}] on bioplate {2} is already connected to another biomaterial", |
5490 |
15 Nov 10 |
nicklas |
270 |
HTML.encodeTags(bw.getRow()+"," + bw.getColumn()), HTML.encodeTags(bw.getPlate().getName())); |
5490 |
15 Nov 10 |
nicklas |
271 |
} |
5490 |
15 Nov 10 |
nicklas |
272 |
sample.setBioWell(bw); |
7703 |
11 Apr 19 |
nicklas |
273 |
cc.setRecent(Item.BIOPLATE, bw == null ? null : bw.getPlate(), subtype, maxRecent); |
4730 |
15 Jan 09 |
martin |
274 |
} |
5490 |
15 Nov 10 |
nicklas |
275 |
|
5490 |
15 Nov 10 |
nicklas |
276 |
// Parents tab |
5663 |
22 Jun 11 |
nicklas |
277 |
Item parentType = Item.valueOf(request.getParameter("parentType")); |
5663 |
22 Jun 11 |
nicklas |
278 |
if (parentType == Item.BIOSOURCE) |
919 |
12 Jul 05 |
nicklas |
279 |
{ |
5490 |
15 Nov 10 |
nicklas |
280 |
int bioSourceId = Values.getInt(request.getParameter("biosource_id"), -1); |
5490 |
15 Nov 10 |
nicklas |
281 |
if (bioSourceId >= 0) // < 0 = denied or unchanged |
5490 |
15 Nov 10 |
nicklas |
282 |
{ |
5490 |
15 Nov 10 |
nicklas |
283 |
BioSource bs = bioSourceId == 0 ? null : BioSource.getById(dc, bioSourceId); |
5663 |
22 Jun 11 |
nicklas |
284 |
creationEvent.setSource(bs); |
7703 |
11 Apr 19 |
nicklas |
285 |
cc.setRecent(Item.BIOSOURCE, bs, maxRecent); |
5490 |
15 Nov 10 |
nicklas |
286 |
} |
919 |
12 Jul 05 |
nicklas |
287 |
} |
5490 |
15 Nov 10 |
nicklas |
288 |
else |
919 |
12 Jul 05 |
nicklas |
289 |
{ |
5663 |
22 Jun 11 |
nicklas |
290 |
if (sample.getParentType() != Item.SAMPLE) |
5663 |
22 Jun 11 |
nicklas |
291 |
{ |
5663 |
22 Jun 11 |
nicklas |
292 |
creationEvent.clearSources(); |
5663 |
22 Jun 11 |
nicklas |
293 |
} |
6312 |
28 Aug 13 |
nicklas |
294 |
String[] modifiedSamples = Values.getString(request.getParameter("+SAMPLE")).split(","); |
5490 |
15 Nov 10 |
nicklas |
295 |
for (int i = 0; i < modifiedSamples.length; ++i) |
951 |
18 Jul 05 |
nicklas |
296 |
{ |
5490 |
15 Nov 10 |
nicklas |
297 |
int sId = Values.getInt(modifiedSamples[i], -1); |
5490 |
15 Nov 10 |
nicklas |
298 |
if (sId != -1) |
5490 |
15 Nov 10 |
nicklas |
299 |
{ |
5490 |
15 Nov 10 |
nicklas |
300 |
Sample s = Sample.getById(dc, sId); |
6312 |
28 Aug 13 |
nicklas |
301 |
creationEvent.addSource(s).setUsedQuantity(Values.getFloat(request.getParameter("SAMPLE."+sId), null)); |
5490 |
15 Nov 10 |
nicklas |
302 |
} |
951 |
18 Jul 05 |
nicklas |
303 |
} |
6312 |
28 Aug 13 |
nicklas |
304 |
String[] removedSamples = Values.getString(request.getParameter("-SAMPLE")).split(","); |
5490 |
15 Nov 10 |
nicklas |
305 |
for (int i = 0; i < removedSamples.length; ++i) |
5490 |
15 Nov 10 |
nicklas |
306 |
{ |
5490 |
15 Nov 10 |
nicklas |
307 |
int sId = Values.getInt(removedSamples[i], -1); |
5490 |
15 Nov 10 |
nicklas |
308 |
if (sId != -1) creationEvent.removeSource(Sample.getById(dc, sId)); |
5490 |
15 Nov 10 |
nicklas |
309 |
} |
919 |
12 Jul 05 |
nicklas |
310 |
} |
5490 |
15 Nov 10 |
nicklas |
311 |
|
5490 |
15 Nov 10 |
nicklas |
312 |
// Annotations tab |
5490 |
15 Nov 10 |
nicklas |
313 |
Base.updateAnnotations(dc, sample, sample, request); |
5490 |
15 Nov 10 |
nicklas |
314 |
|
5490 |
15 Nov 10 |
nicklas |
315 |
// OnSave extensions |
5490 |
15 Nov 10 |
nicklas |
316 |
invoker.render(OnSaveRenderer.ON_SAVE); |
5490 |
15 Nov 10 |
nicklas |
317 |
dc.commit(); |
5490 |
15 Nov 10 |
nicklas |
318 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
1872 |
31 Jan 06 |
nicklas |
319 |
} |
5490 |
15 Nov 10 |
nicklas |
320 |
catch (Exception ex) |
5490 |
15 Nov 10 |
nicklas |
321 |
{ |
5490 |
15 Nov 10 |
nicklas |
322 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
5490 |
15 Nov 10 |
nicklas |
323 |
throw ex; |
5490 |
15 Nov 10 |
nicklas |
324 |
} |
5490 |
15 Nov 10 |
nicklas |
325 |
finally |
5490 |
15 Nov 10 |
nicklas |
326 |
{ |
5490 |
15 Nov 10 |
nicklas |
327 |
cc.removeObject("item"); |
5490 |
15 Nov 10 |
nicklas |
328 |
} |
1872 |
31 Jan 06 |
nicklas |
329 |
} |
1872 |
31 Jan 06 |
nicklas |
330 |
else if ("DeleteItem".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
331 |
{ |
1872 |
31 Jan 06 |
nicklas |
332 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
333 |
dc = sc.newDbControl(":Delete "+itemType); |
1872 |
31 Jan 06 |
nicklas |
334 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
335 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true); |
1872 |
31 Jan 06 |
nicklas |
336 |
dc.commit(); |
1872 |
31 Jan 06 |
nicklas |
337 |
redirect = viewPage; |
1872 |
31 Jan 06 |
nicklas |
338 |
} |
1872 |
31 Jan 06 |
nicklas |
339 |
else if ("DeleteItems".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
340 |
{ |
1872 |
31 Jan 06 |
nicklas |
341 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
342 |
dc = sc.newDbControl(":Delete "+itemType); |
1872 |
31 Jan 06 |
nicklas |
343 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
344 |
int numTotal = cc.getSelected().size(); |
1872 |
31 Jan 06 |
nicklas |
345 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
1872 |
31 Jan 06 |
nicklas |
346 |
dc.commit(); |
1872 |
31 Jan 06 |
nicklas |
347 |
if (numTotal != numRemoved) |
1872 |
31 Jan 06 |
nicklas |
348 |
{ |
1872 |
31 Jan 06 |
nicklas |
349 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
1872 |
31 Jan 06 |
nicklas |
350 |
} |
6192 |
31 Oct 12 |
nicklas |
351 |
redirect = listPage; |
1872 |
31 Jan 06 |
nicklas |
352 |
} |
1872 |
31 Jan 06 |
nicklas |
353 |
else if ("RestoreItem".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
354 |
{ |
1872 |
31 Jan 06 |
nicklas |
355 |
// Restore a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
356 |
dc = sc.newDbControl(":Restore "+itemType); |
1872 |
31 Jan 06 |
nicklas |
357 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
358 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false); |
1872 |
31 Jan 06 |
nicklas |
359 |
dc.commit(); |
1872 |
31 Jan 06 |
nicklas |
360 |
redirect = viewPage; |
1872 |
31 Jan 06 |
nicklas |
361 |
} |
1872 |
31 Jan 06 |
nicklas |
362 |
else if ("RestoreItems".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
363 |
{ |
1872 |
31 Jan 06 |
nicklas |
364 |
// Restore all selected items on the list page |
7954 |
12 May 21 |
nicklas |
365 |
dc = sc.newDbControl(":Restore "+itemType); |
1872 |
31 Jan 06 |
nicklas |
366 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
367 |
int numTotal = cc.getSelected().size(); |
1872 |
31 Jan 06 |
nicklas |
368 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
1872 |
31 Jan 06 |
nicklas |
369 |
dc.commit(); |
1872 |
31 Jan 06 |
nicklas |
370 |
if (numTotal != numRemoved) |
1872 |
31 Jan 06 |
nicklas |
371 |
{ |
2528 |
15 Aug 06 |
martin |
372 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
1872 |
31 Jan 06 |
nicklas |
373 |
} |
6192 |
31 Oct 12 |
nicklas |
374 |
redirect = listPage; |
1872 |
31 Jan 06 |
nicklas |
375 |
} |
1872 |
31 Jan 06 |
nicklas |
376 |
else if ("ShareItem".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
377 |
{ |
1872 |
31 Jan 06 |
nicklas |
378 |
// Display a popup window for sharing a single item |
7954 |
12 May 21 |
nicklas |
379 |
dc = sc.newDbControl(":Share "+itemType); |
1872 |
31 Jan 06 |
nicklas |
380 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
381 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, Collections.singleton(cc.getId())); |
1872 |
31 Jan 06 |
nicklas |
382 |
dc.close(); |
1872 |
31 Jan 06 |
nicklas |
383 |
cc.setObject("MultiPermissions", permissions); |
1872 |
31 Jan 06 |
nicklas |
384 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
1872 |
31 Jan 06 |
nicklas |
385 |
} |
1872 |
31 Jan 06 |
nicklas |
386 |
else if ("ShareItems".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
387 |
{ |
1872 |
31 Jan 06 |
nicklas |
388 |
// Display a popup window for sharing all selected items on the list page |
7954 |
12 May 21 |
nicklas |
389 |
dc = sc.newDbControl(":Share "+itemType); |
1872 |
31 Jan 06 |
nicklas |
390 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
391 |
MultiPermissions permissions = ShareableUtil.getMultiPermissions(dc, itemType, cc.getSelected()); |
1872 |
31 Jan 06 |
nicklas |
392 |
dc.close(); |
1872 |
31 Jan 06 |
nicklas |
393 |
cc.setObject("MultiPermissions", permissions); |
1872 |
31 Jan 06 |
nicklas |
394 |
redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name(); |
1872 |
31 Jan 06 |
nicklas |
395 |
} |
4578 |
13 Oct 08 |
martin |
396 |
else if ("SetOwnerOfItem".equals(cmd)) |
2917 |
15 Nov 06 |
nicklas |
397 |
{ |
4578 |
13 Oct 08 |
martin |
398 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
399 |
dc = sc.newDbControl(":Set owner of "+itemType); |
2917 |
15 Nov 06 |
nicklas |
400 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4587 |
15 Oct 08 |
martin |
401 |
OwnedItem item = (OwnedItem)itemType.getById(dc, cc.getId()); |
4587 |
15 Oct 08 |
martin |
402 |
cc.setObject("OwnedItems", Collections.singleton(item)); |
4578 |
13 Oct 08 |
martin |
403 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
2917 |
15 Nov 06 |
nicklas |
404 |
} |
4578 |
13 Oct 08 |
martin |
405 |
else if ("SetOwnerOfItems".equals(cmd)) |
2917 |
15 Nov 06 |
nicklas |
406 |
{ |
4578 |
13 Oct 08 |
martin |
407 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
408 |
dc = sc.newDbControl(":Set owner of "+itemType); |
2917 |
15 Nov 06 |
nicklas |
409 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4587 |
15 Oct 08 |
martin |
410 |
Set<OwnedItem> items = new HashSet<OwnedItem>(); |
4587 |
15 Oct 08 |
martin |
411 |
for (Integer id : cc.getSelected()) |
4587 |
15 Oct 08 |
martin |
412 |
{ |
4587 |
15 Oct 08 |
martin |
413 |
if (id != null) items.add((OwnedItem)itemType.getById(dc, id)); |
4587 |
15 Oct 08 |
martin |
414 |
} |
4587 |
15 Oct 08 |
martin |
415 |
dc.close(); |
4587 |
15 Oct 08 |
martin |
416 |
cc.setObject("OwnedItems", items); |
4578 |
13 Oct 08 |
martin |
417 |
redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); |
2917 |
15 Nov 06 |
nicklas |
418 |
} |
6695 |
28 Jan 15 |
nicklas |
419 |
else if ("InheritAnnotations".equals(cmd)) |
6695 |
28 Jan 15 |
nicklas |
420 |
{ |
6695 |
28 Jan 15 |
nicklas |
421 |
// Change owner of items selected on a list page |
7954 |
12 May 21 |
nicklas |
422 |
dc = sc.newDbControl(":Inherit annotations"); |
6695 |
28 Jan 15 |
nicklas |
423 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
6695 |
28 Jan 15 |
nicklas |
424 |
Set<AnnotatedItem> items = new HashSet<AnnotatedItem>(); |
6695 |
28 Jan 15 |
nicklas |
425 |
for (Integer id : cc.getSelected()) |
6695 |
28 Jan 15 |
nicklas |
426 |
{ |
6695 |
28 Jan 15 |
nicklas |
427 |
if (id != null) items.add((AnnotatedItem)itemType.getById(dc, id)); |
6695 |
28 Jan 15 |
nicklas |
428 |
} |
6695 |
28 Jan 15 |
nicklas |
429 |
dc.close(); |
6695 |
28 Jan 15 |
nicklas |
430 |
cc.setObject("AnnotatedItems", items); |
6695 |
28 Jan 15 |
nicklas |
431 |
redirect = "../../common/annotations/batch_inherit.jsp?ID="+ID+"&item_type="+itemType.name(); |
6695 |
28 Jan 15 |
nicklas |
432 |
} |
1872 |
31 Jan 06 |
nicklas |
433 |
else if ("ExportItems".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
434 |
{ |
1872 |
31 Jan 06 |
nicklas |
435 |
// Run an export plugin in a list context |
1872 |
31 Jan 06 |
nicklas |
436 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
437 |
final ItemQuery<Sample> query = Sample.getQuery(); |
7954 |
12 May 21 |
nicklas |
438 |
dc = sc.newDbControl(":Export "+itemType); |
7914 |
23 Feb 21 |
nicklas |
439 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
440 |
cc.configureQuery(dc, query, jspContext, true); |
6030 |
28 Mar 12 |
nicklas |
441 |
registerExportUtils(cc); |
6030 |
28 Mar 12 |
nicklas |
442 |
cc.setQuery(query); |
7604 |
25 Feb 19 |
nicklas |
443 |
ExtensionsInvoker<ListColumnAction<Sample,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
444 |
listInvoker.render(new ListColumnExportRenderer<Sample>(cc)); |
5590 |
16 Mar 11 |
nicklas |
445 |
dc.close(); |
1872 |
31 Jan 06 |
nicklas |
446 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+samples"; |
1872 |
31 Jan 06 |
nicklas |
447 |
} |
1872 |
31 Jan 06 |
nicklas |
448 |
else if ("ExportItem".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
449 |
{ |
1872 |
31 Jan 06 |
nicklas |
450 |
// Run an export plugin in single-item context |
1872 |
31 Jan 06 |
nicklas |
451 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4901 |
23 Apr 09 |
martin |
452 |
registerExportUtils(cc); |
1872 |
31 Jan 06 |
nicklas |
453 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+sample"; |
1872 |
31 Jan 06 |
nicklas |
454 |
} |
1872 |
31 Jan 06 |
nicklas |
455 |
else if ("ImportItems".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
456 |
{ |
1872 |
31 Jan 06 |
nicklas |
457 |
// Run an import plugin in a list context |
1872 |
31 Jan 06 |
nicklas |
458 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
459 |
final ItemQuery<Sample> query = Sample.getQuery(); |
7954 |
12 May 21 |
nicklas |
460 |
dc = sc.newDbControl(":Import "+itemType); |
7914 |
23 Feb 21 |
nicklas |
461 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
462 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
463 |
dc.close(); |
1872 |
31 Jan 06 |
nicklas |
464 |
cc.setQuery(query); |
1872 |
31 Jan 06 |
nicklas |
465 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+sample"; |
1872 |
31 Jan 06 |
nicklas |
466 |
} |
1872 |
31 Jan 06 |
nicklas |
467 |
else if ("ImportItem".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
468 |
{ |
1872 |
31 Jan 06 |
nicklas |
469 |
// Run an import plugin in single-item context |
1872 |
31 Jan 06 |
nicklas |
470 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
471 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+sample"; |
1872 |
31 Jan 06 |
nicklas |
472 |
} |
1872 |
31 Jan 06 |
nicklas |
473 |
else if ("RunListPlugin".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
474 |
{ |
1872 |
31 Jan 06 |
nicklas |
475 |
// Run another plugin in a list context |
1872 |
31 Jan 06 |
nicklas |
476 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
477 |
final ItemQuery<Sample> query = Sample.getQuery(); |
7954 |
12 May 21 |
nicklas |
478 |
dc = sc.newDbControl(":Run plugin "+itemType); |
7914 |
23 Feb 21 |
nicklas |
479 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
480 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
481 |
dc.close(); |
1872 |
31 Jan 06 |
nicklas |
482 |
cc.setQuery(query); |
1872 |
31 Jan 06 |
nicklas |
483 |
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 |
484 |
} |
1872 |
31 Jan 06 |
nicklas |
485 |
else if ("RunPlugin".equals(cmd)) |
1872 |
31 Jan 06 |
nicklas |
486 |
{ |
1872 |
31 Jan 06 |
nicklas |
487 |
// Run another plugin in single-item context |
1872 |
31 Jan 06 |
nicklas |
488 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1872 |
31 Jan 06 |
nicklas |
489 |
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 |
490 |
} |
6750 |
19 Feb 15 |
nicklas |
491 |
else if ("CreateItemList".equals(cmd)) |
6750 |
19 Feb 15 |
nicklas |
492 |
{ |
6750 |
19 Feb 15 |
nicklas |
493 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
6750 |
19 Feb 15 |
nicklas |
494 |
final ItemQuery<Sample> query = Sample.getQuery(); |
7954 |
12 May 21 |
nicklas |
495 |
dc = sc.newDbControl(":Create "+itemType+" item list"); |
7914 |
23 Feb 21 |
nicklas |
496 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
497 |
cc.configureQuery(dc, query, jspContext, true); |
6750 |
19 Feb 15 |
nicklas |
498 |
dc.close(); |
6750 |
19 Feb 15 |
nicklas |
499 |
cc.setQuery(query); |
6750 |
19 Feb 15 |
nicklas |
500 |
redirect = "../../views/itemlists/index.jsp?ID="+ID+"&cmd=NewItem&addItems=1&memberType=SAMPLE&formId=samples"; |
6750 |
19 Feb 15 |
nicklas |
501 |
} |
7813 |
19 May 20 |
nicklas |
502 |
else if ("AddItemsToList".equals(cmd)) |
7813 |
19 May 20 |
nicklas |
503 |
{ |
7813 |
19 May 20 |
nicklas |
504 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
7813 |
19 May 20 |
nicklas |
505 |
final ItemQuery<Sample> query = Sample.getQuery(); |
7954 |
12 May 21 |
nicklas |
506 |
dc = sc.newDbControl(":Add to "+itemType+" item list"); |
7914 |
23 Feb 21 |
nicklas |
507 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
508 |
cc.configureQuery(dc, query, jspContext, true); |
7813 |
19 May 20 |
nicklas |
509 |
dc.close(); |
7813 |
19 May 20 |
nicklas |
510 |
cc.setQuery(query); |
7813 |
19 May 20 |
nicklas |
511 |
redirect = "../../views/itemlists/add_items.jsp?ID="+ID+"&memberType=SAMPLE&formId=samples"; |
7813 |
19 May 20 |
nicklas |
512 |
} |
5527 |
13 Dec 10 |
nicklas |
513 |
else if ("PlaceOnPlate".equals(cmd)) |
5527 |
13 Dec 10 |
nicklas |
514 |
{ |
5527 |
13 Dec 10 |
nicklas |
515 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
5527 |
13 Dec 10 |
nicklas |
516 |
final ItemQuery<Sample> query = Sample.getQuery(); |
7954 |
12 May 21 |
nicklas |
517 |
dc = sc.newDbControl(":Place on plate"); |
7914 |
23 Feb 21 |
nicklas |
518 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
519 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
520 |
dc.close(); |
5536 |
21 Dec 10 |
nicklas |
521 |
cc.filterOnSelectedItems(query); |
5536 |
21 Dec 10 |
nicklas |
522 |
sc.getCurrentContext(Item.BIOPLATEEVENT, BioPlateEventType.PLACE_ON_PLATE).setQuery(query); |
5527 |
13 Dec 10 |
nicklas |
523 |
redirect = "../wizards/place_on_plate.jsp?ID="+ID+"&itemType=SAMPLE"; |
5527 |
13 Dec 10 |
nicklas |
524 |
} |
1872 |
31 Jan 06 |
nicklas |
525 |
else |
1872 |
31 Jan 06 |
nicklas |
526 |
{ |
1872 |
31 Jan 06 |
nicklas |
527 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
1872 |
31 Jan 06 |
nicklas |
528 |
} |
919 |
12 Jul 05 |
nicklas |
529 |
} |
919 |
12 Jul 05 |
nicklas |
530 |
finally |
919 |
12 Jul 05 |
nicklas |
531 |
{ |
919 |
12 Jul 05 |
nicklas |
532 |
if (dc != null) dc.close(); |
919 |
12 Jul 05 |
nicklas |
533 |
} |
1872 |
31 Jan 06 |
nicklas |
534 |
|
1872 |
31 Jan 06 |
nicklas |
535 |
if (forward != null) |
1872 |
31 Jan 06 |
nicklas |
536 |
{ |
6192 |
31 Oct 12 |
nicklas |
537 |
sc.setSessionSetting("alert-message", message); |
1872 |
31 Jan 06 |
nicklas |
538 |
pageContext.forward(forward); |
1872 |
31 Jan 06 |
nicklas |
539 |
} |
1872 |
31 Jan 06 |
nicklas |
540 |
else if (redirect != null) |
1872 |
31 Jan 06 |
nicklas |
541 |
{ |
6192 |
31 Oct 12 |
nicklas |
542 |
sc.setSessionSetting("alert-message", message); |
1872 |
31 Jan 06 |
nicklas |
543 |
response.sendRedirect(redirect); |
1872 |
31 Jan 06 |
nicklas |
544 |
} |
1872 |
31 Jan 06 |
nicklas |
545 |
else if (message == null) |
1872 |
31 Jan 06 |
nicklas |
546 |
{ |
1872 |
31 Jan 06 |
nicklas |
547 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
1872 |
31 Jan 06 |
nicklas |
548 |
} |
1872 |
31 Jan 06 |
nicklas |
549 |
else |
1872 |
31 Jan 06 |
nicklas |
550 |
{ |
1872 |
31 Jan 06 |
nicklas |
551 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
1872 |
31 Jan 06 |
nicklas |
552 |
} |
1872 |
31 Jan 06 |
nicklas |
553 |
%> |
1872 |
31 Jan 06 |
nicklas |
554 |
|