Skip to content

Commit

Permalink
#550 Add stub for creating journals in HISinOne
Browse files Browse the repository at this point in the history
  • Loading branch information
Possommi committed Aug 28, 2024
1 parent ae06146 commit 5d140e8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public Source resolve(String href, String base) throws TransformerException {
case creatorType -> resolveCreatorType(fromValue);
case documentType -> resolveDocumentType(fromValue, hostGenre);
case globalIdentifiers -> resolveIdentifierType(fromValue);
case journal -> resolveJournal(fromValue);
case journal -> Mode.resolve.equals(mode) ? resolveJournal(fromValue) : createJournal(fromValue);
case language -> resolveLanguage(fromValue);
case peerReviewed -> resolvePeerReviewedType(fromValue);
case publication -> resolvePublicationLockVersion(fromValue);
Expand All @@ -145,6 +145,10 @@ public Source resolve(String href, String base) throws TransformerException {
return new JDOMSource(new Element("int").setText(String.valueOf(getFieldValue(sysValue, field))));
}

protected SysValue createJournal(String fromValue) {
return SysValue.UnresolvedSysValue;
}

private SysValue resolveJournal(String fromValue) {
String decodedValue = URLDecoder.decode(fromValue, StandardCharsets.UTF_8);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,45 @@
<xsl:copy>
<xsl:comment>Begin - transformer 'mods-create-unresolved-his-keys'</xsl:comment>
<!-- TODO Check user role -->
<xsl:apply-templates select="mods:classification[@authorityURI = $ThUniBib.HISinOne.BaseURL][text() = '-1']" mode="create"/>
<xsl:apply-templates select="mods:classification[@authorityURI = $ThUniBib.HISinOne.BaseURL][text() = '-1']"
mode="create"/>
<xsl:apply-templates select="mods:relatedItem[@otherTypeAuth = $ThUniBib.HISinOne.BaseURL][text() = '-1']"
mode="create"/>

<xsl:comment>End - mods-create-unresolved-his-keys'</xsl:comment>
<!-- Retain mods from previous step, but exclude unresolved values -->
<xsl:apply-templates select="@*|node()[not(text() = '-1')]"/>
</xsl:copy>
</xsl:template>

<!-- Create unresolved journal-->
<xsl:template mode="create"
match="mods:relatedItem[@otherType='host'][@otherTypeAuth = $ThUniBib.HISinOne.BaseURL][contains(@otherTypeAuthURI, 'journal')]">

<xsl:variable name="journal-id" select="fn:document(concat('hisinone:create:id:journal:', mods:titleInfo[1]/mods:title))"/>

<xsl:if test="fn:number($journal-id) &gt; 0">
<mods:relatedItem>
<xsl:copy-of select="@*"/>
<xsl:value-of select="$journal-id"/>
</mods:relatedItem>
</xsl:if>
</xsl:template>

<!-- Create unresolved publisher -->
<xsl:template match="mods:classification[fn:contains(@valueURI, 'fs/res/publisher') and @authorityURI = $ThUniBib.HISinOne.BaseURL]" mode="create">
<xsl:template mode="create"
match="mods:classification[fn:contains(@valueURI, 'fs/res/publisher') and @authorityURI = $ThUniBib.HISinOne.BaseURL]">

<xsl:variable name="publisher-text" select="fn:encode-for-uri(../mods:originInfo/mods:publisher)"/>
<xsl:variable name="publisher-id" select="fn:document(concat('hisinone:create:id:publisher:', $publisher-text))"/>

<mods:classification authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}fs/res/publisher">
<mods:classification>
<xsl:copy-of select="@*"/>
<xsl:value-of select="$publisher-id"/>
</mods:classification>
</xsl:template>

<!-- Remove all elements with unresolved values -->
<xsl:template match="node()[text() = '-1']"/>

</xsl:stylesheet>

0 comments on commit 5d140e8

Please sign in to comment.