Don't base the use of id mappings on hardcoded provenance

There will be more sources that need id mappings.
Just use them if defined.
This commit is contained in:
Michał Politowski 2024-09-18 09:52:49 +02:00
parent b8b83e3d74
commit be43e73e5d
1 changed files with 3 additions and 3 deletions

View File

@ -134,9 +134,9 @@ public class BulkImportServiceImpl implements BulkImportService {
bulkImportReport.addEvent(msg);
fileUtils.writeToFile(bulkImportReportLocation, bulkImportReport.getJsonReport(), false);
// If we have "provenance" = "springerImport", then we have to load the file-id-mappings.
// load the file-id-mappings if defined
final ConcurrentHashMap<String, String> idMappings;
if ( provenance.equals("springerImport") ) {
if ( bulkImportSource.getIdMappingFilePath() != null ) {
idMappings = jsonUtils.loadIdMappings(bulkImportDirName + bulkImportSource.getIdMappingFilePath(), numOfFiles, additionalLoggingMsg);
if ( idMappings == null ) {
String errorMsg = "Could not load the file-id-mappings! As a result, the OpenAIRE-IDs cannot be generated!";
@ -441,7 +441,7 @@ public class BulkImportServiceImpl implements BulkImportService {
String fileLocation = docFileData.getLocation();
FileLocationData fileLocationData = null;
String fileId;
if ( provenance.equals("springerImport") ) {
if ( idMappings != null ) {
String relativeFileLocation = StringUtils.replace(fileLocation, bulkImportDirName, "", 1);
if ( (fileId = idMappings.get(relativeFileLocation)) == null ) { // Take the "DOI" id matching to this file-ID.
logger.error("File '" + fileLocation + "' could not have its relative-path (" + relativeFileLocation + ") mapped with an ID!" + additionalLoggingMsg);