View Javadoc

1   /*
2    *                Doelan development code
3    *
4    * This code may be freely distributed and modified under the
5    * terms of the GNU General Public Licence.  This should
6    * be distributed with the code. If you do not have a copy,
7    * see:
8    *
9    *      http://www.gnu.org/copyleft/gpl.txt
10   *
11   * Copyright (c) 2004-2005 ENS Microarray Platform
12   * Copyright for this code is held jointly by the individual
13   * authors.  These should be listed in @author doc comments.
14   *
15   * For more information on the Doelan project and its aims,
16   * or to join the Doelan mailing list, visit the home page
17   * at:
18   *
19   *      http://www.transcriptome.ens.fr/doelan
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      // Get test suite result
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   // Abstract methods
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   // Constructor
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     // MUST BE EMPTY
154   }
155 
156 }