use of org.hisp.dhis.predictor.PredictionTask in project dhis2-core by dhis2.
the class PredictionController method runPredictors.
@RequestMapping(method = { RequestMethod.POST, RequestMethod.PUT })
@PreAuthorize("hasRole('ALL') or hasRole('F_PREDICTOR_RUN')")
@ResponseBody
public WebMessage runPredictors(@RequestParam Date startDate, @RequestParam Date endDate, @RequestParam(value = "predictor", required = false) List<String> predictors, @RequestParam(value = "predictorGroup", required = false) List<String> predictorGroups, @RequestParam(defaultValue = "false", required = false) boolean async, HttpServletRequest request) {
if (async) {
JobConfiguration jobId = new JobConfiguration("inMemoryPrediction", PREDICTOR, currentUserService.getCurrentUser().getUid(), true);
taskExecutor.executeTask(new PredictionTask(startDate, endDate, predictors, predictorGroups, predictionService, jobId));
return jobConfigurationReport(jobId).setLocation("/system/tasks/" + PREDICTOR);
}
PredictionSummary predictionSummary = predictionService.predictTask(startDate, endDate, predictors, predictorGroups, null);
return new WebMessage(Status.OK, HttpStatus.OK).setResponse(predictionSummary).withPlainResponseBefore(DhisApiVersion.V38);
}
Aggregations