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