2205 |
28 Apr 06 |
enell |
1 |
/* |
2205 |
28 Apr 06 |
enell |
$Id$ |
2205 |
28 Apr 06 |
enell |
3 |
|
2205 |
28 Apr 06 |
enell |
Copyright (C) 2006 Johan Enell |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2007 Nicklas Nordborg |
2205 |
28 Apr 06 |
enell |
6 |
|
2205 |
28 Apr 06 |
enell |
This file is part of BASE - BioArray Software Environment. |
2205 |
28 Apr 06 |
enell |
Available at http://base.thep.lu.se/ |
2205 |
28 Apr 06 |
enell |
9 |
|
2205 |
28 Apr 06 |
enell |
BASE is free software; you can redistribute it and/or modify it |
2205 |
28 Apr 06 |
enell |
under the terms of the GNU General Public License as published by |
4480 |
05 Sep 08 |
jari |
the Free Software Foundation; either version 3 of the License, or |
2205 |
28 Apr 06 |
enell |
(at your option) any later version. |
2205 |
28 Apr 06 |
enell |
14 |
|
2205 |
28 Apr 06 |
enell |
BASE is distributed in the hope that it will be useful, but |
2205 |
28 Apr 06 |
enell |
WITHOUT ANY WARRANTY; without even the implied warranty of |
2205 |
28 Apr 06 |
enell |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2205 |
28 Apr 06 |
enell |
General Public License for more details. |
2205 |
28 Apr 06 |
enell |
19 |
|
2205 |
28 Apr 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/>. |
2205 |
28 Apr 06 |
enell |
22 |
*/ |
2205 |
28 Apr 06 |
enell |
23 |
|
5444 |
12 Oct 10 |
nicklas |
24 |
import java.util.Arrays; |
5444 |
12 Oct 10 |
nicklas |
25 |
|
5228 |
03 Feb 10 |
nicklas |
26 |
import net.sf.basedb.core.BaseException; |
5228 |
03 Feb 10 |
nicklas |
27 |
import net.sf.basedb.core.BioAssaySet; |
5228 |
03 Feb 10 |
nicklas |
28 |
import net.sf.basedb.core.DbControl; |
5228 |
03 Feb 10 |
nicklas |
29 |
import net.sf.basedb.core.Directory; |
5228 |
03 Feb 10 |
nicklas |
30 |
import net.sf.basedb.core.Experiment; |
5228 |
03 Feb 10 |
nicklas |
31 |
import net.sf.basedb.core.File; |
5228 |
03 Feb 10 |
nicklas |
32 |
import net.sf.basedb.core.Formula; |
5228 |
03 Feb 10 |
nicklas |
33 |
import net.sf.basedb.core.Item; |
5228 |
03 Feb 10 |
nicklas |
34 |
import net.sf.basedb.core.Job; |
5228 |
03 Feb 10 |
nicklas |
35 |
import net.sf.basedb.core.ParameterType; |
5228 |
03 Feb 10 |
nicklas |
36 |
import net.sf.basedb.core.Permission; |
5228 |
03 Feb 10 |
nicklas |
37 |
import net.sf.basedb.core.PluginConfiguration; |
5228 |
03 Feb 10 |
nicklas |
38 |
import net.sf.basedb.core.PluginConfigurationRequest; |
5228 |
03 Feb 10 |
nicklas |
39 |
import net.sf.basedb.core.PluginDefinition; |
5228 |
03 Feb 10 |
nicklas |
40 |
import net.sf.basedb.core.PluginParameter; |
5228 |
03 Feb 10 |
nicklas |
41 |
import net.sf.basedb.core.PluginResponse; |
5228 |
03 Feb 10 |
nicklas |
42 |
import net.sf.basedb.core.RequestInformation; |
5444 |
12 Oct 10 |
nicklas |
43 |
import net.sf.basedb.core.StringParameterType; |
5228 |
03 Feb 10 |
nicklas |
44 |
import net.sf.basedb.core.Type; |
5228 |
03 Feb 10 |
nicklas |
45 |
import net.sf.basedb.core.plugin.Response; |
5228 |
03 Feb 10 |
nicklas |
46 |
|
2205 |
28 Apr 06 |
enell |
47 |
public class TestBase1PluginExecuter |
2205 |
28 Apr 06 |
enell |
48 |
{ |
2205 |
28 Apr 06 |
enell |
49 |
static boolean ok = true; |
2205 |
28 Apr 06 |
enell |
50 |
public static void main(String[] args) |
2205 |
28 Apr 06 |
enell |
51 |
{ |
2205 |
28 Apr 06 |
enell |
52 |
TestUtil.checkArgs(args); |
2205 |
28 Apr 06 |
enell |
53 |
TestUtil.begin(); |
2205 |
28 Apr 06 |
enell |
54 |
ok = test_all(); |
2205 |
28 Apr 06 |
enell |
55 |
TestUtil.stop(); |
2205 |
28 Apr 06 |
enell |
56 |
} |
2205 |
28 Apr 06 |
enell |
57 |
|
2205 |
28 Apr 06 |
enell |
58 |
static boolean test_all() |
2205 |
28 Apr 06 |
enell |
59 |
{ |
5228 |
03 Feb 10 |
nicklas |
60 |
boolean wasSetup = TestAnalyzeUtil.setupExperiment(); |
2205 |
28 Apr 06 |
enell |
61 |
write("++Testing TestBase1PluginExecuter"); |
4232 |
17 Apr 08 |
nicklas |
62 |
|
5230 |
04 Feb 10 |
nicklas |
63 |
try |
5228 |
03 Feb 10 |
nicklas |
64 |
{ |
5230 |
04 Feb 10 |
nicklas |
65 |
int experimentId = TestAnalyzeUtil.getItemId("experiment.genepix"); |
5230 |
04 Feb 10 |
nicklas |
66 |
int rootBasId = TestAnalyzeUtil.getItemId("bioassayset.root"); |
5230 |
04 Feb 10 |
nicklas |
67 |
if (experimentId == 0 || rootBasId == 0) |
5230 |
04 Feb 10 |
nicklas |
68 |
{ |
5230 |
04 Feb 10 |
nicklas |
69 |
ok = false; |
5230 |
04 Feb 10 |
nicklas |
70 |
write("Test experiment was not setup correctly."); |
5230 |
04 Feb 10 |
nicklas |
71 |
return ok; |
5230 |
04 Feb 10 |
nicklas |
72 |
} |
5230 |
04 Feb 10 |
nicklas |
73 |
|
5230 |
04 Feb 10 |
nicklas |
74 |
int cloneId = TestAnalyzeUtil.clone_bioassay_set(rootBasId, "Base1PluginExecuter clone"); |
5230 |
04 Feb 10 |
nicklas |
75 |
|
5230 |
04 Feb 10 |
nicklas |
76 |
int filteredBasId = TestBasicAnalysis.test_filter_bioassayset(cloneId, "Filtered; ch1 > ch2", 1); |
5230 |
04 Feb 10 |
nicklas |
77 |
|
5230 |
04 Feb 10 |
nicklas |
// Formulas that are used in configuration files as exported columns |
5230 |
04 Feb 10 |
nicklas |
79 |
int posFormulaId = TestFormula.test_create("position", |
5230 |
04 Feb 10 |
nicklas |
80 |
Formula.Type.COLUMN_EXPRESSION, "genepix", new String[] { "pos()" }, false); |
5230 |
04 Feb 10 |
nicklas |
81 |
int reporterFormulaId = TestFormula.test_create("reporter", |
5230 |
04 Feb 10 |
nicklas |
82 |
Formula.Type.COLUMN_EXPRESSION, "genepix", new String[] { "rep('id')" }, false); |
5230 |
04 Feb 10 |
nicklas |
83 |
int externalIdFormulaId = TestFormula.test_create("reporterId", |
5230 |
04 Feb 10 |
nicklas |
84 |
Formula.Type.COLUMN_EXPRESSION, "genepix", new String[] { "rep('externalId')" }, false); |
5230 |
04 Feb 10 |
nicklas |
85 |
|
5230 |
04 Feb 10 |
nicklas |
// Configuration files and configurations |
5230 |
04 Feb 10 |
nicklas |
87 |
int fileSerialId = TestFile.test_create("data/test.nullplugin.base", false, false); |
5230 |
04 Feb 10 |
nicklas |
88 |
int fileMatrixId = TestFile.test_create("data/test.nullplugin.matrix.base", false, false); |
5230 |
04 Feb 10 |
nicklas |
89 |
int fileCleanStdId = TestFile.test_create("data/test.nullplugin.cleanstd.base", false, false); |
5230 |
04 Feb 10 |
nicklas |
90 |
int fileMergeId = TestFile.test_create("data/test.base1plugin.base", false, false); |
5230 |
04 Feb 10 |
nicklas |
91 |
int directoryId = TestDirectory.test_create(true, "Base1PluginExecuter"); |
5230 |
04 Feb 10 |
nicklas |
92 |
|
5230 |
04 Feb 10 |
nicklas |
93 |
int pluginDefinitionId = TestPluginDefinition.test_get("net.sf.basedb.plugins.Base1PluginExecuter"); |
5230 |
04 Feb 10 |
nicklas |
94 |
int cloneSerialKeepStdId = test_create_configuration(pluginDefinitionId, fileSerialId); |
5230 |
04 Feb 10 |
nicklas |
95 |
int cloneMatrixKeepStd = test_create_configuration(pluginDefinitionId, fileMatrixId); |
5230 |
04 Feb 10 |
nicklas |
96 |
int cloneSerialCleanStdId = test_create_configuration(pluginDefinitionId, fileCleanStdId); |
5230 |
04 Feb 10 |
nicklas |
97 |
int mergeId = test_create_configuration(pluginDefinitionId, fileMergeId); |
5230 |
04 Feb 10 |
nicklas |
98 |
|
5230 |
04 Feb 10 |
nicklas |
// Calculate extra value used by one of the configurations |
5230 |
04 Feb 10 |
nicklas |
100 |
int aExtraValueId = TestExtraValueType.test_create("a", Type.FLOAT, false); |
5230 |
04 Feb 10 |
nicklas |
101 |
TestBasicAnalysis.test_calculate_spotextravalues(cloneId, null, 0, aExtraValueId, 0); |
5230 |
04 Feb 10 |
nicklas |
102 |
TestBasicAnalysis.test_calculate_spotextravalues(filteredBasId, null, 0, aExtraValueId, 0); |
5230 |
04 Feb 10 |
nicklas |
103 |
|
5230 |
04 Feb 10 |
nicklas |
// Copy input to output - serial format |
5230 |
04 Feb 10 |
nicklas |
105 |
int jobId = test_create_job(cloneSerialKeepStdId, experimentId, cloneId, |
5230 |
04 Feb 10 |
nicklas |
106 |
directoryId, "Clone serial (keep std*.txt)"); |
5319 |
20 Apr 10 |
nicklas |
107 |
ok &= TestJob.test_execute(jobId, false); |
5230 |
04 Feb 10 |
nicklas |
108 |
|
5689 |
11 Aug 11 |
nicklas |
// Copy input to output - serial format, remove stdin and stdout |
5230 |
04 Feb 10 |
nicklas |
110 |
int jobIdCleanStd = test_create_job(cloneSerialCleanStdId, experimentId, |
5230 |
04 Feb 10 |
nicklas |
111 |
cloneId, directoryId, "Clone serial (remove std*.txt)"); |
5319 |
20 Apr 10 |
nicklas |
112 |
ok &= TestJob.test_execute(jobIdCleanStd, false); |
5230 |
04 Feb 10 |
nicklas |
113 |
|
5230 |
04 Feb 10 |
nicklas |
// Copy input to output - matrix format |
5230 |
04 Feb 10 |
nicklas |
115 |
int jobIdMatrix = test_create_job(cloneMatrixKeepStd, experimentId, |
5230 |
04 Feb 10 |
nicklas |
116 |
cloneId, directoryId, "Clone matrix (keep std*.txt)"); |
5319 |
20 Apr 10 |
nicklas |
117 |
ok &= TestJob.test_execute(jobIdMatrix, false); |
5230 |
04 Feb 10 |
nicklas |
118 |
|
5230 |
04 Feb 10 |
nicklas |
// Copy input to output - matrix format - filtered bioassayset |
5230 |
04 Feb 10 |
nicklas |
120 |
int jobIdMatrix2 = test_create_job(cloneMatrixKeepStd, experimentId, |
5230 |
04 Feb 10 |
nicklas |
121 |
filteredBasId, directoryId, "Clone filtered matrix (keep std*.txt)"); |
5319 |
20 Apr 10 |
nicklas |
122 |
ok &= TestJob.test_execute(jobIdMatrix2, false); |
5230 |
04 Feb 10 |
nicklas |
123 |
|
5230 |
04 Feb 10 |
nicklas |
// Merge assays + create subdir |
5230 |
04 Feb 10 |
nicklas |
125 |
int jobId3 = test_create_job(mergeId, experimentId, |
5230 |
04 Feb 10 |
nicklas |
126 |
cloneId, directoryId, "Merge assays + create sudir", |
5319 |
20 Apr 10 |
nicklas |
127 |
new TestJob.Parameter("mergeAssays", "1"), |
5319 |
20 Apr 10 |
nicklas |
128 |
new TestJob.Parameter("createSubdir", "1")); |
5319 |
20 Apr 10 |
nicklas |
129 |
ok &= TestJob.test_execute(jobId3, false); |
5230 |
04 Feb 10 |
nicklas |
130 |
|
5230 |
04 Feb 10 |
nicklas |
// Offset positions |
5230 |
04 Feb 10 |
nicklas |
132 |
int jobId4 = test_create_job(mergeId, experimentId, |
5230 |
04 Feb 10 |
nicklas |
133 |
cloneId, directoryId, "Offset positions", |
5319 |
20 Apr 10 |
nicklas |
134 |
new TestJob.Parameter("offsetPositions", "1")); |
5319 |
20 Apr 10 |
nicklas |
135 |
ok &= TestJob.test_execute(jobId4, false); |
5230 |
04 Feb 10 |
nicklas |
136 |
|
5230 |
04 Feb 10 |
nicklas |
// Offset positions and merge assays |
5230 |
04 Feb 10 |
nicklas |
138 |
int jobId5 = test_create_job(mergeId, experimentId, |
5230 |
04 Feb 10 |
nicklas |
139 |
cloneId, directoryId, "Offset position + merge assays", |
5319 |
20 Apr 10 |
nicklas |
140 |
new TestJob.Parameter("mergeAssays", "1"), |
5319 |
20 Apr 10 |
nicklas |
141 |
new TestJob.Parameter("offsetPositions", "1")); |
5319 |
20 Apr 10 |
nicklas |
142 |
ok &= TestJob.test_execute(jobId5, false); |
5230 |
04 Feb 10 |
nicklas |
143 |
|
5230 |
04 Feb 10 |
nicklas |
// Create reporter list |
5230 |
04 Feb 10 |
nicklas |
145 |
int jobId6 = test_create_job(mergeId, experimentId, |
5230 |
04 Feb 10 |
nicklas |
146 |
cloneId, directoryId, "Create reporter list", |
5319 |
20 Apr 10 |
nicklas |
147 |
new TestJob.Parameter("reporterList", "1")); |
5319 |
20 Apr 10 |
nicklas |
148 |
ok &= TestJob.test_execute(jobId6, false); |
5230 |
04 Feb 10 |
nicklas |
149 |
|
5230 |
04 Feb 10 |
nicklas |
150 |
if (TestUtil.waitBeforeDelete()) TestUtil.waitForEnter(); |
5230 |
04 Feb 10 |
nicklas |
151 |
|
5230 |
04 Feb 10 |
nicklas |
// Cleanup |
5230 |
04 Feb 10 |
nicklas |
153 |
TestAnalyzeUtil.test_delete_bioassayset(cloneId); |
5230 |
04 Feb 10 |
nicklas |
154 |
TestJob.test_delete(jobId); |
5230 |
04 Feb 10 |
nicklas |
155 |
TestJob.test_delete(jobId3); |
5230 |
04 Feb 10 |
nicklas |
156 |
TestJob.test_delete(jobId4); |
5230 |
04 Feb 10 |
nicklas |
157 |
TestJob.test_delete(jobId5); |
5230 |
04 Feb 10 |
nicklas |
158 |
TestJob.test_delete(jobId6); |
5230 |
04 Feb 10 |
nicklas |
159 |
TestJob.test_delete(jobIdCleanStd); |
5230 |
04 Feb 10 |
nicklas |
160 |
TestJob.test_delete(jobIdMatrix); |
5230 |
04 Feb 10 |
nicklas |
161 |
TestJob.test_delete(jobIdMatrix2); |
5230 |
04 Feb 10 |
nicklas |
162 |
|
5230 |
04 Feb 10 |
nicklas |
163 |
TestExtraValueType.test_delete(aExtraValueId); |
5230 |
04 Feb 10 |
nicklas |
164 |
TestPluginConfiguration.test_delete(mergeId); |
5230 |
04 Feb 10 |
nicklas |
165 |
TestPluginConfiguration.test_delete(cloneSerialKeepStdId); |
5230 |
04 Feb 10 |
nicklas |
166 |
TestPluginConfiguration.test_delete(cloneMatrixKeepStd); |
5230 |
04 Feb 10 |
nicklas |
167 |
TestPluginConfiguration.test_delete(cloneSerialCleanStdId); |
5230 |
04 Feb 10 |
nicklas |
168 |
|
5230 |
04 Feb 10 |
nicklas |
169 |
TestFormula.test_delete(posFormulaId); |
5230 |
04 Feb 10 |
nicklas |
170 |
TestFormula.test_delete(reporterFormulaId); |
5230 |
04 Feb 10 |
nicklas |
171 |
TestFormula.test_delete(externalIdFormulaId); |
5230 |
04 Feb 10 |
nicklas |
172 |
TestFile.test_delete(fileSerialId); |
5230 |
04 Feb 10 |
nicklas |
173 |
TestFile.test_delete(fileMergeId); |
5230 |
04 Feb 10 |
nicklas |
174 |
TestFile.test_delete(fileMatrixId); |
5230 |
04 Feb 10 |
nicklas |
175 |
TestFile.test_delete(fileCleanStdId); |
5230 |
04 Feb 10 |
nicklas |
176 |
TestDirectory.test_delete(directoryId, true); |
5228 |
03 Feb 10 |
nicklas |
177 |
} |
5230 |
04 Feb 10 |
nicklas |
178 |
finally |
5230 |
04 Feb 10 |
nicklas |
179 |
{ |
5230 |
04 Feb 10 |
nicklas |
180 |
if (wasSetup) TestAnalyzeUtil.cleanupExperiment(); |
5230 |
04 Feb 10 |
nicklas |
181 |
write("++Testing TestBase1PluginExecuter "+(ok ? "OK" : "Failed")+"\n"); |
5230 |
04 Feb 10 |
nicklas |
182 |
} |
2205 |
28 Apr 06 |
enell |
183 |
return ok; |
2205 |
28 Apr 06 |
enell |
184 |
} |
2205 |
28 Apr 06 |
enell |
185 |
|
2205 |
28 Apr 06 |
enell |
186 |
static int test_create_configuration(int pluginDefinitionId, int fileId) |
2205 |
28 Apr 06 |
enell |
187 |
{ |
2205 |
28 Apr 06 |
enell |
188 |
if (pluginDefinitionId == 0 || !TestUtil.hasPermission(Permission.CREATE, Item.PLUGINCONFIGURATION)) return 0; |
2205 |
28 Apr 06 |
enell |
189 |
int id = 0; |
2205 |
28 Apr 06 |
enell |
190 |
DbControl dc = null; |
2205 |
28 Apr 06 |
enell |
191 |
try |
2205 |
28 Apr 06 |
enell |
192 |
{ |
2205 |
28 Apr 06 |
enell |
193 |
dc = TestUtil.getDbControl(); |
2205 |
28 Apr 06 |
enell |
194 |
|
2205 |
28 Apr 06 |
enell |
195 |
PluginDefinition pd = PluginDefinition.getById(dc, pluginDefinitionId); |
2205 |
28 Apr 06 |
enell |
196 |
PluginConfiguration pc = pd.newPluginConfiguration(); |
2205 |
28 Apr 06 |
enell |
197 |
pc.setName(pd.getName()); |
2205 |
28 Apr 06 |
enell |
198 |
|
2205 |
28 Apr 06 |
enell |
199 |
PluginConfigurationRequest request = pc.configure(); |
2205 |
28 Apr 06 |
enell |
200 |
request.setParameterValue("execPath", new java.io.File("").getAbsolutePath()+java.io.File.separator); |
2205 |
28 Apr 06 |
enell |
201 |
request.setParameterValue("file", File.getById(dc, fileId)); |
2205 |
28 Apr 06 |
enell |
202 |
|
2205 |
28 Apr 06 |
enell |
203 |
write_request_information(request.getRequestInformation()); |
2205 |
28 Apr 06 |
enell |
204 |
|
2205 |
28 Apr 06 |
enell |
205 |
PluginResponse response = request.invoke(); |
2205 |
28 Apr 06 |
enell |
206 |
if (response.getStatus() == Response.Status.DONE) |
2205 |
28 Apr 06 |
enell |
207 |
{ |
2205 |
28 Apr 06 |
enell |
208 |
response.saveParameters(dc); |
5444 |
12 Oct 10 |
nicklas |
209 |
|
5444 |
12 Oct 10 |
nicklas |
210 |
if (TestUtil.isWindows()) |
5444 |
12 Oct 10 |
nicklas |
211 |
{ |
5444 |
12 Oct 10 |
nicklas |
212 |
String executable = (String)pc.getParameterValues("execName").get(0); |
5444 |
12 Oct 10 |
nicklas |
213 |
String winExecutable = executable.replace(".sh", ".bat"); |
5444 |
12 Oct 10 |
nicklas |
214 |
pc.setParameterValues("execName", new StringParameterType(255, null, true), Arrays.asList(winExecutable)); |
5444 |
12 Oct 10 |
nicklas |
215 |
} |
5444 |
12 Oct 10 |
nicklas |
216 |
|
2205 |
28 Apr 06 |
enell |
217 |
dc.saveItem(pc); |
2205 |
28 Apr 06 |
enell |
218 |
dc.commit(); |
2205 |
28 Apr 06 |
enell |
219 |
} |
2205 |
28 Apr 06 |
enell |
220 |
else |
2205 |
28 Apr 06 |
enell |
221 |
{ |
2205 |
28 Apr 06 |
enell |
222 |
throw new BaseException(response.getMessage(), response.getErrorList().get(0)); |
2205 |
28 Apr 06 |
enell |
223 |
} |
2205 |
28 Apr 06 |
enell |
224 |
id = pc.getId(); |
2205 |
28 Apr 06 |
enell |
225 |
write("--Create configuration for Base1PluginExecuter OK"); |
2205 |
28 Apr 06 |
enell |
226 |
} |
2205 |
28 Apr 06 |
enell |
227 |
catch (Throwable ex) |
2205 |
28 Apr 06 |
enell |
228 |
{ |
2205 |
28 Apr 06 |
enell |
229 |
write("--Create configuration for Base1PluginExecuter FAILED"); |
2205 |
28 Apr 06 |
enell |
230 |
ex.printStackTrace(); |
2205 |
28 Apr 06 |
enell |
231 |
ok = false; |
2205 |
28 Apr 06 |
enell |
232 |
} |
2205 |
28 Apr 06 |
enell |
233 |
finally |
2205 |
28 Apr 06 |
enell |
234 |
{ |
2205 |
28 Apr 06 |
enell |
235 |
if (dc != null) dc.close(); |
2205 |
28 Apr 06 |
enell |
236 |
} |
2205 |
28 Apr 06 |
enell |
237 |
return id; |
2205 |
28 Apr 06 |
enell |
238 |
} |
2205 |
28 Apr 06 |
enell |
239 |
|
5171 |
29 Oct 09 |
nicklas |
240 |
static int test_create_job(int pluginConfigurationId, int experimentId, int bioAssaySetId, |
5319 |
20 Apr 10 |
nicklas |
241 |
int directoryId, String childName, TestJob.Parameter... parameters) |
2205 |
28 Apr 06 |
enell |
242 |
{ |
5384 |
13 Aug 10 |
nicklas |
243 |
if (pluginConfigurationId == 0 || experimentId == 0 || bioAssaySetId == 0 || |
5384 |
13 Aug 10 |
nicklas |
244 |
!TestUtil.hasPermission(Permission.CREATE, Item.JOB)) return 0; |
2205 |
28 Apr 06 |
enell |
245 |
int id = 0; |
2205 |
28 Apr 06 |
enell |
246 |
DbControl dc = null; |
2205 |
28 Apr 06 |
enell |
247 |
try |
2205 |
28 Apr 06 |
enell |
248 |
{ |
2205 |
28 Apr 06 |
enell |
249 |
dc = TestUtil.getDbControl(); |
2205 |
28 Apr 06 |
enell |
250 |
|
2205 |
28 Apr 06 |
enell |
251 |
Experiment e = Experiment.getById(dc, experimentId); |
4537 |
18 Sep 08 |
nicklas |
252 |
BioAssaySet bioAssaySet = BioAssaySet.getById(dc, bioAssaySetId); |
5228 |
03 Feb 10 |
nicklas |
253 |
dc.getSessionControl().getCurrentContext(Item.EXPERIMENT).setId(experimentId); |
5228 |
03 Feb 10 |
nicklas |
254 |
dc.getSessionControl().getCurrentContext(Item.BIOASSAYSET).setId(bioAssaySetId); |
2205 |
28 Apr 06 |
enell |
255 |
PluginConfiguration pc = PluginConfiguration.getById(dc, pluginConfigurationId); |
4254 |
28 Apr 08 |
nicklas |
256 |
Job j = pc.newJob(e); |
2205 |
28 Apr 06 |
enell |
257 |
j.setName(pc.getName()); |
2205 |
28 Apr 06 |
enell |
258 |
|
2205 |
28 Apr 06 |
enell |
259 |
PluginConfigurationRequest request = j.configure(null); |
4232 |
17 Apr 08 |
nicklas |
260 |
|
4232 |
17 Apr 08 |
nicklas |
// First, set default values |
2205 |
28 Apr 06 |
enell |
262 |
for (PluginParameter<?> p : request.getRequestInformation().getParameters()) |
2205 |
28 Apr 06 |
enell |
263 |
{ |
5171 |
29 Oct 09 |
nicklas |
264 |
if (p.getParameterType() != null) |
5171 |
29 Oct 09 |
nicklas |
265 |
{ |
5171 |
29 Oct 09 |
nicklas |
266 |
request.setParameterValue(p.getName(), p.getParameterType().getDefaultValue()); |
5171 |
29 Oct 09 |
nicklas |
267 |
} |
2205 |
28 Apr 06 |
enell |
268 |
} |
4232 |
17 Apr 08 |
nicklas |
269 |
|
4232 |
17 Apr 08 |
nicklas |
// Then, set values from method call |
4232 |
17 Apr 08 |
nicklas |
271 |
if (parameters != null) |
4232 |
17 Apr 08 |
nicklas |
272 |
{ |
5319 |
20 Apr 10 |
nicklas |
273 |
for (TestJob.Parameter p : parameters) |
4232 |
17 Apr 08 |
nicklas |
274 |
{ |
4232 |
17 Apr 08 |
nicklas |
275 |
request.setParameterValue(p.name, p.value); |
4232 |
17 Apr 08 |
nicklas |
276 |
} |
4232 |
17 Apr 08 |
nicklas |
277 |
} |
4232 |
17 Apr 08 |
nicklas |
278 |
|
3505 |
18 Jun 07 |
nicklas |
279 |
request.setParameterValue("source", bioAssaySet); |
2205 |
28 Apr 06 |
enell |
280 |
request.setParameterValue("pluginDirectory", Directory.getById(dc, directoryId).getPath().toString()); |
5171 |
29 Oct 09 |
nicklas |
281 |
request.setParameterValue("childName", childName); |
2205 |
28 Apr 06 |
enell |
282 |
write_request_information(request.getRequestInformation()); |
2205 |
28 Apr 06 |
enell |
283 |
|
2205 |
28 Apr 06 |
enell |
284 |
PluginResponse response = request.invoke(); |
2205 |
28 Apr 06 |
enell |
285 |
if (response.getStatus() == Response.Status.DONE) |
2205 |
28 Apr 06 |
enell |
286 |
{ |
2205 |
28 Apr 06 |
enell |
287 |
response.saveParameters(dc); |
2205 |
28 Apr 06 |
enell |
288 |
dc.saveItem(j); |
2205 |
28 Apr 06 |
enell |
289 |
dc.commit(); |
2205 |
28 Apr 06 |
enell |
290 |
} |
2205 |
28 Apr 06 |
enell |
291 |
else |
2205 |
28 Apr 06 |
enell |
292 |
{ |
2205 |
28 Apr 06 |
enell |
293 |
throw new BaseException(response.getMessage(), response.getErrorList().get(0)); |
2205 |
28 Apr 06 |
enell |
294 |
} |
2205 |
28 Apr 06 |
enell |
295 |
id = j.getId(); |
2205 |
28 Apr 06 |
enell |
296 |
write("--Create job for Base1PluginExecuter OK"); |
2205 |
28 Apr 06 |
enell |
297 |
} |
2205 |
28 Apr 06 |
enell |
298 |
catch (Throwable ex) |
2205 |
28 Apr 06 |
enell |
299 |
{ |
2205 |
28 Apr 06 |
enell |
300 |
write("--Create job for Base1PluginExecuter FAILED"); |
2205 |
28 Apr 06 |
enell |
301 |
ex.printStackTrace(); |
2205 |
28 Apr 06 |
enell |
302 |
ok = false; |
2205 |
28 Apr 06 |
enell |
303 |
} |
2205 |
28 Apr 06 |
enell |
304 |
finally |
2205 |
28 Apr 06 |
enell |
305 |
{ |
2205 |
28 Apr 06 |
enell |
306 |
if (dc != null) dc.close(); |
2205 |
28 Apr 06 |
enell |
307 |
} |
2205 |
28 Apr 06 |
enell |
308 |
return id; |
2205 |
28 Apr 06 |
enell |
309 |
} |
2205 |
28 Apr 06 |
enell |
310 |
|
2205 |
28 Apr 06 |
enell |
311 |
static void write(String message) |
2205 |
28 Apr 06 |
enell |
312 |
{ |
2205 |
28 Apr 06 |
enell |
313 |
System.out.println(message); |
2205 |
28 Apr 06 |
enell |
314 |
} |
2205 |
28 Apr 06 |
enell |
315 |
|
2205 |
28 Apr 06 |
enell |
316 |
static void write_request_information(RequestInformation ri) |
2205 |
28 Apr 06 |
enell |
317 |
{ |
2205 |
28 Apr 06 |
enell |
318 |
if (TestUtil.getSilent()) return; |
2205 |
28 Apr 06 |
enell |
319 |
|
2205 |
28 Apr 06 |
enell |
320 |
write("Request information for command: "+ri.getCommand()); |
2205 |
28 Apr 06 |
enell |
321 |
write("\tTitle:\t"+ri.getTitle()); |
2205 |
28 Apr 06 |
enell |
322 |
write("\tDescription:\t"+ri.getDescription()); |
2205 |
28 Apr 06 |
enell |
323 |
for (PluginParameter<?> pp : ri.getParameters()) |
2205 |
28 Apr 06 |
enell |
324 |
{ |
6875 |
20 Apr 15 |
nicklas |
325 |
ParameterType<?> pt = pp.getParameterType(); |
2205 |
28 Apr 06 |
enell |
326 |
System.out.println("\tParameter:\t"+pp.getName() + "\t" + pp.getLabel() + "\t" + pt ); |
2205 |
28 Apr 06 |
enell |
327 |
} |
2205 |
28 Apr 06 |
enell |
328 |
} |
5319 |
20 Apr 10 |
nicklas |
329 |
|
2205 |
28 Apr 06 |
enell |
330 |
} |