Skip to content

Commit

Permalink
#550 Added resolve and create mode to HISinOneResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
Possommi committed Jul 16, 2024
1 parent 9a5e8da commit 754ad03
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ public class HISinOneResolver implements URIResolver {
private static final Map<String, SysValue> THESIS_TYPE_MAP = new HashMap<>();
private static final Map<String, SysValue> VISIBILITY_TYPE_MAP = new HashMap<>();

public enum SUPPORTED_URI_PARTS {
public enum Mode {
resolve, create
}

public enum ResolvableTypes {
creatorType,
documentType,
genre,
Expand All @@ -82,16 +86,18 @@ public Source resolve(String href, String base) throws TransformerException {
LOGGER.debug("Resolving '{}'", href);

String[] parts = href.split(":");
String entity = parts[1];
String value = parts[2];

var sysValue = switch (SUPPORTED_URI_PARTS.valueOf(entity)) {
Mode mode = Mode.valueOf(parts[1]);
String entity = parts[2];
String value = parts[3];

var sysValue = switch (ResolvableTypes.valueOf(entity)) {
case creatorType -> resolveCreatorType(value);
case documentType -> resolveDocumentType(value);
case genre -> resolveGenre(value);
case globalIdentifiers -> resolveIdentifierType(value);
case language -> resolveLanguage(value);
case publisher -> resolvePublisher(value);
case publisher -> Mode.resolve.equals(mode) ? resolvePublisher(value) : SysValue.NotObtainedSysValue;
case peerReviewed -> resolvePeerReviewedType(value);
case publicationAccessType -> resolvePublicationAccessType(value);
case researchAreaKdsf -> resolveResearchAreaKdsf(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
</xsl:template>

<xsl:template match="mods:classification[fn:contains(@valueURI, 'fs/res/publisher') and @authorityURI = $ThUniBib.HISinOne.BaseURL]" mode="create">
<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:publisher:', $publisher-text))"/>

<mods:classification authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}fs/res/publisher">
<xsl:value-of select="-42"/>
<xsl:value-of select="$publisher-id"/>
</mods:classification>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<xsl:template name="publisher">
<xsl:if test="mods:originInfo/mods:publisher">
<xsl:variable name="publisher-text" select="fn:encode-for-uri(mods:originInfo/mods:publisher)"/>
<xsl:variable name="publisher-id" select="fn:document(concat('hisinone:publisher:', $publisher-text))"/>
<xsl:variable name="publisher-id" select="fn:document(concat('hisinone:resolve:publisher:', $publisher-text))"/>

<mods:classification authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}fs/res/publisher">
<xsl:value-of select="$publisher-id"/>
Expand All @@ -73,7 +73,7 @@
<xsl:template name="peerReviewed">
<xsl:if test="mods:classification[fn:contains(@valueURI, 'peerreviewed#')]">
<xsl:variable name="categId" select="fn:substring-after(mods:classification[fn:contains(@valueURI, 'peerreviewed#')]/@valueURI, '#')"/>
<xsl:variable name="publication-peerreviewed-type-his-id" select="fn:document(concat('hisinone:peerReviewed:', $categId))"/>
<xsl:variable name="publication-peerreviewed-type-his-id" select="fn:document(concat('hisinone:resolve:peerReviewed:', $categId))"/>

<mods:classification authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}cs/sys/values/peerReviewedValue">
<xsl:value-of select="$publication-peerreviewed-type-his-id"/>
Expand All @@ -85,7 +85,7 @@
<xsl:if test="mods:classification[fn:contains(@valueURI, 'accessrights#')]">

<xsl:variable name="categId" select="fn:substring-after(mods:classification[fn:contains(@valueURI, 'accessrights#')]/@valueURI, '#')"/>
<xsl:variable name="publication-access-type-his-id" select="fn:document(concat('hisinone:publicationAccessType:', $categId))"/>
<xsl:variable name="publication-access-type-his-id" select="fn:document(concat('hisinone:resolve:publicationAccessType:', $categId))"/>

<mods:classification authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}cs/sys/values/publicationAccessTypeValue">
<xsl:value-of select="$publication-access-type-his-id"/>
Expand All @@ -95,13 +95,13 @@

<xsl:template name="globalIdentifiers">
<xsl:for-each select="mods:identifier[contains('doi scopus url', @type)]">
<xsl:variable name="global-identifier-type-id" select="fn:document(concat('hisinone:globalIdentifiers:', @type))"/>
<xsl:variable name="global-identifier-type-id" select="fn:document(concat('hisinone:resolve:globalIdentifiers:', @type))"/>
<mods:identifier type="{@type}" typeURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}fs/res/publication/globalIdentifierType#{$global-identifier-type-id}">
<xsl:value-of select="."/>
</mods:identifier>
</xsl:for-each>

<xsl:variable name="url-type-id" select="fn:document('hisinone:globalIdentifiers:url')"/>
<xsl:variable name="url-type-id" select="fn:document('hisinone:resolve:globalIdentifiers:url')"/>
<mods:identifier type="url" typeURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}fs/res/publication/globalIdentifierType#{$url-type-id}">
<xsl:value-of select="concat($WebApplicationBaseURL, 'receive/', //mycoreobject/@ID)"/>
</mods:identifier>
Expand All @@ -111,14 +111,14 @@
<xsl:choose>
<xsl:when test="mods:classification[contains(@valueURI, 'researchAreaKdsf#')]">
<xsl:for-each select="fn:substring-after(mods:classification[contains(@valueURI, 'researchAreaKdsf#')]/@valueURI, '#')">
<xsl:variable name="research-area-kdsf-his-key" select="fn:document(concat('hisinone:researchAreaKdsf:', .))"/>
<xsl:variable name="research-area-kdsf-his-key" select="fn:document(concat('hisinone:resolve:researchAreaKdsf:', .))"/>
<mods:classification authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}cs/sys/values/researchAreaKdsfValue">
<xsl:value-of select="$research-area-kdsf-his-key"/>
</mods:classification>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="research-area-kdsf-his-key" select="fn:document('hisinone:researchAreaKdsf:001')"/>
<xsl:variable name="research-area-kdsf-his-key" select="fn:document('hisinone:resolve:researchAreaKdsf:001')"/>
<mods:classification authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}cs/sys/values/researchAreaKdsfValue">
<xsl:value-of select="$research-area-kdsf-his-key"/>
</mods:classification>
Expand All @@ -128,7 +128,7 @@

<!-- TODO find the proper source value, currently mapping is fixed to 'Autor/-in'-->
<xsl:template name="creatorType">
<xsl:variable name="creator-type-his-key" select="fn:document('hisinone:creatorType:aut')"/>
<xsl:variable name="creator-type-his-key" select="fn:document('hisinone:resolve:creatorType:aut')"/>
<xsl:if test="$creator-type-his-key">
<mods:classification authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}cs/sys/values/publicationCreatorTypeValue">
<xsl:value-of select="$creator-type-his-key"/>
Expand All @@ -142,7 +142,7 @@
<xsl:variable name="destatis-from-origin" select="$origin//category[@ID=$origin-id]/label[@xml:lang='x-destatis']/@text"/>

<xsl:if test="$destatis-from-origin">
<xsl:variable name="subject-area-his-key" select="fn:document(concat('hisinone:subjectArea:', $destatis-from-origin))"/>
<xsl:variable name="subject-area-his-key" select="fn:document(concat('hisinone:resolve:subjectArea:', $destatis-from-origin))"/>

<xsl:if test="$subject-area-his-key">
<mods:classification authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}{$subject-area-value-uri}">
Expand All @@ -153,7 +153,7 @@

<xsl:for-each select="//mods:classification[contains(@authorityURI, 'fachreferate')]/@valueURI">
<xsl:variable name="subject-area" select="fn:substring-after(., '#')"/>
<xsl:variable name="subject-area-his-key" select="fn:document(concat('hisinone:subjectArea:', $subject-area))"/>
<xsl:variable name="subject-area-his-key" select="fn:document(concat('hisinone:resolve:subjectArea:', $subject-area))"/>

<xsl:if test="$subject-area-his-key">
<mods:classification authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}{$subject-area-value-uri}">
Expand All @@ -165,7 +165,7 @@

<xsl:template name="visibility">
<xsl:param name="status" select="//servflags/servflag[@type='status']"/>
<xsl:variable name="visibility-his-key" select="fn:document(concat('hisinone:visibility:', $status))"/>
<xsl:variable name="visibility-his-key" select="fn:document(concat('hisinone:resolve:visibility:', $status))"/>
<xsl:if test="$visibility-his-key">
<mods:classification authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}cs/sys/values/visibilityValue">
<xsl:value-of select="$visibility-his-key"/>
Expand All @@ -175,7 +175,7 @@

<xsl:template name="state">
<xsl:param name="status" select="//servflags/servflag[@type='status']"/>
<xsl:variable name="status-his-key" select="fn:document(concat('hisinone:state:', $status))"/>
<xsl:variable name="status-his-key" select="fn:document(concat('hisinone:resolve:state:', $status))"/>

<xsl:if test="$status-his-key">
<mods:classification authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}fs/res/state/publication">
Expand All @@ -197,15 +197,15 @@
<xsl:comment>Begin - transformer 'mods-resolve-his-keys'</xsl:comment>

<!-- publicationTypeValue -->
<xsl:variable name="his-key-publication-type-value" select="fn:document(concat('hisinone:genre:', $genre))"/>
<xsl:variable name="his-key-publication-type-value" select="fn:document(concat('hisinone:resolve:genre:', $genre))"/>
<xsl:if test="$his-key-publication-type-value">
<mods:genre authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}cs/sys/values/publicationTypeValue" type="code">
<xsl:value-of select="$his-key-publication-type-value"/>
</mods:genre>
</xsl:if>

<!-- qualificationThesisValue -->
<xsl:variable name="his-key-qualification-thesis-type-value" select="fn:document(concat('hisinone:thesisType:', $genre))"/>
<xsl:variable name="his-key-qualification-thesis-type-value" select="fn:document(concat('hisinone:resolve:thesisType:', $genre))"/>
<xsl:if test="$his-key-publication-type-value">
<mods:genre authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}cs/sys/values/qualificationThesisValue" type="code">
<xsl:value-of select="$his-key-qualification-thesis-type-value"/>
Expand All @@ -219,7 +219,7 @@
TODO GET /fs/res/publication/documentTypes/article
TODO GET /fs/res/publication/documentTypes/book
-->
<xsl:variable name="his-key-document-type-type-value" select="fn:document(concat('hisinone:documentType:', $genre))"/>
<xsl:variable name="his-key-document-type-type-value" select="fn:document(concat('hisinone:resolve:documentType:', $genre))"/>
<xsl:if test="$his-key-document-type-type-value">
<mods:genre authorityURI="{$ThUniBib.HISinOne.BaseURL}" valueURI="{$ThUniBib.HISinOne.BaseURL}{$ThUniBib.HISinOne.BaseURL.API.Path}fs/res/publication/documentTypes" type="code">
<xsl:value-of select="$his-key-document-type-type-value"/>
Expand All @@ -234,7 +234,7 @@

<xsl:copy>
<xsl:copy-of select="*|@*"/>
<xsl:variable name="his-key" select="fn:document(concat('hisinone:language:', $rfc5646))"/>
<xsl:variable name="his-key" select="fn:document(concat('hisinone:resolve:language:', $rfc5646))"/>

<xsl:if test="$his-key">
<xsl:comment>Begin - transformer 'mods-resolve-his-keys'</xsl:comment>
Expand Down

0 comments on commit 754ad03

Please sign in to comment.