Skip to content

Commit

Permalink
FSU040THUL-5393 #650 Allow to indicate actual affiliation of author a…
Browse files Browse the repository at this point in the history
…t time of publication (#651)

* FSU040THUL-5393 #650 Allow to indicate actual affiliation of author at time of publication

* FSU040THUL-5393 #650 Disabled ThUniBibAffiliationEventHandler
  • Loading branch information
Possommi authored Dec 2, 2024
1 parent d24cea9 commit 5b0fc00
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package de.uni_jena.thunibib.common.events;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.filter.Filters;
import org.jdom2.xpath.XPathExpression;
import org.mycore.common.events.MCREvent;
import org.mycore.common.events.MCREventHandlerBase;
import org.mycore.datamodel.metadata.MCRMetaElement;
import org.mycore.datamodel.metadata.MCRObject;

import java.util.List;

import static org.mycore.common.MCRConstants.MODS_NAMESPACE;
import static org.mycore.common.MCRConstants.XPATH_FACTORY;

/**
* This event handler removes previously inserted <code>mods:nameIdentifier[@type='connection']</code> element from a
* <code>mods:name</code> element when that element has a <code>mods:affiliation[@valueURI="isAffiliated#false"</code>
* element.
*
* @author shermann (Silvio Hermann)
*/
public class ThUniBibAffiliationEventHandler extends MCREventHandlerBase {

private final static Logger LOGGER = LogManager.getLogger(ThUniBibAffiliationEventHandler.class);

protected static final XPathExpression<Element> XPATH = XPATH_FACTORY.compile(
"//mods:name[mods:affiliation[contains(@valueURI, 'isAffiliated#false')]]/mods:nameIdentifier[@type='connection']",
Filters.element(), null, MODS_NAMESPACE);

protected void processAffiliation(MCREvent evt, MCRObject obj) {
Document xml = obj.createXML();
List<Element> connectionIDs = XPATH.evaluate(xml);

if (connectionIDs.isEmpty()) {
return;
}

// remove mods:nameIdentifier[@type = 'connection']
for (Element connectionID : connectionIDs) {
LOGGER.info("Removing mods:nameIdentifier[type='connection'][text()='{}'] of mods:name element in {}",
connectionID.getText(), obj.getId());
connectionID.detach();
}

Element updatedMODSContainer = XPATH_FACTORY
.compile("//def.modsContainer", Filters.element(), null, MODS_NAMESPACE)
.evaluateFirst(xml);

// update metadata element
if (updatedMODSContainer != null) {
MCRMetaElement e = new MCRMetaElement();
e.setFromDOM(updatedMODSContainer);
obj.getMetadata().setMetadataElement(e);
}
}

/**
*
* @param evt
* @param obj
*/
@Override
protected void handleObjectUpdated(MCREvent evt, MCRObject obj) {
this.processAffiliation(evt, obj);
}

/**
*
* @param evt
* @param obj
*/
@Override
protected void handleObjectCreated(MCREvent evt, MCRObject obj) {
this.processAffiliation(evt, obj);
}
}
27 changes: 20 additions & 7 deletions common/src/main/resources/META-INF/resources/import-editor.xed
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@
</xed:repeat>

<div class="form-group form-inline col-12 px-0">
<xed:repeat xpath="mods:affiliation">
<xed:repeat xpath="mods:affiliation[not(@authorityURI)][not(@valueURI)]">
<label class="mycore-form-label">
</label>
<textarea class="mycore-form-input" placeholder="Institutionelle Zugehörigkeit"/>
Expand Down Expand Up @@ -516,13 +516,26 @@
</label>
</xed:bind>
<xed:include uri="webapp:import-editor.xed" ref="person"/>
<xed:bind xpath="mods:role/mods:roleTerm[@type='text'][@classID='author_roles']">
<div class="form-group form-inline col-12 px-0">
<label class="mycore-form-label"></label>

<div class="form-group form-inline col-12 px-0">
<xed:bind xpath="mods:role/mods:roleTerm[@type='text'][@classID='author_roles']">
<label class="mycore-form-label"/>
<input type="checkbox" value="corresponding_author"/>
<xed:output i18n="ubo.corresponding_author"/>
</div>
</xed:bind>
<span class="pl-1">
<xed:output i18n="ubo.corresponding_author"/>
</span>
</xed:bind>
</div>

<div class="form-group form-inline col-12 px-0">
<xed:bind xpath="mods:affiliation[@authorityURI=concat($MCR.baseurl, 'classifications/isAffiliated')]">
<label class="mycore-form-label"/>
<input type="checkbox" value="false"/>
<span class="pl-1">
<xed:output i18n="thunibib.editor.affiliation.checkbox"/>
</span>
</xed:bind>
</div>
</div>
</xed:repeat>
</xed:template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ search.update = (Zuordnung anpassen)
thunibib.classification.fachreferate.validation = Bitte w\u00E4hlen sie mindestens ein Fachgebiet aus
thunibib.comment.intern = Zus\u00E4tzliche Hinweise f\u00FCr das Bibliothekspersonal
thunibib.condition.partOf = Bitte geben Sie an, ob die Publikation in der Statistik der Bibliographie gez\u00E4hlt werden soll.
thunibib.editor.affiliation.checkbox = Autor geh\u00F6rte im Publikationszeitraum nicht der Einrichtung an
thunibib.editor.edit.publication = Publikation bearbeiten
thunibib.editor.help.comment.intern = Zus\u00E4tzliche Hinweise f\u00FCr das Bibliothekspersonal
thunibib.editor.help.license = Lizenztyp, unter welchem die Publikation genutzt werden kann
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ search.update = (update link)
thunibib.classification.fachreferate.validation = Please select at least one subject
thunibib.comment.intern = Additional information for the library staff
thunibib.condition.partOf = Please indicate whether the publication should be counted in the bibliography statistics.
thunibib.editor.affiliation.checkbox = Author was not a member of the institution during the publication period
thunibib.editor.edit.publication = Edit publication
thunibib.editor.help.comment.intern = Additional information for the library staff
thunibib.editor.help.license = Type of licence the publication may be used
Expand Down
18 changes: 18 additions & 0 deletions common/src/main/resources/setup/classifications/isAffiliated.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<mycoreclass ID="isAffiliated" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="MCRClassification.xsd">

<label xml:lang="de" text="Affiliation, der Einrichtung zugehörig. Ja oder Nein." />
<label xml:lang="en" text="Affiliation, affiliated to the institution. Yes or No." />

<categories>
<category ID="true">
<label xml:lang="de" text="Ja" description="Autor gehörte im Publikationszeitraum der Einrichtung an"/>
<label xml:lang="en" text="Yes" description="Author was a member of the institution during the publication period"/>
</category>
<category ID="false">
<label xml:lang="de" text="Nein" description="Autor gehörte im Publikationszeitraum nicht der Einrichtung an"/>
<label xml:lang="en" text="No" description="Author was not a member of the institution during the publication period"/>
</category>
</categories>

</mycoreclass>
6 changes: 6 additions & 0 deletions common/src/main/resources/xsl/thunibib-mods-postprocessor.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<xsl:include href="resource:xsl/mods-postprocessor.xsl"/>
<xsl:include href="resource:xsl/coreFunctions.xsl"/>

<xsl:param name="WebApplicationBaseURL"/>

<xsl:template match="mods:subject">
<mods:subject>

Expand All @@ -25,4 +27,8 @@
</mods:subject>
</xsl:template>

<xsl:template match="mods:affiliation[@authorityURI][text() = 'false']">
<mods:affiliation authorityURI="{@authorityURI}" valueURI="{$WebApplicationBaseURL}classifications/isAffiliated#false"/>
</xsl:template>

</xsl:stylesheet>
7 changes: 7 additions & 0 deletions common/src/main/resources/xsl/thunibib-mods-preprocessor.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@
</mods:subject>
</xsl:template>

<xsl:template match="mods:affiliation[@authorityURI][contains(@valueURI, 'classifications/isAffiliated')]">
<xsl:variable name="value" select="substring-after(@valueURI, '#')"/>
<mods:affiliation authorityURI="{@authorityURI}">
<xsl:value-of select="$value"/>
</mods:affiliation>
</xsl:template>

</xsl:stylesheet>

0 comments on commit 5b0fc00

Please sign in to comment.