Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge develop into main #242

Merged
merged 19 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/maven-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

name: Pull Request Checks

on:
release:
on: [ pull_request ]
on: [ pull_request ]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven-publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
push:
branches:
- 'main'
- 'dev'
- 'develop'

jobs:
build:
Expand Down
12 changes: 9 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<parent>
<groupId>org.mycore</groupId>
<artifactId>mycore-parent</artifactId>
<version>47</version>
<version>48</version>
<relativePath />
</parent>

<groupId>org.mycore.ubo</groupId>
<artifactId>ubo</artifactId>
<version>prod-SNAPSHOT</version>
<version>dev-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Universitätsbibliographie</name>
Expand Down Expand Up @@ -45,7 +45,7 @@
<MCR.AppName>ubo</MCR.AppName>
<axis1.version>1.4</axis1.version>
<java.target.version>11</java.target.version>
<mycore.version>2021.06.1-SNAPSHOT</mycore.version>
<mycore.version>2021.06.2-SNAPSHOT</mycore.version>
<node.version>v16.0.0</node.version>
<sortpom.sortDeps>scope,groupId,artifactId</sortpom.sortDeps>
<sortpom.sortFile>https://gist.githubusercontent.com/yagee-de/dfd3698c1b49173dbf251f74eb6a9297/raw/406460c088ff3cb6354e4ae6b40535e6f841607d/mycore_sort.xml</sortpom.sortFile>
Expand Down Expand Up @@ -339,6 +339,12 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>highlightjs</artifactId>
<version>11.5.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion ubo-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.mycore.ubo</groupId>
<artifactId>ubo</artifactId>
<version>prod-SNAPSHOT</version>
<version>dev-SNAPSHOT</version>
</parent>
<artifactId>ubo-cli</artifactId>
<packaging>pom</packaging>
Expand Down
6 changes: 5 additions & 1 deletion ubo-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.mycore.ubo</groupId>
<artifactId>ubo</artifactId>
<version>prod-SNAPSHOT</version>
<version>dev-SNAPSHOT</version>
</parent>

<artifactId>ubo-common</artifactId>
Expand Down Expand Up @@ -225,6 +225,10 @@
<groupId>org.mycore</groupId>
<artifactId>mycore-user2</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>highlightjs</artifactId>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
Expand Down
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);
}
}
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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.mycore.access.MCRAccessException;
import org.mycore.common.MCRConstants;
import org.mycore.common.MCRPersistenceException;
import org.mycore.common.MCRSessionMgr;
import org.mycore.common.MCRTransactionHelper;
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.common.content.MCRContent;
import org.mycore.common.content.transformer.MCRContentTransformer;
Expand Down Expand Up @@ -118,7 +118,7 @@ public void transform(Element formInput) throws Exception {

public void saveAndIndex() throws MCRAccessException {
savePublications();
MCRSessionMgr.getCurrentSession().commitTransaction();
MCRTransactionHelper.commitTransaction();
tryToWaitUntilSolrIndexingFinished();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@
<legend>erschienen in:</legend>
<xed:bind xpath="mods:relatedItem[@type='host']">
<xed:choose>
<xed:when test="@xlink:href">
<xed:when test="string-length(@xlink:href) &gt; 0">
<xed:include uri="webapp:import-editor.xed" ref="linked.relatedItem" />
<xed:include uri="webapp:import-editor.xed" ref="volume" />
<xed:include uri="webapp:import-editor.xed" ref="issue" />
<xed:include uri="webapp:import-editor.xed" ref="pages" />
<xed:include uri="webapp:import-editor.xed" ref="article_number" />
</xed:when>
<xed:otherwise>
<xed:include uri="webapp:import-editor.xed" ref="linked.relatedItem" />
<xed:include uri="webapp:import-editor.xed" ref="host" />
<xed:include uri="webapp:import-editor.xed" ref="oa" />
<xed:include uri="webapp:import-editor.xed" ref="title.complex" />
Expand Down
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>
Loading