Search in sources :

Example 6 with I18nFormat

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

the class DefaultEventDataQueryService method getFromUrl.

@Override
public EventQueryParams getFromUrl(String program, String stage, Date startDate, Date endDate, Set<String> dimension, Set<String> filter, OrganisationUnitSelectionMode ouMode, Set<String> asc, Set<String> desc, boolean skipMeta, boolean skipData, boolean completedOnly, boolean hierarchyMeta, boolean coordinatesOnly, EventStatus eventStatus, ProgramStatus programStatus, DisplayProperty displayProperty, Date relativePeriodDate, String userOrgUnit, String coordinateField, Integer page, Integer pageSize, DhisApiVersion apiVersion) {
    I18nFormat format = i18nManager.getI18nFormat();
    EventQueryParams.Builder params = new EventQueryParams.Builder();
    IdScheme idScheme = IdScheme.UID;
    List<OrganisationUnit> userOrgUnits = dataQueryService.getUserOrgUnits(null, userOrgUnit);
    Program pr = programService.getProgram(program);
    if (pr == null) {
        throw new IllegalQueryException("Program does not exist: " + program);
    }
    ProgramStage ps = programStageService.getProgramStage(stage);
    if (StringUtils.isNotEmpty(stage) && ps == null) {
        throw new IllegalQueryException("Program stage is specified but does not exist: " + stage);
    }
    if (dimension != null) {
        for (String dim : dimension) {
            String dimensionId = getDimensionFromParam(dim);
            List<String> items = getDimensionItemsFromParam(dim);
            DimensionalObject dimObj = dataQueryService.getDimension(dimensionId, items, relativePeriodDate, userOrgUnits, format, true, false, idScheme);
            if (dimObj != null) {
                params.addDimension(dimObj);
            } else {
                params.addItem(getQueryItem(dim, pr));
            }
        }
    }
    if (filter != null) {
        for (String dim : filter) {
            String dimensionId = getDimensionFromParam(dim);
            List<String> items = getDimensionItemsFromParam(dim);
            DimensionalObject dimObj = dataQueryService.getDimension(dimensionId, items, relativePeriodDate, userOrgUnits, format, true, false, idScheme);
            if (dimObj != null) {
                params.addFilter(dimObj);
            } else {
                params.addItemFilter(getQueryItem(dim, pr));
            }
        }
    }
    if (asc != null) {
        for (String sort : asc) {
            params.addAscSortItem(getSortItem(sort, pr));
        }
    }
    if (desc != null) {
        for (String sort : desc) {
            params.addDescSortItem(getSortItem(sort, pr));
        }
    }
    return params.withProgram(pr).withProgramStage(ps).withStartDate(startDate).withEndDate(endDate).withOrganisationUnitMode(ouMode).withSkipMeta(skipMeta).withSkipData(skipData).withCompletedOnly(completedOnly).withHierarchyMeta(hierarchyMeta).withCoordinatesOnly(coordinatesOnly).withEventStatus(eventStatus).withDisplayProperty(displayProperty).withCoordinateField(getCoordinateField(coordinateField)).withPage(page).withPageSize(pageSize).withProgramStatus(programStatus).withApiVersion(apiVersion).build();
}
Also used : EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) I18nFormat(org.hisp.dhis.i18n.I18nFormat)

Example 7 with I18nFormat

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

the class EventChartController method postProcessEntity.

//--------------------------------------------------------------------------
// Hooks
//--------------------------------------------------------------------------
@Override
protected void postProcessEntity(EventChart eventChart) throws Exception {
    eventChart.populateAnalyticalProperties();
    Set<OrganisationUnit> roots = currentUserService.getCurrentUser().getDataViewOrganisationUnitsWithFallback();
    for (OrganisationUnit organisationUnit : eventChart.getOrganisationUnits()) {
        eventChart.getParentGraphMap().put(organisationUnit.getUid(), organisationUnit.getParentGraph(roots));
    }
    I18nFormat format = i18nManager.getI18nFormat();
    if (eventChart.getPeriods() != null && !eventChart.getPeriods().isEmpty()) {
        for (Period period : eventChart.getPeriods()) {
            period.setName(format.formatPeriod(period));
        }
    }
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Period(org.hisp.dhis.period.Period) I18nFormat(org.hisp.dhis.i18n.I18nFormat)

Example 8 with I18nFormat

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

the class MapController method postProcessEntity.

//--------------------------------------------------------------------------
// Hooks
//--------------------------------------------------------------------------
@Override
public void postProcessEntity(Map map) throws Exception {
    I18nFormat format = i18nManager.getI18nFormat();
    Set<OrganisationUnit> roots = currentUserService.getCurrentUser().getDataViewOrganisationUnitsWithFallback();
    for (MapView view : map.getMapViews()) {
        view.populateAnalyticalProperties();
        for (OrganisationUnit organisationUnit : view.getOrganisationUnits()) {
            view.getParentGraphMap().put(organisationUnit.getUid(), organisationUnit.getParentGraph(roots));
        }
        if (view.getPeriods() != null && !view.getPeriods().isEmpty()) {
            for (Period period : view.getPeriods()) {
                period.setName(format.formatPeriod(period));
            }
        }
    }
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) MapView(org.hisp.dhis.mapping.MapView) Period(org.hisp.dhis.period.Period) I18nFormat(org.hisp.dhis.i18n.I18nFormat)

Example 9 with I18nFormat

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

the class DefaultEventDataQueryService method getFromAnalyticalObject.

@Override
public EventQueryParams getFromAnalyticalObject(EventAnalyticalObject object) {
    Assert.notNull(object, "Event analytical object cannot be null");
    Assert.notNull(object.getProgram(), "Event analytical object must specify a program");
    EventQueryParams.Builder params = new EventQueryParams.Builder();
    I18nFormat format = i18nManager.getI18nFormat();
    IdScheme idScheme = IdScheme.UID;
    Date date = object.getRelativePeriodDate();
    object.populateAnalyticalProperties();
    for (DimensionalObject dimension : ListUtils.union(object.getColumns(), object.getRows())) {
        DimensionalObject dimObj = dataQueryService.getDimension(dimension.getDimension(), getDimensionalItemIds(dimension.getItems()), date, null, format, true, false, idScheme);
        if (dimObj != null) {
            params.addDimension(dimObj);
        } else {
            params.addItem(getQueryItem(dimension.getDimension(), dimension.getFilter(), object.getProgram()));
        }
    }
    for (DimensionalObject filter : object.getFilters()) {
        DimensionalObject dimObj = dataQueryService.getDimension(filter.getDimension(), getDimensionalItemIds(filter.getItems()), date, null, format, true, false, idScheme);
        if (dimObj != null) {
            params.addFilter(dimObj);
        } else {
            params.addItemFilter(getQueryItem(filter.getDimension(), filter.getFilter(), object.getProgram()));
        }
    }
    return params.withProgram(object.getProgram()).withProgramStage(object.getProgramStage()).withStartDate(object.getStartDate()).withEndDate(object.getEndDate()).withValue(object.getValue()).withOutputType(object.getOutputType()).build();
}
Also used : EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) I18nFormat(org.hisp.dhis.i18n.I18nFormat) Date(java.util.Date)

Example 10 with I18nFormat

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

the class ReportTableController method postProcessEntity.

//--------------------------------------------------------------------------
// Hooks
//--------------------------------------------------------------------------
@Override
protected void postProcessEntity(ReportTable reportTable) throws Exception {
    reportTable.populateAnalyticalProperties();
    Set<OrganisationUnit> roots = currentUserService.getCurrentUser().getDataViewOrganisationUnitsWithFallback();
    for (OrganisationUnit organisationUnit : reportTable.getOrganisationUnits()) {
        reportTable.getParentGraphMap().put(organisationUnit.getUid(), organisationUnit.getParentGraph(roots));
    }
    I18nFormat format = i18nManager.getI18nFormat();
    if (reportTable.getPeriods() != null && !reportTable.getPeriods().isEmpty()) {
        for (Period period : reportTable.getPeriods()) {
            period.setName(format.formatPeriod(period));
        }
    }
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Period(org.hisp.dhis.period.Period) I18nFormat(org.hisp.dhis.i18n.I18nFormat)

Aggregations

I18nFormat (org.hisp.dhis.i18n.I18nFormat)15 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)10 Period (org.hisp.dhis.period.Period)7 Date (java.util.Date)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 JasperReport (net.sf.jasperreports.engine.JasperReport)2 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)2 EventQueryParams (org.hisp.dhis.analytics.event.EventQueryParams)2 TextUtils.getCommaDelimitedString (org.hisp.dhis.commons.util.TextUtils.getCommaDelimitedString)2 Report (org.hisp.dhis.report.Report)2 ReportTable (org.hisp.dhis.reporttable.ReportTable)2 Action (com.opensymphony.xwork2.Action)1 Connection (java.sql.Connection)1 Locale (java.util.Locale)1 JasperPrint (net.sf.jasperreports.engine.JasperPrint)1 NoSuchPropertyException (ognl.NoSuchPropertyException)1 VelocityContext (org.apache.velocity.VelocityContext)1 Calendar (org.hisp.dhis.calendar.Calendar)1 DimensionalObject (org.hisp.dhis.common.DimensionalObject)1