use of org.hisp.dhis.pushanalysis.PushAnalysis in project dhis2-core by dhis2.
the class PushAnalysisController method renderPushAnalytics.
@GetMapping("/{uid}/render")
public void renderPushAnalytics(@PathVariable() String uid, HttpServletResponse response) throws WebMessageException, IOException {
PushAnalysis pushAnalysis = pushAnalysisService.getByUid(uid);
if (pushAnalysis == null) {
throw new WebMessageException(notFound("Push analysis with uid " + uid + " was not found"));
}
contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.NO_CACHE);
log.info("User '" + currentUserService.getCurrentUser().getUsername() + "' started PushAnalysis for 'rendering'");
String result = pushAnalysisService.generateHtmlReport(pushAnalysis, currentUserService.getCurrentUser(), null);
response.getWriter().write(result);
response.getWriter().close();
}
use of org.hisp.dhis.pushanalysis.PushAnalysis in project dhis2-core by dhis2.
the class PushAnalysisController method sendPushAnalysis.
@ResponseStatus(HttpStatus.NO_CONTENT)
@PostMapping("/{uid}/run")
public void sendPushAnalysis(@PathVariable() String uid) throws WebMessageException, IOException {
PushAnalysis pushAnalysis = pushAnalysisService.getByUid(uid);
if (pushAnalysis == null) {
throw new WebMessageException(notFound("Push analysis with uid " + uid + " was not found"));
}
JobConfiguration pushAnalysisJobConfiguration = new JobConfiguration("pushAnalysisJob from controller", JobType.PUSH_ANALYSIS, "", new PushAnalysisJobParameters(uid), true, true);
schedulingManager.executeNow(pushAnalysisJobConfiguration);
}
Aggregations