diff --git a/ubo-common/src/main/java/org/mycore/ubo/importer/DozBibImportServlet.java b/ubo-common/src/main/java/org/mycore/ubo/importer/DozBibImportServlet.java index 219f1051..9fb9affe 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/importer/DozBibImportServlet.java +++ b/ubo-common/src/main/java/org/mycore/ubo/importer/DozBibImportServlet.java @@ -74,7 +74,12 @@ private void handleImportJob(HttpServletRequest req, HttpServletResponse res) th boolean enrich = "true".equals(formInput.getAttributeValue("enrich")); if (enrich) { - importJob.enrich(); + String enricherId = EnrichmentConfigMgr.getEnricherId(formInput); + if (enricherId != null) { + importJob.enrich(enricherId); + } else { + importJob.enrich(); + } } String targetType = formInput.getAttributeValue("targetType"); 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 new file mode 100644 index 00000000..89f0c039 --- /dev/null +++ b/ubo-common/src/main/java/org/mycore/ubo/importer/EnrichmentConfigMgr.java @@ -0,0 +1,48 @@ +package org.mycore.ubo.importer; + +import org.jdom2.Element; +import org.mycore.common.config.MCRConfiguration2; + +import java.util.Optional; + +/** + * Class retrieves the enricher id from the form input of import-list.xed. + * + * @author shermann (Silvio Hermann) + */ +public class EnrichmentConfigMgr { + static final String DEFAULT_CONFIG_ID = "custom"; + + private EnrichmentConfigMgr() { + } + + /** + * Retrieves the enricher id from the import list form element. + * If the value of the DataSource element is a valid enrichment config id that id is returned. Otherwise, + * it assumed a list of enrichment sources e.g. GBV Unpaywall ... is provided. In that case a new + * configuration with id custom is created and the returned id will be custom. + * + * @param formInput the form input (usually provided by import-list.xed) + * + * @return the enricher id or null + */ + public static String getEnricherId(Element formInput) { + Optional dataSource = formInput.getChildren("DataSources") + .stream() + .filter(element -> !element.getText().isEmpty()) + .findFirst(); + + 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; + } + } +} diff --git a/ubo-common/src/main/java/org/mycore/ubo/importer/ImportJob.java b/ubo-common/src/main/java/org/mycore/ubo/importer/ImportJob.java index a3f1fdef..327246d9 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/importer/ImportJob.java +++ b/ubo-common/src/main/java/org/mycore/ubo/importer/ImportJob.java @@ -81,6 +81,13 @@ public void transform(MCRContent source) throws IOException, JDOMException, SAXE } } + public void enrich(String configId){ + for (Document publication : publications) { + MCREnricher enricher = new MCREnricher(configId); + enricher.enrich(getContainedMODS(publication)); + } + } + public void enrich() { for (Document publication : publications) { MCREnricher enricher = new MCREnricher(ENRICHER_CONFIG_ID); diff --git a/ubo-common/src/main/java/org/mycore/ubo/importer/ImportListJobAction.java b/ubo-common/src/main/java/org/mycore/ubo/importer/ImportListJobAction.java index 54e23c3c..2379aaaa 100644 --- a/ubo-common/src/main/java/org/mycore/ubo/importer/ImportListJobAction.java +++ b/ubo-common/src/main/java/org/mycore/ubo/importer/ImportListJobAction.java @@ -61,7 +61,12 @@ public void execute() throws ExecutionException { job.setParameter(IMPORT_JOB_ID_PARAMETER, importJob.getID()); if ("true".equals(formInput.getAttributeValue("enrich"))) { - importJob.enrich(); + String enricherId = EnrichmentConfigMgr.getEnricherId(formInput); + if (enricherId != null) { + importJob.enrich(enricherId); + } else { + importJob.enrich(); + } } try { @@ -80,7 +85,7 @@ private void sendMail(ImportJob importJob) { String userName = job.getParameter(ImportListJobAction.USER_ID_PARAMETER); MCRUser mcrUser = MCRUserManager.getUser(userName); - if(mcrUser == null) { + if (mcrUser == null) { LOGGER.error("User {} not found", userName); return; } diff --git a/ubo-common/src/main/resources/META-INF/resources/enrichmentDebugger.xed b/ubo-common/src/main/resources/META-INF/resources/enrichmentDebugger.xed index da2ef9e9..7f30c7b7 100644 --- a/ubo-common/src/main/resources/META-INF/resources/enrichmentDebugger.xed +++ b/ubo-common/src/main/resources/META-INF/resources/enrichmentDebugger.xed @@ -13,7 +13,7 @@ - + diff --git a/ubo-common/src/main/resources/META-INF/resources/import-list.xed b/ubo-common/src/main/resources/META-INF/resources/import-list.xed index 2f2b016c..14f55627 100644 --- a/ubo-common/src/main/resources/META-INF/resources/import-list.xed +++ b/ubo-common/src/main/resources/META-INF/resources/import-list.xed @@ -55,7 +55,7 @@ - + : @@ -69,7 +69,7 @@ - + : @@ -85,7 +85,7 @@ - + : @@ -100,7 +100,7 @@ - + : @@ -137,6 +137,26 @@ + + + : + + + + + + + + + + + + + + + + + diff --git a/ubo-common/src/main/resources/META-INF/resources/js/ImportList.js b/ubo-common/src/main/resources/META-INF/resources/js/ImportList.js index a19a5135..a05660c2 100644 --- a/ubo-common/src/main/resources/META-INF/resources/js/ImportList.js +++ b/ubo-common/src/main/resources/META-INF/resources/js/ImportList.js @@ -8,7 +8,7 @@ $(document).ready(function () { width:'auto', dropupAuto: false }); - + }); const UBOImportList = { @@ -41,5 +41,21 @@ const UBOImportList = { } else { $("#submitBtn").removeAttr("disabled"); } + }, + + toggleDataSources: function (element) { + switch (element.id) { + case "datasource-input-custom": + if (element.value != null && element.value.length > 0) { + document.getElementById('datasource-source-select').selectedIndex = 0; + } + break; + + case "datasource-source-select": + if (element.value != null && element.value.length > 0) { + document.getElementById('datasource-input-custom').value = ""; + } + break; + } } } diff --git a/ubo-common/src/main/resources/config/ubo-common/messages_de.properties b/ubo-common/src/main/resources/config/ubo-common/messages_de.properties index 428efb48..8a48be29 100644 --- a/ubo-common/src/main/resources/config/ubo-common/messages_de.properties +++ b/ubo-common/src/main/resources/config/ubo-common/messages_de.properties @@ -1054,9 +1054,11 @@ ubo.import.list.email.body = Liebe Kollegin, lieber Kollege ubo.import.list.email.subject = Listenimport vom {0} abgeschlossen ubo.import.list.form.headline = Literaturliste importieren ubo.import.list.label.async = Import nebenl\u00E4ufig ausf\u00FChren +ubo.import.list.label.dataSources = Datenquellen ubo.import.list.label.enrich = aus externen Datenquellen anreichern ubo.import.list.label.outputFormat = Ausgabeformat ubo.import.list.label.sourceFormat = Quellformat +ubo.import.list.placeholder.dataSources.custom = eigene Angaben, z.B. GBV Unpaywall \u2026 ubo.import.list.submission.success = Ein Importauftrag wurde im System angelegt. Sobald dieser abgearbeitet wurde, erhalten Sie eine E-Mail an die in Ihrem Profil hinterlegte Adresse. ubo.import.list.textarea.placeholder = BibTeX Quellcode bzw. ORCID bzw. PPN/CSV-Literaturliste hierhin kopieren ubo.import.list.tooltip.async = Wenn Sie hier den Haken setzen, wird Ihr Importauftrag ansynchron ausgef\u00FChrt. Das bedeutet, Sie werden nicht unmittelbar zur Ergebnisanzeige weitergeleitet sondern erhalten eine Benachrichtigungs-E-Mail, wenn der Import abgeschlossen ist. Setzen Sie den Haken, wenn Sie eine gro\u00DFe Menge an Publikationen \u00FCber IDs importieren wollen. diff --git a/ubo-common/src/main/resources/config/ubo-common/messages_en.properties b/ubo-common/src/main/resources/config/ubo-common/messages_en.properties index 1f15b778..38f3a894 100644 --- a/ubo-common/src/main/resources/config/ubo-common/messages_en.properties +++ b/ubo-common/src/main/resources/config/ubo-common/messages_en.properties @@ -1040,9 +1040,11 @@ ubo.import.list.email.body = Dear colleague,\n\n ubo.import.list.email.subject = List import from {} completed ubo.import.list.form.headline = Import bibliography ubo.import.list.label.async = Run import concurrently +ubo.import.list.label.dataSources = Data Sources ubo.import.list.label.enrich = enrich from external data sources ubo.import.list.label.outputFormat = Output format ubo.import.list.label.sourceFormat = Source format +ubo.import.list.placeholder.dataSources.custom = custom settings e.g. GBV Unpaywall \u2026 ubo.import.list.submission.success = An import job has been created in the system. As soon as this has been processed, you will receive an email to the address stored in your user profile. ubo.import.list.textarea.placeholder = Copy BibTeX source code or ORCID or PPN/CSV bibliography here ubo.import.list.tooltip.async = If you tick this box, your import job will be carried out asynchronously. This means that you will not be redirected to the results display immediately, but will receive a notification email when the import is completed. Tick this box if you want to import a large number of publications using IDs. diff --git a/ubo-common/src/main/resources/xsl/enrichers2options.xsl b/ubo-common/src/main/resources/xsl/enrichers2options.xsl new file mode 100644 index 00000000..f4cd37d0 --- /dev/null +++ b/ubo-common/src/main/resources/xsl/enrichers2options.xsl @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + +
custom
null