Search in sources :

Example 11 with ListMap

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);
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) DataElementCategoryCombo(org.hisp.dhis.dataelement.DataElementCategoryCombo) DataSet(org.hisp.dhis.dataset.DataSet) DataSetElement(org.hisp.dhis.dataset.DataSetElement) Section(org.hisp.dhis.dataset.Section) ListMap(org.hisp.dhis.common.ListMap)

Example 12 with ListMap

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);
}
Also used : SchedulingStrategy(org.hisp.dhis.webapi.webdomain.SchedulingStrategy) ListMap(org.hisp.dhis.common.ListMap) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with ListMap

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;
}
Also used : PeriodType(org.hisp.dhis.period.PeriodType) DataElement(org.hisp.dhis.dataelement.DataElement) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) ListMap(org.hisp.dhis.common.ListMap)

Example 14 with ListMap

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;
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) ListMap(org.hisp.dhis.common.ListMap)

Example 15 with ListMap

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;
}
Also used : DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) Period(org.hisp.dhis.period.Period) ListMap(org.hisp.dhis.common.ListMap)

Aggregations

ListMap (org.hisp.dhis.common.ListMap)22 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)14 DataElement (org.hisp.dhis.dataelement.DataElement)8 Period (org.hisp.dhis.period.Period)7 PeriodType (org.hisp.dhis.period.PeriodType)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)5 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)5 AnalyticsAggregationType (org.hisp.dhis.analytics.AnalyticsAggregationType)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 AllArgsConstructor (lombok.AllArgsConstructor)2 StringUtils (org.apache.commons.lang3.StringUtils)2 AggregationType (org.hisp.dhis.analytics.AggregationType)2 DataType (org.hisp.dhis.analytics.DataType)2 CategoryCombo (org.hisp.dhis.category.CategoryCombo)2 CategoryOption (org.hisp.dhis.category.CategoryOption)2 CategoryService (org.hisp.dhis.category.CategoryService)2 BaseDimensionalObject (org.hisp.dhis.common.BaseDimensionalObject)2