Search in sources :

Example 46 with JobConfiguration

use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.

the class DataValueSetController method startAsyncImport.

// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
/**
 * Starts an asynchronous import task.
 *
 * @param importOptions the ImportOptions.
 * @param format the resource representation format.
 * @param request the HttpRequest.
 */
private WebMessage startAsyncImport(ImportOptions importOptions, String format, HttpServletRequest request) throws IOException {
    InputStream inputStream = saveTmp(request.getInputStream());
    JobConfiguration jobId = new JobConfiguration("dataValueImport", DATAVALUE_IMPORT, currentUserService.getCurrentUser().getUid(), true);
    taskExecutor.executeTask(new ImportDataValueTask(dataValueSetService, adxDataService, sessionFactory, inputStream, importOptions, jobId, format));
    return jobConfigurationReport(jobId).setLocation("/system/tasks/" + DATAVALUE_IMPORT);
}
Also used : BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) ImportDataValueTask(org.hisp.dhis.dxf2.datavalueset.tasks.ImportDataValueTask)

Example 47 with JobConfiguration

use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.

the class PdfFormController method sendFormPdfDataSet.

@PostMapping("/dataSet")
@PreAuthorize("hasRole('ALL') or hasRole('F_DATAVALUE_ADD')")
@ResponseBody
public WebMessage sendFormPdfDataSet(HttpServletRequest request) throws Exception {
    JobConfiguration jobId = new JobConfiguration("inMemoryDataValueImport", JobType.DATAVALUE_IMPORT, currentUserService.getCurrentUser().getUid(), true);
    notifier.clear(jobId);
    InputStream in = request.getInputStream();
    in = StreamUtils.wrapAndCheckCompressionFormat(in);
    ImportSummary summary = dataValueSetService.importDataValueSetPdf(in, ImportOptions.getDefaultImportOptions(), jobId);
    return importSummary(summary);
}
Also used : InputStream(java.io.InputStream) ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) PostMapping(org.springframework.web.bind.annotation.PostMapping) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 48 with JobConfiguration

use of org.hisp.dhis.scheduling.JobConfiguration 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)

Example 49 with JobConfiguration

use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.

the class ResourceTableController method resourceTables.

@RequestMapping(method = { RequestMethod.PUT, RequestMethod.POST })
@PreAuthorize("hasRole('ALL') or hasRole('F_PERFORM_MAINTENANCE')")
@ResponseBody
public WebMessage resourceTables() {
    JobConfiguration resourceTableJob = new JobConfiguration("inMemoryResourceTableJob", JobType.RESOURCE_TABLE, currentUserService.getCurrentUser().getUid(), true);
    schedulingManager.executeNow(resourceTableJob);
    return jobConfigurationReport(resourceTableJob);
}
Also used : JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 50 with JobConfiguration

use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.

the class ResourceTableController method monitoring.

@RequestMapping(value = "/monitoring", method = { RequestMethod.PUT, RequestMethod.POST })
@PreAuthorize("hasRole('ALL') or hasRole('F_PERFORM_MAINTENANCE')")
@ResponseBody
public WebMessage monitoring() {
    JobConfiguration monitoringJob = new JobConfiguration("inMemoryMonitoringJob", JobType.MONITORING, "", new MonitoringJobParameters(), true, true);
    schedulingManager.executeNow(monitoringJob);
    return jobConfigurationReport(monitoringJob);
}
Also used : JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) MonitoringJobParameters(org.hisp.dhis.scheduling.parameters.MonitoringJobParameters) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

JobConfiguration (org.hisp.dhis.scheduling.JobConfiguration)55 Test (org.junit.jupiter.api.Test)23 ErrorReport (org.hisp.dhis.feedback.ErrorReport)10 List (java.util.List)7 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 ArrayList (java.util.ArrayList)5 ImportOptions (org.hisp.dhis.dxf2.common.ImportOptions)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 InputStream (java.io.InputStream)4 IdScheme (org.hisp.dhis.common.IdScheme)4 CachingMap (org.hisp.dhis.commons.collection.CachingMap)4 ImportSummaries (org.hisp.dhis.dxf2.importsummary.ImportSummaries)4 ImportStrategy (org.hisp.dhis.importexport.ImportStrategy)4 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 IdSchemes (org.hisp.dhis.common.IdSchemes)3 IdentifiableObjectManager (org.hisp.dhis.common.IdentifiableObjectManager)3 TrackerTrigramIndexJobParameters (org.hisp.dhis.scheduling.parameters.TrackerTrigramIndexJobParameters)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3