4670 |
27 Nov 08 |
martin |
1 |
/** |
4670 |
27 Nov 08 |
martin |
$Id$ |
4670 |
27 Nov 08 |
martin |
3 |
|
4670 |
27 Nov 08 |
martin |
Copyright (C) 2007 Martin Svensson |
4670 |
27 Nov 08 |
martin |
5 |
|
4670 |
27 Nov 08 |
martin |
This file is part of BASE - BioArray Software Environment. |
4670 |
27 Nov 08 |
martin |
Available at http://base.thep.lu.se/ |
4670 |
27 Nov 08 |
martin |
8 |
|
4670 |
27 Nov 08 |
martin |
BASE is free software; you can redistribute it and/or |
4670 |
27 Nov 08 |
martin |
modify it under the terms of the GNU General Public License |
4670 |
27 Nov 08 |
martin |
as published by the Free Software Foundation; either version 3 |
4670 |
27 Nov 08 |
martin |
of the License, or (at your option) any later version. |
4670 |
27 Nov 08 |
martin |
13 |
|
4670 |
27 Nov 08 |
martin |
BASE is distributed in the hope that it will be useful, |
4670 |
27 Nov 08 |
martin |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4670 |
27 Nov 08 |
martin |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4670 |
27 Nov 08 |
martin |
GNU General Public License for more details. |
4670 |
27 Nov 08 |
martin |
18 |
|
4670 |
27 Nov 08 |
martin |
You should have received a copy of the GNU General Public License |
4670 |
27 Nov 08 |
martin |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4670 |
27 Nov 08 |
martin |
21 |
*/ |
4670 |
27 Nov 08 |
martin |
22 |
|
4671 |
27 Nov 08 |
martin |
23 |
import net.sf.basedb.core.BaseException; |
4671 |
27 Nov 08 |
martin |
24 |
import net.sf.basedb.core.BioPlate; |
5260 |
04 Mar 10 |
nicklas |
25 |
import net.sf.basedb.core.BioPlateType; |
5323 |
27 Apr 10 |
nicklas |
26 |
import net.sf.basedb.core.BioWell; |
4671 |
27 Nov 08 |
martin |
27 |
import net.sf.basedb.core.DbControl; |
5338 |
07 May 10 |
nicklas |
28 |
import net.sf.basedb.core.Extract; |
4732 |
21 Jan 09 |
martin |
29 |
import net.sf.basedb.core.Hardware; |
4671 |
27 Nov 08 |
martin |
30 |
import net.sf.basedb.core.Item; |
5340 |
10 May 10 |
nicklas |
31 |
import net.sf.basedb.core.ItemProxy; |
4671 |
27 Nov 08 |
martin |
32 |
import net.sf.basedb.core.ItemResultList; |
4685 |
04 Dec 08 |
martin |
33 |
import net.sf.basedb.core.MeasuredBioMaterial; |
4671 |
27 Nov 08 |
martin |
34 |
import net.sf.basedb.core.Permission; |
4671 |
27 Nov 08 |
martin |
35 |
import net.sf.basedb.core.PlateGeometry; |
5630 |
13 May 11 |
nicklas |
36 |
import net.sf.basedb.core.Protocol; |
5338 |
07 May 10 |
nicklas |
37 |
import net.sf.basedb.core.Sample; |
4732 |
21 Jan 09 |
martin |
38 |
import net.sf.basedb.core.SystemItems; |
5632 |
17 May 11 |
nicklas |
39 |
import net.sf.basedb.core.Tag; |
5445 |
13 Oct 10 |
nicklas |
40 |
import net.sf.basedb.core.Trashcan; |
5338 |
07 May 10 |
nicklas |
41 |
import net.sf.basedb.util.collections.BasicItemToIdTransformer; |
5338 |
07 May 10 |
nicklas |
42 |
import net.sf.basedb.util.formatter.WellCoordinateFormatter; |
4671 |
27 Nov 08 |
martin |
43 |
|
5338 |
07 May 10 |
nicklas |
44 |
import java.util.ArrayList; |
4671 |
27 Nov 08 |
martin |
45 |
import java.util.Date; |
5338 |
07 May 10 |
nicklas |
46 |
import java.util.List; |
5340 |
10 May 10 |
nicklas |
47 |
import java.util.Set; |
4671 |
27 Nov 08 |
martin |
48 |
|
4670 |
27 Nov 08 |
martin |
49 |
/** |
4671 |
27 Nov 08 |
martin |
@author martin |
4671 |
27 Nov 08 |
martin |
@version 2.10 |
4672 |
27 Nov 08 |
martin |
@base.modified $Date$ |
4670 |
27 Nov 08 |
martin |
53 |
*/ |
4670 |
27 Nov 08 |
martin |
54 |
|
4670 |
27 Nov 08 |
martin |
55 |
public class TestBioPlate |
4670 |
27 Nov 08 |
martin |
56 |
{ |
4670 |
27 Nov 08 |
martin |
57 |
static boolean ok = true; |
4670 |
27 Nov 08 |
martin |
58 |
public static void main(String[] args) |
4670 |
27 Nov 08 |
martin |
59 |
{ |
4670 |
27 Nov 08 |
martin |
60 |
TestUtil.checkArgs(args); |
4670 |
27 Nov 08 |
martin |
61 |
TestUtil.begin(); |
4670 |
27 Nov 08 |
martin |
62 |
ok = test_all(); |
4670 |
27 Nov 08 |
martin |
63 |
TestUtil.stop(); |
4670 |
27 Nov 08 |
martin |
64 |
} |
4670 |
27 Nov 08 |
martin |
65 |
|
4670 |
27 Nov 08 |
martin |
66 |
static boolean test_all() |
4670 |
27 Nov 08 |
martin |
67 |
{ |
4678 |
02 Dec 08 |
martin |
68 |
write("++Testing bioplates"); |
4670 |
27 Nov 08 |
martin |
69 |
write_header(); |
4670 |
27 Nov 08 |
martin |
70 |
|
6100 |
04 Sep 12 |
nicklas |
71 |
int sampleId = TestSample.test_create(0, "Sample A.1", 0, true); |
6100 |
04 Sep 12 |
nicklas |
72 |
int sample2Id = TestSample.test_create(0, "Sample A.2", 0, true); |
6100 |
04 Sep 12 |
nicklas |
73 |
int sample3Id = TestSample.test_create(0, "Sample A.3", 0, true); |
5641 |
25 May 11 |
nicklas |
74 |
int extractId = TestExtract.test_create(sampleId, "Extract A.1", 0, 0, true); |
5632 |
17 May 11 |
nicklas |
75 |
int labelId = TestTag.test_create("Test label", SystemItems.getId(Tag.LABEL), true); |
5641 |
25 May 11 |
nicklas |
76 |
int labeledExtractId = TestExtract.test_create(extractId, "Labeled extract A.1", |
5641 |
25 May 11 |
nicklas |
77 |
SystemItems.getId(Extract.LABELED), labelId, true); |
5630 |
13 May 11 |
nicklas |
78 |
int freezerId = TestHardware.test_create(SystemItems.getId(Hardware.FREEZER), null, false); |
5630 |
13 May 11 |
nicklas |
79 |
int protocolId = TestProtocol.test_create(SystemItems.getId(Protocol.SAMPLING), |
5323 |
27 Apr 10 |
nicklas |
80 |
"A plate event protocol", false); |
5630 |
13 May 11 |
nicklas |
81 |
int hybProtocolId = TestProtocol.test_create(SystemItems.getId(Protocol.HYBRIDIZATION), |
5323 |
27 Apr 10 |
nicklas |
82 |
"A hyb event protocol", false); |
4685 |
04 Dec 08 |
martin |
83 |
|
4670 |
27 Nov 08 |
martin |
// Standard tests: create, load, list |
4670 |
27 Nov 08 |
martin |
85 |
int plateGeometryId = TestPlateGeometry.test_create(8, 12, false); |
5456 |
28 Oct 10 |
nicklas |
86 |
int bioPlateTypeId = TestBioPlateType.test_create("Test for bioplate", null, BioWell.LockMode.UNLOCKED); |
5456 |
28 Oct 10 |
nicklas |
87 |
int addOnlyTypeId = TestBioPlateType.test_create("Add-only plate type", null, BioWell.LockMode.LOCKED_AFTER_ADD); |
5456 |
28 Oct 10 |
nicklas |
88 |
int moveTypeId = TestBioPlateType.test_create("Move plate type", null, BioWell.LockMode.LOCKED_AFTER_MOVE); |
5452 |
27 Oct 10 |
nicklas |
89 |
int id = test_create("Test BioPlate", plateGeometryId, bioPlateTypeId, freezerId, true); |
5456 |
28 Oct 10 |
nicklas |
90 |
int id2 = test_create("Add-only plate", plateGeometryId, addOnlyTypeId, 0, false); |
5456 |
28 Oct 10 |
nicklas |
91 |
int id3 = test_create("Move plate", plateGeometryId, moveTypeId, 0, false); |
4670 |
27 Nov 08 |
martin |
92 |
test_load(id); |
4670 |
27 Nov 08 |
martin |
93 |
test_list(-1); |
4670 |
27 Nov 08 |
martin |
94 |
|
5456 |
28 Oct 10 |
nicklas |
// Wells -- unlocked plate |
5456 |
28 Oct 10 |
nicklas |
96 |
boolean FAIL = true; |
5456 |
28 Oct 10 |
nicklas |
97 |
test_set_well(id, 0, 0, Item.SAMPLE, sampleId, !FAIL); |
5456 |
28 Oct 10 |
nicklas |
98 |
test_set_well(id, 0, 1, Item.EXTRACT, extractId, !FAIL); |
5323 |
27 Apr 10 |
nicklas |
99 |
test_list_wells(id, 2); |
5456 |
28 Oct 10 |
nicklas |
100 |
test_clear_well(id, 0, 0, !FAIL); |
5456 |
28 Oct 10 |
nicklas |
101 |
test_clear_well(id, 0, 1, !FAIL); |
5456 |
28 Oct 10 |
nicklas |
102 |
test_list_wells(id, 0); |
5323 |
27 Apr 10 |
nicklas |
103 |
|
5456 |
28 Oct 10 |
nicklas |
// Wells -- add-only plate |
5456 |
28 Oct 10 |
nicklas |
105 |
test_set_well(id2, 0, 0, Item.SAMPLE, sample2Id, !FAIL); |
5456 |
28 Oct 10 |
nicklas |
106 |
test_clear_well(id2, 0, 0, FAIL); |
5456 |
28 Oct 10 |
nicklas |
107 |
test_set_well(id2, 0, 0, Item.SAMPLE, sample3Id, FAIL); |
5456 |
28 Oct 10 |
nicklas |
108 |
|
5456 |
28 Oct 10 |
nicklas |
// Wells -- locked-after-move plate |
5456 |
28 Oct 10 |
nicklas |
110 |
test_set_well(id3, 0, 0, Item.SAMPLE, sample3Id, !FAIL); |
5456 |
28 Oct 10 |
nicklas |
111 |
test_clear_well(id3, 0, 0, !FAIL); |
5456 |
28 Oct 10 |
nicklas |
112 |
test_list_wells(id3, 0); |
5456 |
28 Oct 10 |
nicklas |
113 |
test_list_original_biomaterial(id3, 1); |
5456 |
28 Oct 10 |
nicklas |
114 |
test_set_well(id3, 0, 0, Item.SAMPLE, sample3Id, FAIL); |
5456 |
28 Oct 10 |
nicklas |
115 |
|
4670 |
27 Nov 08 |
martin |
116 |
if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter(); |
4670 |
27 Nov 08 |
martin |
// Standard test: Delete |
5641 |
25 May 11 |
nicklas |
118 |
TestExtract.test_delete(labeledExtractId); |
5632 |
17 May 11 |
nicklas |
119 |
TestTag.test_delete(labelId); |
4685 |
04 Dec 08 |
martin |
120 |
TestExtract.test_delete(extractId); |
4685 |
04 Dec 08 |
martin |
121 |
TestSample.test_delete(sampleId); |
5456 |
28 Oct 10 |
nicklas |
122 |
TestSample.test_delete(sample2Id); |
5456 |
28 Oct 10 |
nicklas |
123 |
TestSample.test_delete(sample3Id); |
4670 |
27 Nov 08 |
martin |
124 |
test_delete(id); |
5456 |
28 Oct 10 |
nicklas |
125 |
test_delete(id2); |
5456 |
28 Oct 10 |
nicklas |
126 |
test_delete(id3); |
5456 |
28 Oct 10 |
nicklas |
127 |
|
4670 |
27 Nov 08 |
martin |
128 |
TestPlateGeometry.test_delete(plateGeometryId); |
5260 |
04 Mar 10 |
nicklas |
129 |
TestBioPlateType.test_delete(bioPlateTypeId); |
5456 |
28 Oct 10 |
nicklas |
130 |
TestBioPlateType.test_delete(addOnlyTypeId); |
5456 |
28 Oct 10 |
nicklas |
131 |
TestBioPlateType.test_delete(moveTypeId); |
4732 |
21 Jan 09 |
martin |
132 |
TestHardware.test_delete(freezerId); |
5323 |
27 Apr 10 |
nicklas |
133 |
TestProtocol.test_delete(protocolId); |
5323 |
27 Apr 10 |
nicklas |
134 |
TestProtocol.test_delete(hybProtocolId); |
4670 |
27 Nov 08 |
martin |
135 |
|
4670 |
27 Nov 08 |
martin |
136 |
write("++Testing plates "+(ok ? "OK" : "Failed")+"\n"); |
4670 |
27 Nov 08 |
martin |
137 |
return ok; |
4670 |
27 Nov 08 |
martin |
138 |
} |
4670 |
27 Nov 08 |
martin |
139 |
|
4670 |
27 Nov 08 |
martin |
140 |
static void test_delete(int id) |
4670 |
27 Nov 08 |
martin |
141 |
{ |
4670 |
27 Nov 08 |
martin |
142 |
if (id == 0) return; |
4678 |
02 Dec 08 |
martin |
143 |
DbControl dc = null; |
4678 |
02 Dec 08 |
martin |
144 |
try |
4678 |
02 Dec 08 |
martin |
145 |
{ |
4678 |
02 Dec 08 |
martin |
146 |
dc = TestUtil.getDbControl(); |
4678 |
02 Dec 08 |
martin |
147 |
BioPlate bp = BioPlate.getById(dc, id); |
4678 |
02 Dec 08 |
martin |
148 |
dc.deleteItem(bp); |
5340 |
10 May 10 |
nicklas |
149 |
Set<ItemProxy> using = bp.getUsingItems(); |
5340 |
10 May 10 |
nicklas |
150 |
if (using.size() > 0) |
5340 |
10 May 10 |
nicklas |
151 |
{ |
5340 |
10 May 10 |
nicklas |
152 |
throw new BaseException(bp + " is used by " + using); |
5340 |
10 May 10 |
nicklas |
153 |
} |
4678 |
02 Dec 08 |
martin |
154 |
dc.commit(); |
4685 |
04 Dec 08 |
martin |
155 |
write("--Delete bioplate OK"); |
4678 |
02 Dec 08 |
martin |
156 |
} |
4678 |
02 Dec 08 |
martin |
157 |
catch (Throwable ex) |
4678 |
02 Dec 08 |
martin |
158 |
{ |
4678 |
02 Dec 08 |
martin |
159 |
write("--Delete bioplate FAILED"); |
4678 |
02 Dec 08 |
martin |
160 |
ex.printStackTrace(); |
4678 |
02 Dec 08 |
martin |
161 |
ok = false; |
4678 |
02 Dec 08 |
martin |
162 |
} |
4678 |
02 Dec 08 |
martin |
163 |
finally |
4678 |
02 Dec 08 |
martin |
164 |
{ |
4678 |
02 Dec 08 |
martin |
165 |
if (dc != null) dc.close(); |
4678 |
02 Dec 08 |
martin |
166 |
} |
4685 |
04 Dec 08 |
martin |
167 |
|
4670 |
27 Nov 08 |
martin |
168 |
} |
4670 |
27 Nov 08 |
martin |
169 |
|
5696 |
12 Aug 11 |
nicklas |
170 |
static boolean test_list(int expectedResults) |
4670 |
27 Nov 08 |
martin |
171 |
{ |
4670 |
27 Nov 08 |
martin |
172 |
DbControl dc = null; |
4670 |
27 Nov 08 |
martin |
173 |
try |
4670 |
27 Nov 08 |
martin |
174 |
{ |
4670 |
27 Nov 08 |
martin |
175 |
dc = TestUtil.getDbControl(); |
4670 |
27 Nov 08 |
martin |
176 |
ItemResultList<BioPlate> plates = BioPlate.getQuery().list(dc); |
4670 |
27 Nov 08 |
martin |
177 |
for (int i = 0; i<plates.size(); i++) |
4670 |
27 Nov 08 |
martin |
178 |
{ |
4670 |
27 Nov 08 |
martin |
179 |
write_item(i, plates.get(i)); |
4670 |
27 Nov 08 |
martin |
180 |
} |
4670 |
27 Nov 08 |
martin |
181 |
if (expectedResults >=0 && expectedResults != plates.size()) |
4670 |
27 Nov 08 |
martin |
182 |
{ |
4670 |
27 Nov 08 |
martin |
183 |
throw new BaseException("Expected " + expectedResults + " results, " + |
4670 |
27 Nov 08 |
martin |
184 |
"not " + plates.size()); |
4670 |
27 Nov 08 |
martin |
185 |
} |
4670 |
27 Nov 08 |
martin |
186 |
write ("--List bioplates OK (" + plates.size() +")"); |
4670 |
27 Nov 08 |
martin |
187 |
} |
4670 |
27 Nov 08 |
martin |
188 |
catch (Throwable ex) |
4670 |
27 Nov 08 |
martin |
189 |
{ |
4670 |
27 Nov 08 |
martin |
190 |
write("--List bioplates FAILED"); |
4670 |
27 Nov 08 |
martin |
191 |
ex.printStackTrace(); |
4670 |
27 Nov 08 |
martin |
192 |
ok = false; |
5696 |
12 Aug 11 |
nicklas |
193 |
return false; |
4670 |
27 Nov 08 |
martin |
194 |
} |
4670 |
27 Nov 08 |
martin |
195 |
finally |
4670 |
27 Nov 08 |
martin |
196 |
{ |
4670 |
27 Nov 08 |
martin |
197 |
if (dc != null) dc.close(); |
4670 |
27 Nov 08 |
martin |
198 |
} |
5696 |
12 Aug 11 |
nicklas |
199 |
return ok; |
4670 |
27 Nov 08 |
martin |
200 |
} |
4670 |
27 Nov 08 |
martin |
201 |
|
4670 |
27 Nov 08 |
martin |
202 |
static void test_load(int id) |
4670 |
27 Nov 08 |
martin |
203 |
{ |
4678 |
02 Dec 08 |
martin |
204 |
if (id == 0) return; |
4678 |
02 Dec 08 |
martin |
205 |
DbControl dc = null; |
4678 |
02 Dec 08 |
martin |
206 |
try |
4678 |
02 Dec 08 |
martin |
207 |
{ |
4678 |
02 Dec 08 |
martin |
208 |
dc = TestUtil.getDbControl(); |
4678 |
02 Dec 08 |
martin |
209 |
BioPlate bp = BioPlate.getById(dc, id); |
4678 |
02 Dec 08 |
martin |
210 |
write("--Load bioplate OK"); |
4678 |
02 Dec 08 |
martin |
211 |
} |
4678 |
02 Dec 08 |
martin |
212 |
catch (Throwable ex) |
4678 |
02 Dec 08 |
martin |
213 |
{ |
4678 |
02 Dec 08 |
martin |
214 |
write("--Load bioplate FAILED"); |
4678 |
02 Dec 08 |
martin |
215 |
ex.printStackTrace(); |
4678 |
02 Dec 08 |
martin |
216 |
ok = false; |
4678 |
02 Dec 08 |
martin |
217 |
} |
4678 |
02 Dec 08 |
martin |
218 |
finally |
4678 |
02 Dec 08 |
martin |
219 |
{ |
4678 |
02 Dec 08 |
martin |
220 |
if (dc != null) dc.close(); |
4678 |
02 Dec 08 |
martin |
221 |
} |
4670 |
27 Nov 08 |
martin |
222 |
} |
4670 |
27 Nov 08 |
martin |
223 |
|
5452 |
27 Oct 10 |
nicklas |
224 |
static int test_create(String name, int plateGeometryId, int plateTypeId, int freezerId, boolean setAll) |
4670 |
27 Nov 08 |
martin |
225 |
{ |
5260 |
04 Mar 10 |
nicklas |
226 |
if (plateGeometryId == 0 || plateTypeId == 0 || !TestUtil.hasPermission(Permission.CREATE, Item.BIOPLATE)) |
4670 |
27 Nov 08 |
martin |
227 |
{ |
4670 |
27 Nov 08 |
martin |
228 |
return 0; |
4670 |
27 Nov 08 |
martin |
229 |
} |
4670 |
27 Nov 08 |
martin |
230 |
int id = 0; |
4670 |
27 Nov 08 |
martin |
231 |
DbControl dc = null; |
4670 |
27 Nov 08 |
martin |
232 |
try |
4670 |
27 Nov 08 |
martin |
233 |
{ |
4678 |
02 Dec 08 |
martin |
234 |
dc = TestUtil.getDbControl(); |
5260 |
04 Mar 10 |
nicklas |
235 |
PlateGeometry pg = PlateGeometry.getById(dc, plateGeometryId); |
5260 |
04 Mar 10 |
nicklas |
236 |
BioPlateType pt = BioPlateType.getById(dc, plateTypeId); |
5452 |
27 Oct 10 |
nicklas |
237 |
BioPlate bp = BioPlate.getNew(dc, pg, pt); |
5260 |
04 Mar 10 |
nicklas |
238 |
Item bioMaterialType = pt.getBioMaterialType(); |
5338 |
07 May 10 |
nicklas |
239 |
bp.setName(name); |
4670 |
27 Nov 08 |
martin |
240 |
if (setAll) |
4670 |
27 Nov 08 |
martin |
241 |
{ |
4670 |
27 Nov 08 |
martin |
242 |
bp.setDescription("Added at " + new Date()); |
4670 |
27 Nov 08 |
martin |
243 |
bp.setExternalId("test.bioplate.plate1"); |
4670 |
27 Nov 08 |
martin |
244 |
bp.setBarcode("995522"); |
6063 |
13 Jun 12 |
nicklas |
245 |
bp.setSection("1"); |
6063 |
13 Jun 12 |
nicklas |
246 |
bp.setTray("B4"); |
6063 |
13 Jun 12 |
nicklas |
247 |
bp.setPosition("3"); |
4732 |
21 Jan 09 |
martin |
248 |
if (freezerId > 0) bp.setFreezer(Hardware.getById(dc, freezerId)); |
4670 |
27 Nov 08 |
martin |
249 |
} |
4670 |
27 Nov 08 |
martin |
250 |
dc.saveItem(bp); |
4670 |
27 Nov 08 |
martin |
251 |
dc.commit(); |
4670 |
27 Nov 08 |
martin |
252 |
id = bp.getId(); |
4670 |
27 Nov 08 |
martin |
253 |
dc = TestUtil.getDbControl(); |
5060 |
19 Aug 09 |
nicklas |
254 |
dc.reattachItem(bp, false); |
4670 |
27 Nov 08 |
martin |
255 |
write_item(0, bp); |
4670 |
27 Nov 08 |
martin |
256 |
write("--Create bioplate OK"); |
4670 |
27 Nov 08 |
martin |
257 |
} |
4670 |
27 Nov 08 |
martin |
258 |
catch (Throwable ex) |
4670 |
27 Nov 08 |
martin |
259 |
{ |
4670 |
27 Nov 08 |
martin |
260 |
write("--Create bioplate FAIILED"); |
4670 |
27 Nov 08 |
martin |
261 |
ex.printStackTrace(); |
4670 |
27 Nov 08 |
martin |
262 |
ok = false; |
4670 |
27 Nov 08 |
martin |
263 |
} |
4670 |
27 Nov 08 |
martin |
264 |
finally |
4670 |
27 Nov 08 |
martin |
265 |
{ |
4670 |
27 Nov 08 |
martin |
266 |
if (dc != null) dc.close(); |
4670 |
27 Nov 08 |
martin |
267 |
} |
4670 |
27 Nov 08 |
martin |
268 |
return id; |
4670 |
27 Nov 08 |
martin |
269 |
} |
4670 |
27 Nov 08 |
martin |
270 |
|
5445 |
13 Oct 10 |
nicklas |
271 |
static void test_delete_all() |
5445 |
13 Oct 10 |
nicklas |
272 |
{ |
5445 |
13 Oct 10 |
nicklas |
273 |
DbControl dc = null; |
5445 |
13 Oct 10 |
nicklas |
274 |
try |
5445 |
13 Oct 10 |
nicklas |
275 |
{ |
5445 |
13 Oct 10 |
nicklas |
276 |
dc = TestUtil.getDbControl(); |
5445 |
13 Oct 10 |
nicklas |
277 |
ItemResultList<BioPlate> l = BioPlate.getQuery().list(dc); |
5688 |
10 Aug 11 |
nicklas |
278 |
int numDeleted = Trashcan.delete(dc.getSessionControl(), l, true, null); |
5688 |
10 Aug 11 |
nicklas |
279 |
if (numDeleted != l.size()) throw new BaseException("Could not delete all items: " + numDeleted + " of " + l.size()); |
5445 |
13 Oct 10 |
nicklas |
280 |
dc.commit(); |
5445 |
13 Oct 10 |
nicklas |
281 |
write("--Delete all bioplates OK ("+l.size()+")"); |
5445 |
13 Oct 10 |
nicklas |
282 |
} |
5445 |
13 Oct 10 |
nicklas |
283 |
catch (Throwable ex) |
5445 |
13 Oct 10 |
nicklas |
284 |
{ |
5445 |
13 Oct 10 |
nicklas |
285 |
write("--Delete all bioplates FAILED"); |
5445 |
13 Oct 10 |
nicklas |
286 |
ex.printStackTrace(); |
5445 |
13 Oct 10 |
nicklas |
287 |
ok = false; |
5445 |
13 Oct 10 |
nicklas |
288 |
} |
5445 |
13 Oct 10 |
nicklas |
289 |
finally |
5445 |
13 Oct 10 |
nicklas |
290 |
{ |
5445 |
13 Oct 10 |
nicklas |
291 |
if (dc != null) dc.close(); |
5445 |
13 Oct 10 |
nicklas |
292 |
} |
5445 |
13 Oct 10 |
nicklas |
293 |
} |
5445 |
13 Oct 10 |
nicklas |
294 |
|
4670 |
27 Nov 08 |
martin |
295 |
static void write_header() |
4670 |
27 Nov 08 |
martin |
296 |
{ |
4670 |
27 Nov 08 |
martin |
297 |
if (!TestUtil.getSilent()) |
4670 |
27 Nov 08 |
martin |
298 |
{ |
6063 |
13 Jun 12 |
nicklas |
299 |
System.out.println(" \tID \tExternal id\tName \tPlate type\tDescription\tBarcode\tGeometry\tFreezer\tSection\tTray\tPosition"); |
6063 |
13 Jun 12 |
nicklas |
300 |
System.out.println("-- \t-- \t-----------\t----------\t----------\t-----------\t-------\t--------\t-------\t-------\t----\t--------"); |
4670 |
27 Nov 08 |
martin |
301 |
} |
4670 |
27 Nov 08 |
martin |
302 |
} |
4670 |
27 Nov 08 |
martin |
303 |
|
4670 |
27 Nov 08 |
martin |
304 |
static void write(String message) |
4670 |
27 Nov 08 |
martin |
305 |
{ |
4670 |
27 Nov 08 |
martin |
306 |
System.out.println(message); |
4670 |
27 Nov 08 |
martin |
307 |
} |
4670 |
27 Nov 08 |
martin |
308 |
|
4670 |
27 Nov 08 |
martin |
309 |
static void write_item(int i, BioPlate bioPlate) |
4670 |
27 Nov 08 |
martin |
310 |
{ |
5260 |
04 Mar 10 |
nicklas |
311 |
if (!TestUtil.getSilent()) System.out.println(i+":\t"+bioPlate.getId()+"\t"+bioPlate.getExternalId()+ |
5260 |
04 Mar 10 |
nicklas |
312 |
"\t"+bioPlate.getName()+"\t"+bioPlate.getBioPlateType()+"\t"+bioPlate.getDescription()+ |
6063 |
13 Jun 12 |
nicklas |
313 |
"\t"+bioPlate.getBarcode()+"\t"+bioPlate.getPlateGeometry()+"\t"+bioPlate.getFreezer()+ |
6063 |
13 Jun 12 |
nicklas |
314 |
"\t"+bioPlate.getSection()+"\t"+bioPlate.getTray()+"\t"+bioPlate.getPosition()); |
4670 |
27 Nov 08 |
martin |
315 |
} |
5323 |
27 Apr 10 |
nicklas |
316 |
|
5323 |
27 Apr 10 |
nicklas |
317 |
static void write_item(int i, BioWell well) |
5323 |
27 Apr 10 |
nicklas |
318 |
{ |
5323 |
27 Apr 10 |
nicklas |
319 |
if (!TestUtil.getSilent()) System.out.println(i+":\t"+well.getId()+"\t["+well.getRow()+ |
5456 |
28 Oct 10 |
nicklas |
320 |
","+well.getColumn()+"]\t"+well.getBioMaterial()+"\t"+well.getOriginalBioMaterial()); |
5323 |
27 Apr 10 |
nicklas |
321 |
} |
5323 |
27 Apr 10 |
nicklas |
322 |
|
5323 |
27 Apr 10 |
nicklas |
323 |
|
5456 |
28 Oct 10 |
nicklas |
324 |
static int test_set_well(int bioPlateId, int row, int column, Item bioMaterialType, int bioMaterialId, boolean shouldFail) |
5323 |
27 Apr 10 |
nicklas |
325 |
{ |
5323 |
27 Apr 10 |
nicklas |
326 |
if (bioPlateId == 0 || bioMaterialId == 0) |
5323 |
27 Apr 10 |
nicklas |
327 |
{ |
5323 |
27 Apr 10 |
nicklas |
328 |
return 0; |
5323 |
27 Apr 10 |
nicklas |
329 |
} |
5323 |
27 Apr 10 |
nicklas |
330 |
int wellId = 0; |
5323 |
27 Apr 10 |
nicklas |
331 |
DbControl dc = null; |
5323 |
27 Apr 10 |
nicklas |
332 |
try |
5323 |
27 Apr 10 |
nicklas |
333 |
{ |
5456 |
28 Oct 10 |
nicklas |
334 |
Throwable t = null; |
5456 |
28 Oct 10 |
nicklas |
335 |
BioPlate plate = null; |
5456 |
28 Oct 10 |
nicklas |
336 |
try |
5456 |
28 Oct 10 |
nicklas |
337 |
{ |
5456 |
28 Oct 10 |
nicklas |
338 |
dc = TestUtil.getDbControl(); |
5456 |
28 Oct 10 |
nicklas |
339 |
plate = BioPlate.getById(dc, bioPlateId); |
5456 |
28 Oct 10 |
nicklas |
340 |
MeasuredBioMaterial bm = (MeasuredBioMaterial)bioMaterialType.getById(dc, bioMaterialId); |
5456 |
28 Oct 10 |
nicklas |
341 |
BioWell well = plate.getBioWell(row, column); |
5456 |
28 Oct 10 |
nicklas |
342 |
bm.setBioWell(well); |
5456 |
28 Oct 10 |
nicklas |
343 |
dc.commit(); |
5456 |
28 Oct 10 |
nicklas |
344 |
wellId = well.getId(); |
5456 |
28 Oct 10 |
nicklas |
345 |
} |
5456 |
28 Oct 10 |
nicklas |
346 |
catch (Throwable t1) |
5456 |
28 Oct 10 |
nicklas |
347 |
{ |
5456 |
28 Oct 10 |
nicklas |
348 |
t = t1; |
5456 |
28 Oct 10 |
nicklas |
349 |
} |
5456 |
28 Oct 10 |
nicklas |
350 |
if (shouldFail) |
5456 |
28 Oct 10 |
nicklas |
351 |
{ |
5456 |
28 Oct 10 |
nicklas |
352 |
if (t == null) throw new RuntimeException("Well shuld be locked"); |
5456 |
28 Oct 10 |
nicklas |
353 |
write("--Set well " + plate + "[" + row + "," + column + "] OK (well was locked)"); |
5456 |
28 Oct 10 |
nicklas |
354 |
} |
5456 |
28 Oct 10 |
nicklas |
355 |
else |
5456 |
28 Oct 10 |
nicklas |
356 |
{ |
5456 |
28 Oct 10 |
nicklas |
357 |
if (t != null) throw t; |
5456 |
28 Oct 10 |
nicklas |
358 |
write("--Set well " + plate + "[" + row + "," + column + "] OK"); |
5456 |
28 Oct 10 |
nicklas |
359 |
} |
5323 |
27 Apr 10 |
nicklas |
360 |
} |
5323 |
27 Apr 10 |
nicklas |
361 |
catch (Throwable ex) |
5323 |
27 Apr 10 |
nicklas |
362 |
{ |
5323 |
27 Apr 10 |
nicklas |
363 |
write("--Set well BioPlate[id=" + bioPlateId + "][" + row + "," + column + "] FAILED"); |
5323 |
27 Apr 10 |
nicklas |
364 |
ex.printStackTrace(); |
5323 |
27 Apr 10 |
nicklas |
365 |
ok = false; |
5323 |
27 Apr 10 |
nicklas |
366 |
} |
5323 |
27 Apr 10 |
nicklas |
367 |
finally |
5323 |
27 Apr 10 |
nicklas |
368 |
{ |
5323 |
27 Apr 10 |
nicklas |
369 |
if (dc != null) dc.close(); |
5323 |
27 Apr 10 |
nicklas |
370 |
} |
5323 |
27 Apr 10 |
nicklas |
371 |
return wellId; |
5323 |
27 Apr 10 |
nicklas |
372 |
} |
5323 |
27 Apr 10 |
nicklas |
373 |
|
5456 |
28 Oct 10 |
nicklas |
374 |
|
5456 |
28 Oct 10 |
nicklas |
375 |
static void test_clear_well(int bioPlateId, int row, int column, boolean shouldFail) |
5456 |
28 Oct 10 |
nicklas |
376 |
{ |
5456 |
28 Oct 10 |
nicklas |
377 |
if (bioPlateId == 0) return; |
5456 |
28 Oct 10 |
nicklas |
378 |
int wellId = 0; |
5456 |
28 Oct 10 |
nicklas |
379 |
DbControl dc = null; |
5456 |
28 Oct 10 |
nicklas |
380 |
try |
5456 |
28 Oct 10 |
nicklas |
381 |
{ |
5456 |
28 Oct 10 |
nicklas |
382 |
Throwable t = null; |
5456 |
28 Oct 10 |
nicklas |
383 |
BioPlate plate = null; |
5456 |
28 Oct 10 |
nicklas |
384 |
try |
5456 |
28 Oct 10 |
nicklas |
385 |
{ |
5456 |
28 Oct 10 |
nicklas |
386 |
dc = TestUtil.getDbControl(); |
5456 |
28 Oct 10 |
nicklas |
387 |
plate = BioPlate.getById(dc, bioPlateId); |
5456 |
28 Oct 10 |
nicklas |
388 |
BioWell well = plate.getBioWell(row, column); |
5456 |
28 Oct 10 |
nicklas |
389 |
well.getBioMaterial().setBioWell(null); |
5456 |
28 Oct 10 |
nicklas |
390 |
dc.commit(); |
5456 |
28 Oct 10 |
nicklas |
391 |
} |
5456 |
28 Oct 10 |
nicklas |
392 |
catch (Throwable t1) |
5456 |
28 Oct 10 |
nicklas |
393 |
{ |
5456 |
28 Oct 10 |
nicklas |
394 |
t = t1; |
5456 |
28 Oct 10 |
nicklas |
395 |
} |
5456 |
28 Oct 10 |
nicklas |
396 |
if (shouldFail) |
5456 |
28 Oct 10 |
nicklas |
397 |
{ |
5456 |
28 Oct 10 |
nicklas |
398 |
if (t == null) throw new RuntimeException("Well shuld be locked"); |
5456 |
28 Oct 10 |
nicklas |
399 |
write("--Clear well " + plate + "[" + row + "," + column + "] OK (well was locked)"); |
5456 |
28 Oct 10 |
nicklas |
400 |
} |
5456 |
28 Oct 10 |
nicklas |
401 |
else |
5456 |
28 Oct 10 |
nicklas |
402 |
{ |
5456 |
28 Oct 10 |
nicklas |
403 |
if (t != null) throw t; |
5456 |
28 Oct 10 |
nicklas |
404 |
write("--Clear well " + plate + "[" + row + "," + column + "] OK"); |
5456 |
28 Oct 10 |
nicklas |
405 |
} |
5456 |
28 Oct 10 |
nicklas |
406 |
} |
5456 |
28 Oct 10 |
nicklas |
407 |
catch (Throwable ex) |
5456 |
28 Oct 10 |
nicklas |
408 |
{ |
5456 |
28 Oct 10 |
nicklas |
409 |
write("--Clear well BioPlate[id=" + bioPlateId + "][" + row + "," + column + "] FAILED"); |
5456 |
28 Oct 10 |
nicklas |
410 |
ex.printStackTrace(); |
5456 |
28 Oct 10 |
nicklas |
411 |
ok = false; |
5456 |
28 Oct 10 |
nicklas |
412 |
} |
5456 |
28 Oct 10 |
nicklas |
413 |
finally |
5456 |
28 Oct 10 |
nicklas |
414 |
{ |
5456 |
28 Oct 10 |
nicklas |
415 |
if (dc != null) dc.close(); |
5456 |
28 Oct 10 |
nicklas |
416 |
} |
5456 |
28 Oct 10 |
nicklas |
417 |
} |
5456 |
28 Oct 10 |
nicklas |
418 |
|
5456 |
28 Oct 10 |
nicklas |
419 |
|
5323 |
27 Apr 10 |
nicklas |
420 |
static void test_list_wells(int bioPlateId, int expectedResults) |
5323 |
27 Apr 10 |
nicklas |
421 |
{ |
5323 |
27 Apr 10 |
nicklas |
422 |
if (bioPlateId == 0) return; |
5323 |
27 Apr 10 |
nicklas |
423 |
DbControl dc = null; |
5323 |
27 Apr 10 |
nicklas |
424 |
try |
5323 |
27 Apr 10 |
nicklas |
425 |
{ |
5323 |
27 Apr 10 |
nicklas |
426 |
dc = TestUtil.getDbControl(); |
5323 |
27 Apr 10 |
nicklas |
427 |
BioPlate plate = BioPlate.getById(dc, bioPlateId); |
5323 |
27 Apr 10 |
nicklas |
428 |
ItemResultList<BioWell> wells = plate.getBioWells().list(dc); |
5323 |
27 Apr 10 |
nicklas |
429 |
int numWells = 0; |
5323 |
27 Apr 10 |
nicklas |
430 |
for (int i = 0; i<wells.size(); i++) |
5323 |
27 Apr 10 |
nicklas |
431 |
{ |
5323 |
27 Apr 10 |
nicklas |
432 |
BioWell well = wells.get(i); |
5323 |
27 Apr 10 |
nicklas |
433 |
if (well.getBioMaterial() != null) |
5323 |
27 Apr 10 |
nicklas |
434 |
{ |
5323 |
27 Apr 10 |
nicklas |
435 |
write_item(i, well); |
5323 |
27 Apr 10 |
nicklas |
436 |
numWells++; |
5323 |
27 Apr 10 |
nicklas |
437 |
} |
5323 |
27 Apr 10 |
nicklas |
438 |
} |
5323 |
27 Apr 10 |
nicklas |
439 |
if (expectedResults >=0 && expectedResults != numWells) |
5323 |
27 Apr 10 |
nicklas |
440 |
{ |
5323 |
27 Apr 10 |
nicklas |
441 |
throw new BaseException("Expected " + expectedResults + " results, " + |
5323 |
27 Apr 10 |
nicklas |
442 |
"not " + numWells); |
5323 |
27 Apr 10 |
nicklas |
443 |
} |
5323 |
27 Apr 10 |
nicklas |
444 |
write ("--List wells OK (" + numWells +")"); |
5323 |
27 Apr 10 |
nicklas |
445 |
} |
5323 |
27 Apr 10 |
nicklas |
446 |
catch (Throwable ex) |
5323 |
27 Apr 10 |
nicklas |
447 |
{ |
5323 |
27 Apr 10 |
nicklas |
448 |
write("--List wells FAILED"); |
5323 |
27 Apr 10 |
nicklas |
449 |
ex.printStackTrace(); |
5323 |
27 Apr 10 |
nicklas |
450 |
ok = false; |
5323 |
27 Apr 10 |
nicklas |
451 |
} |
5323 |
27 Apr 10 |
nicklas |
452 |
finally |
5323 |
27 Apr 10 |
nicklas |
453 |
{ |
5323 |
27 Apr 10 |
nicklas |
454 |
if (dc != null) dc.close(); |
5323 |
27 Apr 10 |
nicklas |
455 |
} |
5323 |
27 Apr 10 |
nicklas |
456 |
} |
5456 |
28 Oct 10 |
nicklas |
457 |
|
5456 |
28 Oct 10 |
nicklas |
458 |
static void test_list_original_biomaterial(int bioPlateId, int expectedResults) |
5456 |
28 Oct 10 |
nicklas |
459 |
{ |
5456 |
28 Oct 10 |
nicklas |
460 |
if (bioPlateId == 0) return; |
5456 |
28 Oct 10 |
nicklas |
461 |
DbControl dc = null; |
5456 |
28 Oct 10 |
nicklas |
462 |
try |
5456 |
28 Oct 10 |
nicklas |
463 |
{ |
5456 |
28 Oct 10 |
nicklas |
464 |
dc = TestUtil.getDbControl(); |
5456 |
28 Oct 10 |
nicklas |
465 |
BioPlate plate = BioPlate.getById(dc, bioPlateId); |
5456 |
28 Oct 10 |
nicklas |
466 |
ItemResultList<BioWell> wells = plate.getBioWells().list(dc); |
5456 |
28 Oct 10 |
nicklas |
467 |
int numWells = 0; |
5456 |
28 Oct 10 |
nicklas |
468 |
for (int i = 0; i<wells.size(); i++) |
5456 |
28 Oct 10 |
nicklas |
469 |
{ |
5456 |
28 Oct 10 |
nicklas |
470 |
BioWell well = wells.get(i); |
5456 |
28 Oct 10 |
nicklas |
471 |
if (well.getOriginalBioMaterial() != null) |
5456 |
28 Oct 10 |
nicklas |
472 |
{ |
5456 |
28 Oct 10 |
nicklas |
473 |
write_item(i, well); |
5456 |
28 Oct 10 |
nicklas |
474 |
numWells++; |
5456 |
28 Oct 10 |
nicklas |
475 |
} |
5456 |
28 Oct 10 |
nicklas |
476 |
} |
5456 |
28 Oct 10 |
nicklas |
477 |
if (expectedResults >=0 && expectedResults != numWells) |
5456 |
28 Oct 10 |
nicklas |
478 |
{ |
5456 |
28 Oct 10 |
nicklas |
479 |
throw new BaseException("Expected " + expectedResults + " results, " + |
5456 |
28 Oct 10 |
nicklas |
480 |
"not " + numWells); |
5456 |
28 Oct 10 |
nicklas |
481 |
} |
5456 |
28 Oct 10 |
nicklas |
482 |
write ("--List wells with original biomaterial OK (" + numWells +")"); |
5456 |
28 Oct 10 |
nicklas |
483 |
} |
5456 |
28 Oct 10 |
nicklas |
484 |
catch (Throwable ex) |
5456 |
28 Oct 10 |
nicklas |
485 |
{ |
5456 |
28 Oct 10 |
nicklas |
486 |
write("--List wells with original biomaterial FAILED"); |
5456 |
28 Oct 10 |
nicklas |
487 |
ex.printStackTrace(); |
5456 |
28 Oct 10 |
nicklas |
488 |
ok = false; |
5456 |
28 Oct 10 |
nicklas |
489 |
} |
5456 |
28 Oct 10 |
nicklas |
490 |
finally |
5456 |
28 Oct 10 |
nicklas |
491 |
{ |
5456 |
28 Oct 10 |
nicklas |
492 |
if (dc != null) dc.close(); |
5456 |
28 Oct 10 |
nicklas |
493 |
} |
5456 |
28 Oct 10 |
nicklas |
494 |
} |
5456 |
28 Oct 10 |
nicklas |
495 |
|
5323 |
27 Apr 10 |
nicklas |
496 |
|
5632 |
17 May 11 |
nicklas |
497 |
static List<Integer> test_fill(int bioPlateId, Item itemType, String rootName, int tagId) |
5338 |
07 May 10 |
nicklas |
498 |
{ |
5338 |
07 May 10 |
nicklas |
499 |
if (bioPlateId == 0) return null; |
5338 |
07 May 10 |
nicklas |
500 |
List<Integer> ids = null; |
5338 |
07 May 10 |
nicklas |
501 |
DbControl dc = null; |
5338 |
07 May 10 |
nicklas |
502 |
try |
5338 |
07 May 10 |
nicklas |
503 |
{ |
5338 |
07 May 10 |
nicklas |
504 |
dc = TestUtil.getDbControl(); |
5338 |
07 May 10 |
nicklas |
505 |
BioPlate plate = BioPlate.getById(dc, bioPlateId); |
5632 |
17 May 11 |
nicklas |
506 |
Tag label = tagId == 0 ? null : Tag.getById(dc, tagId); |
5338 |
07 May 10 |
nicklas |
507 |
PlateGeometry geometry = plate.getPlateGeometry(); |
5338 |
07 May 10 |
nicklas |
508 |
int rows = geometry.getRows(); |
5338 |
07 May 10 |
nicklas |
509 |
int cols = geometry.getColumns(); |
5338 |
07 May 10 |
nicklas |
510 |
List<MeasuredBioMaterial> items = new ArrayList<MeasuredBioMaterial>(rows * cols); |
5338 |
07 May 10 |
nicklas |
511 |
WellCoordinateFormatter rowFormat = new WellCoordinateFormatter(true); |
5338 |
07 May 10 |
nicklas |
512 |
WellCoordinateFormatter colFormat = new WellCoordinateFormatter(false); |
5338 |
07 May 10 |
nicklas |
513 |
for (int row = 0; row < rows; ++row) |
5338 |
07 May 10 |
nicklas |
514 |
{ |
5338 |
07 May 10 |
nicklas |
515 |
for (int col = 0; col < cols; ++col) |
5338 |
07 May 10 |
nicklas |
516 |
{ |
5338 |
07 May 10 |
nicklas |
517 |
BioWell well = plate.getBioWell(row, col); |
5338 |
07 May 10 |
nicklas |
518 |
MeasuredBioMaterial item = null; |
5338 |
07 May 10 |
nicklas |
519 |
if (itemType == Item.SAMPLE) |
5338 |
07 May 10 |
nicklas |
520 |
{ |
5338 |
07 May 10 |
nicklas |
521 |
item = Sample.getNew(dc); |
5338 |
07 May 10 |
nicklas |
522 |
} |
5338 |
07 May 10 |
nicklas |
523 |
else if (itemType == Item.EXTRACT) |
5338 |
07 May 10 |
nicklas |
524 |
{ |
5338 |
07 May 10 |
nicklas |
525 |
item = Extract.getNew(dc); |
5338 |
07 May 10 |
nicklas |
526 |
} |
5338 |
07 May 10 |
nicklas |
527 |
item.setName(rootName + " [" + rowFormat.format(row) + colFormat.format(col) + "]"); |
5338 |
07 May 10 |
nicklas |
528 |
dc.saveItem(item); |
5338 |
07 May 10 |
nicklas |
529 |
item.setBioWell(well); |
5338 |
07 May 10 |
nicklas |
530 |
items.add(item); |
5338 |
07 May 10 |
nicklas |
531 |
} |
5338 |
07 May 10 |
nicklas |
532 |
} |
5338 |
07 May 10 |
nicklas |
533 |
dc.commit(); |
5338 |
07 May 10 |
nicklas |
534 |
ids = new ArrayList<Integer>(items.size()); |
5338 |
07 May 10 |
nicklas |
535 |
new BasicItemToIdTransformer().transform(items, ids); |
5338 |
07 May 10 |
nicklas |
536 |
write("--Fill bioplate OK"); |
5338 |
07 May 10 |
nicklas |
537 |
} |
5338 |
07 May 10 |
nicklas |
538 |
catch (Throwable ex) |
5338 |
07 May 10 |
nicklas |
539 |
{ |
5338 |
07 May 10 |
nicklas |
540 |
write("--Fill bioplate FAILED"); |
5338 |
07 May 10 |
nicklas |
541 |
ex.printStackTrace(); |
5338 |
07 May 10 |
nicklas |
542 |
ok = false; |
5338 |
07 May 10 |
nicklas |
543 |
} |
5338 |
07 May 10 |
nicklas |
544 |
finally |
5338 |
07 May 10 |
nicklas |
545 |
{ |
5338 |
07 May 10 |
nicklas |
546 |
if (dc != null) dc.close(); |
5338 |
07 May 10 |
nicklas |
547 |
} |
5338 |
07 May 10 |
nicklas |
548 |
return ids; |
5338 |
07 May 10 |
nicklas |
549 |
} |
5323 |
27 Apr 10 |
nicklas |
550 |
|
5323 |
27 Apr 10 |
nicklas |
551 |
|
5338 |
07 May 10 |
nicklas |
552 |
static void test_delete_contents(int id) |
5338 |
07 May 10 |
nicklas |
553 |
{ |
5338 |
07 May 10 |
nicklas |
554 |
if (id == 0) return; |
5338 |
07 May 10 |
nicklas |
555 |
DbControl dc = null; |
5338 |
07 May 10 |
nicklas |
556 |
try |
5338 |
07 May 10 |
nicklas |
557 |
{ |
5338 |
07 May 10 |
nicklas |
558 |
dc = TestUtil.getDbControl(); |
5338 |
07 May 10 |
nicklas |
559 |
BioPlate bp = BioPlate.getById(dc, id); |
5338 |
07 May 10 |
nicklas |
560 |
List<BioWell> wells = bp.getBioWells().list(dc); |
5338 |
07 May 10 |
nicklas |
561 |
for (BioWell well : wells) |
5338 |
07 May 10 |
nicklas |
562 |
{ |
5338 |
07 May 10 |
nicklas |
563 |
MeasuredBioMaterial item = well.getBioMaterial(); |
5338 |
07 May 10 |
nicklas |
564 |
if (item != null) dc.deleteItem(item); |
5338 |
07 May 10 |
nicklas |
565 |
} |
5338 |
07 May 10 |
nicklas |
566 |
dc.commit(); |
5338 |
07 May 10 |
nicklas |
567 |
write("--Delete bioplate contents OK"); |
5338 |
07 May 10 |
nicklas |
568 |
} |
5338 |
07 May 10 |
nicklas |
569 |
catch (Throwable ex) |
5338 |
07 May 10 |
nicklas |
570 |
{ |
5338 |
07 May 10 |
nicklas |
571 |
write("--Delete bioplate contents FAILED"); |
5338 |
07 May 10 |
nicklas |
572 |
ex.printStackTrace(); |
5338 |
07 May 10 |
nicklas |
573 |
ok = false; |
5338 |
07 May 10 |
nicklas |
574 |
} |
5338 |
07 May 10 |
nicklas |
575 |
finally |
5338 |
07 May 10 |
nicklas |
576 |
{ |
5338 |
07 May 10 |
nicklas |
577 |
if (dc != null) dc.close(); |
5338 |
07 May 10 |
nicklas |
578 |
} |
5338 |
07 May 10 |
nicklas |
579 |
|
5338 |
07 May 10 |
nicklas |
580 |
} |
5338 |
07 May 10 |
nicklas |
581 |
|
5338 |
07 May 10 |
nicklas |
582 |
|
4670 |
27 Nov 08 |
martin |
583 |
} |