Search in sources :

Example 1 with SchedulingStrategy

use of org.hisp.dhis.webapi.webdomain.SchedulingStrategy 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)

Aggregations

ListMap (org.hisp.dhis.common.ListMap)1 SchedulingStrategy (org.hisp.dhis.webapi.webdomain.SchedulingStrategy)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1