5528 |
15 Dec 10 |
nicklas |
1 |
<%-- $Id$ |
5528 |
15 Dec 10 |
nicklas |
2 |
------------------------------------------------------------------ |
5528 |
15 Dec 10 |
nicklas |
Copyright (C) 2010 Nicklas Nordborg |
5528 |
15 Dec 10 |
nicklas |
4 |
|
5528 |
15 Dec 10 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
5528 |
15 Dec 10 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
5528 |
15 Dec 10 |
nicklas |
7 |
|
5528 |
15 Dec 10 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
5528 |
15 Dec 10 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
5528 |
15 Dec 10 |
nicklas |
10 |
as published by the Free Software Foundation; either version 3 |
5528 |
15 Dec 10 |
nicklas |
11 |
of the License, or (at your option) any later version. |
5528 |
15 Dec 10 |
nicklas |
12 |
|
5528 |
15 Dec 10 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
5528 |
15 Dec 10 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5528 |
15 Dec 10 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5528 |
15 Dec 10 |
nicklas |
16 |
GNU General Public License for more details. |
5528 |
15 Dec 10 |
nicklas |
17 |
|
5528 |
15 Dec 10 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
5528 |
15 Dec 10 |
nicklas |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
5528 |
15 Dec 10 |
nicklas |
20 |
------------------------------------------------------------------ |
5528 |
15 Dec 10 |
nicklas |
21 |
|
5528 |
15 Dec 10 |
nicklas |
22 |
@author Nicklas |
5528 |
15 Dec 10 |
nicklas |
23 |
--%> |
5528 |
15 Dec 10 |
nicklas |
24 |
<%@ page pageEncoding="UTF-8" session="false" |
5528 |
15 Dec 10 |
nicklas |
25 |
import="net.sf.basedb.core.SessionControl" |
5535 |
21 Dec 10 |
nicklas |
26 |
import="net.sf.basedb.core.BioMaterial" |
5528 |
15 Dec 10 |
nicklas |
27 |
import="net.sf.basedb.core.BioMaterialEvent" |
5722 |
07 Sep 11 |
nicklas |
28 |
import="net.sf.basedb.core.BioMaterialEventSource" |
5528 |
15 Dec 10 |
nicklas |
29 |
import="net.sf.basedb.core.BioPlate" |
5548 |
24 Jan 11 |
nicklas |
30 |
import="net.sf.basedb.core.BioPlateType" |
5528 |
15 Dec 10 |
nicklas |
31 |
import="net.sf.basedb.core.BioPlateEvent" |
5528 |
15 Dec 10 |
nicklas |
32 |
import="net.sf.basedb.core.BioPlateEventType" |
5528 |
15 Dec 10 |
nicklas |
33 |
import="net.sf.basedb.core.BioPlateEventParticipant" |
5528 |
15 Dec 10 |
nicklas |
34 |
import="net.sf.basedb.core.BioWell" |
5642 |
26 May 11 |
nicklas |
35 |
import="net.sf.basedb.core.PhysicalBioAssay" |
5528 |
15 Dec 10 |
nicklas |
36 |
import="net.sf.basedb.core.DbControl" |
5528 |
15 Dec 10 |
nicklas |
37 |
import="net.sf.basedb.core.Item" |
5528 |
15 Dec 10 |
nicklas |
38 |
import="net.sf.basedb.core.ItemContext" |
5528 |
15 Dec 10 |
nicklas |
39 |
import="net.sf.basedb.core.MeasuredBioMaterial" |
5528 |
15 Dec 10 |
nicklas |
40 |
import="net.sf.basedb.core.Hardware" |
6997 |
03 Nov 15 |
nicklas |
41 |
import="net.sf.basedb.core.Kit" |
5528 |
15 Dec 10 |
nicklas |
42 |
import="net.sf.basedb.core.Protocol" |
5548 |
24 Jan 11 |
nicklas |
43 |
import="net.sf.basedb.core.Sample" |
5548 |
24 Jan 11 |
nicklas |
44 |
import="net.sf.basedb.core.Extract" |
5641 |
25 May 11 |
nicklas |
45 |
import="net.sf.basedb.core.Tag" |
5723 |
07 Sep 11 |
nicklas |
46 |
import="net.sf.basedb.core.ItemSubtype" |
5528 |
15 Dec 10 |
nicklas |
47 |
import="net.sf.basedb.core.PlateGeometry" |
5549 |
26 Jan 11 |
nicklas |
48 |
import="net.sf.basedb.core.InvalidDataException" |
5528 |
15 Dec 10 |
nicklas |
49 |
import="net.sf.basedb.clients.web.Base" |
5528 |
15 Dec 10 |
nicklas |
50 |
import="net.sf.basedb.clients.web.WebException" |
5528 |
15 Dec 10 |
nicklas |
51 |
import="net.sf.basedb.util.Values" |
5528 |
15 Dec 10 |
nicklas |
52 |
import="net.sf.basedb.util.formatter.Formatter" |
5528 |
15 Dec 10 |
nicklas |
53 |
import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
5528 |
15 Dec 10 |
nicklas |
54 |
import="net.sf.basedb.clients.web.formatter.FormatterSettings" |
5528 |
15 Dec 10 |
nicklas |
55 |
import="net.sf.basedb.clients.web.util.HTML" |
5528 |
15 Dec 10 |
nicklas |
56 |
import="java.util.Set" |
5528 |
15 Dec 10 |
nicklas |
57 |
import="java.util.Date" |
5528 |
15 Dec 10 |
nicklas |
58 |
%> |
5528 |
15 Dec 10 |
nicklas |
59 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
5528 |
15 Dec 10 |
nicklas |
60 |
<% |
5528 |
15 Dec 10 |
nicklas |
61 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
5528 |
15 Dec 10 |
nicklas |
62 |
final String ID = sc.getId(); |
5528 |
15 Dec 10 |
nicklas |
63 |
final String cmd = request.getParameter("cmd"); |
5528 |
15 Dec 10 |
nicklas |
64 |
final String root = request.getContextPath()+"/"; |
5528 |
15 Dec 10 |
nicklas |
65 |
final String mode = request.getParameter("mode"); |
5528 |
15 Dec 10 |
nicklas |
66 |
final String callback = request.getParameter("callback"); |
5528 |
15 Dec 10 |
nicklas |
67 |
String forward = null; |
5528 |
15 Dec 10 |
nicklas |
68 |
String redirect = null; |
5528 |
15 Dec 10 |
nicklas |
69 |
String message = null; |
5528 |
15 Dec 10 |
nicklas |
70 |
DbControl dc = null; |
5528 |
15 Dec 10 |
nicklas |
71 |
|
5528 |
15 Dec 10 |
nicklas |
72 |
try |
5528 |
15 Dec 10 |
nicklas |
73 |
{ |
5528 |
15 Dec 10 |
nicklas |
74 |
if ("PlaceOnPlate".equals(cmd)) |
5528 |
15 Dec 10 |
nicklas |
75 |
{ |
7954 |
12 May 21 |
nicklas |
76 |
dc = sc.newDbControl(":Place on plate wizard"); |
5528 |
15 Dec 10 |
nicklas |
77 |
Item bioMaterialType = Item.valueOf(request.getParameter("itemType")); |
5529 |
15 Dec 10 |
nicklas |
78 |
String subContext = Values.getString(request.getParameter("subcontext"), ""); |
5536 |
21 Dec 10 |
nicklas |
79 |
ItemContext cc = sc.getCurrentContext(Item.BIOPLATEEVENT, BioPlateEventType.PLACE_ON_PLATE); |
5528 |
15 Dec 10 |
nicklas |
80 |
final int maxRecent = Base.getMaxRecent(sc); |
5528 |
15 Dec 10 |
nicklas |
81 |
|
5528 |
15 Dec 10 |
nicklas |
82 |
sc.setUserClientSetting("place-on-plate.auto-select-unmapped-item", |
5528 |
15 Dec 10 |
nicklas |
83 |
Values.getBoolean(request.getParameter("autoSelectUnmappedItem")) ? "1" : "0"); |
5528 |
15 Dec 10 |
nicklas |
84 |
BioPlate plate = BioPlate.getById(dc, Values.getInt(request.getParameter("plate_id"))); |
5528 |
15 Dec 10 |
nicklas |
85 |
int rows = Values.getInt(request.getParameter("rows")); |
5528 |
15 Dec 10 |
nicklas |
86 |
int columns = Values.getInt(request.getParameter("columns")); |
5528 |
15 Dec 10 |
nicklas |
87 |
|
5528 |
15 Dec 10 |
nicklas |
88 |
BioPlateEventType placeOnPlate = BioPlateEventType.getById(dc, BioPlateEventType.PLACE_ON_PLATE); |
5528 |
15 Dec 10 |
nicklas |
89 |
BioPlateEvent event = BioPlateEvent.getNew(dc, placeOnPlate); |
5528 |
15 Dec 10 |
nicklas |
90 |
BioPlateEventParticipant destination = event.addParticipant(plate, "destination", 1); |
5528 |
15 Dec 10 |
nicklas |
91 |
|
5528 |
15 Dec 10 |
nicklas |
92 |
event.setName(Values.getStringOrNull(request.getParameter("name"))); |
5528 |
15 Dec 10 |
nicklas |
93 |
event.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
5528 |
15 Dec 10 |
nicklas |
94 |
Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
5528 |
15 Dec 10 |
nicklas |
95 |
event.setEventDate(dateFormatter.parseString(Values.getStringOrNull(request.getParameter("event_date")))); |
5528 |
15 Dec 10 |
nicklas |
96 |
int protocolId = Values.getInt(request.getParameter("protocol_id")); |
5528 |
15 Dec 10 |
nicklas |
97 |
if (protocolId > 0) |
5528 |
15 Dec 10 |
nicklas |
98 |
{ |
5528 |
15 Dec 10 |
nicklas |
99 |
Protocol pt = Protocol.getById(dc, protocolId); |
5528 |
15 Dec 10 |
nicklas |
100 |
event.setProtocol(pt); |
7703 |
11 Apr 19 |
nicklas |
101 |
cc.setRecent(Item.PROTOCOL, pt, maxRecent); |
5528 |
15 Dec 10 |
nicklas |
102 |
} |
6997 |
03 Nov 15 |
nicklas |
103 |
int kitId = Values.getInt(request.getParameter("kit_id")); |
6997 |
03 Nov 15 |
nicklas |
104 |
if (kitId > 0) |
6997 |
03 Nov 15 |
nicklas |
105 |
{ |
6997 |
03 Nov 15 |
nicklas |
106 |
Kit kit = Kit.getById(dc, kitId); |
6997 |
03 Nov 15 |
nicklas |
107 |
event.setKit(kit); |
7703 |
11 Apr 19 |
nicklas |
108 |
cc.setRecent(Item.KIT, kit, maxRecent); |
6997 |
03 Nov 15 |
nicklas |
109 |
} |
5528 |
15 Dec 10 |
nicklas |
110 |
int hardwareId = Values.getInt(request.getParameter("hardware_id")); |
5528 |
15 Dec 10 |
nicklas |
111 |
if (hardwareId > 0) |
5528 |
15 Dec 10 |
nicklas |
112 |
{ |
5528 |
15 Dec 10 |
nicklas |
113 |
Hardware hw = Hardware.getById(dc, hardwareId); |
5528 |
15 Dec 10 |
nicklas |
114 |
event.setHardware(hw); |
7703 |
11 Apr 19 |
nicklas |
115 |
cc.setRecent(Item.HARDWARE, hw, maxRecent); |
5528 |
15 Dec 10 |
nicklas |
116 |
} |
5528 |
15 Dec 10 |
nicklas |
117 |
dc.saveItem(event); |
5528 |
15 Dec 10 |
nicklas |
118 |
|
5528 |
15 Dec 10 |
nicklas |
119 |
int numPlaced = 0; |
5528 |
15 Dec 10 |
nicklas |
120 |
for (int row = 0; row < rows; ++row) |
5528 |
15 Dec 10 |
nicklas |
121 |
{ |
5528 |
15 Dec 10 |
nicklas |
122 |
for (int column = 0; column < columns; ++column) |
5528 |
15 Dec 10 |
nicklas |
123 |
{ |
5528 |
15 Dec 10 |
nicklas |
124 |
int bioMaterialId = Values.getInt(request.getParameter("well." + row + "." + column)); |
5528 |
15 Dec 10 |
nicklas |
125 |
if (bioMaterialId > 0) |
5528 |
15 Dec 10 |
nicklas |
126 |
{ |
5528 |
15 Dec 10 |
nicklas |
127 |
MeasuredBioMaterial bioMaterial = (MeasuredBioMaterial)bioMaterialType.getById(dc, bioMaterialId); |
5528 |
15 Dec 10 |
nicklas |
128 |
BioWell well = plate.getBioWell(row, column); |
5528 |
15 Dec 10 |
nicklas |
129 |
bioMaterial.setBioWell(well); |
5528 |
15 Dec 10 |
nicklas |
130 |
BioMaterialEvent bmEvent = bioMaterial.newEvent(destination); |
5528 |
15 Dec 10 |
nicklas |
131 |
bmEvent.setComment("Well: " + well.getCoordinate()); |
5528 |
15 Dec 10 |
nicklas |
132 |
dc.saveItem(bmEvent); |
5528 |
15 Dec 10 |
nicklas |
133 |
numPlaced++; |
5528 |
15 Dec 10 |
nicklas |
134 |
} |
5528 |
15 Dec 10 |
nicklas |
135 |
} |
5528 |
15 Dec 10 |
nicklas |
136 |
} |
5528 |
15 Dec 10 |
nicklas |
137 |
|
5528 |
15 Dec 10 |
nicklas |
138 |
dc.commit(); |
5528 |
15 Dec 10 |
nicklas |
139 |
message = "Placed " + numPlaced + " items on plate " + plate.getName(); |
5528 |
15 Dec 10 |
nicklas |
140 |
} |
5535 |
21 Dec 10 |
nicklas |
141 |
else if ("MoveBioMaterial".equals(cmd)) |
5535 |
21 Dec 10 |
nicklas |
142 |
{ |
7954 |
12 May 21 |
nicklas |
143 |
dc = sc.newDbControl(":Move biomaterial wizard"); |
5535 |
21 Dec 10 |
nicklas |
144 |
ItemContext cc = sc.getCurrentContext(Item.BIOPLATEEVENT, BioPlateEventType.MOVE); |
5535 |
21 Dec 10 |
nicklas |
145 |
final int maxRecent = Base.getMaxRecent(sc); |
5541 |
17 Jan 11 |
nicklas |
146 |
sc.setUserClientSetting("move-biomaterial.show-source-coordinates", |
5541 |
17 Jan 11 |
nicklas |
147 |
Values.getBoolean(request.getParameter("showSourceCoordinates")) ? "1" : "0"); |
5535 |
21 Dec 10 |
nicklas |
148 |
|
5535 |
21 Dec 10 |
nicklas |
149 |
BioPlate sourcePlate = BioPlate.getById(dc, Values.getInt(request.getParameter("sourceplate_id"))); |
5535 |
21 Dec 10 |
nicklas |
150 |
BioPlate destPlate = BioPlate.getById(dc, Values.getInt(request.getParameter("destplate_id"))); |
5535 |
21 Dec 10 |
nicklas |
151 |
int rows = Values.getInt(request.getParameter("rows")); |
5535 |
21 Dec 10 |
nicklas |
152 |
int columns = Values.getInt(request.getParameter("columns")); |
5535 |
21 Dec 10 |
nicklas |
153 |
|
5535 |
21 Dec 10 |
nicklas |
154 |
BioPlateEventType moveBioMaterial = BioPlateEventType.getById(dc, BioPlateEventType.MOVE); |
5535 |
21 Dec 10 |
nicklas |
155 |
BioPlateEvent event = BioPlateEvent.getNew(dc, moveBioMaterial); |
5535 |
21 Dec 10 |
nicklas |
156 |
BioPlateEventParticipant destination = event.addParticipant(destPlate, "destination", 1); |
5535 |
21 Dec 10 |
nicklas |
157 |
BioPlateEventParticipant source = event.addParticipant(sourcePlate, "source", 1); |
5535 |
21 Dec 10 |
nicklas |
158 |
|
5535 |
21 Dec 10 |
nicklas |
159 |
event.setName(Values.getStringOrNull(request.getParameter("name"))); |
5535 |
21 Dec 10 |
nicklas |
160 |
event.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
5535 |
21 Dec 10 |
nicklas |
161 |
Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
5535 |
21 Dec 10 |
nicklas |
162 |
event.setEventDate(dateFormatter.parseString(Values.getStringOrNull(request.getParameter("event_date")))); |
5535 |
21 Dec 10 |
nicklas |
163 |
int protocolId = Values.getInt(request.getParameter("protocol_id")); |
5535 |
21 Dec 10 |
nicklas |
164 |
if (protocolId > 0) |
5535 |
21 Dec 10 |
nicklas |
165 |
{ |
5535 |
21 Dec 10 |
nicklas |
166 |
Protocol pt = Protocol.getById(dc, protocolId); |
5535 |
21 Dec 10 |
nicklas |
167 |
event.setProtocol(pt); |
7703 |
11 Apr 19 |
nicklas |
168 |
cc.setRecent(Item.PROTOCOL, pt, maxRecent); |
5535 |
21 Dec 10 |
nicklas |
169 |
} |
6997 |
03 Nov 15 |
nicklas |
170 |
int kitId = Values.getInt(request.getParameter("kit_id")); |
6997 |
03 Nov 15 |
nicklas |
171 |
if (kitId > 0) |
6997 |
03 Nov 15 |
nicklas |
172 |
{ |
6997 |
03 Nov 15 |
nicklas |
173 |
Kit kit = Kit.getById(dc, kitId); |
6997 |
03 Nov 15 |
nicklas |
174 |
event.setKit(kit); |
7703 |
11 Apr 19 |
nicklas |
175 |
cc.setRecent(Item.KIT, kit, maxRecent); |
6997 |
03 Nov 15 |
nicklas |
176 |
} |
5535 |
21 Dec 10 |
nicklas |
177 |
int hardwareId = Values.getInt(request.getParameter("hardware_id")); |
5535 |
21 Dec 10 |
nicklas |
178 |
if (hardwareId > 0) |
5535 |
21 Dec 10 |
nicklas |
179 |
{ |
5535 |
21 Dec 10 |
nicklas |
180 |
Hardware hw = Hardware.getById(dc, hardwareId); |
5535 |
21 Dec 10 |
nicklas |
181 |
event.setHardware(hw); |
7703 |
11 Apr 19 |
nicklas |
182 |
cc.setRecent(Item.HARDWARE, hw, maxRecent); |
5535 |
21 Dec 10 |
nicklas |
183 |
} |
5535 |
21 Dec 10 |
nicklas |
184 |
dc.saveItem(event); |
5535 |
21 Dec 10 |
nicklas |
185 |
|
5535 |
21 Dec 10 |
nicklas |
186 |
int numMoved = 0; |
5535 |
21 Dec 10 |
nicklas |
187 |
for (int row = 0; row < rows; ++row) |
5535 |
21 Dec 10 |
nicklas |
188 |
{ |
5535 |
21 Dec 10 |
nicklas |
189 |
for (int column = 0; column < columns; ++column) |
5535 |
21 Dec 10 |
nicklas |
190 |
{ |
5535 |
21 Dec 10 |
nicklas |
191 |
int bioMaterialId = Values.getInt(request.getParameter("well." + row + "." + column)); |
5535 |
21 Dec 10 |
nicklas |
192 |
if (bioMaterialId > 0) |
5535 |
21 Dec 10 |
nicklas |
193 |
{ |
5535 |
21 Dec 10 |
nicklas |
194 |
MeasuredBioMaterial bioMaterial = (MeasuredBioMaterial)BioMaterial.getById(dc, bioMaterialId); |
5535 |
21 Dec 10 |
nicklas |
195 |
BioWell well = destPlate.getBioWell(row, column); |
5535 |
21 Dec 10 |
nicklas |
196 |
bioMaterial.setBioWell(well); |
5535 |
21 Dec 10 |
nicklas |
197 |
BioMaterialEvent bmEvent = bioMaterial.newEvent(destination); |
5535 |
21 Dec 10 |
nicklas |
198 |
bmEvent.setComment("Well: " + well.getCoordinate()); |
5535 |
21 Dec 10 |
nicklas |
199 |
dc.saveItem(bmEvent); |
5535 |
21 Dec 10 |
nicklas |
200 |
numMoved++; |
5535 |
21 Dec 10 |
nicklas |
201 |
} |
5535 |
21 Dec 10 |
nicklas |
202 |
} |
5535 |
21 Dec 10 |
nicklas |
203 |
} |
5535 |
21 Dec 10 |
nicklas |
204 |
|
5535 |
21 Dec 10 |
nicklas |
205 |
dc.commit(); |
5535 |
21 Dec 10 |
nicklas |
206 |
message = "Moved " + numMoved + " items to plate " + destPlate.getName(); |
5535 |
21 Dec 10 |
nicklas |
207 |
} |
5548 |
24 Jan 11 |
nicklas |
208 |
else if ("CreateChildPlate".equals(cmd)) |
5548 |
24 Jan 11 |
nicklas |
209 |
{ |
7954 |
12 May 21 |
nicklas |
210 |
dc = sc.newDbControl(":Create child plate wizard"); |
5548 |
24 Jan 11 |
nicklas |
211 |
ItemContext cc = sc.getCurrentContext(Item.BIOPLATEEVENT, BioPlateEventType.CREATE_BIOMATERIAL); |
5548 |
24 Jan 11 |
nicklas |
212 |
final int maxRecent = Base.getMaxRecent(sc); |
5548 |
24 Jan 11 |
nicklas |
213 |
sc.setUserClientSetting("create-child-plate.show-source-coordinates", |
5548 |
24 Jan 11 |
nicklas |
214 |
Values.getBoolean(request.getParameter("showSourceCoordinates")) ? "1" : "0"); |
5548 |
24 Jan 11 |
nicklas |
215 |
|
5548 |
24 Jan 11 |
nicklas |
216 |
BioPlate sourcePlate = BioPlate.getById(dc, Values.getInt(request.getParameter("sourceplate_id"))); |
5549 |
26 Jan 11 |
nicklas |
217 |
Item sourceBioMaterialType = sourcePlate.getBioPlateType().getBioMaterialType(); |
5549 |
26 Jan 11 |
nicklas |
218 |
Item childBioMaterialType = Item.valueOf(request.getParameter("child_biomaterial_type")); |
5642 |
26 May 11 |
nicklas |
219 |
boolean isBioAssayEvent = childBioMaterialType == Item.PHYSICALBIOASSAY; |
5559 |
31 Jan 11 |
nicklas |
220 |
|
5548 |
24 Jan 11 |
nicklas |
221 |
// The event object |
5559 |
31 Jan 11 |
nicklas |
222 |
BioPlateEventType createBioMaterial = BioPlateEventType.getById(dc, |
5642 |
26 May 11 |
nicklas |
223 |
isBioAssayEvent ? BioPlateEventType.PHYSICAL_BIOASSAY : BioPlateEventType.CREATE_BIOMATERIAL); |
5548 |
24 Jan 11 |
nicklas |
224 |
BioPlateEvent event = BioPlateEvent.getNew(dc, createBioMaterial); |
5548 |
24 Jan 11 |
nicklas |
225 |
event.setName(Values.getStringOrNull(request.getParameter("event_name"))); |
5548 |
24 Jan 11 |
nicklas |
226 |
event.setDescription(Values.getStringOrNull(request.getParameter("event_description"))); |
5559 |
31 Jan 11 |
nicklas |
227 |
BioPlateEventParticipant sourceParticipant = event.addParticipant(sourcePlate, "source", 1); |
5548 |
24 Jan 11 |
nicklas |
228 |
Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
5548 |
24 Jan 11 |
nicklas |
229 |
event.setEventDate(dateFormatter.parseString(Values.getStringOrNull(request.getParameter("event_date")))); |
5548 |
24 Jan 11 |
nicklas |
230 |
int protocolId = Values.getInt(request.getParameter("protocol_id")); |
5548 |
24 Jan 11 |
nicklas |
231 |
if (protocolId > 0) |
5548 |
24 Jan 11 |
nicklas |
232 |
{ |
5548 |
24 Jan 11 |
nicklas |
233 |
Protocol pt = Protocol.getById(dc, protocolId); |
5548 |
24 Jan 11 |
nicklas |
234 |
event.setProtocol(pt); |
7703 |
11 Apr 19 |
nicklas |
235 |
cc.setRecent(Item.PROTOCOL, pt, sourceBioMaterialType.name(), maxRecent); |
5548 |
24 Jan 11 |
nicklas |
236 |
} |
6997 |
03 Nov 15 |
nicklas |
237 |
int kitId = Values.getInt(request.getParameter("kit_id")); |
6997 |
03 Nov 15 |
nicklas |
238 |
if (kitId > 0) |
6997 |
03 Nov 15 |
nicklas |
239 |
{ |
6997 |
03 Nov 15 |
nicklas |
240 |
Kit kit = Kit.getById(dc, kitId); |
6997 |
03 Nov 15 |
nicklas |
241 |
event.setKit(kit); |
7703 |
11 Apr 19 |
nicklas |
242 |
cc.setRecent(Item.KIT, kit, sourceBioMaterialType.name(), maxRecent); |
6997 |
03 Nov 15 |
nicklas |
243 |
} |
5548 |
24 Jan 11 |
nicklas |
244 |
int hardwareId = Values.getInt(request.getParameter("hardware_id")); |
5548 |
24 Jan 11 |
nicklas |
245 |
if (hardwareId > 0) |
5548 |
24 Jan 11 |
nicklas |
246 |
{ |
5548 |
24 Jan 11 |
nicklas |
247 |
Hardware hw = Hardware.getById(dc, hardwareId); |
5548 |
24 Jan 11 |
nicklas |
248 |
event.setHardware(hw); |
7703 |
11 Apr 19 |
nicklas |
249 |
cc.setRecent(Item.HARDWARE, hw, sourceBioMaterialType.name(), maxRecent); |
5548 |
24 Jan 11 |
nicklas |
250 |
} |
5548 |
24 Jan 11 |
nicklas |
251 |
dc.saveItem(event); |
5548 |
24 Jan 11 |
nicklas |
252 |
|
5548 |
24 Jan 11 |
nicklas |
253 |
// Child plates & biomaterial |
5548 |
24 Jan 11 |
nicklas |
254 |
Hardware freezer = null; |
5642 |
26 May 11 |
nicklas |
255 |
if (!isBioAssayEvent) |
5548 |
24 Jan 11 |
nicklas |
256 |
{ |
5559 |
31 Jan 11 |
nicklas |
257 |
int freezerId = Values.getInt(request.getParameter("freezer_id")); |
5559 |
31 Jan 11 |
nicklas |
258 |
if (freezerId > 0) |
5559 |
31 Jan 11 |
nicklas |
259 |
{ |
5559 |
31 Jan 11 |
nicklas |
260 |
freezer = Hardware.getById(dc, freezerId); |
7703 |
11 Apr 19 |
nicklas |
261 |
cc.setRecent(Item.HARDWARE, freezer, "freezer", maxRecent); |
5559 |
31 Jan 11 |
nicklas |
262 |
} |
5548 |
24 Jan 11 |
nicklas |
263 |
} |
5723 |
07 Sep 11 |
nicklas |
264 |
ItemSubtype subtype = null; |
5723 |
07 Sep 11 |
nicklas |
265 |
int subtypeId = Values.getInt(request.getParameter("subtype_id")); |
5723 |
07 Sep 11 |
nicklas |
266 |
if (subtypeId > 0) |
5723 |
07 Sep 11 |
nicklas |
267 |
{ |
5723 |
07 Sep 11 |
nicklas |
268 |
subtype = ItemSubtype.getById(dc, subtypeId); |
7703 |
11 Apr 19 |
nicklas |
269 |
cc.setRecent(Item.ITEMSUBTYPE, subtype, sourceBioMaterialType.name(), maxRecent); |
5723 |
07 Sep 11 |
nicklas |
270 |
} |
5723 |
07 Sep 11 |
nicklas |
271 |
Tag tag = null; |
5723 |
07 Sep 11 |
nicklas |
272 |
int tagId = Values.getInt(request.getParameter("tag_id")); |
5723 |
07 Sep 11 |
nicklas |
273 |
if (tagId > 0) |
5723 |
07 Sep 11 |
nicklas |
274 |
{ |
5723 |
07 Sep 11 |
nicklas |
275 |
tag = Tag.getById(dc, tagId); |
5723 |
07 Sep 11 |
nicklas |
276 |
} |
5548 |
24 Jan 11 |
nicklas |
277 |
int numChildPlates = Values.getInt(request.getParameter("number_of_plates")); |
5642 |
26 May 11 |
nicklas |
278 |
int size = Values.getInt(request.getParameter("size")); |
5561 |
02 Feb 11 |
nicklas |
279 |
PlateGeometry childGeometry = null; |
5642 |
26 May 11 |
nicklas |
280 |
if (!isBioAssayEvent) |
5561 |
02 Feb 11 |
nicklas |
281 |
{ |
5561 |
02 Feb 11 |
nicklas |
282 |
childGeometry = PlateGeometry.getById(dc, Values.getInt(request.getParameter("plategeometry_id"))); |
7703 |
11 Apr 19 |
nicklas |
283 |
cc.setRecent(Item.PLATEGEOMETRY, childGeometry, sourceBioMaterialType.name(), maxRecent); |
5561 |
02 Feb 11 |
nicklas |
284 |
} |
5642 |
26 May 11 |
nicklas |
285 |
int rows = isBioAssayEvent ? 1 : childGeometry.getRows(); |
5642 |
26 May 11 |
nicklas |
286 |
int columns = isBioAssayEvent ? size : childGeometry.getColumns(); |
5548 |
24 Jan 11 |
nicklas |
287 |
int numCreated = 0; |
5559 |
31 Jan 11 |
nicklas |
288 |
BioPlateType childPlateType = null; |
5642 |
26 May 11 |
nicklas |
289 |
if (!isBioAssayEvent) |
5559 |
31 Jan 11 |
nicklas |
290 |
{ |
5559 |
31 Jan 11 |
nicklas |
291 |
childPlateType = BioPlateType.getById(dc, Values.getInt(request.getParameter("bioplatetype_id"))); |
7703 |
11 Apr 19 |
nicklas |
292 |
cc.setRecent(Item.BIOPLATETYPE, childPlateType, sourceBioMaterialType.name(), maxRecent); |
5559 |
31 Jan 11 |
nicklas |
293 |
} |
5559 |
31 Jan 11 |
nicklas |
294 |
Float usedQuantity = Values.getFloat(request.getParameter("used_quantity")); |
5559 |
31 Jan 11 |
nicklas |
295 |
Float originalQuantity = Values.getFloat(request.getParameter("original_quantity")); |
5548 |
24 Jan 11 |
nicklas |
296 |
for (int plateNo = 0; plateNo < numChildPlates; ++plateNo) |
5548 |
24 Jan 11 |
nicklas |
297 |
{ |
5642 |
26 May 11 |
nicklas |
298 |
PhysicalBioAssay pba = null; |
5642 |
26 May 11 |
nicklas |
299 |
BioMaterialEvent pbaCreationEvent = null; |
5559 |
31 Jan 11 |
nicklas |
300 |
BioPlate childPlate = null; |
5559 |
31 Jan 11 |
nicklas |
301 |
BioPlateEventParticipant destParticipant = null; |
5642 |
26 May 11 |
nicklas |
302 |
if (isBioAssayEvent) |
5559 |
31 Jan 11 |
nicklas |
303 |
{ |
5642 |
26 May 11 |
nicklas |
304 |
pba = PhysicalBioAssay.getNew(dc, sourceParticipant); |
5642 |
26 May 11 |
nicklas |
305 |
pba.setName(Values.getStringOrNull(request.getParameter("plate." + plateNo + ".name"))); |
5642 |
26 May 11 |
nicklas |
306 |
pba.setDescription(Values.getStringOrNull(request.getParameter("plate_description"))); |
5642 |
26 May 11 |
nicklas |
307 |
pba.setSize(size); |
5723 |
07 Sep 11 |
nicklas |
308 |
pba.setItemSubtype(subtype); |
5642 |
26 May 11 |
nicklas |
309 |
dc.saveItem(pba); |
5642 |
26 May 11 |
nicklas |
310 |
pbaCreationEvent = pba.getCreationEvent(); |
5996 |
05 Mar 12 |
nicklas |
311 |
pbaCreationEvent.setEventDate(event.getEventDate()); |
5559 |
31 Jan 11 |
nicklas |
312 |
} |
5559 |
31 Jan 11 |
nicklas |
313 |
else |
5559 |
31 Jan 11 |
nicklas |
314 |
{ |
5559 |
31 Jan 11 |
nicklas |
315 |
childPlate = BioPlate.getNew(dc, childGeometry, childPlateType); |
5559 |
31 Jan 11 |
nicklas |
316 |
childPlate.setName(Values.getStringOrNull(request.getParameter("plate." + plateNo + ".name"))); |
5559 |
31 Jan 11 |
nicklas |
317 |
childPlate.setDescription(Values.getStringOrNull(request.getParameter("plate_description"))); |
5996 |
05 Mar 12 |
nicklas |
318 |
childPlate.setEventDate(event.getEventDate()); |
5559 |
31 Jan 11 |
nicklas |
319 |
if (freezer != null) childPlate.setFreezer(freezer); |
5559 |
31 Jan 11 |
nicklas |
320 |
childPlate.setBarcode(Values.getStringOrNull(request.getParameter("plate." + plateNo + ".barcode"))); |
5559 |
31 Jan 11 |
nicklas |
321 |
dc.saveItem(childPlate); |
5559 |
31 Jan 11 |
nicklas |
322 |
destParticipant = event.addParticipant(childPlate, "destination", plateNo); |
5559 |
31 Jan 11 |
nicklas |
323 |
} |
5548 |
24 Jan 11 |
nicklas |
324 |
for (int row = 0; row < rows; ++row) |
5548 |
24 Jan 11 |
nicklas |
325 |
{ |
5548 |
24 Jan 11 |
nicklas |
326 |
for (int column = 0; column < columns; ++column) |
5548 |
24 Jan 11 |
nicklas |
327 |
{ |
5549 |
26 Jan 11 |
nicklas |
328 |
String prefix = "well." + +plateNo + "." + row + "." + column; |
5549 |
26 Jan 11 |
nicklas |
329 |
int bioMaterialId = Values.getInt(request.getParameter(prefix)); |
5548 |
24 Jan 11 |
nicklas |
330 |
if (bioMaterialId > 0) |
5548 |
24 Jan 11 |
nicklas |
331 |
{ |
5549 |
26 Jan 11 |
nicklas |
332 |
MeasuredBioMaterial parent = (MeasuredBioMaterial)sourceBioMaterialType.getById(dc, bioMaterialId); |
5642 |
26 May 11 |
nicklas |
333 |
if (isBioAssayEvent) |
5549 |
26 Jan 11 |
nicklas |
334 |
{ |
5662 |
20 Jun 11 |
nicklas |
335 |
BioMaterialEventSource evtSrc = pbaCreationEvent.addSource(parent); |
5662 |
20 Jun 11 |
nicklas |
336 |
evtSrc.setUsedQuantity(usedQuantity); |
5662 |
20 Jun 11 |
nicklas |
337 |
evtSrc.setPosition(column+1); |
5549 |
26 Jan 11 |
nicklas |
338 |
} |
5549 |
26 Jan 11 |
nicklas |
339 |
else |
5549 |
26 Jan 11 |
nicklas |
340 |
{ |
5559 |
31 Jan 11 |
nicklas |
341 |
BioWell well = childPlate.getBioWell(row, column); |
5559 |
31 Jan 11 |
nicklas |
342 |
MeasuredBioMaterial child = null; |
5559 |
31 Jan 11 |
nicklas |
343 |
if (childBioMaterialType == Item.SAMPLE) |
5559 |
31 Jan 11 |
nicklas |
344 |
{ |
5559 |
31 Jan 11 |
nicklas |
345 |
child = Sample.getNew(dc, destParticipant); |
5559 |
31 Jan 11 |
nicklas |
346 |
} |
5559 |
31 Jan 11 |
nicklas |
347 |
else if (childBioMaterialType == Item.EXTRACT) |
5559 |
31 Jan 11 |
nicklas |
348 |
{ |
5723 |
07 Sep 11 |
nicklas |
349 |
Extract extract = Extract.getNew(dc, destParticipant); |
5723 |
07 Sep 11 |
nicklas |
350 |
if (tag != null) |
5723 |
07 Sep 11 |
nicklas |
351 |
{ |
5723 |
07 Sep 11 |
nicklas |
352 |
extract.setTag(tag); |
5723 |
07 Sep 11 |
nicklas |
353 |
} |
5723 |
07 Sep 11 |
nicklas |
354 |
else if (parent instanceof Extract) |
5723 |
07 Sep 11 |
nicklas |
355 |
{ |
5723 |
07 Sep 11 |
nicklas |
356 |
extract.setTag(((Extract)parent).getTag()); |
5723 |
07 Sep 11 |
nicklas |
357 |
} |
5723 |
07 Sep 11 |
nicklas |
358 |
child = extract; |
5559 |
31 Jan 11 |
nicklas |
359 |
} |
5559 |
31 Jan 11 |
nicklas |
360 |
else |
5559 |
31 Jan 11 |
nicklas |
361 |
{ |
5559 |
31 Jan 11 |
nicklas |
362 |
throw new InvalidDataException("Can't create child biomaterial of type: " + childBioMaterialType); |
5559 |
31 Jan 11 |
nicklas |
363 |
} |
5723 |
07 Sep 11 |
nicklas |
364 |
child.setItemSubtype(subtype); |
5559 |
31 Jan 11 |
nicklas |
365 |
child.setName(Values.getStringOrNull(request.getParameter(prefix + ".name"))); |
5559 |
31 Jan 11 |
nicklas |
366 |
child.setDescription(Values.getStringOrNull(request.getParameter("child_description"))); |
5559 |
31 Jan 11 |
nicklas |
367 |
child.setBioWell(well); |
5559 |
31 Jan 11 |
nicklas |
368 |
child.setOriginalQuantity(originalQuantity); |
5723 |
07 Sep 11 |
nicklas |
369 |
child.getCreationEvent().setSource(parent).setUsedQuantity(usedQuantity); |
5559 |
31 Jan 11 |
nicklas |
370 |
dc.saveItem(child); |
5549 |
26 Jan 11 |
nicklas |
371 |
} |
5548 |
24 Jan 11 |
nicklas |
372 |
numCreated++; |
5548 |
24 Jan 11 |
nicklas |
373 |
} |
5548 |
24 Jan 11 |
nicklas |
374 |
} |
5548 |
24 Jan 11 |
nicklas |
375 |
} |
5548 |
24 Jan 11 |
nicklas |
376 |
} |
5548 |
24 Jan 11 |
nicklas |
377 |
|
5548 |
24 Jan 11 |
nicklas |
378 |
dc.commit(); |
5642 |
26 May 11 |
nicklas |
379 |
if (isBioAssayEvent) |
5559 |
31 Jan 11 |
nicklas |
380 |
{ |
5642 |
26 May 11 |
nicklas |
381 |
message = "Used " + numCreated + " items on " + numChildPlates + " physical bioassay(s)"; |
5559 |
31 Jan 11 |
nicklas |
382 |
} |
5559 |
31 Jan 11 |
nicklas |
383 |
else |
5559 |
31 Jan 11 |
nicklas |
384 |
{ |
5559 |
31 Jan 11 |
nicklas |
385 |
message = "Created " + numCreated + " items on " + numChildPlates + " child plate(s)"; |
5559 |
31 Jan 11 |
nicklas |
386 |
} |
5548 |
24 Jan 11 |
nicklas |
387 |
} |
5528 |
15 Dec 10 |
nicklas |
388 |
else |
5528 |
15 Dec 10 |
nicklas |
389 |
{ |
5528 |
15 Dec 10 |
nicklas |
390 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
5528 |
15 Dec 10 |
nicklas |
391 |
} |
5528 |
15 Dec 10 |
nicklas |
392 |
} |
5528 |
15 Dec 10 |
nicklas |
393 |
finally |
5528 |
15 Dec 10 |
nicklas |
394 |
{ |
5528 |
15 Dec 10 |
nicklas |
395 |
if (dc != null) dc.close(); |
5528 |
15 Dec 10 |
nicklas |
396 |
} |
5528 |
15 Dec 10 |
nicklas |
397 |
|
5528 |
15 Dec 10 |
nicklas |
398 |
if (forward != null) |
5528 |
15 Dec 10 |
nicklas |
399 |
{ |
6192 |
31 Oct 12 |
nicklas |
400 |
sc.setSessionSetting("alert-message", message); |
5528 |
15 Dec 10 |
nicklas |
401 |
pageContext.forward(forward); |
5528 |
15 Dec 10 |
nicklas |
402 |
} |
5528 |
15 Dec 10 |
nicklas |
403 |
else if (redirect != null) |
5528 |
15 Dec 10 |
nicklas |
404 |
{ |
6192 |
31 Oct 12 |
nicklas |
405 |
sc.setSessionSetting("alert-message", message); |
5528 |
15 Dec 10 |
nicklas |
406 |
response.sendRedirect(redirect); |
5528 |
15 Dec 10 |
nicklas |
407 |
} |
5528 |
15 Dec 10 |
nicklas |
408 |
else if (message == null) |
5528 |
15 Dec 10 |
nicklas |
409 |
{ |
5528 |
15 Dec 10 |
nicklas |
410 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
5528 |
15 Dec 10 |
nicklas |
411 |
} |
5528 |
15 Dec 10 |
nicklas |
412 |
else |
5528 |
15 Dec 10 |
nicklas |
413 |
{ |
5528 |
15 Dec 10 |
nicklas |
414 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
5528 |
15 Dec 10 |
nicklas |
415 |
} |
5528 |
15 Dec 10 |
nicklas |
416 |
%> |