-
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.
* develop: UBO-212 improve contrast of input placeholders UBO-197 fix attribute check and always show option to linked.relatedItem (#254) UBO-211 Allow to linked catalog in mods-display.xsl to be customizable UBO-209 fix xpath for dateIssued, old version matches other mods in UBO-210 add minPointLength configuration to also show minimal values UBO-207 Allow to further restrict access to single items... (#252) Fix dependency scope Fix pom sort Change version of children to dev-SNAPSHOT Change version to dev-SNAPSHOT Fix workflow file Sort identifiers by type issues/UBO-201-provide-enrichment-debugger (#241) UBO-204 Bug fixes for input forms UBO-205 Order importlist by date not by name (#247) Group delete/cancel delete buttons in a button group Added class 'mb-2' to <article> containing recently imported lists UBO-202 ThULB/ThUniBib#210 Display link to dbt when possible UBO-199 update to mycore 2021.06.2 snapshot
- Loading branch information
Showing
25 changed files
with
1,492 additions
and
959 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,7 @@ | |
|
||
name: Pull Request Checks | ||
|
||
on: | ||
release: | ||
on: [ pull_request ] | ||
on: [ pull_request ] | ||
|
||
jobs: | ||
build: | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
push: | ||
branches: | ||
- 'main' | ||
- 'dev' | ||
- 'develop' | ||
|
||
jobs: | ||
build: | ||
|
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
65 changes: 65 additions & 0 deletions
65
ubo-common/src/main/java/org/mycore/mods/enrichment/EnrichmentConfigResolver.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,65 @@ | ||
package org.mycore.mods.enrichment; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Map.Entry; | ||
|
||
import javax.xml.transform.Source; | ||
import javax.xml.transform.TransformerException; | ||
import javax.xml.transform.URIResolver; | ||
|
||
import org.jdom2.Element; | ||
import org.jdom2.transform.JDOMSource; | ||
import org.mycore.common.config.MCRConfiguration2; | ||
|
||
/** | ||
* URI Resolver that returns the enrichment resolver configuration | ||
* defined in mycore.properties, as XML to be read in enrichmentDebugger.xed | ||
* | ||
* @author Frank Lützenkirchen | ||
**/ | ||
public class EnrichmentConfigResolver implements URIResolver { | ||
|
||
private static final String CONFIG_PREFIX = "MCR.MODS.EnrichmentResolver."; | ||
|
||
@Override | ||
public Source resolve(String href, String base) throws TransformerException { | ||
String selectedDefault = href.substring(href.indexOf(":") + 1); | ||
|
||
Element enrichmentDebugger = new Element("enrichmentDebugger"); | ||
Element enrichers = new Element("enrichers").setAttribute("selected", selectedDefault); | ||
enrichmentDebugger.addContent(enrichers); | ||
|
||
Map<String, String> config = MCRConfiguration2.getSubPropertiesMap(CONFIG_PREFIX + "DataSources."); | ||
Map<String, Element> dataSourceMap = new HashMap<String, Element>(); | ||
|
||
for (Entry<String, String> configLine : config.entrySet()) { | ||
String id = configLine.getKey(); | ||
String dataSources = configLine.getValue(); | ||
|
||
Element enricher = new Element("enricher"); | ||
enricher.setAttribute("id", id).setText(dataSources); | ||
enrichers.addContent(enricher); | ||
|
||
for (String dataSourceID : dataSources.split("[\\s+\\(\\)]")) { | ||
if (!(dataSourceMap.containsKey(dataSourceID) || dataSourceID.isEmpty())) { | ||
String configProperty = CONFIG_PREFIX + "DataSource." + dataSourceID + ".IdentifierTypes"; | ||
String identifiers = MCRConfiguration2.getStringOrThrow(configProperty); | ||
|
||
Element dsXml = new Element("dataSource"); | ||
dsXml.setAttribute("id", dataSourceID); | ||
dsXml.setText(identifiers); | ||
dataSourceMap.put(dataSourceID, dsXml); | ||
} | ||
} | ||
} | ||
|
||
Element dataSources = new Element("dataSources"); | ||
dataSourceMap.entrySet() | ||
.stream().sorted((ds1, ds2) -> ds1.getKey().compareTo(ds2.getKey())) | ||
.forEach(entry -> dataSources.addContent(entry.getValue())); | ||
enrichmentDebugger.addContent(dataSources); | ||
|
||
return new JDOMSource(enrichmentDebugger); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
ubo-common/src/main/java/org/mycore/mods/enrichment/EnrichmentDebuggerServlet.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,60 @@ | ||
package org.mycore.mods.enrichment; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.jdom2.Document; | ||
import org.jdom2.Element; | ||
import org.mycore.common.MCRConstants; | ||
import org.mycore.common.config.MCRConfiguration2; | ||
import org.mycore.common.content.MCRJDOMContent; | ||
import org.mycore.frontend.servlets.MCRServlet; | ||
import org.mycore.frontend.servlets.MCRServletJob; | ||
import org.mycore.ubo.AccessControl; | ||
|
||
/** | ||
* Backend of enrichmentDebugger.xed: | ||
* Takes mods:mods and selected enrichment resolver configuration. | ||
* Returns enrichment resolver debugging output to be rendered by debugEnrichment.xsl | ||
* | ||
* @author Frank Lützenkirchen | ||
**/ | ||
@SuppressWarnings("serial") | ||
public class EnrichmentDebuggerServlet extends MCRServlet { | ||
|
||
public void doGetPost(MCRServletJob job) throws Exception { | ||
HttpServletRequest req = job.getRequest(); | ||
HttpServletResponse res = job.getResponse(); | ||
|
||
if (!AccessControl.currentUserIsAdmin()) { | ||
res.sendError(HttpServletResponse.SC_FORBIDDEN); | ||
return; | ||
} | ||
|
||
Document doc = (Document) req.getAttribute("MCRXEditorSubmission"); | ||
Element root = doc.getRootElement(); | ||
|
||
Element choosenEnricher = root.getChild("enrichers").getChild("enricher"); | ||
String enricherID = choosenEnricher.getAttributeValue("id"); | ||
|
||
if ("custom".equals(enricherID)) { | ||
// Do ad-hoc configuration of a custom enrichment resolver | ||
String propertyName = "MCR.MODS.EnrichmentResolver.DataSources." + enricherID; | ||
MCRConfiguration2.set(propertyName, choosenEnricher.getTextTrim()); | ||
} | ||
|
||
MCREnricher enricher = new MCREnricher(enricherID); | ||
|
||
MCRToXMLEnrichmentDebugger debugger = new MCRToXMLEnrichmentDebugger(); | ||
enricher.setDebugger(debugger); | ||
|
||
Element mods = root.getChild("mods", MCRConstants.MODS_NAMESPACE).detach(); | ||
enricher.enrich(mods); | ||
|
||
Element output = debugger.getDebugXML(); | ||
output.addContent(0, choosenEnricher.detach()); | ||
output.addContent(new Element("result").addContent(mods)); | ||
|
||
getLayoutService().doLayout(req, res, new MCRJDOMContent(output)); | ||
} | ||
} |
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
146 changes: 146 additions & 0 deletions
146
ubo-common/src/main/resources/META-INF/resources/enrichmentDebugger.xed
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,146 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
Frontend of enrichment debugger: | ||
Form to select enrichment resolver configuration and input mods:mods. | ||
Sends input to EnrichmentDebuggerServlet to run and display debug output. | ||
--> | ||
|
||
<webpage id="ubo.enrichmentDebugger"> | ||
<title xml:lang="de">Enrichment Resolver Debugger</title> | ||
|
||
<article class="card mb-1"> | ||
<div class="card-body"> | ||
<xed:form xmlns:xed="http://www.mycore.de/xeditor" method="post" role="form"> | ||
|
||
<xed:source uri="cache:enrichmentConfig:custom" /> | ||
|
||
<xed:bind xpath="enrichmentDebugger"> | ||
|
||
<xed:include uri="webapp:import-editor.xed" ref="displayValidationMessages" /> | ||
|
||
<fieldset> | ||
<legend>Zu verwendende Enrichment Resolver Konfiguration:</legend> | ||
|
||
<xed:bind xpath="enrichers"> | ||
<xed:bind xpath="enricher[@id='custom']" /> <!-- Empty placeholder for custom enrichment --> | ||
|
||
<xed:repeat xpath="enricher"> | ||
<div class="form-group form-inline"> | ||
<label class="mycore-form-label"> | ||
<xed:output value="@id" /> | ||
|
||
<!-- Workaround to choose the ID via radio buttons: --> | ||
<!-- 1. Remember the current enricher/@id in a variable --> | ||
<!-- 2. Bind to a common parent's attribute so all radio buttons get same name --> | ||
<xed:bind xpath="@id" name="id" /> | ||
<xed:bind xpath="../@selected"> | ||
<input type="radio" value="{$id}" class="ml-2" style="transform:scale(1.5);" /> | ||
</xed:bind> | ||
|
||
</label> | ||
<xed:choose> | ||
<xed:when test="@id='custom'"> | ||
<input type="text" class="mycore-form-input {$xed-validation-marker}" style="flex: 0 0 70%; max-width: 70%;" /> | ||
</xed:when> | ||
<xed:otherwise> | ||
<input type="text" class="mycore-form-input" style="flex: 0 0 70%; max-width: 70%;" disabled="disabled" /> | ||
</xed:otherwise> | ||
</xed:choose> | ||
|
||
</div> | ||
</xed:repeat> | ||
|
||
<xed:validate xpath="/enrichmentDebugger/enrichers/@selected" required="true" display="global">Bitte eine Enrichment Resolver Konfiguration wählen!</xed:validate> | ||
<xed:validate xpath="/enrichmentDebugger/enrichers/enricher[@id='custom']" relevant-if="/enrichmentDebugger/enrichers/@selected='custom'" required="true" display="global">Bitte IDs der Datenquellen eingeben!</xed:validate> | ||
|
||
<!-- Remove those enrichment resolver configs that have not been selected --> | ||
<xed:cleanup-rule xpath="/enrichmentDebugger/enrichers/enricher" relevant-if="@id=../@selected" /> | ||
|
||
</xed:bind> | ||
|
||
</fieldset> | ||
|
||
<fieldset class="mt-4"> | ||
<legend>Aufzulösende Identifier als Ausgangsbasis:</legend> | ||
|
||
<xed:bind xpath="mods:mods"> | ||
|
||
<xed:bind xpath="mods:identifier"> | ||
|
||
<div class="form-group form-inline"> | ||
|
||
<div class="mycore-form-label"> | ||
<xed:bind xpath="@type" default="doi"> | ||
<select class="form-control w-100 custom-select"> | ||
<option value="doi">DOI (10. ...):</option> | ||
<option value="urn">URN (urn:nbn:de: ...):</option> | ||
<option value="issn">ISSN:</option> | ||
<option value="isbn">ISBN:</option> | ||
<option value="pubmed">PubMed ID:</option> | ||
<option value="scopus">Scopus ID:</option> | ||
<option value="arxiv">arXiv.org:</option> | ||
<option value="ieee">IEEE Explore:</option> | ||
<option value="isi">Web of Science ID:</option> | ||
<option value="duepublico2">DuEPublico 2 ID:</option> | ||
<option value="mms">Alma MMS ID:</option> | ||
<option value="ppn">PPN:</option> | ||
<option value="zdb">ZDB ID:</option> | ||
</select> | ||
</xed:bind> | ||
</div> | ||
|
||
<input type="text" class="mycore-form-input {$xed-validation-marker}" /> | ||
</div> | ||
</xed:bind> | ||
|
||
<xed:include uri="webapp:import-editor.xed" ref="validationRules4Identifiers" /> | ||
|
||
<xed:bind xpath="mods:location/mods:shelfLocator"> | ||
<div class="form-group form-inline"> | ||
<label class="mycore-form-label">Signatur der UB:</label> | ||
<input type="text" class="mycore-form-input {$xed-validation-marker}" /> | ||
</div> | ||
</xed:bind> | ||
|
||
</xed:bind> | ||
|
||
</fieldset> | ||
|
||
<div class="form-inline form-group mb-4"> | ||
<label class="mycore-form-label" /> | ||
<button class="btn btn-sm btn-primary mr-2" type="submit" xed:target="servlet" xed:href="EnrichmentDebuggerServlet"> | ||
<xed:output i18n="button.submit" /> | ||
</button> | ||
<button class="ml-2 btn btn-sm btn-primary" type="submit" xed:target="debug">Debug</button> | ||
</div> | ||
|
||
<!-- List all supported data sources and identifiers --> | ||
<xed:bind xpath="dataSources"> | ||
<table class="table table-sm table-hover mt-4"> | ||
<thead> | ||
<th class="text-right" scope="col">Datenquelle</th> | ||
<th scope="col">Unterstütze Identifier</th> | ||
</thead> | ||
<tbody> | ||
<xed:repeat xpath="dataSource"> | ||
<tr> | ||
<th class="text-right" scope="row"> | ||
<xed:output value="@id" /> | ||
</th> | ||
<td> | ||
<xed:output value="text()" /> | ||
</td> | ||
</tr> | ||
</xed:repeat> | ||
</tbody> | ||
</table> | ||
</xed:bind> | ||
|
||
</xed:bind> | ||
|
||
</xed:form> | ||
</div> | ||
</article> | ||
|
||
</webpage> |
Oops, something went wrong.