class DefaultVisualizationService extends
    GenericAnalyticalObjectService<Visualization> implements
    VisualizationService {

    @Override
    @Transactional( readOnly = true )
    public Grid getVisualizationGridByUser( final String uid, final Date relativePeriodDate,
        final String organisationUnitUid, final User user )
    {
        Visualization visualization = loadVisualization( uid );
        final boolean hasPermission = visualization != null;

        if ( hasPermission )
        {
            I18nFormat format = i18nManager.getI18nFormat();
            OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitUid );

            List<OrganisationUnit> atLevels = new ArrayList<>();
            List<OrganisationUnit> inGroups = new ArrayList<>();

            if ( visualization.hasOrganisationUnitLevels() )
            {
                atLevels.addAll( organisationUnitService.getOrganisationUnitsAtLevels(
                    visualization.getOrganisationUnitLevels(), visualization.getOrganisationUnits() ) );
            }

            if ( visualization.hasItemOrganisationUnitGroups() )
            {
                inGroups.addAll( organisationUnitService.getOrganisationUnits(
                    visualization.getItemOrganisationUnitGroups(), visualization.getOrganisationUnits() ) );
            }

            visualization.init( user, relativePeriodDate, organisationUnit, atLevels, inGroups, format );

            Map<String, Object> valueMap = analyticsService.getAggregatedDataValueMapping( visualization );

            Grid visualizationGrid = visualization.getGrid( new ListGrid(), valueMap, SHORTNAME, true );

            visualization.clearTransientState();

            return visualizationGrid;
        }
        else
        {
            return new ListGrid();
        }
    }

    public  DefaultVisualizationService( final AnalyticsService analyticsService,
        @Qualifier( "org.hisp.dhis.visualization.generic.VisualizationStore" )
        final AnalyticalObjectStore<Visualization> visualizationStore,
        final OrganisationUnitService organisationUnitService, final CurrentUserService currentUserService,
        final I18nManager i18nManager );

}