1116 |
23 Aug 05 |
nicklas |
1 |
/* |
1116 |
23 Aug 05 |
nicklas |
$Id$ |
1116 |
23 Aug 05 |
nicklas |
3 |
|
3675 |
16 Aug 07 |
jari |
Copyright (C) 2005 Nicklas Nordborg |
4889 |
06 Apr 09 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg |
1116 |
23 Aug 05 |
nicklas |
6 |
|
2304 |
22 May 06 |
jari |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
Available at http://base.thep.lu.se/ |
1116 |
23 Aug 05 |
nicklas |
9 |
|
1116 |
23 Aug 05 |
nicklas |
BASE is free software; you can redistribute it and/or |
1116 |
23 Aug 05 |
nicklas |
modify it under the terms of the GNU General Public License |
4480 |
05 Sep 08 |
jari |
as published by the Free Software Foundation; either version 3 |
1116 |
23 Aug 05 |
nicklas |
of the License, or (at your option) any later version. |
1116 |
23 Aug 05 |
nicklas |
14 |
|
1116 |
23 Aug 05 |
nicklas |
BASE is distributed in the hope that it will be useful, |
1116 |
23 Aug 05 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1116 |
23 Aug 05 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1116 |
23 Aug 05 |
nicklas |
GNU General Public License for more details. |
1116 |
23 Aug 05 |
nicklas |
19 |
|
1116 |
23 Aug 05 |
nicklas |
You should have received a copy of the GNU General Public License |
4514 |
11 Sep 08 |
jari |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
1116 |
23 Aug 05 |
nicklas |
22 |
*/ |
1116 |
23 Aug 05 |
nicklas |
23 |
import net.sf.basedb.core.*; |
4426 |
29 Aug 08 |
nicklas |
24 |
|
1116 |
23 Aug 05 |
nicklas |
25 |
import java.util.Date; |
5340 |
10 May 10 |
nicklas |
26 |
import java.util.Set; |
1116 |
23 Aug 05 |
nicklas |
27 |
|
5642 |
26 May 11 |
nicklas |
28 |
public class TestPhysicalBioAssay |
1116 |
23 Aug 05 |
nicklas |
29 |
{ |
1116 |
23 Aug 05 |
nicklas |
30 |
|
1116 |
23 Aug 05 |
nicklas |
31 |
static boolean ok = true; |
1116 |
23 Aug 05 |
nicklas |
32 |
public static void main(String[] args) |
1116 |
23 Aug 05 |
nicklas |
33 |
{ |
1116 |
23 Aug 05 |
nicklas |
34 |
TestUtil.checkArgs(args); |
1116 |
23 Aug 05 |
nicklas |
35 |
TestUtil.begin(); |
1116 |
23 Aug 05 |
nicklas |
36 |
ok = test_all(); |
1116 |
23 Aug 05 |
nicklas |
37 |
TestUtil.stop(); |
1116 |
23 Aug 05 |
nicklas |
38 |
} |
1116 |
23 Aug 05 |
nicklas |
39 |
|
1116 |
23 Aug 05 |
nicklas |
40 |
static boolean test_all() |
1116 |
23 Aug 05 |
nicklas |
41 |
{ |
5642 |
26 May 11 |
nicklas |
42 |
write("++Testing physical bioassays"); |
1116 |
23 Aug 05 |
nicklas |
43 |
write_header(); |
1116 |
23 Aug 05 |
nicklas |
// Standard tests: create, load, list |
5653 |
13 Jun 11 |
nicklas |
45 |
int id = test_create(0, "Hyb #1",SystemItems.getId(PhysicalBioAssay.HYBRIDIZATION), 1); |
5739 |
15 Sep 11 |
nicklas |
46 |
int id2 = test_create(0,"Flow cell #2", SystemItems.getId(PhysicalBioAssay.CLONAL_AMPLIFICATION), 1); |
1116 |
23 Aug 05 |
nicklas |
47 |
|
1116 |
23 Aug 05 |
nicklas |
48 |
test_load(id); |
1116 |
23 Aug 05 |
nicklas |
49 |
|
3820 |
12 Oct 07 |
nicklas |
50 |
int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false); |
1116 |
23 Aug 05 |
nicklas |
51 |
int arrayBatchId = TestArrayBatch.test_create(arrayDesignId, false); |
1116 |
23 Aug 05 |
nicklas |
52 |
int arraySlideId = TestArraySlide.test_create(arrayBatchId, false); |
5653 |
13 Jun 11 |
nicklas |
53 |
int id3 = test_create(arraySlideId, "Test #3", 0, 1); |
1116 |
23 Aug 05 |
nicklas |
54 |
|
5641 |
25 May 11 |
nicklas |
55 |
int cy3 = TestTag.test_load("cy3"); |
5641 |
25 May 11 |
nicklas |
56 |
int cy5 = TestTag.test_load("cy5"); |
5641 |
25 May 11 |
nicklas |
57 |
int labeledExtract = SystemItems.getId(Extract.LABELED); |
5641 |
25 May 11 |
nicklas |
58 |
int labeledExtractId1 = TestExtract.test_create(0, "Labeled #1", labeledExtract, cy3, false); |
5641 |
25 May 11 |
nicklas |
59 |
int labeledExtractId2 = TestExtract.test_create(0, "Labeled #2", labeledExtract, cy5, false); |
5653 |
13 Jun 11 |
nicklas |
60 |
int id4 = test_create(0, "Hyb #4", SystemItems.getId(PhysicalBioAssay.HYBRIDIZATION), 1, labeledExtractId1, labeledExtractId2); |
1116 |
23 Aug 05 |
nicklas |
61 |
|
1116 |
23 Aug 05 |
nicklas |
62 |
test_list(-1); |
1999 |
16 Feb 06 |
nicklas |
63 |
|
5642 |
26 May 11 |
nicklas |
64 |
TestExtract.test_list_bioassays(labeledExtractId1, 1); |
5641 |
25 May 11 |
nicklas |
65 |
ok = ok && TestExtract.ok; |
1116 |
23 Aug 05 |
nicklas |
66 |
|
1116 |
23 Aug 05 |
nicklas |
// Standard test: Delete |
1529 |
27 Oct 05 |
nicklas |
68 |
if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter(); |
1116 |
23 Aug 05 |
nicklas |
69 |
test_delete(id); |
1116 |
23 Aug 05 |
nicklas |
70 |
test_delete(id2); |
1116 |
23 Aug 05 |
nicklas |
71 |
test_delete(id3); |
1116 |
23 Aug 05 |
nicklas |
72 |
test_delete(id4); |
1116 |
23 Aug 05 |
nicklas |
73 |
|
5641 |
25 May 11 |
nicklas |
74 |
TestExtract.test_delete(labeledExtractId1); |
5641 |
25 May 11 |
nicklas |
75 |
TestExtract.test_delete(labeledExtractId2); |
1116 |
23 Aug 05 |
nicklas |
76 |
|
1116 |
23 Aug 05 |
nicklas |
77 |
TestArraySlide.test_delete(arraySlideId); |
1116 |
23 Aug 05 |
nicklas |
78 |
TestArrayBatch.test_delete(arrayBatchId); |
1116 |
23 Aug 05 |
nicklas |
79 |
TestArrayDesign.test_delete(arrayDesignId); |
5642 |
26 May 11 |
nicklas |
80 |
write("++Testing physical bioassays "+(ok ? "OK" : "Failed")+"\n"); |
1116 |
23 Aug 05 |
nicklas |
81 |
return ok; |
1116 |
23 Aug 05 |
nicklas |
82 |
} |
1116 |
23 Aug 05 |
nicklas |
83 |
|
5653 |
13 Jun 11 |
nicklas |
84 |
static int test_create(int arraySlideId, String name, int subtypeId, int size, int... extractIds) |
1116 |
23 Aug 05 |
nicklas |
85 |
{ |
5642 |
26 May 11 |
nicklas |
86 |
if (!TestUtil.hasPermission(Permission.CREATE, Item.PHYSICALBIOASSAY)) return 0; |
1116 |
23 Aug 05 |
nicklas |
87 |
int id = 0; |
1116 |
23 Aug 05 |
nicklas |
88 |
DbControl dc = null; |
1116 |
23 Aug 05 |
nicklas |
89 |
try |
1116 |
23 Aug 05 |
nicklas |
90 |
{ |
1116 |
23 Aug 05 |
nicklas |
91 |
dc = TestUtil.getDbControl(); |
5642 |
26 May 11 |
nicklas |
92 |
PhysicalBioAssay h = PhysicalBioAssay.getNew(dc); |
5653 |
13 Jun 11 |
nicklas |
93 |
h.setName(name); |
5653 |
13 Jun 11 |
nicklas |
94 |
h.setSize(size); |
5653 |
13 Jun 11 |
nicklas |
95 |
h.setDescription("Added at "+new Date()); |
5642 |
26 May 11 |
nicklas |
96 |
if (subtypeId != 0) |
5642 |
26 May 11 |
nicklas |
97 |
{ |
5642 |
26 May 11 |
nicklas |
98 |
h.setItemSubtype(ItemSubtype.getById(dc, subtypeId)); |
5642 |
26 May 11 |
nicklas |
99 |
} |
1116 |
23 Aug 05 |
nicklas |
100 |
if (arraySlideId != 0) |
1116 |
23 Aug 05 |
nicklas |
101 |
{ |
1116 |
23 Aug 05 |
nicklas |
102 |
h.setArraySlide(ArraySlide.getById(dc, arraySlideId)); |
1116 |
23 Aug 05 |
nicklas |
103 |
} |
1116 |
23 Aug 05 |
nicklas |
104 |
BioMaterialEvent evt = h.getCreationEvent(); |
5652 |
10 Jun 11 |
nicklas |
105 |
for (int extractId : extractIds) |
1116 |
23 Aug 05 |
nicklas |
106 |
{ |
5652 |
10 Jun 11 |
nicklas |
107 |
Extract le = Extract.getById(dc, extractId); |
5662 |
20 Jun 11 |
nicklas |
108 |
BioMaterialEventSource eventSource = evt.addSource(le); |
5662 |
20 Jun 11 |
nicklas |
109 |
eventSource.setUsedQuantity(100.0f); |
1116 |
23 Aug 05 |
nicklas |
110 |
} |
1116 |
23 Aug 05 |
nicklas |
111 |
dc.saveItem(h); |
1116 |
23 Aug 05 |
nicklas |
112 |
dc.commit(); |
1116 |
23 Aug 05 |
nicklas |
113 |
id = h.getId(); |
1116 |
23 Aug 05 |
nicklas |
114 |
dc = TestUtil.getDbControl(); |
5060 |
19 Aug 09 |
nicklas |
115 |
dc.reattachItem(h, false); |
5060 |
19 Aug 09 |
nicklas |
116 |
dc.reattachItem(h.getCreationEvent(), false); |
1116 |
23 Aug 05 |
nicklas |
117 |
write_item(0, h); |
5642 |
26 May 11 |
nicklas |
118 |
write("--Create physical bioassay OK"); |
1116 |
23 Aug 05 |
nicklas |
119 |
} |
1116 |
23 Aug 05 |
nicklas |
120 |
catch (Throwable ex) |
1116 |
23 Aug 05 |
nicklas |
121 |
{ |
5642 |
26 May 11 |
nicklas |
122 |
write("--Create physical bioassay FAILED"); |
1116 |
23 Aug 05 |
nicklas |
123 |
ex.printStackTrace(); |
1116 |
23 Aug 05 |
nicklas |
124 |
ok = false; |
1116 |
23 Aug 05 |
nicklas |
125 |
} |
1116 |
23 Aug 05 |
nicklas |
126 |
finally |
1116 |
23 Aug 05 |
nicklas |
127 |
{ |
1116 |
23 Aug 05 |
nicklas |
128 |
if (dc != null) dc.close(); |
1116 |
23 Aug 05 |
nicklas |
129 |
} |
1116 |
23 Aug 05 |
nicklas |
130 |
return id; |
1116 |
23 Aug 05 |
nicklas |
131 |
} |
1116 |
23 Aug 05 |
nicklas |
132 |
|
1116 |
23 Aug 05 |
nicklas |
133 |
static void test_load(int id) |
1116 |
23 Aug 05 |
nicklas |
134 |
{ |
1116 |
23 Aug 05 |
nicklas |
135 |
if (id == 0) return; |
1116 |
23 Aug 05 |
nicklas |
136 |
DbControl dc = null; |
1116 |
23 Aug 05 |
nicklas |
137 |
try |
1116 |
23 Aug 05 |
nicklas |
138 |
{ |
1116 |
23 Aug 05 |
nicklas |
139 |
dc = TestUtil.getDbControl(); |
5642 |
26 May 11 |
nicklas |
140 |
PhysicalBioAssay h = PhysicalBioAssay.getById(dc, id); |
1116 |
23 Aug 05 |
nicklas |
141 |
write_item(0, h); |
5642 |
26 May 11 |
nicklas |
142 |
write("--Load physical bioassay OK"); |
1116 |
23 Aug 05 |
nicklas |
143 |
} |
1116 |
23 Aug 05 |
nicklas |
144 |
catch (Throwable ex) |
1116 |
23 Aug 05 |
nicklas |
145 |
{ |
5642 |
26 May 11 |
nicklas |
146 |
write("--Load physical bioassay FAILED"); |
1116 |
23 Aug 05 |
nicklas |
147 |
ex.printStackTrace(); |
1116 |
23 Aug 05 |
nicklas |
148 |
ok = false; |
1116 |
23 Aug 05 |
nicklas |
149 |
} |
1116 |
23 Aug 05 |
nicklas |
150 |
finally |
1116 |
23 Aug 05 |
nicklas |
151 |
{ |
1116 |
23 Aug 05 |
nicklas |
152 |
if (dc != null) dc.close(); |
1116 |
23 Aug 05 |
nicklas |
153 |
} |
1116 |
23 Aug 05 |
nicklas |
154 |
} |
1116 |
23 Aug 05 |
nicklas |
155 |
|
5696 |
12 Aug 11 |
nicklas |
156 |
static boolean test_list(int expectedResults) |
1116 |
23 Aug 05 |
nicklas |
157 |
{ |
1116 |
23 Aug 05 |
nicklas |
158 |
DbControl dc = null; |
1116 |
23 Aug 05 |
nicklas |
159 |
try |
1116 |
23 Aug 05 |
nicklas |
160 |
{ |
1116 |
23 Aug 05 |
nicklas |
161 |
dc = TestUtil.getDbControl(); |
5642 |
26 May 11 |
nicklas |
162 |
ItemResultList<PhysicalBioAssay> l = PhysicalBioAssay.getQuery().list(dc); |
1116 |
23 Aug 05 |
nicklas |
163 |
for (int i = 0; i<l.size(); i++) |
1116 |
23 Aug 05 |
nicklas |
164 |
{ |
1116 |
23 Aug 05 |
nicklas |
165 |
write_item(i, l.get(i)); |
1116 |
23 Aug 05 |
nicklas |
166 |
} |
1116 |
23 Aug 05 |
nicklas |
167 |
if (expectedResults >= 0 && expectedResults != l.size()) |
1116 |
23 Aug 05 |
nicklas |
168 |
{ |
1116 |
23 Aug 05 |
nicklas |
169 |
throw new BaseException("Expected "+expectedResults+" results, not "+l.size()); |
1116 |
23 Aug 05 |
nicklas |
170 |
} |
5642 |
26 May 11 |
nicklas |
171 |
write("--List physical bioassay OK ("+l.size()+")"); |
1116 |
23 Aug 05 |
nicklas |
172 |
} |
1116 |
23 Aug 05 |
nicklas |
173 |
catch (Throwable ex) |
1116 |
23 Aug 05 |
nicklas |
174 |
{ |
5642 |
26 May 11 |
nicklas |
175 |
write("--List physical bioassay FAILED"); |
1116 |
23 Aug 05 |
nicklas |
176 |
ex.printStackTrace(); |
1116 |
23 Aug 05 |
nicklas |
177 |
ok = false; |
5696 |
12 Aug 11 |
nicklas |
178 |
return false; |
1116 |
23 Aug 05 |
nicklas |
179 |
} |
1116 |
23 Aug 05 |
nicklas |
180 |
finally |
1116 |
23 Aug 05 |
nicklas |
181 |
{ |
1116 |
23 Aug 05 |
nicklas |
182 |
if (dc != null) dc.close(); |
1116 |
23 Aug 05 |
nicklas |
183 |
} |
5696 |
12 Aug 11 |
nicklas |
184 |
return true; |
1116 |
23 Aug 05 |
nicklas |
185 |
} |
1116 |
23 Aug 05 |
nicklas |
186 |
|
1116 |
23 Aug 05 |
nicklas |
187 |
static void test_delete(int id) |
1116 |
23 Aug 05 |
nicklas |
188 |
{ |
1116 |
23 Aug 05 |
nicklas |
189 |
if (id == 0) return; |
1116 |
23 Aug 05 |
nicklas |
190 |
DbControl dc = null; |
1116 |
23 Aug 05 |
nicklas |
191 |
try |
1116 |
23 Aug 05 |
nicklas |
192 |
{ |
1116 |
23 Aug 05 |
nicklas |
193 |
dc = TestUtil.getDbControl(); |
5642 |
26 May 11 |
nicklas |
194 |
PhysicalBioAssay h = PhysicalBioAssay.getById(dc, id); |
1116 |
23 Aug 05 |
nicklas |
195 |
dc.deleteItem(h); |
5340 |
10 May 10 |
nicklas |
196 |
Set<ItemProxy> using = h.getUsingItems(); |
5340 |
10 May 10 |
nicklas |
197 |
if (using.size() > 0) |
5340 |
10 May 10 |
nicklas |
198 |
{ |
5340 |
10 May 10 |
nicklas |
199 |
throw new BaseException(h + " is used by " + using); |
5340 |
10 May 10 |
nicklas |
200 |
} |
1116 |
23 Aug 05 |
nicklas |
201 |
dc.commit(); |
5642 |
26 May 11 |
nicklas |
202 |
write("--Delete physical bioassay OK"); |
1116 |
23 Aug 05 |
nicklas |
203 |
} |
1116 |
23 Aug 05 |
nicklas |
204 |
catch (Throwable ex) |
1116 |
23 Aug 05 |
nicklas |
205 |
{ |
5642 |
26 May 11 |
nicklas |
206 |
write("--Delete physical bioassay FAILED"); |
1116 |
23 Aug 05 |
nicklas |
207 |
ex.printStackTrace(); |
1116 |
23 Aug 05 |
nicklas |
208 |
ok = false; |
1116 |
23 Aug 05 |
nicklas |
209 |
} |
1116 |
23 Aug 05 |
nicklas |
210 |
finally |
1116 |
23 Aug 05 |
nicklas |
211 |
{ |
1116 |
23 Aug 05 |
nicklas |
212 |
if (dc != null) dc.close(); |
1116 |
23 Aug 05 |
nicklas |
213 |
} |
1116 |
23 Aug 05 |
nicklas |
214 |
} |
1116 |
23 Aug 05 |
nicklas |
215 |
|
4426 |
29 Aug 08 |
nicklas |
216 |
static void test_delete_all() |
4426 |
29 Aug 08 |
nicklas |
217 |
{ |
4426 |
29 Aug 08 |
nicklas |
218 |
DbControl dc = null; |
4426 |
29 Aug 08 |
nicklas |
219 |
try |
4426 |
29 Aug 08 |
nicklas |
220 |
{ |
4426 |
29 Aug 08 |
nicklas |
221 |
dc = TestUtil.getDbControl(); |
5642 |
26 May 11 |
nicklas |
222 |
ItemResultList<PhysicalBioAssay> l = PhysicalBioAssay.getQuery().list(dc); |
5688 |
10 Aug 11 |
nicklas |
223 |
int numDeleted = Trashcan.delete(dc.getSessionControl(), l, true, null); |
5688 |
10 Aug 11 |
nicklas |
224 |
if (numDeleted != l.size()) throw new BaseException("Could not delete all items: " + numDeleted + " of " + l.size()); |
4426 |
29 Aug 08 |
nicklas |
225 |
dc.commit(); |
5642 |
26 May 11 |
nicklas |
226 |
write("--Delete all physical bioassay OK ("+l.size()+")"); |
4426 |
29 Aug 08 |
nicklas |
227 |
} |
4426 |
29 Aug 08 |
nicklas |
228 |
catch (Throwable ex) |
4426 |
29 Aug 08 |
nicklas |
229 |
{ |
5642 |
26 May 11 |
nicklas |
230 |
write("--Delete all physical bioassay FAILED"); |
4426 |
29 Aug 08 |
nicklas |
231 |
ex.printStackTrace(); |
4426 |
29 Aug 08 |
nicklas |
232 |
ok = false; |
4426 |
29 Aug 08 |
nicklas |
233 |
} |
4426 |
29 Aug 08 |
nicklas |
234 |
finally |
4426 |
29 Aug 08 |
nicklas |
235 |
{ |
4426 |
29 Aug 08 |
nicklas |
236 |
if (dc != null) dc.close(); |
4426 |
29 Aug 08 |
nicklas |
237 |
} |
4426 |
29 Aug 08 |
nicklas |
238 |
} |
4426 |
29 Aug 08 |
nicklas |
239 |
|
4426 |
29 Aug 08 |
nicklas |
240 |
|
1116 |
23 Aug 05 |
nicklas |
241 |
static void write_header() |
1116 |
23 Aug 05 |
nicklas |
242 |
{ |
1116 |
23 Aug 05 |
nicklas |
243 |
if (!TestUtil.getSilent()) |
1116 |
23 Aug 05 |
nicklas |
244 |
{ |
5642 |
26 May 11 |
nicklas |
245 |
write(" \tID \tName \tType\tDescription\tArray slide\tLabeled extracts"); |
5642 |
26 May 11 |
nicklas |
246 |
write("-- \t-- \t--------- \t----\t-----------\t-----------\t----------------"); |
1116 |
23 Aug 05 |
nicklas |
247 |
} |
1116 |
23 Aug 05 |
nicklas |
248 |
} |
5642 |
26 May 11 |
nicklas |
249 |
static void write_item(int i, PhysicalBioAssay h) |
1116 |
23 Aug 05 |
nicklas |
250 |
throws BaseException |
1116 |
23 Aug 05 |
nicklas |
251 |
{ |
1116 |
23 Aug 05 |
nicklas |
252 |
if (!TestUtil.getSilent()) |
1116 |
23 Aug 05 |
nicklas |
253 |
{ |
1116 |
23 Aug 05 |
nicklas |
254 |
StringBuilder sb = new StringBuilder(); |
1116 |
23 Aug 05 |
nicklas |
255 |
sb.append("["); |
5663 |
22 Jun 11 |
nicklas |
256 |
for (BioMaterial le : h.getCreationEvent().getSources().list(h.getDbControl())) |
1116 |
23 Aug 05 |
nicklas |
257 |
{ |
1116 |
23 Aug 05 |
nicklas |
258 |
sb.append(le.toString()); |
1116 |
23 Aug 05 |
nicklas |
259 |
sb.append(","); |
1116 |
23 Aug 05 |
nicklas |
260 |
} |
1116 |
23 Aug 05 |
nicklas |
261 |
sb.append("]"); |
5642 |
26 May 11 |
nicklas |
262 |
System.out.println(i+":\t"+h.getId()+"\t"+h.getName()+"\t"+h.getItemSubtype()+"\t"+h.getDescription()+ |
1116 |
23 Aug 05 |
nicklas |
263 |
"\t"+h.getArraySlide()+"\t"+sb); |
1116 |
23 Aug 05 |
nicklas |
264 |
} |
1116 |
23 Aug 05 |
nicklas |
265 |
} |
1116 |
23 Aug 05 |
nicklas |
266 |
static void write(String message) |
1116 |
23 Aug 05 |
nicklas |
267 |
{ |
1116 |
23 Aug 05 |
nicklas |
268 |
System.out.println(message); |
1116 |
23 Aug 05 |
nicklas |
269 |
} |
4740 |
05 Feb 09 |
nicklas |
270 |
|
5662 |
20 Jun 11 |
nicklas |
271 |
static void test_add_extract(int hybId, int extractId, int position, Float usedQuantity) |
4740 |
05 Feb 09 |
nicklas |
272 |
{ |
5652 |
10 Jun 11 |
nicklas |
273 |
if (hybId == 0 || extractId == 0) return; |
4740 |
05 Feb 09 |
nicklas |
274 |
DbControl dc = null; |
4740 |
05 Feb 09 |
nicklas |
275 |
try |
4740 |
05 Feb 09 |
nicklas |
276 |
{ |
4740 |
05 Feb 09 |
nicklas |
277 |
dc = TestUtil.getDbControl(); |
5642 |
26 May 11 |
nicklas |
278 |
PhysicalBioAssay h = PhysicalBioAssay.getById(dc, hybId); |
5652 |
10 Jun 11 |
nicklas |
279 |
Extract le = Extract.getById(dc, extractId); |
4740 |
05 Feb 09 |
nicklas |
280 |
BioMaterialEvent event = h.getCreationEvent(); |
5662 |
20 Jun 11 |
nicklas |
281 |
BioMaterialEventSource eventSource = event.addSource(le); |
5662 |
20 Jun 11 |
nicklas |
282 |
eventSource.setUsedQuantity(usedQuantity); |
5662 |
20 Jun 11 |
nicklas |
283 |
eventSource.setPosition(position); |
4740 |
05 Feb 09 |
nicklas |
284 |
dc.commit(); |
5652 |
10 Jun 11 |
nicklas |
285 |
write("--Add extract to bioassay OK"); |
4740 |
05 Feb 09 |
nicklas |
286 |
} |
4740 |
05 Feb 09 |
nicklas |
287 |
catch (Throwable ex) |
4740 |
05 Feb 09 |
nicklas |
288 |
{ |
5652 |
10 Jun 11 |
nicklas |
289 |
write("--Add extract to bioassay FAILED"); |
4740 |
05 Feb 09 |
nicklas |
290 |
ex.printStackTrace(); |
4740 |
05 Feb 09 |
nicklas |
291 |
ok = false; |
4740 |
05 Feb 09 |
nicklas |
292 |
} |
4740 |
05 Feb 09 |
nicklas |
293 |
finally |
4740 |
05 Feb 09 |
nicklas |
294 |
{ |
4740 |
05 Feb 09 |
nicklas |
295 |
if (dc != null) dc.close(); |
4740 |
05 Feb 09 |
nicklas |
296 |
} |
4740 |
05 Feb 09 |
nicklas |
297 |
} |
4740 |
05 Feb 09 |
nicklas |
298 |
|
1116 |
23 Aug 05 |
nicklas |
299 |
} |