1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package fr.ens.transcriptome.doelan.algorithms;
23
24 import fr.ens.transcriptome.doelan.data.DoelanDataUtils;
25 import fr.ens.transcriptome.doelan.data.TestSuiteResult;
26 import fr.ens.transcriptome.doelan.data.QualityGlobalTestResult;
27 import fr.ens.transcriptome.doelan.data.QualityGlobalTestResultData;
28 import fr.ens.transcriptome.doelan.data.QualityUnitTestResult;
29 import fr.ens.transcriptome.nividic.om.BioAssay;
30 import fr.ens.transcriptome.nividic.platform.PlatformException;
31 import fr.ens.transcriptome.nividic.platform.workflow.Container;
32 import fr.ens.transcriptome.nividic.platform.workflow.SimpleAlgorithmEvent;
33 import fr.ens.transcriptome.nividic.util.parameter.Parameters;
34
35 /***
36 * This class define a abstract global test. Tha aim of the a global test is
37 * only to set global parameters for the DoelanGenerateReport algorithm.
38 * @author Laurent Jourdren
39 */
40 public abstract class QualityGlobalTest extends QualityTest {
41
42 /***
43 * Test if the test is deletable().
44 * @return true if the test is deletable
45 */
46 public boolean isDeletable() {
47 return true;
48 }
49
50 /***
51 * Test if only one instance of the test could be created.
52 * @return true if only one instance of the test could be created
53 */
54 public boolean isUniqueInstance() {
55 return true;
56 }
57
58 /***
59 * Test if the test is modifiable.
60 * @return true if the test is modifiable
61 */
62 public boolean isModifiable() {
63 return true;
64 }
65
66 /***
67 * Test if the test could be showed.
68 * @return true if the test could be showed
69 */
70 public boolean isShowable() {
71 return true;
72 }
73
74 /***
75 * Test if the test could be diplayed in the list of tests to add.
76 * @return true if the test could be showed
77 */
78 public boolean isAddable() {
79 return true;
80 }
81
82 protected void doIt(final Container c, final Parameters parameters)
83 throws PlatformException {
84
85
86 TestSuiteResult testSuiteResult = DoelanDataUtils.getTestSuiteResult(c);
87 testSuiteResult.addGlobalTest(this, parameters);
88
89 sendEvent(new SimpleAlgorithmEvent(this, GLOBAL_TEST_INIT_EVENT, this
90 .getId(), "set global parameter"));
91 }
92
93 /***
94 * This method is called once all the unit tests was executed.
95 * @param c Container
96 * @param parameters Parameters of the test
97 * @throws PlatformException if an error occurs during the test
98 */
99 public void doTest(final Container c, final Parameters parameters)
100 throws PlatformException {
101
102 BioAssay bioassay = DoelanDataUtils.getBioAssay(c);
103 BioAssay arraylist = DoelanDataUtils.getArrayList(c);
104 QualityUnitTestResult[] unitTestResults = DoelanDataUtils
105 .getQualityUnitTestResults(c);
106
107 TestSuiteResult tsr = DoelanDataUtils.getTestSuiteResult(c);
108 tsr.addTestId(this.getId());
109
110 QualityGlobalTestResult globalResult = test(bioassay, arraylist,
111 parameters, unitTestResults);
112
113 if (globalResult == null)
114 throw new PlatformException("The result of " + getId() + " ("
115 + aboutModule().getName() + ") is null");
116
117 globalResult.setTestDescription(this.aboutModule().getShortDescription());
118 QualityGlobalTestResultData data = new QualityGlobalTestResultData(
119 globalResult);
120
121 c.add(data);
122
123 sendEvent(new SimpleAlgorithmEvent(this, RESULT_EVENT, globalResult,
124 "result data"));
125 }
126
127
128
129
130
131 /***
132 * Do the test.
133 * @param parameters Parameters of the test
134 * @param bioassay BioAssay to test
135 * @param arrayList The array list
136 * @param unitResults results of the units tests
137 * @throws PlatformException if an error occurs while executing the test.
138 */
139 protected abstract QualityGlobalTestResult test(final BioAssay bioassay,
140 final BioAssay arrayList, final Parameters parameters,
141 final QualityUnitTestResult[] unitResults) throws PlatformException;
142
143
144
145
146
147 /***
148 * Public constructor.
149 * @throws PlatformException If the name or the version of the element is
150 * <b>null </b>.
151 */
152 public QualityGlobalTest() throws PlatformException {
153
154 }
155
156 }