Skip to content

Commit

Permalink
fix: null check for dashboardItems (dhis2#6947)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenoh authored Dec 18, 2020
1 parent b45bc96 commit 0b4a11f
Showing 1 changed file with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public ResponseEntity<RootNode> getDataSetWithDependencies( @PathVariable( "uid"
/**
* Logic required to keep the backward compatibility with Chart and ReporTable.
* Otherwise it would always return VISUALIZATION type for any Chart or ReportTable.
*
* <p>
* Only needed during the transition from Chart/ReportTable APIs to Visualization API.
* Once the Visualization API is fully enabled this logic should be removed.
*
Expand All @@ -124,8 +124,8 @@ public ResponseEntity<RootNode> getDataSetWithDependencies( @PathVariable( "uid"
*/
@Override
@Deprecated
protected void postProcessResponseEntities(final List<Dashboard> dashboards, final WebOptions options,
final java.util.Map<String, String> parameters )
protected void postProcessResponseEntities( final List<Dashboard> dashboards, final WebOptions options,
final java.util.Map<String, String> parameters )
{
if ( isNotEmpty( dashboards ) )
{
Expand All @@ -139,7 +139,7 @@ protected void postProcessResponseEntities(final List<Dashboard> dashboards, fin
/**
* Logic required to keep the backward compatibility with Chart and ReportTable.
* Otherwise it would always return VISUALIZATION type for any Chart or ReportTable.
*
* <p>
* Only needed during the transition from Chart/ReportTable APIs to Visualization API.
* Once the Visualization API is fully enabled this logic should be removed.
*
Expand All @@ -158,31 +158,36 @@ protected void postProcessResponseEntity( final Dashboard dashboard, final WebOp

for ( final DashboardItem dashboardItem : dashboardItems )
{
if ( dashboardItem == null )
{
continue;
}

if ( dashboardItem.getVisualization() != null )
{
final VisualizationType type = dashboardItem.getVisualization().getType();

switch ( type )
{
case PIVOT_TABLE:
dashboardItem.setReportTable( convertToReportTable ( dashboardItem.getVisualization()) );
break;
case AREA:
case BAR:
case COLUMN:
case GAUGE:
case LINE:
case PIE:
case RADAR:
case SINGLE_VALUE:
case STACKED_BAR:
case STACKED_COLUMN:
case YEAR_OVER_YEAR_COLUMN:
case YEAR_OVER_YEAR_LINE:
case SCATTER:
case BUBBLE:
dashboardItem.setChart( convertToChart ( dashboardItem.getVisualization() ) );
break;
case PIVOT_TABLE:
dashboardItem.setReportTable( convertToReportTable( dashboardItem.getVisualization() ) );
break;
case AREA:
case BAR:
case COLUMN:
case GAUGE:
case LINE:
case PIE:
case RADAR:
case SINGLE_VALUE:
case STACKED_BAR:
case STACKED_COLUMN:
case YEAR_OVER_YEAR_COLUMN:
case YEAR_OVER_YEAR_LINE:
case SCATTER:
case BUBBLE:
dashboardItem.setChart( convertToChart( dashboardItem.getVisualization() ) );
break;
}
}
}
Expand Down

0 comments on commit 0b4a11f

Please sign in to comment.