use of org.hisp.dhis.i18n.I18nFormat in project dhis2-core by dhis2.
the class EventReportController method postProcessEntity.
//--------------------------------------------------------------------------
// Hooks
//--------------------------------------------------------------------------
@Override
protected void postProcessEntity(EventReport report) throws Exception {
report.populateAnalyticalProperties();
Set<OrganisationUnit> roots = currentUserService.getCurrentUser().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));
}
}
}
use of org.hisp.dhis.i18n.I18nFormat in project dhis2-core by dhis2.
the class ChartController method postProcessEntity.
//--------------------------------------------------------------------------
// Hooks
//--------------------------------------------------------------------------
@Override
public void postProcessEntity(Chart chart) throws Exception {
chart.populateAnalyticalProperties();
Set<OrganisationUnit> roots = currentUserService.getCurrentUser().getDataViewOrganisationUnitsWithFallback();
for (OrganisationUnit organisationUnit : chart.getOrganisationUnits()) {
chart.getParentGraphMap().put(organisationUnit.getUid(), organisationUnit.getParentGraph(roots));
}
if (chart.getPeriods() != null && !chart.getPeriods().isEmpty()) {
I18nFormat format = i18nManager.getI18nFormat();
for (Period period : chart.getPeriods()) {
period.setName(format.formatPeriod(period));
}
}
}
use of org.hisp.dhis.i18n.I18nFormat in project dhis2-core by dhis2.
the class I18nInterceptor method intercept.
@Override
public String intercept(ActionInvocation invocation) throws Exception {
Action action = (Action) invocation.getAction();
I18n i18n = i18nManager.getI18n(action.getClass());
I18nFormat i18nFormat = i18nManager.getI18nFormat();
Locale locale = localeManager.getCurrentLocale();
// ---------------------------------------------------------------------
// Make the objects available for web templates
// ---------------------------------------------------------------------
Map<String, Object> i18nMap = new HashMap<>(3);
i18nMap.put(KEY_I18N, i18n);
i18nMap.put(KEY_I18N_FORMAT, i18nFormat);
i18nMap.put(KEY_LOCALE, locale);
invocation.getStack().push(i18nMap);
// ---------------------------------------------------------------------
// Set the objects in the action class if the properties exist
// ---------------------------------------------------------------------
Map<?, ?> contextMap = invocation.getInvocationContext().getContextMap();
try {
Ognl.setValue(KEY_I18N, contextMap, action, i18n);
} catch (NoSuchPropertyException ignored) {
}
try {
Ognl.setValue(KEY_I18N_FORMAT, contextMap, action, i18nFormat);
} catch (NoSuchPropertyException ignored) {
}
try {
Ognl.setValue(KEY_LOCALE, contextMap, action, locale);
} catch (NoSuchPropertyException ignored) {
}
return invocation.invoke();
}
use of org.hisp.dhis.i18n.I18nFormat in project dhis2-core by dhis2.
the class DefaultDataQueryService method getFromRequest.
// -------------------------------------------------------------------------
// DataQueryService implementation
// -------------------------------------------------------------------------
@Override
public DataQueryParams getFromRequest(DataQueryRequest request) {
I18nFormat format = i18nManager.getI18nFormat();
DataQueryParams.Builder params = DataQueryParams.newBuilder();
IdScheme inputIdScheme = ObjectUtils.firstNonNull(request.getInputIdScheme(), IdScheme.UID);
if (request.getDimension() != null && !request.getDimension().isEmpty()) {
params.addDimensions(getDimensionalObjects(request.getDimension(), request.getRelativePeriodDate(), request.getUserOrgUnit(), format, request.isAllowAllPeriods(), inputIdScheme));
}
if (request.getFilter() != null && !request.getFilter().isEmpty()) {
params.addFilters(getDimensionalObjects(request.getFilter(), request.getRelativePeriodDate(), request.getUserOrgUnit(), format, request.isAllowAllPeriods(), inputIdScheme));
}
if (request.getMeasureCriteria() != null && !request.getMeasureCriteria().isEmpty()) {
params.withMeasureCriteria(getMeasureCriteriaFromParam(request.getMeasureCriteria()));
}
if (request.getPreAggregationMeasureCriteria() != null && !request.getPreAggregationMeasureCriteria().isEmpty()) {
params.withPreAggregationMeasureCriteria(getMeasureCriteriaFromParam(request.getPreAggregationMeasureCriteria()));
}
if (request.getAggregationType() != null) {
params.withAggregationType(AnalyticsAggregationType.fromAggregationType(request.getAggregationType()));
}
return params.withStartDate(request.getStartDate()).withEndDate(request.getEndDate()).withOrder(request.getOrder()).withTimeField(request.getTimeField()).withOrgUnitField(request.getOrgUnitField()).withSkipMeta(request.isSkipMeta()).withSkipData(request.isSkipData()).withSkipRounding(request.isSkipRounding()).withCompletedOnly(request.isCompletedOnly()).withIgnoreLimit(request.isIgnoreLimit()).withHierarchyMeta(request.isHierarchyMeta()).withHideEmptyRows(request.isHideEmptyRows()).withHideEmptyColumns(request.isHideEmptyColumns()).withShowHierarchy(request.isShowHierarchy()).withIncludeNumDen(request.isIncludeNumDen()).withIncludeMetadataDetails(request.isIncludeMetadataDetails()).withDisplayProperty(request.getDisplayProperty()).withOutputIdScheme(request.getOutputIdScheme()).withOutputDataElementIdScheme(request.getOutputDataElementIdScheme()).withOutputOrgUnitIdScheme(request.getOutputOrgUnitIdScheme()).withOutputFormat(OutputFormat.ANALYTICS).withDuplicatesOnly(request.isDuplicatesOnly()).withApprovalLevel(request.getApprovalLevel()).withApiVersion(request.getApiVersion()).withUserOrgUnitType(request.getUserOrgUnitType()).build();
}
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(), object.getOutputType()));
}
}
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(), object.getOutputType()));
}
}
return params.withProgram(object.getProgram()).withProgramStage(object.getProgramStage()).withStartDate(object.getStartDate()).withEndDate(object.getEndDate()).withValue(object.getValue()).withOutputType(object.getOutputType()).build();
}
Aggregations