1906 |
03 Feb 06 |
enell |
1 |
/* |
1906 |
03 Feb 06 |
enell |
$Id$ |
1906 |
03 Feb 06 |
enell |
3 |
|
5228 |
03 Feb 10 |
nicklas |
Copyright (C) 2010 Nicklas Nordborg |
1906 |
03 Feb 06 |
enell |
5 |
|
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/ |
1906 |
03 Feb 06 |
enell |
8 |
|
1906 |
03 Feb 06 |
enell |
BASE is free software; you can redistribute it and/or |
1906 |
03 Feb 06 |
enell |
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 |
1906 |
03 Feb 06 |
enell |
of the License, or (at your option) any later version. |
1906 |
03 Feb 06 |
enell |
13 |
|
1906 |
03 Feb 06 |
enell |
BASE is distributed in the hope that it will be useful, |
1906 |
03 Feb 06 |
enell |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
1906 |
03 Feb 06 |
enell |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1906 |
03 Feb 06 |
enell |
GNU General Public License for more details. |
1906 |
03 Feb 06 |
enell |
18 |
|
1906 |
03 Feb 06 |
enell |
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/>. |
1906 |
03 Feb 06 |
enell |
21 |
*/ |
5228 |
03 Feb 10 |
nicklas |
22 |
import java.util.HashMap; |
1906 |
03 Feb 06 |
enell |
23 |
import java.util.List; |
1906 |
03 Feb 06 |
enell |
24 |
import java.util.Map; |
1906 |
03 Feb 06 |
enell |
25 |
|
4537 |
18 Sep 08 |
nicklas |
26 |
import net.sf.basedb.core.BioAssaySet; |
1906 |
03 Feb 06 |
enell |
27 |
import net.sf.basedb.core.DbControl; |
1906 |
03 Feb 06 |
enell |
28 |
import net.sf.basedb.core.Experiment; |
5228 |
03 Feb 10 |
nicklas |
29 |
import net.sf.basedb.core.Formula; |
1906 |
03 Feb 06 |
enell |
30 |
import net.sf.basedb.core.Item; |
4537 |
18 Sep 08 |
nicklas |
31 |
import net.sf.basedb.core.ItemQuery; |
3820 |
12 Oct 07 |
nicklas |
32 |
import net.sf.basedb.core.Platform; |
1906 |
03 Feb 06 |
enell |
33 |
import net.sf.basedb.core.RawBioAssay; |
5228 |
03 Feb 10 |
nicklas |
34 |
import net.sf.basedb.core.RawDataType; |
5228 |
03 Feb 10 |
nicklas |
35 |
import net.sf.basedb.core.Transformation; |
5228 |
03 Feb 10 |
nicklas |
36 |
import net.sf.basedb.core.Type; |
5228 |
03 Feb 10 |
nicklas |
37 |
import net.sf.basedb.core.query.Expressions; |
4537 |
18 Sep 08 |
nicklas |
38 |
import net.sf.basedb.core.query.Hql; |
5228 |
03 Feb 10 |
nicklas |
39 |
import net.sf.basedb.core.query.Restrictions; |
5228 |
03 Feb 10 |
nicklas |
40 |
import net.sf.basedb.util.ConsoleProgressReporter; |
5228 |
03 Feb 10 |
nicklas |
41 |
import net.sf.basedb.util.IntensityCalculator; |
5228 |
03 Feb 10 |
nicklas |
42 |
import net.sf.basedb.util.IntensityCalculatorUtil; |
1906 |
03 Feb 06 |
enell |
43 |
|
5228 |
03 Feb 10 |
nicklas |
44 |
public class TestAnalyzeUtil |
1906 |
03 Feb 06 |
enell |
45 |
{ |
5228 |
03 Feb 10 |
nicklas |
46 |
|
5228 |
03 Feb 10 |
nicklas |
47 |
private static Map<String, Integer> itemIds = new HashMap<String, Integer>(); |
5228 |
03 Feb 10 |
nicklas |
48 |
private static boolean isSetup = false; |
5228 |
03 Feb 10 |
nicklas |
49 |
|
5228 |
03 Feb 10 |
nicklas |
50 |
static int getItemId(String key) |
1906 |
03 Feb 06 |
enell |
51 |
{ |
5228 |
03 Feb 10 |
nicklas |
52 |
Integer id = itemIds.get(key); |
5228 |
03 Feb 10 |
nicklas |
53 |
return id == null ? 0 : id; |
5228 |
03 Feb 10 |
nicklas |
54 |
} |
5228 |
03 Feb 10 |
nicklas |
55 |
|
5228 |
03 Feb 10 |
nicklas |
56 |
static void setItemId(String key, int id) |
5228 |
03 Feb 10 |
nicklas |
57 |
{ |
5228 |
03 Feb 10 |
nicklas |
58 |
if (id != 0) |
5228 |
03 Feb 10 |
nicklas |
59 |
{ |
5228 |
03 Feb 10 |
nicklas |
60 |
itemIds.put(key, id); |
5228 |
03 Feb 10 |
nicklas |
61 |
} |
5228 |
03 Feb 10 |
nicklas |
62 |
} |
5228 |
03 Feb 10 |
nicklas |
63 |
|
5228 |
03 Feb 10 |
nicklas |
64 |
static boolean hasItemId(String key) |
5228 |
03 Feb 10 |
nicklas |
65 |
{ |
5228 |
03 Feb 10 |
nicklas |
66 |
return itemIds.containsKey(key); |
5228 |
03 Feb 10 |
nicklas |
67 |
} |
5228 |
03 Feb 10 |
nicklas |
68 |
|
5228 |
03 Feb 10 |
nicklas |
69 |
static boolean setupExperiment() |
5228 |
03 Feb 10 |
nicklas |
70 |
{ |
5228 |
03 Feb 10 |
nicklas |
71 |
if (isSetup) return false; |
5228 |
03 Feb 10 |
nicklas |
72 |
write("++Setting up experiment"); |
5228 |
03 Feb 10 |
nicklas |
// Import reporters |
5228 |
03 Feb 10 |
nicklas |
74 |
TestReporter.test_import_from_file("data/test.rawdata.import.txt", |
5228 |
03 Feb 10 |
nicklas |
75 |
"\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", "\\t", 4, 3); |
5228 |
03 Feb 10 |
nicklas |
76 |
|
5228 |
03 Feb 10 |
nicklas |
// Create array design |
5228 |
03 Feb 10 |
nicklas |
78 |
int arrayDesignId = TestArrayDesign.test_create(Platform.GENERIC, false); |
5228 |
03 Feb 10 |
nicklas |
79 |
TestArrayDesign.test_import_from_file(arrayDesignId, "data/test.rawdata.import.txt", |
5228 |
03 Feb 10 |
nicklas |
80 |
"\"Block\"\\t\"Column\"\\t\"Row\"\\t\"Name\"\\t\"ID\".*", null, 0, 2, 1, 4); |
5228 |
03 Feb 10 |
nicklas |
81 |
setItemId("arraydesign.generic", arrayDesignId); |
5228 |
03 Feb 10 |
nicklas |
82 |
|
5228 |
03 Feb 10 |
nicklas |
// Create raw bioassays and import raw data |
5748 |
19 Sep 11 |
nicklas |
84 |
int rba1 = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", "Genepix.1", 0, 0, 0, 0, arrayDesignId, false); |
5748 |
19 Sep 11 |
nicklas |
85 |
int rba2 = TestRawBioAssay.test_create(Platform.GENERIC, "genepix", "Genepix.2", 0, 0, 0, 0, arrayDesignId, false); |
5228 |
03 Feb 10 |
nicklas |
86 |
TestRawBioAssay.test_import_from_file(rba1, "data/test.rawdata.import.txt"); |
5228 |
03 Feb 10 |
nicklas |
87 |
TestRawBioAssay.test_import_from_file(rba2, "data/test.rawdata.import.txt"); |
5228 |
03 Feb 10 |
nicklas |
88 |
setItemId("rawbioassay.generic.1", rba1); |
5228 |
03 Feb 10 |
nicklas |
89 |
setItemId("rawbioassay.generic.2", rba2); |
5228 |
03 Feb 10 |
nicklas |
90 |
|
5228 |
03 Feb 10 |
nicklas |
// Experimental factors |
5228 |
03 Feb 10 |
nicklas |
92 |
int drugFactor = TestAnnotationType.test_create("Drug resistance", Type.STRING, 0, null, null, Item.RAWBIOASSAY, 1, new String[] { "high", "medium", "low" }, false); |
5228 |
03 Feb 10 |
nicklas |
93 |
int tempFactor = TestAnnotationType.test_create("Temperature", Type.FLOAT, 0, null, null, Item.RAWBIOASSAY, 1, null, false); |
5228 |
03 Feb 10 |
nicklas |
94 |
TestAnnotation.test_annotatate(Item.RAWBIOASSAY, rba1, drugFactor, 0, "medium"); |
5228 |
03 Feb 10 |
nicklas |
95 |
TestAnnotation.test_annotatate(Item.RAWBIOASSAY, rba2, drugFactor, 0, "high"); |
5228 |
03 Feb 10 |
nicklas |
96 |
TestAnnotation.test_annotatate(Item.RAWBIOASSAY, rba1, tempFactor, 0, 25.0); |
5228 |
03 Feb 10 |
nicklas |
97 |
TestAnnotation.test_annotatate(Item.RAWBIOASSAY, rba2, tempFactor, 0, 30.0); |
5228 |
03 Feb 10 |
nicklas |
98 |
setItemId("factor.drug-resistance", drugFactor); |
5228 |
03 Feb 10 |
nicklas |
99 |
setItemId("factor.temperature", tempFactor); |
5228 |
03 Feb 10 |
nicklas |
100 |
|
5228 |
03 Feb 10 |
nicklas |
// The experiment |
5228 |
03 Feb 10 |
nicklas |
102 |
int experiment1 = TestExperiment.test_create("genepix", true); |
5228 |
03 Feb 10 |
nicklas |
103 |
TestExperiment.test_add_experimental_factors(experiment1, drugFactor, tempFactor); |
5228 |
03 Feb 10 |
nicklas |
104 |
TestExperiment.test_add_rawbioassay(experiment1, rba1, rba2); |
5228 |
03 Feb 10 |
nicklas |
105 |
setItemId("experiment.genepix", experiment1); |
5228 |
03 Feb 10 |
nicklas |
106 |
|
5228 |
03 Feb 10 |
nicklas |
// Some other useful stuff - extra value types |
5228 |
03 Feb 10 |
nicklas |
108 |
int intExtraId = TestExtraValueType.test_create("test.int", Type.INT, false); |
5228 |
03 Feb 10 |
nicklas |
109 |
int floatExtraId = TestExtraValueType.test_create("test.float", Type.FLOAT, false); |
5228 |
03 Feb 10 |
nicklas |
110 |
int stringExtraId = TestExtraValueType.test_create("test.string", Type.STRING, false); |
5228 |
03 Feb 10 |
nicklas |
111 |
setItemId("extravaluetype.int", intExtraId); |
5228 |
03 Feb 10 |
nicklas |
112 |
setItemId("extravaluetype.float", floatExtraId); |
5228 |
03 Feb 10 |
nicklas |
113 |
setItemId("extravaluetype.string", stringExtraId); |
5228 |
03 Feb 10 |
nicklas |
114 |
|
5228 |
03 Feb 10 |
nicklas |
// formulas |
5228 |
03 Feb 10 |
nicklas |
116 |
int formulaId = TestFormula.test_create("Mean FG", Formula.Type.INTENSITY_EXPRESSION, |
5228 |
03 Feb 10 |
nicklas |
117 |
"genepix", new String[] { "raw('ch1FgMean')", "raw('ch2FgMean')" }, false); |
5228 |
03 Feb 10 |
nicklas |
118 |
setItemId("formula.intensity.genepix.mean", formulaId); |
5228 |
03 Feb 10 |
nicklas |
119 |
|
5228 |
03 Feb 10 |
nicklas |
// create a root bioassay set |
5228 |
03 Feb 10 |
nicklas |
121 |
int rootId = test_create_root_bioassayset(experiment1, "mean", "Default root"); |
5228 |
03 Feb 10 |
nicklas |
122 |
setItemId("bioassayset.root", rootId); |
5228 |
03 Feb 10 |
nicklas |
123 |
|
5228 |
03 Feb 10 |
nicklas |
124 |
isSetup = true; |
5228 |
03 Feb 10 |
nicklas |
125 |
return true; |
5228 |
03 Feb 10 |
nicklas |
126 |
} |
5228 |
03 Feb 10 |
nicklas |
127 |
|
5228 |
03 Feb 10 |
nicklas |
128 |
|
5228 |
03 Feb 10 |
nicklas |
129 |
static int test_create_root_bioassayset(int experimentId, String intensityFormula, String name) |
5228 |
03 Feb 10 |
nicklas |
130 |
{ |
5228 |
03 Feb 10 |
nicklas |
131 |
if (experimentId == 0) return 0; |
1906 |
03 Feb 06 |
enell |
132 |
int id = 0; |
1906 |
03 Feb 06 |
enell |
133 |
DbControl dc = null; |
5228 |
03 Feb 10 |
nicklas |
134 |
long time; |
1906 |
03 Feb 06 |
enell |
135 |
try |
1906 |
03 Feb 06 |
enell |
136 |
{ |
1906 |
03 Feb 06 |
enell |
137 |
dc = TestUtil.getDbControl(); |
5228 |
03 Feb 10 |
nicklas |
138 |
Experiment e = Experiment.getById(dc, experimentId); |
5228 |
03 Feb 10 |
nicklas |
139 |
|
5228 |
03 Feb 10 |
nicklas |
140 |
List<RawBioAssay> rbaCollection = e.getRawBioAssays().list(dc); |
5228 |
03 Feb 10 |
nicklas |
141 |
|
5228 |
03 Feb 10 |
nicklas |
142 |
RawDataType rdt = e.getRawDataType(); |
5228 |
03 Feb 10 |
nicklas |
143 |
IntensityCalculator iCalc = IntensityCalculatorUtil.createJepIntensityCalculator( |
5228 |
03 Feb 10 |
nicklas |
144 |
dc, rdt, rdt.getIntensityFormula(intensityFormula).getExpressions()); |
5228 |
03 Feb 10 |
nicklas |
145 |
|
5228 |
03 Feb 10 |
nicklas |
146 |
time = System.currentTimeMillis(); |
5228 |
03 Feb 10 |
nicklas |
147 |
BioAssaySet root = IntensityCalculatorUtil.createRootBioAssaySet( |
5228 |
03 Feb 10 |
nicklas |
148 |
dc, e, rbaCollection, null, iCalc, TestUtil.getSilent() ? null : new ConsoleProgressReporter()); |
5228 |
03 Feb 10 |
nicklas |
149 |
root.setName(name); |
5228 |
03 Feb 10 |
nicklas |
150 |
root.getTransformation().setName(name); |
1906 |
03 Feb 06 |
enell |
151 |
dc.commit(); |
5228 |
03 Feb 10 |
nicklas |
152 |
|
5228 |
03 Feb 10 |
nicklas |
153 |
time = System.currentTimeMillis()-time; |
5228 |
03 Feb 10 |
nicklas |
154 |
int numSpots = root.getNumSpots(); |
5228 |
03 Feb 10 |
nicklas |
155 |
id = root.getId(); |
5228 |
03 Feb 10 |
nicklas |
156 |
write("--Create root bioassayset using calculator OK ("+numSpots+" spots inserted; "+time+" ms)"); |
1906 |
03 Feb 06 |
enell |
157 |
} |
1906 |
03 Feb 06 |
enell |
158 |
catch (Throwable ex) |
1906 |
03 Feb 06 |
enell |
159 |
{ |
5228 |
03 Feb 10 |
nicklas |
160 |
write("--Create root bioassayset using calculator FAILED"); |
1906 |
03 Feb 06 |
enell |
161 |
ex.printStackTrace(); |
1906 |
03 Feb 06 |
enell |
162 |
} |
1906 |
03 Feb 06 |
enell |
163 |
finally |
1906 |
03 Feb 06 |
enell |
164 |
{ |
1906 |
03 Feb 06 |
enell |
165 |
if (dc != null) dc.close(); |
5228 |
03 Feb 10 |
nicklas |
166 |
} |
1906 |
03 Feb 06 |
enell |
167 |
return id; |
1906 |
03 Feb 06 |
enell |
168 |
} |
1906 |
03 Feb 06 |
enell |
169 |
|
5228 |
03 Feb 10 |
nicklas |
170 |
static int clone_bioassay_set(int bioassayset_id, String cloneName) |
1906 |
03 Feb 06 |
enell |
171 |
{ |
5228 |
03 Feb 10 |
nicklas |
172 |
if (bioassayset_id == 0) return 0; |
5228 |
03 Feb 10 |
nicklas |
173 |
int id = 0; |
1906 |
03 Feb 06 |
enell |
174 |
DbControl dc = null; |
1906 |
03 Feb 06 |
enell |
175 |
try |
1906 |
03 Feb 06 |
enell |
176 |
{ |
1906 |
03 Feb 06 |
enell |
177 |
dc = TestUtil.getDbControl(); |
5228 |
03 Feb 10 |
nicklas |
178 |
BioAssaySet bas = BioAssaySet.getById(dc, bioassayset_id); |
5228 |
03 Feb 10 |
nicklas |
179 |
|
5228 |
03 Feb 10 |
nicklas |
180 |
Transformation t = bas.newTransformation(null); |
5228 |
03 Feb 10 |
nicklas |
181 |
t.setName(cloneName); |
5228 |
03 Feb 10 |
nicklas |
182 |
BioAssaySet clone = t.newProduct(null, null, true); |
5228 |
03 Feb 10 |
nicklas |
183 |
clone.setName(cloneName); |
5228 |
03 Feb 10 |
nicklas |
184 |
dc.saveItem(t); |
5228 |
03 Feb 10 |
nicklas |
185 |
dc.saveItem(clone); |
5228 |
03 Feb 10 |
nicklas |
186 |
dc.commit(); |
5228 |
03 Feb 10 |
nicklas |
187 |
id = clone.getId(); |
5228 |
03 Feb 10 |
nicklas |
188 |
|
5228 |
03 Feb 10 |
nicklas |
189 |
write("--Clone bioassayset OK ("+cloneName+")"); |
1906 |
03 Feb 06 |
enell |
190 |
} |
1906 |
03 Feb 06 |
enell |
191 |
catch (Throwable ex) |
1906 |
03 Feb 06 |
enell |
192 |
{ |
5384 |
13 Aug 10 |
nicklas |
193 |
write("--Clone bioassayset FAILED ("+cloneName+")"); |
1906 |
03 Feb 06 |
enell |
194 |
ex.printStackTrace(); |
1906 |
03 Feb 06 |
enell |
195 |
} |
1906 |
03 Feb 06 |
enell |
196 |
finally |
1906 |
03 Feb 06 |
enell |
197 |
{ |
1906 |
03 Feb 06 |
enell |
198 |
if (dc != null) dc.close(); |
1906 |
03 Feb 06 |
enell |
199 |
} |
1906 |
03 Feb 06 |
enell |
200 |
return id; |
5228 |
03 Feb 10 |
nicklas |
201 |
|
1906 |
03 Feb 06 |
enell |
202 |
} |
1906 |
03 Feb 06 |
enell |
203 |
|
5230 |
04 Feb 10 |
nicklas |
204 |
static boolean test_delete_bioassayset(int bioAssaySetId) |
5230 |
04 Feb 10 |
nicklas |
205 |
{ |
5230 |
04 Feb 10 |
nicklas |
206 |
if (bioAssaySetId == 0) return true; |
5230 |
04 Feb 10 |
nicklas |
207 |
boolean ok = true; |
5230 |
04 Feb 10 |
nicklas |
208 |
DbControl dc = null; |
5230 |
04 Feb 10 |
nicklas |
209 |
try |
5230 |
04 Feb 10 |
nicklas |
210 |
{ |
5230 |
04 Feb 10 |
nicklas |
211 |
dc = TestUtil.getDbControl(); |
5230 |
04 Feb 10 |
nicklas |
212 |
BioAssaySet bas = BioAssaySet.getById(dc, bioAssaySetId); |
5230 |
04 Feb 10 |
nicklas |
213 |
dc.deleteItem(bas); |
5230 |
04 Feb 10 |
nicklas |
214 |
dc.commit(); |
5230 |
04 Feb 10 |
nicklas |
215 |
write("--Delete bioassayset OK"); |
5230 |
04 Feb 10 |
nicklas |
216 |
} |
5230 |
04 Feb 10 |
nicklas |
217 |
catch (Throwable ex) |
5230 |
04 Feb 10 |
nicklas |
218 |
{ |
5230 |
04 Feb 10 |
nicklas |
219 |
write("--Delete bioassayset FAILED"); |
5230 |
04 Feb 10 |
nicklas |
220 |
ex.printStackTrace(); |
5230 |
04 Feb 10 |
nicklas |
221 |
ok = false; |
5230 |
04 Feb 10 |
nicklas |
222 |
} |
5230 |
04 Feb 10 |
nicklas |
223 |
finally |
5230 |
04 Feb 10 |
nicklas |
224 |
{ |
5230 |
04 Feb 10 |
nicklas |
225 |
if (dc != null) dc.close(); |
5230 |
04 Feb 10 |
nicklas |
226 |
} |
5230 |
04 Feb 10 |
nicklas |
227 |
return ok; |
5230 |
04 Feb 10 |
nicklas |
228 |
} |
5230 |
04 Feb 10 |
nicklas |
229 |
|
5228 |
03 Feb 10 |
nicklas |
230 |
static void cleanupExperiment() |
5228 |
03 Feb 10 |
nicklas |
231 |
{ |
5228 |
03 Feb 10 |
nicklas |
232 |
if (!isSetup) return; |
5228 |
03 Feb 10 |
nicklas |
233 |
if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter(); |
5228 |
03 Feb 10 |
nicklas |
234 |
write("--Cleaning up experiment"); |
5228 |
03 Feb 10 |
nicklas |
235 |
|
5228 |
03 Feb 10 |
nicklas |
236 |
TestExperiment.test_delete(getItemId("experiment.genepix")); |
5228 |
03 Feb 10 |
nicklas |
237 |
TestRawBioAssay.test_delete(getItemId("rawbioassay.generic.1")); |
5228 |
03 Feb 10 |
nicklas |
238 |
TestRawBioAssay.test_delete(getItemId("rawbioassay.generic.2")); |
5228 |
03 Feb 10 |
nicklas |
239 |
|
5228 |
03 Feb 10 |
nicklas |
240 |
TestAnnotationType.test_delete(getItemId("factor.drug-resistance")); |
5228 |
03 Feb 10 |
nicklas |
241 |
TestAnnotationType.test_delete(getItemId("factor.temperature")); |
5228 |
03 Feb 10 |
nicklas |
242 |
TestExtraValueType.test_delete(getItemId("extravaluetype.int")); |
5228 |
03 Feb 10 |
nicklas |
243 |
TestExtraValueType.test_delete(getItemId("extravaluetype.float")); |
5228 |
03 Feb 10 |
nicklas |
244 |
TestExtraValueType.test_delete(getItemId("extravaluetype.string")); |
5228 |
03 Feb 10 |
nicklas |
245 |
TestFormula.test_delete(getItemId("formula.intensity")); |
5228 |
03 Feb 10 |
nicklas |
246 |
|
5228 |
03 Feb 10 |
nicklas |
247 |
TestArrayDesign.test_delete(getItemId("arraydesign.generic")); |
5228 |
03 Feb 10 |
nicklas |
248 |
|
5228 |
03 Feb 10 |
nicklas |
249 |
TestReporter.test_delete(); |
5228 |
03 Feb 10 |
nicklas |
250 |
} |
5228 |
03 Feb 10 |
nicklas |
251 |
|
5228 |
03 Feb 10 |
nicklas |
252 |
static int getBioAssaySetIdByName(int experimentId, String name) |
5228 |
03 Feb 10 |
nicklas |
253 |
{ |
5228 |
03 Feb 10 |
nicklas |
254 |
if (experimentId == 0) return 0; |
5228 |
03 Feb 10 |
nicklas |
255 |
int id = 0; |
5228 |
03 Feb 10 |
nicklas |
256 |
DbControl dc = null; |
5228 |
03 Feb 10 |
nicklas |
257 |
try |
5228 |
03 Feb 10 |
nicklas |
258 |
{ |
5228 |
03 Feb 10 |
nicklas |
259 |
dc = TestUtil.getDbControl(); |
5228 |
03 Feb 10 |
nicklas |
260 |
Experiment e = Experiment.getById(dc, experimentId); |
5228 |
03 Feb 10 |
nicklas |
261 |
ItemQuery<BioAssaySet> query = e.getBioAssaySets(); |
5228 |
03 Feb 10 |
nicklas |
262 |
query.restrict(Restrictions.eq(Hql.property("name"), Expressions.string(name))); |
5228 |
03 Feb 10 |
nicklas |
263 |
List<BioAssaySet> list = query.list(dc); |
5228 |
03 Feb 10 |
nicklas |
264 |
if (list.size() > 0) id = list.get(0).getId(); |
5228 |
03 Feb 10 |
nicklas |
265 |
dc.commit(); |
5228 |
03 Feb 10 |
nicklas |
266 |
} |
5228 |
03 Feb 10 |
nicklas |
267 |
finally |
5228 |
03 Feb 10 |
nicklas |
268 |
{ |
5228 |
03 Feb 10 |
nicklas |
269 |
if (dc != null) dc.close(); |
5228 |
03 Feb 10 |
nicklas |
270 |
} |
5228 |
03 Feb 10 |
nicklas |
271 |
return id; |
5228 |
03 Feb 10 |
nicklas |
272 |
} |
5228 |
03 Feb 10 |
nicklas |
273 |
|
1906 |
03 Feb 06 |
enell |
274 |
static void write(String message) |
1906 |
03 Feb 06 |
enell |
275 |
{ |
1906 |
03 Feb 06 |
enell |
276 |
System.out.println(message); |
1906 |
03 Feb 06 |
enell |
277 |
} |
1906 |
03 Feb 06 |
enell |
278 |
} |