1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.changes.issues;
20
21 import java.text.DateFormat;
22 import java.text.SimpleDateFormat;
23 import java.util.List;
24 import java.util.ResourceBundle;
25
26 import org.apache.maven.doxia.sink.Sink;
27
28
29
30
31
32
33
34
35
36 public class IssuesReportRenderer extends AbstractIssuesReportRenderer {
37
38
39
40 private static final String NOT_AVAILABLE = "n/a";
41
42
43
44
45 private final List<Integer> columns;
46
47 private final List<Issue> issueList;
48
49
50
51
52 public IssuesReportRenderer(
53 Sink sink, ResourceBundle bundle, List<Integer> includedColumns, List<Issue> issueList) {
54 super(sink, bundle);
55 this.columns = includedColumns;
56 this.issueList = issueList;
57 }
58
59 @Override
60 public void renderBody() {
61 if (issueList == null || issueList.isEmpty()) {
62 paragraph(bundle.getString("report.issues.error"));
63 } else {
64 startTable();
65 constructHeaderRow();
66 constructDetailRows();
67 endTable();
68 }
69 }
70
71 private void constructHeaderRow() {
72
73 sink.tableRow();
74
75 for (int column : columns) {
76 switch (column) {
77 case IssuesReportHelper.COLUMN_ASSIGNEE:
78 tableHeaderCell(bundle.getString("report.issues.label.assignee"));
79 break;
80
81 case IssuesReportHelper.COLUMN_COMPONENT:
82 tableHeaderCell(bundle.getString("report.issues.label.component"));
83 break;
84
85 case IssuesReportHelper.COLUMN_CREATED:
86 tableHeaderCell(bundle.getString("report.issues.label.created"));
87 break;
88
89 case IssuesReportHelper.COLUMN_FIX_VERSION:
90 tableHeaderCell(bundle.getString("report.issues.label.fixVersion"));
91 break;
92
93 case IssuesReportHelper.COLUMN_ID:
94 tableHeaderCell(bundle.getString("report.issues.label.id"));
95 break;
96
97 case IssuesReportHelper.COLUMN_KEY:
98 tableHeaderCell(bundle.getString("report.issues.label.key"));
99 break;
100
101 case IssuesReportHelper.COLUMN_PRIORITY:
102 tableHeaderCell(bundle.getString("report.issues.label.priority"));
103 break;
104
105 case IssuesReportHelper.COLUMN_REPORTER:
106 tableHeaderCell(bundle.getString("report.issues.label.reporter"));
107 break;
108
109 case IssuesReportHelper.COLUMN_RESOLUTION:
110 tableHeaderCell(bundle.getString("report.issues.label.resolution"));
111 break;
112
113 case IssuesReportHelper.COLUMN_STATUS:
114 tableHeaderCell(bundle.getString("report.issues.label.status"));
115 break;
116
117 case IssuesReportHelper.COLUMN_SUMMARY:
118 tableHeaderCell(bundle.getString("report.issues.label.summary"));
119 break;
120
121 case IssuesReportHelper.COLUMN_TYPE:
122 tableHeaderCell(bundle.getString("report.issues.label.type"));
123 break;
124
125 case IssuesReportHelper.COLUMN_UPDATED:
126 tableHeaderCell(bundle.getString("report.issues.label.updated"));
127 break;
128
129 case IssuesReportHelper.COLUMN_VERSION:
130 tableHeaderCell(bundle.getString("report.issues.label.version"));
131 break;
132
133 default:
134
135 break;
136 }
137 }
138
139 sink.tableRow_();
140 }
141
142 private void constructDetailRows() {
143
144
145
146 DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
147
148 for (Issue issue : issueList) {
149
150 sink.tableRow();
151
152 for (int column : columns) {
153 switch (column) {
154 case IssuesReportHelper.COLUMN_ASSIGNEE:
155 sinkCell(issue.getAssignee());
156 break;
157
158 case IssuesReportHelper.COLUMN_COMPONENT:
159 sinkCell(IssuesReportHelper.printValues(issue.getComponents()));
160 break;
161
162 case IssuesReportHelper.COLUMN_CREATED:
163 String created = NOT_AVAILABLE;
164 if (issue.getCreated() != null) {
165 created = df.format(issue.getCreated());
166 }
167 sinkCell(created);
168 break;
169
170 case IssuesReportHelper.COLUMN_FIX_VERSION:
171 sinkCell(IssuesReportHelper.printValues(issue.getFixVersions()));
172 break;
173
174 case IssuesReportHelper.COLUMN_ID:
175 sinkCellLink(issue.getId(), issue.getLink());
176 break;
177
178 case IssuesReportHelper.COLUMN_KEY:
179 sinkCellLink(issue.getKey(), issue.getLink());
180 break;
181
182 case IssuesReportHelper.COLUMN_PRIORITY:
183 sinkCell(issue.getPriority());
184 break;
185
186 case IssuesReportHelper.COLUMN_REPORTER:
187 sinkCell(issue.getReporter());
188 break;
189
190 case IssuesReportHelper.COLUMN_RESOLUTION:
191 sinkCell(issue.getResolution());
192 break;
193
194 case IssuesReportHelper.COLUMN_STATUS:
195 sinkCell(issue.getStatus());
196 break;
197
198 case IssuesReportHelper.COLUMN_SUMMARY:
199 sinkCell(issue.getSummary());
200 break;
201
202 case IssuesReportHelper.COLUMN_TYPE:
203 sinkCell(issue.getType());
204 break;
205
206 case IssuesReportHelper.COLUMN_UPDATED:
207 String updated = NOT_AVAILABLE;
208 if (issue.getUpdated() != null) {
209 updated = df.format(issue.getUpdated());
210 }
211 sinkCell(updated);
212 break;
213
214 case IssuesReportHelper.COLUMN_VERSION:
215 sinkCell(issue.getVersion());
216 break;
217
218 default:
219
220 break;
221 }
222 }
223
224 sink.tableRow_();
225 }
226 }
227 }