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