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.maven.artifact.versioning.ArtifactVersion;
22 import org.apache.maven.doxia.sink.Sink;
23 import org.eclipse.mylyn.tasks.core.data.TaskData;
24
25 import de.smartics.maven.issues.RendererConfig;
26 import de.smartics.maven.issues.bugzilla.Versions.VersionedSections;
27
28
29
30
31
32
33
34
35
36 public class VersionedSectionReportRenderer extends
37 AbstractSectionReportRenderer
38 {
39
40
41
42
43
44
45
46
47
48
49 protected String currentVersionString;
50
51
52
53
54
55
56
57
58
59
60
61
62 public VersionedSectionReportRenderer(final RendererConfig config,
63 final Sink sink, final List<TaskData> issues)
64 {
65 super(config, sink, issues);
66 }
67
68
69
70
71
72
73
74
75
76
77
78
79 @Override
80 public String getTitle()
81 {
82 return getTitle("report.name.release");
83 }
84
85
86
87
88 @Override
89 public String getDescription()
90 {
91 return getDescription("report.description.release");
92 }
93
94
95
96
97 @Override
98 public String getNoResultsDescription()
99 {
100 return getNoResultsDescription("report.noResultsDescription.release");
101 }
102
103
104
105
106
107
108 @Override
109 protected void renderBody()
110 {
111 sink.section1();
112 final boolean noResults = issues.isEmpty();
113 renderTitle(noResults);
114
115 if (!noResults)
116 {
117 final ResourceBundle bundle = config.getBundle();
118 final String versionText =
119 ReportHelper.getLabel(bundle, getVersionTextId());
120
121 final VersionSkipper skipper = createVersionSkipper();
122 final Sectioner<Versions> sectioner = createSectioner();
123 final Versions versions = sectioner.run();
124 final ArtifactVersion releaseVersion = config.getCurrentReleaseVersion();
125 for (VersionedSections versionedSections : versions)
126 {
127 final ArtifactVersion version = versionedSections.getVersion();
128 if (skipper.skipVersion(releaseVersion, version))
129 {
130 continue;
131 }
132 sink.section2();
133 sink.sectionTitle2();
134 final String versionString = version.toString();
135 this.currentVersionString = versionString;
136 sink.text(versionText + ' ' + versionString);
137 sink.sectionTitle2_();
138
139 renderSections(versionedSections.getSections());
140 sink.section2_();
141 }
142 }
143
144 renderPreviousReportReferences();
145
146 renderFooter();
147 sink.section1_();
148 }
149
150
151
152
153
154
155
156
157 protected VersionSkipper createVersionSkipper()
158 {
159 return new DefaultVersionSkipper(config.getIncludeOnSamePageAllOfVersion(),
160 config.getVersionRange() != null);
161 }
162
163
164
165
166
167
168 protected Sectioner<Versions> createSectioner()
169 {
170 return new VersionedSectioner(config, issues);
171 }
172
173
174
175
176
177
178 protected String getVersionTextId()
179 {
180 return "version.header";
181 }
182
183
184
185
186
187
188
189 protected void renderSectionSectionStart()
190 {
191 sink.section3();
192 }
193
194
195
196
197
198
199
200 protected void renderSectionSectionEnd()
201 {
202 sink.section3_();
203 }
204
205
206
207
208
209
210
211 protected void renderSectionTitleStart()
212 {
213 sink.sectionTitle3();
214 }
215
216
217
218
219
220
221
222 protected void renderSectionTitleEnd()
223 {
224 sink.sectionTitle3_();
225 }
226
227
228
229
230
231
232
233
234
235 protected String getSectionText(final ResourceBundle bundle,
236 final String sectionId)
237 {
238 return ReportHelper.getLabel(bundle, "section.text.versioned", sectionId,
239 currentVersionString);
240 }
241
242
243
244 }