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();
}
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));
}
}
}
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));
}
}
}
}
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();
}
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));
}
}
}
Aggregations