-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UBO-378 Allow to choose data sources used for enrichment in list impo…
…rt (#446) * UBO-378 Added form elements to import-list.xed for selecting DataSources for enrichment * UBO-378 Allow to handle custom enrichment config ids in DozBibImportServlet and ImportJob * UBO-378 Added toggleDataSources to ImportList.js * UBO-378 Added class EnrichmentConfigMgr to reuse code in ImportListJobAction * UBO-378 Load existing configs via uri resolver and do not cach in enrichmentDebugger.xed * UBO-378 Fixed javadoc * UBO-378 Removed class form-control from select affected by bootstrap-select * UBO-378 Added class attributes to selects * UBO-378 Updated javadoc in EnrichmentConfigMgr * UBO-378 Simplified control flow * UBO-378 Include changes from UBO-372 * UBO-378 Updated col classes for DataSource select and input * UBO-378 Reduce diff * UBO-378 Applied requested changes * UBO-378 Removed form-group class from <div> containing the DataSource select/inputs
- Loading branch information
Showing
10 changed files
with
133 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
ubo-common/src/main/java/org/mycore/ubo/importer/EnrichmentConfigMgr.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. <em>GBV Unpaywall ...</em> is provided. In that case a new | ||
* configuration with id <code>custom</code> is created and the returned id will be <code>custom</code>. | ||
* | ||
* @param formInput the form input (usually provided by import-list.xed) | ||
* | ||
* @return the enricher id or <code>null</code> | ||
*/ | ||
public static String getEnricherId(Element formInput) { | ||
Optional<Element> 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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
exclude-result-prefixes="xsl"> | ||
<xsl:output method="html"/> | ||
|
||
<xsl:template match="/"> | ||
<result> | ||
<xsl:apply-templates select="enrichmentDebugger/enrichers/enricher"> | ||
<xsl:sort select="@id"/> | ||
</xsl:apply-templates> | ||
</result> | ||
</xsl:template> | ||
|
||
<xsl:template match="enricher"> | ||
<option value="{@id}" title="{@id}"> | ||
<xsl:value-of select="text()"/> | ||
</option> | ||
</xsl:template> | ||
</xsl:stylesheet> |