Search in sources :

Example 1 with PushAnalysis

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();
}
Also used : WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) PushAnalysis(org.hisp.dhis.pushanalysis.PushAnalysis) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with PushAnalysis

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);
}
Also used : PushAnalysisJobParameters(org.hisp.dhis.scheduling.parameters.PushAnalysisJobParameters) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) PushAnalysis(org.hisp.dhis.pushanalysis.PushAnalysis) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Aggregations

WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)2 PushAnalysis (org.hisp.dhis.pushanalysis.PushAnalysis)2 JobConfiguration (org.hisp.dhis.scheduling.JobConfiguration)1 PushAnalysisJobParameters (org.hisp.dhis.scheduling.parameters.PushAnalysisJobParameters)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1