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 java.awt.Graphics;
25 import java.awt.image.BufferedImage;
26 import java.net.URL;
27 import java.util.HashMap;
28 import java.util.Map;
29
30 import javax.swing.ImageIcon;
31
32 import fr.ens.transcriptome.doelan.data.DoelanDataUtils;
33 import fr.ens.transcriptome.doelan.data.QualityTestResult;
34 import fr.ens.transcriptome.doelan.data.TestSuiteResult;
35 import fr.ens.transcriptome.doelan.gui.CommonWindow;
36 import fr.ens.transcriptome.doelan.gui.ReportTabWidget;
37 import fr.ens.transcriptome.doelan.gui.StatusWidget;
38 import fr.ens.transcriptome.nividic.platform.PlatformException;
39 import fr.ens.transcriptome.nividic.platform.module.AboutModule;
40 import fr.ens.transcriptome.nividic.platform.module.Module;
41 import fr.ens.transcriptome.nividic.platform.module.ModuleDescription;
42 import fr.ens.transcriptome.nividic.platform.workflow.Algorithm;
43 import fr.ens.transcriptome.nividic.platform.workflow.Container;
44 import fr.ens.transcriptome.nividic.util.parameter.Parameters;
45
46 /***
47 * This algorithm show in doelan GUI the status and the report of the test
48 * suite.
49 * @author Laurent Jourdren
50 */
51 public class DoelanShowReport extends Algorithm implements Module {
52
53 private ReportTabWidget report;
54 private StatusWidget status;
55
56
57
58
59
60 /***
61 * Get the report widget.
62 * @return Returns the report widget
63 */
64 public ReportTabWidget getReport() {
65 return report;
66 }
67
68 /***
69 * Get the status widget.
70 * @return Returns the status widget
71 */
72 public StatusWidget getStatus() {
73 return status;
74 }
75
76
77
78
79
80 /***
81 * Set the report widget.
82 * @param report The report widget to set
83 */
84 public void setReport(final ReportTabWidget report) {
85 this.report = report;
86 }
87
88 /***
89 * Set the status widget.
90 * @param status The status widget
91 */
92 public void setStatus(final StatusWidget status) {
93 this.status = status;
94 }
95
96
97
98
99
100 /***
101 * Get the description of the module.
102 * @return The description of the module
103 */
104 public AboutModule aboutModule() {
105 ModuleDescription md = null;
106 try {
107 md = new ModuleDescription("DoelanShowReport",
108 "Show report of a test suite");
109 md.setStability(AboutModule.STATE_STABLE);
110 } catch (PlatformException e) {
111 getLogger().error("Unable to create the module description");
112 }
113 return md;
114 }
115
116 /***
117 * Set the parameters of the element.
118 */
119 protected Parameters defineParameters() {
120 return null;
121 }
122
123 /***
124 * This method contains all the code to manipulate the container <b>c </b> in
125 * this element.
126 * @param c The container to be manipulated
127 * @param parameters Parameters of the elements
128 * @throws PlatformException if an error occurs while showing the results
129 */
130 protected void doIt(final Container c, final Parameters parameters)
131 throws PlatformException {
132
133 if (getReport() == null || getStatus() == null)
134 return;
135
136
137 TestSuiteResult testSuiteResult = DoelanDataUtils.getTestSuiteResult(c);
138
139 if (testSuiteResult == null)
140 return;
141
142
143 getReport().setGalData(testSuiteResult.getNewArrayList());
144
145 Map mapImages = new HashMap();
146
147 if (testSuiteResult.getResult())
148 getStatus().setStatus(StatusWidget.STATUS_PASS);
149 else
150 getStatus().setStatus(StatusWidget.STATUS_FAILLED);
151
152
153
154 QualityTestResult[] results = DoelanDataUtils.getQualityTestResults(c);
155 for (int i = 0; i < results.length; i++) {
156 if (results[i].getImage() != null)
157 mapImages.put(results[i].getTestId() + ".jpeg", results[i].getImage());
158 }
159
160
161
162 mapImages.put("arrayplot.jpeg", testSuiteResult.getArrayPlot());
163
164
165 URL url = CommonWindow.class.getResource("/files/doelan-200.png");
166 ImageIcon ii = new ImageIcon(url);
167 BufferedImage buffuredImage = new BufferedImage(ii.getIconWidth(), ii
168 .getIconHeight(), BufferedImage.TYPE_INT_BGR);
169 Graphics g = buffuredImage.createGraphics();
170 g.drawImage(ii.getImage(), 0, 0, null);
171
172 mapImages.put("logo.jpeg", buffuredImage);
173
174 if (mapImages.size() == 0)
175 getReport().setImages(null);
176 else
177 getReport().setImages(mapImages);
178
179 getReport().setText(testSuiteResult.getHtmlReport());
180
181 }
182
183
184
185
186
187 /***
188 * Public constructor.
189 * @throws PlatformException If the name or the version of the element is
190 * <b>null </b>.
191 */
192 public DoelanShowReport() throws PlatformException {
193
194 }
195
196 }