Search in sources :

Example 36 with I18nFormat

use of org.hisp.dhis.i18n.I18nFormat in project dhis2-core by dhis2.

the class EventVisualizationController method postProcessResponseEntity.

@Override
protected void postProcessResponseEntity(final EventVisualization eventVisualization, final WebOptions options, final Map<String, String> parameters) {
    eventVisualization.populateAnalyticalProperties();
    final User currentUser = currentUserService.getCurrentUser();
    if (currentUser != null) {
        final Set<OrganisationUnit> roots = currentUser.getDataViewOrganisationUnitsWithFallback();
        for (OrganisationUnit organisationUnit : eventVisualization.getOrganisationUnits()) {
            eventVisualization.getParentGraphMap().put(organisationUnit.getUid(), organisationUnit.getParentGraph(roots));
        }
    }
    final I18nFormat format = i18nManager.getI18nFormat();
    if (eventVisualization.getPeriods() != null && !eventVisualization.getPeriods().isEmpty()) {
        for (final Period period : eventVisualization.getPeriods()) {
            period.setName(format.formatPeriod(period));
        }
    }
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) User(org.hisp.dhis.user.User) Period(org.hisp.dhis.period.Period) I18nFormat(org.hisp.dhis.i18n.I18nFormat)

Example 37 with I18nFormat

use of org.hisp.dhis.i18n.I18nFormat in project dhis2-core by dhis2.

the class EventReportController method postProcessResponseEntity.

@Override
protected void postProcessResponseEntity(EventReport report, WebOptions options, Map<String, String> parameters) throws Exception {
    report.populateAnalyticalProperties();
    User currentUser = currentUserService.getCurrentUser();
    if (currentUser != null) {
        Set<OrganisationUnit> roots = currentUser.getDataViewOrganisationUnitsWithFallback();
        for (OrganisationUnit organisationUnit : report.getOrganisationUnits()) {
            report.getParentGraphMap().put(organisationUnit.getUid(), organisationUnit.getParentGraph(roots));
        }
    }
    I18nFormat format = i18nManager.getI18nFormat();
    if (report.getPeriods() != null && !report.getPeriods().isEmpty()) {
        for (Period period : report.getPeriods()) {
            period.setName(format.formatPeriod(period));
        }
    }
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) User(org.hisp.dhis.user.User) Period(org.hisp.dhis.period.Period) I18nFormat(org.hisp.dhis.i18n.I18nFormat)

Aggregations

I18nFormat (org.hisp.dhis.i18n.I18nFormat)37 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)24 Period (org.hisp.dhis.period.Period)19 ArrayList (java.util.ArrayList)10 Date (java.util.Date)8 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 Grid (org.hisp.dhis.common.Grid)5 IdScheme (org.hisp.dhis.common.IdScheme)5 I18n (org.hisp.dhis.i18n.I18n)5 ListGrid (org.hisp.dhis.system.grid.ListGrid)5 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)4 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)4 DataElement (org.hisp.dhis.dataelement.DataElement)4 DeflatedDataValue (org.hisp.dhis.datavalue.DeflatedDataValue)4 User (org.hisp.dhis.user.User)4 Transactional (org.springframework.transaction.annotation.Transactional)4 PostMapping (org.springframework.web.bind.annotation.PostMapping)4 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)4 HashMap (java.util.HashMap)3