From 6f3fb3e3ac55f3e188f804393d94ef035a85177c Mon Sep 17 00:00:00 2001 From: Silvio Hermann Date: Fri, 6 Dec 2024 10:56:38 +0100 Subject: [PATCH] UBO-378 Simplified control flow --- .../ubo/importer/EnrichmentConfigMgr.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/ubo-common/src/main/java/org/mycore/ubo/importer/EnrichmentConfigMgr.java b/ubo-common/src/main/java/org/mycore/ubo/importer/EnrichmentConfigMgr.java index f2c2ee57..89f0c039 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/importer/EnrichmentConfigMgr.java +++ b/ubo-common/src/main/java/org/mycore/ubo/importer/EnrichmentConfigMgr.java @@ -32,18 +32,17 @@ public static String getEnricherId(Element formInput) { .filter(element -> !element.getText().isEmpty()) .findFirst(); - String enrchrIdOrEnrchmntSrcs = dataSource.isPresent() ? dataSource.get().getText() : null; - if (enrchrIdOrEnrchmntSrcs != null) { - if (MCRConfiguration2 - .getString("MCR.MODS.EnrichmentResolver.DataSources." + enrchrIdOrEnrchmntSrcs) - .isPresent()) { - return enrchrIdOrEnrchmntSrcs; - } else { - String property = "MCR.MODS.EnrichmentResolver.DataSources." + DEFAULT_CONFIG_ID; - MCRConfiguration2.set(property, dataSource.get().getText()); - return DEFAULT_CONFIG_ID; - } + if (dataSource.isEmpty()) { + return null; + } + + String dataSrcTxt = dataSource.get().getText(); + if (MCRConfiguration2.getString("MCR.MODS.EnrichmentResolver.DataSources." + dataSrcTxt).isPresent()) { + return dataSrcTxt; + } else { + String property = "MCR.MODS.EnrichmentResolver.DataSources." + DEFAULT_CONFIG_ID; + MCRConfiguration2.set(property, dataSrcTxt); + return DEFAULT_CONFIG_ID; } - return null; } }