Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  UBO-355 Add more batch editor configuration
  UBO-356 enable classification mapping for destatis classification
  UBO-353 FSU040THUL-4126 Do not copy connection id of the replaced author (#414)
  UBO-354 Omit credentials (to bypass http basic auth) when fetching language classification
  UBO-352 FSU040THUL-1064 Made whole badge indicating duplicates clickable, support English in badge (#413)
  UBO-338 Improved indexing of corresponding author (#406)
  UBO-351 Improved logging in UBOUserByConnectionResolver (#412)
  UBO-350 Set pica2mods version to 2.10 (#411)
  • Loading branch information
kkrebs committed Aug 23, 2024
2 parents f46fce9 + efc0a5c commit 8d3ff58
Show file tree
Hide file tree
Showing 12 changed files with 3,200 additions and 89 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<jquery.version>3.5.1</jquery.version>
<mycore.version>2022.06.3-SNAPSHOT</mycore.version>
<node.version>v16.0.0</node.version>
<pica2mods.version>2.9-SNAPSHOT</pica2mods.version>
<pica2mods.version>2.10</pica2mods.version>
<sortpom.sortDeps>scope,groupId,artifactId</sortpom.sortDeps>
<sortpom.sortFile>https://gist.githubusercontent.com/yagee-de/dfd3698c1b49173dbf251f74eb6a9297/raw/406460c088ff3cb6354e4ae6b40535e6f841607d/mycore_sort.xml</sortpom.sortFile>
<sortpom.sortProps>true</sortpom.sortProps>
Expand Down
889 changes: 838 additions & 51 deletions ubo-cli/src/main/setup/classifications/ORIGIN.xml

Large diffs are not rendered by default.

2,233 changes: 2,233 additions & 0 deletions ubo-cli/src/main/setup/classifications/destatis.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@

package org.mycore.ubo;

import java.util.List;
import java.util.stream.Collectors;

import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.URIResolver;

import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.util.JAXBSource;
import org.apache.logging.log4j.LogManager;
Expand All @@ -35,6 +28,12 @@
import org.mycore.user2.MCRUserManager;
import org.mycore.user2.utils.MCRUserTransformer;

import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.URIResolver;
import java.util.List;
import java.util.stream.Collectors;

/**
* Resolves a User by connection id
*/
Expand All @@ -46,10 +45,18 @@ public class UBOUserByConnectionResolver implements URIResolver {
public Source resolve(String href, String base) throws TransformerException {
String connection_id = href.split(":", 2)[1];
final List<MCRUser> users = MCRUserManager.getUsers("id_connection", connection_id).collect(Collectors.toList());
if(users.size()!=1){
LOGGER.warn("There is a connection ID which has no User in DB {}", connection_id);

int size = users.size();
if (size != 1) {
if (size == 0) {
LOGGER.warn("Connection ID {} has no user in DB", connection_id);
}
if (size > 1) {
LOGGER.warn("Connection ID {} appears multiple times but for different users in DB", connection_id);
}
return new JDOMSource(new Element("null"));
}

final MCRUser user = users.get(0);

try {
Expand All @@ -58,5 +65,4 @@ public Source resolve(String href, String base) throws TransformerException {
throw new TransformerException(e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@

package org.mycore.ubo.basket;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.logging.log4j.LogManager;
Expand All @@ -29,6 +25,10 @@
import org.mycore.ubo.AccessControl;
import org.mycore.ubo.DozBibEntryServlet;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Servlet invoked by edit-contributors.xml to
* change contributor name and pid entries in the basket of bibliography entries
Expand Down Expand Up @@ -99,6 +99,12 @@ private void changeContributorInBasket(NameEntry nameEntryFromBasket, NameEntry
contributor.removeChildren("nameIdentifier", MCRConstants.MODS_NAMESPACE);

for (Element child : nameEntryEdited.getModsName().getChildren()) {
// retain all nameIdentifier elements, except of type 'connection'
String typeAttr = child.getAttributeValue("type");
if ("nameIdentifier".equals(child.getName()) && "connection".equals(typeAttr)) {
continue;
}

if ("namePart".equals(child.getName()) || "nameIdentifier".equals(child.getName())) {
if (!child.getTextTrim().isEmpty()) {
contributor.addContent(child.clone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class LanguageSearchInput {
const baseURL = window['webApplicationBaseURL'];
const response = await fetch(baseURL + 'api/v2/classifications/rfc5646', {
method: 'GET',
credentials: 'omit',
headers: {
'Accept': 'application/json'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,11 @@ ubo.article_number.placeholder = Alternative zur Seitenzahl, z.
ubo.articlenumber = Artikel
ubo.authorlink.local.text = Lokal
ubo.authorlink.local.title = Lokale ID
ubo.badge.duplicate.start = Es gibt eventuell
ubo.badge.duplicate.singular = eine Dublette
ubo.badge.duplicate.plural = {0} Dubletten


ubo.category = Kategorie
ubo.comment = Anmerkungen, Kommentare
ubo.conference = Konferenz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,9 @@ ubo.article_number.placeholder = number of online ar
ubo.articlenumber = Article
ubo.authorlink.local.text = Local
ubo.authorlink.local.title = Local ID
ubo.badge.duplicate.start = There may be
ubo.badge.duplicate.singular = one duplicate
ubo.badge.duplicate.plural = {0} duplicates
ubo.category = Category
ubo.comment = Notes, comments
ubo.conference = Conference
Expand Down
36 changes: 36 additions & 0 deletions ubo-common/src/main/resources/config/ubo-common/mycore.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ MCR.Solr.Proxy.WhiteList=/select,/select2,/uboExport,/statistics
MCR.URIResolver.xslImports.solr-document=solr-basetemplate.xsl,ubo-solr.xsl

MCR.EventHandler.MCRObject.013.Class=org.mycore.mods.MCRExtractRelatedItemsEventHandler
MCR.EventHandler.MCRObject.016.Class=org.mycore.mods.classification.MCRClassificationMappingEventHandler
MCR.EventHandler.MCRObject.018.Class=org.mycore.ubo.dedup.DeDupEventHandler
#MCR.EventHandler.MCRObject.019.Class=org.mycore.ubo.publication.PublicationEventHandler
MCR.EventHandler.MCRObject.040.Class=
Expand Down Expand Up @@ -947,6 +948,41 @@ MCR.BatchEditor.orcid.Path2Add=mods:nameIdentifier[@type="orcid"][text()="{0}"]=
MCR.BatchEditor.scopus.Path2Remove=mods:nameIdentifier[@type="scopus"][text()="{0}"]
MCR.BatchEditor.scopus.Path2Add=mods:nameIdentifier[@type="scopus"][text()="{0}"]="{0}"

# Edit Connection ID (internal UUID to link users to publications)
MCR.BatchEditor.connection.Path2Remove=mods:nameIdentifier[@type="connection"][text()="{0}"]
MCR.BatchEditor.connection.Path2Add=mods:nameIdentifier[@type="connection"][text()="{0}"]="{0}"

# Base URI for classifications
MCR.BatchEditor.ClassificationsBaseURI=https://bibliographie.ub.uni-due.de/classifications/

# Edit ORIGIN category
MCR.BatchEditor.origin.Path2Remove=mods:classification[@valueURI="%MCR.BatchEditor.ClassificationsBaseURI%ORIGIN#{0}"]
MCR.BatchEditor.origin.Path2Add=mods:classification[@authorityURI="%MCR.BatchEditor.ClassificationsBaseURI%ORIGIN"][@valueURI="%MCR.BatchEditor.ClassificationsBaseURI%ORIGIN#{0}"]

# Edit fachreferate category
MCR.BatchEditor.fachreferat.Path2Remove=mods:classification[@valueURI="%MCR.BatchEditor.ClassificationsBaseURI%fachreferate#{0}"]
MCR.BatchEditor.fachreferat.Path2Add=mods:classification[@authorityURI="%MCR.BatchEditor.ClassificationsBaseURI%fachreferate"][@valueURI="%MCR.BatchEditor.ClassificationsBaseURI%fachreferate#{0}"]

# Edit OA classification
MCR.BatchEditor.oa.Path2Remove=mods:classification[@valueURI="%MCR.BatchEditor.ClassificationsBaseURI%oa#{0}"]
MCR.BatchEditor.oa.Path2Add=mods:classification[@authorityURI="%MCR.BatchEditor.ClassificationsBaseURI%oa"][@valueURI="%MCR.BatchEditor.ClassificationsBaseURI%oa#{0}"]

# Edit Access Rights
MCR.BatchEditor.accessrights.Path2Remove=mods:classification[@valueURI="%MCR.BatchEditor.ClassificationsBaseURI%accessrights#{0}"]
MCR.BatchEditor.accessrights.Path2Add=mods:classification[@authorityURI="%MCR.BatchEditor.ClassificationsBaseURI%accessrights"][@valueURI="%MCR.BatchEditor.ClassificationsBaseURI%accessrights#{0}"]

# Edit mods:genre
MCR.BatchEditor.genre.Path2Remove=mods:genre[@type="intern"][@valueURI="%MCR.BatchEditor.ClassificationsBaseURI%ubogenre#{0}"]
MCR.BatchEditor.genre.Path2Add=mods:genre[@type="intern"][@authorityURI="%MCR.BatchEditor.ClassificationsBaseURI%ubogenre"][@valueURI="%MCR.BatchEditor.ClassificationsBaseURI%ubogenre#{0}"]

# Note that adding/removing mods:subject/mods:topic has limitations here:
MCR.BatchEditor.topic.Path2Remove=mods:subject[mods:topic[text()="{0}"]]
MCR.BatchEditor.topic.Path2Add=mods:subject[mods:topic[text()="{0}"]="{0}"]
# "remove" will completely remove the mods:subject,
# if there is any mods:topic below that matches
# "add" will always add a new mods:subject with mods:topic below,
# except there is already any mods:topic with exact that text.

######################################################################
# #
# Primo #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,15 @@
"stored": true
}
},
{
"add-field": {
"name": "origin_text",
"type": "string",
"multiValued": true,
"indexed": true,
"stored": true
}
},
{
"add-field": {
"name": "pages",
Expand Down Expand Up @@ -686,6 +695,15 @@
"stored": true
}
},
{
"add-field": {
"name": "destatis",
"type": "ubo_id",
"multiValued": true,
"indexed": true,
"stored": true
}
},
{
"add-dynamic-field": {
"name": "host_id_*",
Expand Down
25 changes: 12 additions & 13 deletions ubo-common/src/main/resources/xsl/mycoreobject.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,8 @@

<xsl:if test="$numlinks &gt; 0">
<span class="badge badge-alternative mr-1">
<xsl:value-of select="i18n:translate('ubo.relatedItem.link')"/>
<xsl:text>: </xsl:text>
<a href="solr/select?q=link:{/mycoreobject/@ID}&amp;sort=year+desc">
<xsl:value-of select="$numlinks" />
<xsl:text> </xsl:text>
<xsl:value-of select="i18n:translate('ubo.relatedItem.host.contains.publications')"/>
<xsl:value-of select="concat(i18n:translate('ubo.relatedItem.link'),': ', $numlinks, ' ', i18n:translate('ubo.relatedItem.host.contains.publications'))"/>
</a>
</span>
</xsl:if>
Expand Down Expand Up @@ -285,16 +281,19 @@

<xsl:if test="$numDuplicates &gt; 0">
<span class="badge badge-alternative ml-1 mr-1">
<xsl:text>Es gibt eventuell </xsl:text>
<a href="{$ServletsBaseURL}DozBibEntryServlet?id={/mycoreobject/@ID}&amp;XSL.Style=structure">
<xsl:choose>
<xsl:when test="$numDuplicates = 1">eine Dublette</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($numDuplicates,' Dubletten')" />
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="extro">
<xsl:choose>
<xsl:when test="$numDuplicates = 1">
<xsl:value-of select="i18n:translate('ubo.badge.duplicate.singular')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="i18n:translate('ubo.badge.duplicate.plural', $numDuplicates)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat(i18n:translate('ubo.badge.duplicate.start'), ' ', $extro, '.')"/>
</a>
<xsl:text>.</xsl:text>
</span>
</xsl:if>

Expand Down
37 changes: 27 additions & 10 deletions ubo-common/src/main/resources/xsl/ubo-solr.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

<xsl:import href="xslImport:solr-document:ubo-solr.xsl" />
<xsl:include href="coreFunctions.xsl"/>

<xsl:key use="substring-after(@valueURI,'#')" name="destatisByCategory" match="//mods:mods/mods:classification[contains(@authorityURI,'destatis')]"></xsl:key>
<xsl:variable name="origin" select="document('classification:metadata:-1:children:ORIGIN')/mycoreclass/categories" />

<xsl:template match="mycoreobject">
<xsl:apply-templates select="." mode="baseFields" />
Expand All @@ -36,6 +39,7 @@
<xsl:apply-templates select="descendant::mods:name[mods:nameIdentifier[@type='lsf']]" mode="solrField.lsf" />
<xsl:apply-templates select="mods:name[@type='personal'][mods:role/mods:roleTerm[@type='code'][contains('aut cre tch pht prg edt',text())]]/mods:nameIdentifier[@type='lsf']" mode="solrField.ae" />
<xsl:apply-templates select="mods:name[@type='personal'][mods:role/mods:roleTerm[@type='code'][contains('aut cre tch pht prg edt',text())]]/mods:nameIdentifier[@type='orcid']" mode="solrField.ae" />
<xsl:apply-templates select="mods:name[@type='personal'][mods:role/mods:roleTerm[contains(@authorityURI,'author_roles')]]" mode="solrField.ar" />
<xsl:apply-templates select="descendant::mods:name[@type='personal']" mode="child" />
<xsl:apply-templates select="mods:genre[@type='intern']" mode="solrField" />
<xsl:apply-templates select="mods:accessCondition[@xlink:href]" mode="solrField" />
Expand Down Expand Up @@ -66,6 +70,7 @@
<xsl:call-template name="oa" />
<xsl:call-template name="partOf" />
<xsl:call-template name="year" />
<xsl:call-template name="destatis" />
</xsl:template>

<xsl:template name="sortby_person">
Expand Down Expand Up @@ -159,18 +164,18 @@
<field name="person_{text()}">
<xsl:apply-templates select="../.." mode="solrField" />
</field>
</xsl:template>

<xsl:if test="../mods:roleTerm/text() = 'corresponding_author'">
<field name="corresponding_aut">
<xsl:apply-templates select="../.." mode="solrField"/>
</field>
<xsl:template match="mods:name[@type='personal'][mods:role/mods:roleTerm[contains(@authorityURI,'author_roles')]]" mode="solrField.ar">
<field name="corresponding_aut">
<xsl:apply-templates select="." mode="solrField"/>
</field>

<xsl:for-each select="../../mods:nameIdentifier">
<field name="corresponding_aut_id">
<xsl:value-of select="."/>
</field>
</xsl:for-each>
</xsl:if>
<xsl:for-each select="mods:nameIdentifier"><!-- TODO: besser nur connection-ID bzw. 2 Suchfelder? -->
<field name="corresponding_aut_id">
<xsl:value-of select="."/>
</field>
</xsl:for-each>
</xsl:template>

<xsl:template match="mods:name[@type='personal']" mode="solrField">
Expand Down Expand Up @@ -262,6 +267,9 @@
<field name="origin_exact">
<xsl:value-of select="$category" />
</field>
<field name="origin_text">
<xsl:value-of select="$origin//category[@ID=$category]/label[lang($DefaultLang)]/@text"/>
</field>

<!-- Derive destatis from origin if fachreferate is not set -->
<xsl:if test="not (../mods:classification[contains(@authorityURI,'fachreferate')])">
Expand Down Expand Up @@ -344,6 +352,15 @@
</field>
</xsl:template>

<xsl:template name="destatis">
<!-- to avoid duplicates, only use first occurence of each destatis category -->
<xsl:for-each select="mods:classification[contains(@authorityURI,'destatis')][generate-id() = generate-id(key('destatisByCategory',substring-after(@valueURI,'#'))[1])]">
<field name="destatis">
<xsl:value-of select="substring-after(@valueURI,'#')"/>
</field>
</xsl:for-each>
</xsl:template>

<xsl:template name="partOf">
<xsl:choose>
<xsl:when test="mods:classification[contains(@authorityURI,'partOf')]">
Expand Down

0 comments on commit 8d3ff58

Please sign in to comment.