Search in sources :

Example 1 with TaskId

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

the class GetImportSummaryAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() {
    TaskId taskId = new TaskId(category, currentUserService.getCurrentUser());
    summary = (ImportSummary) notifier.getTaskSummary(taskId);
    return SUCCESS;
}
Also used : TaskId(org.hisp.dhis.scheduling.TaskId)

Example 2 with TaskId

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

the class GetImportSummaryAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() {
    TaskId taskId = new TaskId(category, currentUserService.getCurrentUser());
    summary = (ImportSummary) notifier.getTaskSummary(taskId);
    return SUCCESS;
}
Also used : TaskId(org.hisp.dhis.scheduling.TaskId)

Example 3 with TaskId

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

the class MetaDataImportAction method execute.

// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    strategy = strategy != null ? strategy : ImportStrategy.NEW_AND_UPDATES;
    User user = currentUserService.getCurrentUser();
    TaskId taskId = new TaskId(TaskCategory.METADATA_IMPORT, user);
    notifier.clear(taskId);
    InputStream in = StreamUtils.wrapAndCheckCompressionFormat(new FileInputStream(upload));
    MetadataImportParams importParams = createMetadataImportParams(taskId, strategy, atomicMode, dryRun).setFilename(uploadFileName);
    if ("csv".equals(importFormat)) {
        if (classKey != null && CSV_SUPPORTED_CLASSES.containsKey(classKey)) {
            scheduler.executeTask(new ImportMetaDataCsvTask(importService, csvImportService, schemaService, importParams, in, CSV_SUPPORTED_CLASSES.get(classKey)));
        }
    } else if ("gml".equals(importFormat)) {
        scheduler.executeTask(new ImportMetaDataGmlTask(gmlImportService, importParams, in));
    } else if ("json".equals(importFormat) || "xml".equals(importFormat)) {
        scheduler.executeTask(new ImportMetaDataTask(importService, schemaService, importParams, in, importFormat));
    }
    return SUCCESS;
}
Also used : User(org.hisp.dhis.user.User) TaskId(org.hisp.dhis.scheduling.TaskId) MetadataImportParams(org.hisp.dhis.dxf2.metadata.MetadataImportParams) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ImportMetaDataTask(org.hisp.dhis.importexport.action.util.ImportMetaDataTask) ImportMetaDataCsvTask(org.hisp.dhis.importexport.action.util.ImportMetaDataCsvTask) FileInputStream(java.io.FileInputStream) ImportMetaDataGmlTask(org.hisp.dhis.importexport.action.util.ImportMetaDataGmlTask)

Example 4 with TaskId

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

the class DataIntegrityController method runAsyncDataIntegrity.

//--------------------------------------------------------------------------
// Start asynchronous data integrity task
//--------------------------------------------------------------------------
@PreAuthorize("hasRole('ALL') or hasRole('F_PERFORM_MAINTENANCE')")
@RequestMapping(value = DataIntegrityController.RESOURCE_PATH, method = RequestMethod.POST)
public void runAsyncDataIntegrity(HttpServletResponse response, HttpServletRequest request) {
    TaskId taskId = new TaskId(TaskCategory.DATAINTEGRITY, currentUserService.getCurrentUser());
    notifier.clear(taskId);
    scheduler.executeTask(new DataIntegrityTask(taskId, dataIntegrityService, notifier));
    response.setHeader("Location", ContextUtils.getRootPath(request) + "/system/tasks/" + TaskCategory.DATAINTEGRITY);
    response.setStatus(HttpServletResponse.SC_ACCEPTED);
}
Also used : TaskId(org.hisp.dhis.scheduling.TaskId) DataIntegrityTask(org.hisp.dhis.dataintegrity.tasks.DataIntegrityTask) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with TaskId

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

the class CompleteDataSetRegistrationController method asyncImport.

private void asyncImport(ImportOptions importOptions, String format, HttpServletRequest request, HttpServletResponse response) throws IOException {
    Pair<InputStream, Path> tmpFile = saveTmpFile(request.getInputStream());
    TaskId taskId = new TaskId(TaskCategory.COMPLETE_DATA_SET_REGISTRATION_IMPORT, currentUserService.getCurrentUser());
    scheduler.executeTask(new ImportCompleteDataSetRegistrationsTask(registrationExchangeService, sessionFactory, tmpFile.getLeft(), tmpFile.getRight(), importOptions, format, taskId));
    response.setHeader("Location", ContextUtils.getRootPath(request) + "/system/tasks/" + TaskCategory.COMPLETE_DATA_SET_REGISTRATION_IMPORT);
    response.setStatus(HttpServletResponse.SC_ACCEPTED);
}
Also used : Path(java.nio.file.Path) ImportCompleteDataSetRegistrationsTask(org.hisp.dhis.dxf2.dataset.tasks.ImportCompleteDataSetRegistrationsTask) TaskId(org.hisp.dhis.scheduling.TaskId) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream)

Aggregations

TaskId (org.hisp.dhis.scheduling.TaskId)25 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 InputStream (java.io.InputStream)9 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)9 FileInputStream (java.io.FileInputStream)5 ImportOptions (org.hisp.dhis.dxf2.common.ImportOptions)5 Set (java.util.Set)4 Events (org.hisp.dhis.dxf2.events.event.Events)4 ImportEventsTask (org.hisp.dhis.dxf2.events.event.ImportEventsTask)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 TaskCategory (org.hisp.dhis.scheduling.TaskCategory)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Lists (com.google.common.collect.Lists)2 Sets (com.google.common.collect.Sets)2 ByteSource (com.google.common.io.ByteSource)2 BufferedInputStream (java.io.BufferedInputStream)2 OutputStream (java.io.OutputStream)2