use of org.hisp.dhis.common.ListMap in project dhis2-core by dhis2.
the class DefaultDataSetReportService method getDefaultDataSetReport.
@Override
public List<Grid> getDefaultDataSetReport(DataSet dataSet, Period period, OrganisationUnit unit, Set<String> dimensions, boolean selectedUnitOnly, I18nFormat format, I18n i18n) {
ListMap<DataElementCategoryCombo, DataElement> map = new ListMap<>();
for (DataSetElement element : dataSet.getDataSetElements()) {
map.putValue(element.getResolvedCategoryCombo(), element.getDataElement());
}
DataSet tmpDataSet = new DataSet(dataSet.getName(), dataSet.getShortName(), dataSet.getPeriodType());
tmpDataSet.setDataSetElements(dataSet.getDataSetElements());
for (DataElementCategoryCombo categoryCombo : map.keySet()) {
List<DataElement> dataElements = map.get(categoryCombo);
String name = categoryCombo.isDefault() ? dataSet.getName() : categoryCombo.getName();
Section section = new Section(name, dataSet, dataElements, null);
tmpDataSet.getSections().add(section);
}
return getSectionDataSetReport(tmpDataSet, period, unit, dimensions, selectedUnitOnly, format, i18n);
}
use of org.hisp.dhis.common.ListMap in project dhis2-core by dhis2.
the class SchedulingController method schedule.
@PreAuthorize("hasRole('ALL') or hasRole('F_SCHEDULING_ADMIN')")
@RequestMapping(method = { RequestMethod.POST, RequestMethod.PUT }, consumes = { ContextUtils.CONTENT_TYPE_JSON })
@ResponseStatus(HttpStatus.NO_CONTENT)
public void schedule(HttpServletRequest request, HttpServletResponse response) throws IOException {
SchedulingStrategy strategy = renderService.fromJson(request.getInputStream(), SchedulingStrategy.class);
ListMap<String, String> cronKeyMap = new ListMap<>();
if (STRATEGY_ALL_DAILY.equals(strategy.getResourceTableStrategy())) {
cronKeyMap.putValue(CRON_DAILY_0AM, TASK_RESOURCE_TABLE);
} else if (STRATEGY_ALL_15_MIN.equals(strategy.getResourceTableStrategy())) {
cronKeyMap.putValue(CRON_EVERY_15MIN, TASK_RESOURCE_TABLE_15_MINS);
}
if (STRATEGY_ALL_DAILY.equals(strategy.getAnalyticsStrategy())) {
cronKeyMap.putValue(CRON_DAILY_0AM, TASK_ANALYTICS_ALL);
} else if (STRATEGY_LAST_3_YEARS_DAILY.equals(strategy.getAnalyticsStrategy())) {
cronKeyMap.putValue(CRON_DAILY_0AM, TASK_ANALYTICS_LAST_3_YEARS);
}
if (STRATEGY_ALL_DAILY.equals(strategy.getDataMartStrategy())) {
cronKeyMap.putValue(CRON_DAILY_0AM, TASK_DATAMART_LAST_YEAR);
}
if (STRATEGY_ALL_DAILY.equals(strategy.getMonitoringStrategy())) {
cronKeyMap.putValue(CRON_DAILY_0AM, TASK_MONITORING_LAST_DAY);
}
if (STRATEGY_ENABLED.equals(strategy.getDataSynchStrategy())) {
cronKeyMap.putValue(CRON_EVERY_MIN, TASK_DATA_SYNCH);
}
schedulingManager.scheduleTasks(cronKeyMap);
}
use of org.hisp.dhis.common.ListMap in project dhis2-core by dhis2.
the class QueryPlannerUtils method getPeriodTypeDataElementMap.
/**
* Creates a mapping between the period type and the data element for the
* given data elements.
*
* @param dataElements list of data elements.
*/
public static ListMap<PeriodType, DimensionalItemObject> getPeriodTypeDataElementMap(Collection<DimensionalItemObject> dataElements) {
ListMap<PeriodType, DimensionalItemObject> map = new ListMap<>();
for (DimensionalItemObject element : dataElements) {
DataElement dataElement = (DataElement) element;
map.putValue(dataElement.getPeriodType(), element);
}
return map;
}
use of org.hisp.dhis.common.ListMap in project dhis2-core by dhis2.
the class QueryPlannerUtils method getLevelOrgUnitMap.
/**
* Creates a mapping between level and organisation units for the given
* organisation units.
*
* @param orgUnits list of organisation units.
*/
public static ListMap<Integer, DimensionalItemObject> getLevelOrgUnitMap(List<DimensionalItemObject> orgUnits) {
ListMap<Integer, DimensionalItemObject> map = new ListMap<>();
for (DimensionalItemObject orgUnit : orgUnits) {
OrganisationUnit ou = (OrganisationUnit) orgUnit;
map.putValue(ou.getLevel(), orgUnit);
}
return map;
}
use of org.hisp.dhis.common.ListMap in project dhis2-core by dhis2.
the class QueryPlannerUtils method getDaysPeriodMap.
/**
* Creates a mapping between the number of days in the period interval and
* periods for the given periods.
*
* @param periods
*/
public static ListMap<Integer, DimensionalItemObject> getDaysPeriodMap(List<DimensionalItemObject> periods) {
ListMap<Integer, DimensionalItemObject> map = new ListMap<>();
for (DimensionalItemObject period : periods) {
Period pe = (Period) period;
map.putValue(pe.getDaysInPeriod(), pe);
}
return map;
}
Aggregations