use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class ResourceTableController method analytics.
@RequestMapping(value = "/analytics", method = { RequestMethod.PUT, RequestMethod.POST })
@PreAuthorize("hasRole('ALL') or hasRole('F_PERFORM_MAINTENANCE')")
@ResponseBody
public WebMessage analytics(@RequestParam(required = false) boolean skipResourceTables, @RequestParam(required = false) boolean skipAggregate, @RequestParam(required = false) boolean skipEvents, @RequestParam(required = false) boolean skipEnrollment, @RequestParam(required = false) Integer lastYears) {
Set<AnalyticsTableType> skipTableTypes = new HashSet<>();
Set<String> skipPrograms = new HashSet<>();
if (skipAggregate) {
skipTableTypes.add(AnalyticsTableType.DATA_VALUE);
skipTableTypes.add(AnalyticsTableType.COMPLETENESS);
skipTableTypes.add(AnalyticsTableType.COMPLETENESS_TARGET);
}
if (skipEvents) {
skipTableTypes.add(AnalyticsTableType.EVENT);
}
if (skipEnrollment) {
skipTableTypes.add(AnalyticsTableType.ENROLLMENT);
}
AnalyticsJobParameters analyticsJobParameters = new AnalyticsJobParameters(lastYears, skipTableTypes, skipPrograms, skipResourceTables);
JobConfiguration analyticsTableJob = new JobConfiguration("inMemoryAnalyticsJob", JobType.ANALYTICS_TABLE, "", analyticsJobParameters, true, true);
analyticsTableJob.setUserUid(currentUserService.getCurrentUser().getUid());
schedulingManager.executeNow(analyticsTableJob);
return jobConfigurationReport(analyticsTableJob);
}
use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class EnrollmentController method startAsyncImport.
// -------------------------------------------------------------------------
// HELPERS
// -------------------------------------------------------------------------
/**
* Starts an asynchronous enrollment task.
*
* @param importOptions the ImportOptions.
* @param enrollments the enrollments to import.
*/
private WebMessage startAsyncImport(ImportOptions importOptions, List<Enrollment> enrollments) {
JobConfiguration jobId = new JobConfiguration("inMemoryEventImport", ENROLLMENT_IMPORT, currentUserService.getCurrentUser().getUid(), true);
taskExecutor.executeTask(new ImportEnrollmentsTask(enrollments, enrollmentService, importOptions, jobId));
return jobConfigurationReport(jobId).setLocation("/system/tasks/" + ENROLLMENT_IMPORT);
}
use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class JobConfigurationController method executeJobConfiguration.
@PostMapping(value = "{uid}/execute", produces = { APPLICATION_JSON_VALUE, "application/javascript" })
public ObjectReport executeJobConfiguration(@PathVariable("uid") String uid) throws WebMessageException {
JobConfiguration jobConfiguration = jobConfigurationService.getJobConfigurationByUid(uid);
checkConfigurable(jobConfiguration, HttpStatus.FORBIDDEN, "Job %s is a system job that cannot be executed.");
ObjectReport objectReport = new ObjectReport(JobConfiguration.class, 0);
boolean success = schedulingManager.executeNow(jobConfiguration);
if (!success) {
objectReport.addErrorReport(new ErrorReport(JobConfiguration.class, new ErrorMessage(ErrorCode.E7006, jobConfiguration.getName())));
}
return objectReport;
}
use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class TrackerImportStrategyImpl method importReport.
@Override
public TrackerImportReport importReport(TrackerImportReportRequest trackerImportReportRequest) {
setTrackerImportParams(trackerImportReportRequest);
if (trackerImportReportRequest.isAsync()) {
return importAsyncStrategy.importReport(trackerImportReportRequest);
} else {
JobConfiguration jobConfiguration = new JobConfiguration("", JobType.TRACKER_IMPORT_JOB, trackerImportReportRequest.getUserUid(), trackerImportReportRequest.isAsync());
jobConfiguration.setUid(trackerImportReportRequest.getUid());
trackerImportReportRequest.getTrackerImportParams().setJobConfiguration(jobConfiguration);
return importAsyncFalseStrategy.importReport(trackerImportReportRequest);
}
}
use of org.hisp.dhis.scheduling.JobConfiguration in project dhis2-core by dhis2.
the class TrackerImportStrategyHandlerImplTest method shouldCreateReportAsyncFalse.
@Test
void shouldCreateReportAsyncFalse() {
TrackerImportReportRequest trackerImportReportRequest = TrackerImportReportRequest.builder().trackerImportParams(TrackerImportParams.builder().jobConfiguration(new JobConfiguration("", JobType.TRACKER_IMPORT_JOB, "userId", false)).build()).trackerBundleReportMode(TrackerBundleReportMode.FULL).build();
importAsyncFalseStrategy.importReport(trackerImportReportRequest);
verify(trackerImportService).importTracker(trackerImportReportRequest.getTrackerImportParams());
verify(trackerImportService).buildImportReport(any(), any());
}
Aggregations