@@ -58,8 +58,8 @@ public abstract class AbstractVersionsReportRenderer<T> extends VersionsReportRe
58
58
*/
59
59
protected T model ;
60
60
61
- protected ArtifactVersionsCache oldestUpdateCache
62
- = new ArtifactVersionsCache ( AbstractVersionDetails ::getOldestUpdate );
61
+ protected ArtifactVersionsCache newestUpdateCache
62
+ = new ArtifactVersionsCache ( AbstractVersionDetails ::getNewestUpdate );
63
63
64
64
protected ArtifactVersionsCache allUpdatesCache
65
65
= new ArtifactVersionsCache ( AbstractVersionDetails ::getAllUpdates );
@@ -136,59 +136,11 @@ protected void renderOverview()
136
136
*/
137
137
protected <Q extends OverviewStats > void renderOverviewTableRow ( Q stats )
138
138
{
139
- sink .tableCell ();
140
- renderSuccessIcon ();
141
- sink .tableCell_ ();
142
- sink .tableCell ();
143
- sink .text ( getText ( "report.overview.numUpToDate" ) );
144
- sink .tableCell_ ();
145
- sink .tableCell ();
146
- sink .text ( Integer .toString ( stats .getUpToDate () ) );
147
- sink .tableCell_ ();
148
- sink .tableRow_ ();
149
- sink .tableRow ();
150
- sink .tableCell ();
151
- renderWarningIcon ();
152
- sink .tableCell_ ();
153
- sink .tableCell ();
154
- sink .text ( getText ( "report.overview.numNewerVersionAvailable" ) );
155
- sink .tableCell_ ();
156
- sink .tableCell ();
157
- sink .text ( Integer .toString ( stats .getAny () ) );
158
- sink .tableCell_ ();
159
- sink .tableRow_ ();
160
- sink .tableRow ();
161
- sink .tableCell ();
162
- renderWarningIcon ();
163
- sink .tableCell_ ();
164
- sink .tableCell ();
165
- sink .text ( getText ( "report.overview.numNewerIncrementalAvailable" ) );
166
- sink .tableCell_ ();
167
- sink .tableCell ();
168
- sink .text ( Integer .toString ( stats .getIncremental () ) );
169
- sink .tableCell_ ();
170
- sink .tableRow_ ();
171
- sink .tableRow ();
172
- sink .tableCell ();
173
- renderWarningIcon ();
174
- sink .tableCell_ ();
175
- sink .tableCell ();
176
- sink .text ( getText ( "report.overview.numNewerMinorAvailable" ) );
177
- sink .tableCell_ ();
178
- sink .tableCell ();
179
- sink .text ( Integer .toString ( stats .getMinor () ) );
180
- sink .tableCell_ ();
181
- sink .tableRow_ ();
182
- sink .tableRow ();
183
- sink .tableCell ();
184
- renderWarningIcon ();
185
- sink .tableCell_ ();
186
- sink .tableCell ();
187
- sink .text ( getText ( "report.overview.numNewerMajorAvailable" ) );
188
- sink .tableCell_ ();
189
- sink .tableCell ();
190
- sink .text ( Integer .toString ( stats .getMajor () ) );
191
- sink .tableCell_ ();
139
+ renderStatRow ( "report.overview.numUpToDate" , stats .getUpToDate () );
140
+ renderStatRow ( "report.overview.numNewerVersionAvailable" , stats .getAny () );
141
+ renderStatRow ( "report.overview.numNewerIncrementalAvailable" , stats .getIncremental () );
142
+ renderStatRow ( "report.overview.numNewerMinorAvailable" , stats .getMinor () );
143
+ renderStatRow ( "report.overview.numNewerMajorAvailable" , stats .getMajor () );
192
144
}
193
145
194
146
/**
@@ -237,13 +189,15 @@ protected void renderSummaryTableHeader( boolean hasScope, boolean hasType )
237
189
"report.latestIncremental" , "report.latestMinor" , "report.latestMajor" );
238
190
}
239
191
240
- protected void renderSummaryTableRow ( Dependency artifact , ArtifactVersions artifactVersions ,
241
- boolean includeScope )
192
+ protected void renderSummaryTableRow ( Dependency artifact , ArtifactVersions details ,
193
+ boolean includeScope )
242
194
{
195
+ ArtifactVersion [] allUpdates = allUpdatesCache .get ( details , empty () );
196
+ boolean upToDate = allUpdates == null || allUpdates .length == 0 ;
197
+
243
198
sink .tableRow ();
244
199
sink .tableCell ();
245
- ArtifactVersion [] allUpdates = artifactVersions .getAllUpdates ( empty () );
246
- if ( allUpdates == null || allUpdates .length == 0 )
200
+ if ( upToDate )
247
201
{
248
202
renderSuccessIcon ();
249
203
}
@@ -275,37 +229,37 @@ protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions arti
275
229
sink .tableCell_ ();
276
230
277
231
sink .tableCell ();
278
- if ( artifactVersions . getNewestUpdate ( of ( SUBINCREMENTAL ) ) != null )
232
+ if ( newestUpdateCache . get ( details , of ( SUBINCREMENTAL ) ) != null )
279
233
{
280
234
safeBold ();
281
- sink .text ( artifactVersions . getNewestUpdate ( of ( SUBINCREMENTAL ) ).toString () );
235
+ sink .text ( newestUpdateCache . get ( details , of ( SUBINCREMENTAL ) ).toString () );
282
236
safeBold_ ();
283
237
}
284
238
sink .tableCell_ ();
285
239
286
240
sink .tableCell ();
287
- if ( artifactVersions . getNewestUpdate ( of ( INCREMENTAL ) ) != null )
241
+ if ( newestUpdateCache . get ( details , of ( INCREMENTAL ) ) != null )
288
242
{
289
243
safeBold ();
290
- sink .text ( artifactVersions . getNewestUpdate ( of ( INCREMENTAL ) ).toString () );
244
+ sink .text ( newestUpdateCache . get ( details , of ( INCREMENTAL ) ).toString () );
291
245
safeBold_ ();
292
246
}
293
247
sink .tableCell_ ();
294
248
295
249
sink .tableCell ();
296
- if ( artifactVersions . getNewestUpdate ( of ( MINOR ) ) != null )
250
+ if ( newestUpdateCache . get ( details , of ( MINOR ) ) != null )
297
251
{
298
252
safeBold ();
299
- sink .text ( artifactVersions . getNewestUpdate ( of ( MINOR ) ).toString () );
253
+ sink .text ( newestUpdateCache . get ( details , of ( MINOR ) ).toString () );
300
254
safeBold_ ();
301
255
}
302
256
sink .tableCell_ ();
303
257
304
258
sink .tableCell ();
305
- if ( artifactVersions . getNewestUpdate ( of ( MAJOR ) ) != null )
259
+ if ( newestUpdateCache . get ( details , of ( MAJOR ) ) != null )
306
260
{
307
261
safeBold ();
308
- sink .text ( artifactVersions . getNewestUpdate ( of ( MAJOR ) ).toString () );
262
+ sink .text ( newestUpdateCache . get ( details , of ( MAJOR ) ).toString () );
309
263
safeBold_ ();
310
264
}
311
265
sink .tableCell_ ();
@@ -316,37 +270,39 @@ protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions arti
316
270
@ SuppressWarnings ( "checkstyle:MethodLength" )
317
271
protected void renderDependencyDetailTable ( Dependency artifact , ArtifactVersions details , boolean includeScope )
318
272
{
273
+ ArtifactVersion [] allUpdates = allUpdatesCache .get ( details , empty () );
274
+ boolean upToDate = allUpdates == null || allUpdates .length == 0 ;
275
+
319
276
final SinkEventAttributes headerAttributes = new SinkEventAttributeSet ();
320
- headerAttributes .addAttribute ( SinkEventAttributes .WIDTH , "20 %" );
277
+ headerAttributes .addAttribute ( SinkEventAttributes .WIDTH , "70 %" );
321
278
final SinkEventAttributes cellAttributes = new SinkEventAttributeSet ();
322
- headerAttributes .addAttribute ( SinkEventAttributes .WIDTH , "80 %" );
279
+ headerAttributes .addAttribute ( SinkEventAttributes .WIDTH , "30 %" );
323
280
sink .table ();
324
281
sink .tableRows ( new int [] { Sink .JUSTIFY_RIGHT , Sink .JUSTIFY_LEFT }, false );
325
282
sink .tableRow ();
326
283
sink .tableHeaderCell ( headerAttributes );
327
284
sink .text ( getText ( "report.status" ) );
328
285
sink .tableHeaderCell_ ();
329
286
sink .tableCell ( cellAttributes );
330
- ArtifactVersion [] versions = allUpdatesCache .get ( details , empty () );
331
- if ( oldestUpdateCache .get ( details , of ( SUBINCREMENTAL ) ) != null )
287
+ if ( newestUpdateCache .get ( details , of ( SUBINCREMENTAL ) ) != null )
332
288
{
333
289
renderWarningIcon ();
334
290
sink .nonBreakingSpace ();
335
291
sink .text ( getText ( "report.otherUpdatesAvailable" ) );
336
292
}
337
- else if ( oldestUpdateCache .get ( details , of ( INCREMENTAL ) ) != null )
293
+ else if ( newestUpdateCache .get ( details , of ( INCREMENTAL ) ) != null )
338
294
{
339
295
renderWarningIcon ();
340
296
sink .nonBreakingSpace ();
341
297
sink .text ( getText ( "report.incrementalUpdatesAvailable" ) );
342
298
}
343
- else if ( oldestUpdateCache .get ( details , of ( MINOR ) ) != null )
299
+ else if ( newestUpdateCache .get ( details , of ( MINOR ) ) != null )
344
300
{
345
301
renderWarningIcon ();
346
302
sink .nonBreakingSpace ();
347
303
sink .text ( getText ( "report.minorUpdatesAvailable" ) );
348
304
}
349
- else if ( oldestUpdateCache .get ( details , of ( MAJOR ) ) != null )
305
+ else if ( newestUpdateCache .get ( details , of ( MAJOR ) ) != null )
350
306
{
351
307
renderWarningIcon ();
352
308
sink .nonBreakingSpace ();
@@ -411,25 +367,25 @@ else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null )
411
367
sink .text ( artifact .getType () );
412
368
sink .tableCell_ ();
413
369
sink .tableRow_ ();
414
- if ( versions != null && versions . length > 0 )
370
+ if ( ! upToDate )
415
371
{
416
372
sink .tableRow ();
417
373
sink .tableHeaderCell ( headerAttributes );
418
374
sink .text ( getText ( "report.updateVersions" ) );
419
375
sink .tableHeaderCell_ ();
420
376
sink .tableCell ( cellAttributes );
421
- for ( int i = 0 ; i < versions .length ; i ++ )
377
+ for ( int i = 0 ; i < allUpdates .length ; i ++ )
422
378
{
423
379
if ( i > 0 )
424
380
{
425
381
sink .lineBreak ();
426
382
}
427
- String label = getLabel ( versions [i ], details );
383
+ String label = getLabel ( allUpdates [i ], details );
428
384
if ( label != null )
429
385
{
430
386
safeBold ();
431
387
}
432
- sink .text ( versions [i ].toString () );
388
+ sink .text ( allUpdates [i ].toString () );
433
389
if ( label != null )
434
390
{
435
391
safeBold_ ();
@@ -462,4 +418,29 @@ protected void renderTableHeaderCells( String... keys )
462
418
sink .tableHeaderCell_ ();
463
419
} );
464
420
}
421
+
422
+ protected String getLabel ( ArtifactVersion version , AbstractVersionDetails details )
423
+ {
424
+ if ( equals ( version , newestUpdateCache .get ( details , of ( SUBINCREMENTAL ) ) ) )
425
+ {
426
+ return getText ( "report.latestSubIncremental" );
427
+ }
428
+
429
+ if ( equals ( version , newestUpdateCache .get ( details , of ( INCREMENTAL ) ) ) )
430
+ {
431
+ return getText ( "report.latestIncremental" );
432
+ }
433
+
434
+ if ( equals ( version , newestUpdateCache .get ( details , of ( MINOR ) ) ) )
435
+ {
436
+ return getText ( "report.latestMinor" );
437
+ }
438
+
439
+ if ( equals ( version , newestUpdateCache .get ( details , of ( MAJOR ) ) ) )
440
+ {
441
+ return getText ( "report.latestMajor" );
442
+ }
443
+
444
+ return null ;
445
+ }
465
446
}
0 commit comments