Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
87 changes: 87 additions & 0 deletions ubo-common/src/main/java/org/mycore/ubo/wos/WoSResolver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package org.mycore.ubo.wos;

import java.io.InputStream;

import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status.Family;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.URIResolver;

import org.jdom2.transform.JDOMSource;
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.common.content.MCRContent;
import org.mycore.common.content.MCRStreamContent;
import org.mycore.ubo.importer.JSON2XMLTransformer;

/**
* URI Resolver to get publication data from Web of Science.
*
* To retrieve via Web of Science ID, call wos:[ID]
* To retrieve via a user query, append query, e.g. wos:DO=10.1039/c4tb01010h
*
* UBO.WebOfScience.API.BaseURL
* UBO.WebOfScience.API.Key
*
* must be set.
*
* @author Frank L\u00FCtzenkirchen
*/
public class WoSResolver implements URIResolver {

private static final String ACCEPT_TYPE = "application/json";

private static final String API_KEY_HEADER = "X-ApiKey";

private static final String[] PARAMS = { "databaseId", "WOS", "count", "1", "firstRecord", "1",
"optionView", "FR" };

private static final String USR_QUERY = "usrQuery";

private static final String WOS_ID_PREFIX = "WOS:";

private String apiKey;

private WebTarget baseTarget;

public WoSResolver() {
String prefix = "UBO.WebOfScience.API.";
String baseURL = MCRConfiguration2.getStringOrThrow(prefix + "BaseURL");

this.baseTarget = ClientBuilder.newClient().target(baseURL);
this.apiKey = MCRConfiguration2.getStringOrThrow(prefix + "Key");
}

@Override
public Source resolve(String href, String base) throws TransformerException {
String ref = href.substring(href.indexOf(":") + 1);

WebTarget target = baseTarget;
if (!ref.contains("=")) {
String id = WOS_ID_PREFIX + ref;
target = target.path("id").path(id);
} else {
target = target.queryParam(USR_QUERY, ref);
}

for (int i = 0; i < PARAMS.length;) {
target = target.queryParam(PARAMS[i++], PARAMS[i++]);
}

Response r = target.request().accept(ACCEPT_TYPE).header(API_KEY_HEADER, apiKey).get();

if (r.getStatusInfo().getFamily() != Family.SUCCESSFUL) {
throw new TransformerException(r.getStatus() + " " + r.getStatusInfo().getReasonPhrase());
}

try {
MCRContent json = new MCRStreamContent(r.readEntity(InputStream.class));
MCRContent xml = new JSON2XMLTransformer().transform(json);
return new JDOMSource(xml.asXML());
} catch (Exception ex) {
throw new TransformerException(ex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<option value="doi">DOI</option>
<option value="pubmed">PubMed ID</option>
<option value="scopus">Scopus ID</option>
<option value="isi">Web of Science ID</option>
<option value="ieee">IEEE Article No.</option>
<option value="arxiv">arXiv.org ID</option>
<option value="isbn">ISBN</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ ubo.newPublicationWizard.duplicates.noContinue = Nein, das ist eine andere Publ
ubo.newPublicationWizard.duplicates.pleaseCheck = Bitte pr\u00FCfen Sie, ob die Publikation, die Sie melden m\u00F6chten, nicht bereits in der unten aufgef\u00FChrten Liste verzeichnet ist.
ubo.newPublicationWizard.notFound = Keine Publikationsdaten gefunden
ubo.newPublicationWizard.notFound.continue = Alternativ Titel und Autor*in eingeben
ubo.newPublicationWizard.notFound.info = Leider konnten wir f\u00FCr die eingegebene ID keine Publikationsdaten finden. Wir k\u00F6nnen derzeit DOIs aus Scopus, PubMed, IEEE, CrossRef und DataCite aufl\u00F6sen. Bitte pr\u00FCfen Sie die ID oder wenden sich ggf. an die Universit\u00E4tsbibliothek:
ubo.newPublicationWizard.notFound.info = Leider konnten wir f\u00FCr die eingegebene ID keine Publikationsdaten finden. Wir k\u00F6nnen derzeit DOIs aus Scopus, Web of Science, PubMed, IEEE, CrossRef und DataCite aufl\u00F6sen. Bitte pr\u00FCfen Sie die ID oder wenden sich ggf. an die Universit\u00E4tsbibliothek:
ubo.newPublicationWizard.publishedIn = ver\u00F6ffentlicht in
ubo.newPublicationWizard.required = Bitte geben Sie einen DOI oder anderen Identifikator oder alternativ Titel UND Autor*innenname ein!
ubo.newPublicationWizard.selectGenre = Bitte w\u00E4hlen Sie den Publikationstyp bzw. korrigieren die Auswahl!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ ubo.newPublicationWizard.duplicates.noContinue = No, it is another publication,
ubo.newPublicationWizard.duplicates.pleaseCheck = Please check if the publication you want to register isn't already listed below.
ubo.newPublicationWizard.notFound = No publication data found
ubo.newPublicationWizard.notFound.continue = Alternatively, continue by entering title and author
ubo.newPublicationWizard.notFound.info = Unfortunately we could'nt find publication data for the identifier entered. We currently resolve DOIs from Scopus, PubMed, IEEE, CrossRef and DataCite. Please check the identifier or contact us:
ubo.newPublicationWizard.notFound.info = Unfortunately we could'nt find publication data for the identifier entered. We currently resolve DOIs from Scopus, Web of Science, PubMed, IEEE, CrossRef and DataCite. Please check the identifier or contact us:
ubo.newPublicationWizard.publishedIn = published in
ubo.newPublicationWizard.required = Please enter the DOI or other ID or alternativly BOTH title and author!
ubo.newPublicationWizard.selectGenre = Please choose the publication type resp. fix the selection!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,18 @@ MCR.MODS.EnrichmentResolver.DataSource.Scopus.scopus.URI=xslStyle:import/scopus2

UBO.WebOfScience.Link=http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:ut/

UBO.WebOfScience.API.BaseURL=https://wos-api.clarivate.com/api/wos/
# Set in local mycore.properties:
UBO.WebOfScience.API.Key=this_is_a_dummy-set-in-local-mycore.properties

MCR.URIResolver.ModuleResolver.wos=org.mycore.ubo.wos.WoSResolver

# Configuration to import data via EnrichmentResolver
MCR.MODS.EnrichmentResolver.DataSource.WebOfScience.IdentifierTypes=isi doi pubmed
MCR.MODS.EnrichmentResolver.DataSource.WebOfScience.isi.URI=xslStyle:import/simplify-json-xml,import/wos2mods,import/genre2genre:wos:{0}
MCR.MODS.EnrichmentResolver.DataSource.WebOfScience.doi.URI=xslStyle:import/simplify-json-xml,import/wos2mods,import/genre2genre:wos:DO={0}
MCR.MODS.EnrichmentResolver.DataSource.WebOfScience.pubmed.URI=xslStyle:import/wos2mods,import/genre2genre:wos:PMID={0}

######################################################################
# #
# CrossRef #
Expand Down Expand Up @@ -792,7 +804,7 @@ MCR.MODS.EnrichmentResolver.DataSource.GOLD.issn.URI=gold:{1}
MCR.MODS.EnrichmentResolver.IdentifierType.shelfmark=mods:location/mods:shelfLocator

# Configuration to import new publication by given ID:
MCR.MODS.EnrichmentResolver.DataSources.import=DuEPublico1 DuEPublico2 EVALuna (Scopus CrossRef PubMed IEEE DataCite arXiv) Unpaywall (LOBID GBV Alma) ZDB JOP
MCR.MODS.EnrichmentResolver.DataSources.import=DuEPublico1 DuEPublico2 EVALuna (Scopus WebOfScience CrossRef PubMed IEEE DataCite arXiv) Unpaywall (LOBID GBV Alma) ZDB JOP

# Configuration to enrich publications imported from BibTeX/ORCID/CSV (import-list.xed):
MCR.MODS.EnrichmentResolver.DataSources.import-list=(Scopus CrossRef PubMed IEEE DataCite arXiv) Unpaywall (LOBID GBV Alma) ZDB JOP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<xsl:template match="xpf:*[@key]">
<xsl:if test="(count(*) &gt; 0) or (string-length(text()) &gt; 0)">
<xsl:element name="{@key}">
<xsl:element name="{translate(@key,':','_')}">
<xsl:apply-templates select="*|text()" />
</xsl:element>
</xsl:if>
Expand Down
225 changes: 225 additions & 0 deletions ubo-common/src/main/resources/xsl/import/wos2mods.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:mods="http://www.loc.gov/mods/v3">

<xsl:output method="xml" encoding="UTF-8" indent="yes" />

<xsl:template match="/">
<xsl:apply-templates select="/entry/Data/Records/records/REC/entry[1]" />
</xsl:template>

<xsl:template match="REC/entry">
<mods:mods>
<xsl:apply-templates select="static_data/summary/doctypes/doctype" />
<xsl:apply-templates select="static_data/summary/titles/title/entry[type='item']" />
<xsl:apply-templates select="static_data/summary/names/name/entry" />
<xsl:apply-templates select="static_data/summary/pub_info/pubyear" />
<xsl:apply-templates select="static_data/fullrecord_metadata/normalized_languages/language" />
<xsl:apply-templates select="dynamic_data/cluster_related/identifiers/identifier/entry[type='doi']" />
<xsl:apply-templates select="dynamic_data/cluster_related/identifiers/identifier/entry[type='pmid']" />
<xsl:apply-templates select="UID" />
<mods:relatedItem type="host">
<xsl:apply-templates select="static_data/summary/pub_info/pubtype" />
<xsl:apply-templates select="static_data/summary/titles/title/entry[type='source']" />
<xsl:apply-templates select="static_data/summary/publishers/publisher" />
<xsl:apply-templates
select="dynamic_data/cluster_related/identifiers/identifier/entry[(type='issn') or (type='eissn')]" />
<xsl:apply-templates select="static_data/summary/pub_info" mode="part" />
</mods:relatedItem>
</mods:mods>
</xsl:template>

<xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>

<xsl:template match="language">
<!-- Find language with matching label in any language, or with matching ID in any supported code schema -->
<xsl:variable name="given"
select="translate(content,$upper,$lower)" />
<xsl:for-each select="document('classification:metadata:-1:children:rfc4646')/mycoreclass/categories">
<xsl:for-each select="category[@ID=$given or label[translate(@text,$upper,$lower)=$given]][1]">
<mods:language>
<mods:languageTerm authority="rfc4646" type="code">
<xsl:value-of select="@ID" />
</mods:languageTerm>
</mods:language>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

<xsl:template match="doctype|pubtype">
<mods:genre>
<xsl:value-of select="." />
</mods:genre>
</xsl:template>

<xsl:template match="title/entry">
<mods:titleInfo>
<mods:title>
<xsl:value-of select="content" />
</mods:title>
</mods:titleInfo>
</xsl:template>

<xsl:template match="name/entry">
<mods:name type="personal">
<xsl:apply-templates select="last_name" />
<xsl:apply-templates select="first_name" />
<xsl:apply-templates select="role" />
<xsl:apply-templates select="daisng_id" mode="affiliation" />
<xsl:apply-templates select="orcid_id" />
<xsl:apply-templates select="r_id" />
</mods:name>
</xsl:template>

<xsl:template match="last_name">
<mods:namePart type="family">
<xsl:value-of select="." />
</mods:namePart>
</xsl:template>

<xsl:template match="first_name">
<mods:namePart type="given">
<xsl:value-of select="." />
</mods:namePart>
</xsl:template>

<xsl:template match="role">
<mods:role>
<mods:roleTerm authority="marcrelator" type="code">aut</mods:roleTerm>
</mods:role>
</xsl:template>

<xsl:template match="daisng_id" mode="affiliation">
<xsl:variable name="id" select="text()" />
<xsl:for-each
select="ancestor::static_data/fullrecord_metadata/addresses/address_name/entry[names/name[daisng_id=$id]]/address_spec">
<mods:affiliation>
<xsl:for-each select="organizations/organization/entry[pref='Y']">
<xsl:value-of select="content" />
</xsl:for-each>
<xsl:for-each select="suborganizations/suborganization">
<xsl:text>, </xsl:text>
<xsl:value-of select="text()" />
</xsl:for-each>
</mods:affiliation>
</xsl:for-each>
</xsl:template>

<xsl:template match="orcid_id">
<mods:nameIdentifier type="orcid">
<xsl:value-of select="." />
</mods:nameIdentifier>
</xsl:template>

<xsl:template match="r_id">
<mods:nameIdentifier type="researcherid">
<xsl:value-of select="." />
</mods:nameIdentifier>
</xsl:template>

<xsl:template match="pubyear">
<mods:originInfo>
<mods:dateIssued encoding="w3cdtf">
<xsl:value-of select="." />
</mods:dateIssued>
</mods:originInfo>
</xsl:template>

<xsl:template match="publisher">
<mods:originInfo>
<xsl:apply-templates select="address_spec" />
<xsl:apply-templates select="names/name[1]" />
</mods:originInfo>
</xsl:template>

<xsl:template match="publisher/names/name">
<mods:publisher>
<xsl:value-of select="unified_name" />
</mods:publisher>
</xsl:template>

<xsl:template match="publisher/address_spec">
<mods:place>
<mods:placeTerm type="text">
<xsl:value-of select="city" />
</mods:placeTerm>
</mods:place>
</xsl:template>

<xsl:template match="pub_info" mode="part">
<mods:part>
<xsl:apply-templates select="vol" />
<xsl:apply-templates select="issue" />
<xsl:apply-templates select="page" />
</mods:part>
</xsl:template>

<xsl:template match="vol">
<mods:detail type="volume">
<mods:number>
<xsl:value-of select="." />
</mods:number>
</mods:detail>
</xsl:template>

<xsl:template match="issue">
<mods:detail type="issue">
<mods:number>
<xsl:value-of select="." />
</mods:number>
</mods:detail>
</xsl:template>

<xsl:template match="page">
<mods:extent unit="pages">
<xsl:apply-templates select="begin" />
<xsl:apply-templates select="end" />
</mods:extent>
</xsl:template>

<xsl:template match="page/begin">
<mods:start>
<xsl:value-of select="." />
</mods:start>
</xsl:template>

<xsl:template match="page/end">
<mods:end>
<xsl:value-of select="." />
</mods:end>
</xsl:template>

<xsl:variable name="wosPrefix">
WOS:
</xsl:variable>

<xsl:template match="UID[starts-with(text(),$wosPrefix)]">
<mods:identifier type="isi">
<xsl:value-of select="substring-after(text(),$wosPrefix)" />
</mods:identifier>
</xsl:template>

<xsl:template match="identifier/entry[type='doi']">
<mods:identifier type="doi">
<xsl:value-of select="value" />
</mods:identifier>
</xsl:template>

<xsl:template match="identifier/entry[type='pmid']">
<mods:identifier type="pubmed">
<xsl:value-of select="substring-after(text(),':')" />
</mods:identifier>
</xsl:template>

<xsl:template match="identifier/entry[(type='issn') or (type='eissn')]">
<mods:identifier type="issn">
<xsl:value-of select="value" />
</mods:identifier>
</xsl:template>

<xsl:template match="*" />

</xsl:stylesheet>