1 | |
package org.apache.maven.plugin.issues; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.doxia.sink.Sink; |
23 | |
|
24 | |
import java.text.DateFormat; |
25 | |
import java.util.List; |
26 | |
import java.util.Locale; |
27 | |
import java.util.ResourceBundle; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public class IssuesReportGenerator extends AbstractIssuesReportGenerator |
38 | |
{ |
39 | |
|
40 | |
|
41 | |
|
42 | |
private static final String NOT_AVAILABLE = "n/a"; |
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
private int[] columns; |
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
public IssuesReportGenerator( int[] includedColumns ) |
54 | 2 | { |
55 | 2 | this.columns = includedColumns; |
56 | 2 | } |
57 | |
|
58 | |
public void doGenerateEmptyReport( ResourceBundle bundle, Sink sink ) |
59 | |
{ |
60 | 0 | sinkBeginReport( sink, bundle ); |
61 | |
|
62 | 0 | sink.paragraph(); |
63 | |
|
64 | 0 | sink.text( bundle.getString( "report.issues.error" ) ); |
65 | |
|
66 | 0 | sink.paragraph_(); |
67 | |
|
68 | 0 | sinkEndReport( sink ); |
69 | 0 | } |
70 | |
|
71 | |
public void doGenerateReport( ResourceBundle bundle, Sink sink, List issueList ) |
72 | |
{ |
73 | 2 | sinkBeginReport( sink, bundle ); |
74 | |
|
75 | 2 | constructHeaderRow( sink, issueList, bundle ); |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | 2 | constructDetailRows( sink, issueList, bundle, new Locale( "sv" ) ); |
81 | |
|
82 | 2 | sinkEndReport( sink ); |
83 | 2 | } |
84 | |
|
85 | |
private void constructHeaderRow( Sink sink, List issueList, ResourceBundle bundle ) |
86 | |
{ |
87 | 2 | if ( issueList == null ) |
88 | |
{ |
89 | 0 | return; |
90 | |
} |
91 | |
|
92 | 2 | sink.table(); |
93 | |
|
94 | 2 | sink.tableRow(); |
95 | |
|
96 | 12 | for ( int columnIndex = 0; columnIndex < columns.length; columnIndex++ ) |
97 | |
{ |
98 | 10 | switch ( columns[columnIndex] ) |
99 | |
{ |
100 | |
case IssuesReportHelper.COLUMN_ASSIGNEE: |
101 | 2 | sinkHeader( sink, bundle.getString( "report.issues.label.assignee" ) ); |
102 | 2 | break; |
103 | |
|
104 | |
case IssuesReportHelper.COLUMN_COMPONENT: |
105 | 0 | sinkHeader( sink, bundle.getString( "report.issues.label.component" ) ); |
106 | 0 | break; |
107 | |
|
108 | |
case IssuesReportHelper.COLUMN_CREATED: |
109 | 0 | sinkHeader( sink, bundle.getString( "report.issues.label.created" ) ); |
110 | 0 | break; |
111 | |
|
112 | |
case IssuesReportHelper.COLUMN_FIX_VERSION: |
113 | 0 | sinkHeader( sink, bundle.getString( "report.issues.label.fixVersion" ) ); |
114 | 0 | break; |
115 | |
|
116 | |
case IssuesReportHelper.COLUMN_ID: |
117 | 0 | sinkHeader( sink, bundle.getString( "report.issues.label.id" ) ); |
118 | 0 | break; |
119 | |
|
120 | |
case IssuesReportHelper.COLUMN_KEY: |
121 | 2 | sinkHeader( sink, bundle.getString( "report.issues.label.key" ) ); |
122 | 2 | break; |
123 | |
|
124 | |
case IssuesReportHelper.COLUMN_PRIORITY: |
125 | 0 | sinkHeader( sink, bundle.getString( "report.issues.label.priority" ) ); |
126 | 0 | break; |
127 | |
|
128 | |
case IssuesReportHelper.COLUMN_REPORTER: |
129 | 0 | sinkHeader( sink, bundle.getString( "report.issues.label.reporter" ) ); |
130 | 0 | break; |
131 | |
|
132 | |
case IssuesReportHelper.COLUMN_RESOLUTION: |
133 | 2 | sinkHeader( sink, bundle.getString( "report.issues.label.resolution" ) ); |
134 | 2 | break; |
135 | |
|
136 | |
case IssuesReportHelper.COLUMN_STATUS: |
137 | 2 | sinkHeader( sink, bundle.getString( "report.issues.label.status" ) ); |
138 | 2 | break; |
139 | |
|
140 | |
case IssuesReportHelper.COLUMN_SUMMARY: |
141 | 2 | sinkHeader( sink, bundle.getString( "report.issues.label.summary" ) ); |
142 | 2 | break; |
143 | |
|
144 | |
case IssuesReportHelper.COLUMN_TYPE: |
145 | 0 | sinkHeader( sink, bundle.getString( "report.issues.label.type" ) ); |
146 | 0 | break; |
147 | |
|
148 | |
case IssuesReportHelper.COLUMN_UPDATED: |
149 | 0 | sinkHeader( sink, bundle.getString( "report.issues.label.updated" ) ); |
150 | 0 | break; |
151 | |
|
152 | |
case IssuesReportHelper.COLUMN_VERSION: |
153 | 0 | sinkHeader( sink, bundle.getString( "report.issues.label.version" ) ); |
154 | 0 | break; |
155 | |
|
156 | |
default: |
157 | |
|
158 | |
break; |
159 | |
} |
160 | |
} |
161 | |
|
162 | 2 | sink.tableRow_(); |
163 | 2 | } |
164 | |
|
165 | |
private void constructDetailRows( Sink sink, List issueList, ResourceBundle bundle, Locale locale ) |
166 | |
{ |
167 | 2 | if ( issueList == null ) |
168 | |
{ |
169 | 0 | return; |
170 | |
} |
171 | |
|
172 | 6 | for ( int idx = 0; idx < issueList.size(); idx++ ) |
173 | |
{ |
174 | |
|
175 | 4 | DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT, locale ); |
176 | |
|
177 | 4 | Issue issue = (Issue) issueList.get( idx ); |
178 | |
|
179 | 4 | sink.tableRow(); |
180 | |
|
181 | 24 | for ( int columnIndex = 0; columnIndex < columns.length; columnIndex++ ) |
182 | |
{ |
183 | 20 | switch ( columns[columnIndex] ) |
184 | |
{ |
185 | |
case IssuesReportHelper.COLUMN_ASSIGNEE: |
186 | 4 | sinkCell( sink, issue.getAssignee() ); |
187 | 4 | break; |
188 | |
|
189 | |
case IssuesReportHelper.COLUMN_COMPONENT: |
190 | 0 | sinkCell( sink, IssuesReportHelper.printValues( issue.getComponents() ) ); |
191 | 0 | break; |
192 | |
|
193 | |
case IssuesReportHelper.COLUMN_CREATED: |
194 | 0 | String created = NOT_AVAILABLE; |
195 | 0 | if ( issue.getCreated() != null ) |
196 | |
{ |
197 | 0 | created = df.format( issue.getCreated() ); |
198 | |
} |
199 | 0 | sinkCell( sink, created ); |
200 | 0 | break; |
201 | |
|
202 | |
case IssuesReportHelper.COLUMN_FIX_VERSION: |
203 | 0 | sinkCell( sink, IssuesReportHelper.printValues( issue.getFixVersions() ) ); |
204 | 0 | break; |
205 | |
|
206 | |
case IssuesReportHelper.COLUMN_ID: |
207 | 0 | sink.tableCell(); |
208 | 0 | sink.link( issue.getLink() ); |
209 | 0 | sink.text( issue.getId() ); |
210 | 0 | sink.link_(); |
211 | 0 | sink.tableCell_(); |
212 | 0 | break; |
213 | |
|
214 | |
case IssuesReportHelper.COLUMN_KEY: |
215 | 4 | sink.tableCell(); |
216 | 4 | sink.link( issue.getLink() ); |
217 | 4 | sink.text( issue.getKey() ); |
218 | 4 | sink.link_(); |
219 | 4 | sink.tableCell_(); |
220 | 4 | break; |
221 | |
|
222 | |
case IssuesReportHelper.COLUMN_PRIORITY: |
223 | 0 | sinkCell( sink, issue.getPriority() ); |
224 | 0 | break; |
225 | |
|
226 | |
case IssuesReportHelper.COLUMN_REPORTER: |
227 | 0 | sinkCell( sink, issue.getReporter() ); |
228 | 0 | break; |
229 | |
|
230 | |
case IssuesReportHelper.COLUMN_RESOLUTION: |
231 | 4 | sinkCell( sink, issue.getResolution() ); |
232 | 4 | break; |
233 | |
|
234 | |
case IssuesReportHelper.COLUMN_STATUS: |
235 | 4 | sinkCell( sink, issue.getStatus() ); |
236 | 4 | break; |
237 | |
|
238 | |
case IssuesReportHelper.COLUMN_SUMMARY: |
239 | 4 | sinkCell( sink, issue.getSummary() ); |
240 | 4 | break; |
241 | |
|
242 | |
case IssuesReportHelper.COLUMN_TYPE: |
243 | 0 | sinkCell( sink, issue.getType() ); |
244 | 0 | break; |
245 | |
|
246 | |
case IssuesReportHelper.COLUMN_UPDATED: |
247 | 0 | String updated = NOT_AVAILABLE; |
248 | 0 | if ( issue.getUpdated() != null ) |
249 | |
{ |
250 | 0 | updated = df.format( issue.getUpdated() ); |
251 | |
} |
252 | 0 | sinkCell( sink, updated ); |
253 | 0 | break; |
254 | |
|
255 | |
case IssuesReportHelper.COLUMN_VERSION: |
256 | 0 | sinkCell( sink, issue.getVersion() ); |
257 | 0 | break; |
258 | |
|
259 | |
default: |
260 | |
|
261 | |
break; |
262 | |
} |
263 | |
} |
264 | |
|
265 | 4 | sink.tableRow_(); |
266 | |
} |
267 | |
|
268 | 2 | sink.table_(); |
269 | 2 | } |
270 | |
} |