1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package de.smartics.maven.issues.bugzilla;
18
19 import java.util.List;
20 import java.util.ResourceBundle;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.apache.maven.doxia.sink.Sink;
25 import org.eclipse.mylyn.tasks.core.data.TaskData;
26
27 import de.smartics.maven.issues.RendererConfig;
28 import de.smartics.maven.issues.bugzilla.Sections.Section;
29 import de.smartics.maven.issues.util.ReportReference;
30
31
32
33
34
35
36
37
38 public abstract class AbstractSectionReportRenderer extends
39 AbstractIssuesReportRenderer
40 {
41
42
43
44
45
46
47
48 private static final Log LOG = LogFactory
49 .getLog(AbstractSectionReportRenderer.class);
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 protected AbstractSectionReportRenderer(final RendererConfig config,
65 final Sink sink, final List<TaskData> issues)
66 {
67 super(config, sink, issues);
68 }
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 @Override
84 protected void renderBody()
85 {
86 sink.section1();
87 final boolean noResults = issues.isEmpty();
88 renderTitle(noResults);
89
90 if (!noResults)
91 {
92 final SimpleSectioner sectioner = new SimpleSectioner(config, issues);
93 final Sections sections = sectioner.run();
94 renderSections(sections);
95 }
96
97 renderPreviousReportReferences();
98
99 renderFooter();
100 sink.section1_();
101 }
102
103
104
105
106 protected void renderPreviousReportReferences()
107 {
108 final List<ReportReference> refs = config.getReportReferences();
109 if (refs != null && !refs.isEmpty())
110 {
111 sink.section2();
112 renderSectionHeader("previousReleases");
113 sink.list();
114 for (ReportReference ref : refs)
115 {
116 sink.listItem();
117 ReportHelper.renderLink(sink, ref.getUrl(), ref.getLabel());
118 sink.listItem_();
119 }
120 sink.list_();
121 sink.section2_();
122 }
123 }
124
125
126
127
128
129
130 protected void renderSections(final Sections sections)
131 {
132 for (Section section : sections)
133 {
134 final String sectionId = section.getSectionName();
135 final List<TaskData> sectionIssues = section.getTasks();
136 if (!sectionIssues.isEmpty())
137 {
138 renderSectionSectionStart();
139 renderSectionHeader(sectionId);
140 sink.table();
141 renderTableHeader();
142 for (TaskData issue : sectionIssues)
143 {
144 renderTableRow(issue);
145 }
146 sink.table_();
147 renderSectionSectionEnd();
148 }
149 else
150 {
151 if (LOG.isDebugEnabled())
152 {
153 LOG.debug("No issues for section '" + sectionId + "' found.");
154 }
155 }
156 }
157 }
158
159
160
161
162
163
164
165 protected void renderSectionHeader(final String sectionId)
166 {
167 final ResourceBundle bundle = config.getBundle();
168 final String sectionLabel =
169 ReportHelper.getLabel(bundle, "section", sectionId);
170 renderSectionTitleStart();
171 sink.text(sectionLabel);
172 renderSectionTitleEnd();
173
174 final String sectionText = getSectionText(bundle, sectionId);
175 sink.paragraph();
176 sink.text(sectionText);
177 sink.paragraph_();
178 }
179
180
181
182
183
184
185
186
187
188 protected String getSectionText(final ResourceBundle bundle,
189 final String sectionId)
190 {
191 return ReportHelper.getLabel(bundle, "section.text.unversioned", sectionId);
192 }
193
194
195
196
197
198
199
200 protected void renderSectionSectionStart()
201 {
202 sink.section2();
203 }
204
205
206
207
208
209
210
211 protected void renderSectionSectionEnd()
212 {
213 sink.section2_();
214 }
215
216
217
218
219
220
221
222 protected void renderSectionTitleStart()
223 {
224 sink.sectionTitle2();
225 }
226
227
228
229
230
231
232
233 protected void renderSectionTitleEnd()
234 {
235 sink.sectionTitle2_();
236 }
237
238
239
240 }