use of org.hisp.dhis.importexport.action.util.ImportMetaDataCsvTask 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;
}
Aggregations