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