use of org.hisp.dhis.preheat.PreheatMode in project dhis2-core by dhis2.
the class DefaultMetadataImportService method getParamsFromMap.
@Override
@Transactional(readOnly = true)
public MetadataImportParams getParamsFromMap(Map<String, List<String>> parameters) {
MetadataImportParams params = new MetadataImportParams();
if (params.getUser() == null) {
params.setUser(currentUserService.getCurrentUser());
}
params.setSkipSharing(getBooleanWithDefault(parameters, "skipSharing", false));
params.setSkipTranslation(getBooleanWithDefault(parameters, "skipTranslation", false));
params.setSkipValidation(getBooleanWithDefault(parameters, "skipValidation", false));
params.setUserOverrideMode(getEnumWithDefault(UserOverrideMode.class, parameters, "userOverrideMode", UserOverrideMode.NONE));
params.setImportMode(getEnumWithDefault(ObjectBundleMode.class, parameters, "importMode", ObjectBundleMode.COMMIT));
params.setPreheatMode(getEnumWithDefault(PreheatMode.class, parameters, "preheatMode", PreheatMode.REFERENCE));
params.setIdentifier(getEnumWithDefault(PreheatIdentifier.class, parameters, "identifier", PreheatIdentifier.UID));
params.setImportStrategy(getEnumWithDefault(ImportStrategy.class, parameters, "importStrategy", ImportStrategy.CREATE_AND_UPDATE));
params.setAtomicMode(getEnumWithDefault(AtomicMode.class, parameters, "atomicMode", AtomicMode.ALL));
params.setMergeMode(getEnumWithDefault(MergeMode.class, parameters, "mergeMode", MergeMode.REPLACE));
params.setFlushMode(getEnumWithDefault(FlushMode.class, parameters, "flushMode", FlushMode.AUTO));
params.setImportReportMode(getEnumWithDefault(ImportReportMode.class, parameters, "importReportMode", ImportReportMode.ERRORS));
params.setFirstRowIsHeader(getBooleanWithDefault(parameters, "firstRowIsHeader", true));
if (getBooleanWithDefault(parameters, "async", false)) {
JobConfiguration jobId = new JobConfiguration("metadataImport", JobType.METADATA_IMPORT, params.getUser().getUid(), true);
notifier.clear(jobId);
params.setId(jobId);
}
if (params.getUserOverrideMode() == UserOverrideMode.SELECTED) {
User overrideUser = null;
if (parameters.containsKey("overrideUser")) {
List<String> overrideUsers = parameters.get("overrideUser");
overrideUser = manager.get(User.class, overrideUsers.get(0));
}
if (overrideUser == null) {
throw new MetadataImportException("UserOverrideMode.SELECTED is enabled, but overrideUser parameter does not point to a valid user.");
} else {
params.setOverrideUser(overrideUser);
}
}
return params;
}
Aggregations