From 1a0e5db1596802596ea75006af0bfa80968948bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20L=C3=BCtzenkirchen?= Date: Mon, 30 May 2022 10:35:55 +0200 Subject: [PATCH 1/3] UBO-161 Added basic functionality to import publications from Web of Science --- .../java/org/mycore/ubo/wos/WoSResolver.java | 87 +++++++ .../config/ubo-common/mycore.properties | 14 +- .../xsl/import/simplify-json-xml.xsl | 2 +- .../main/resources/xsl/import/wos2mods.xsl | 225 ++++++++++++++++++ 4 files changed, 326 insertions(+), 2 deletions(-) create mode 100644 ubo-common/src/main/java/org/mycore/ubo/wos/WoSResolver.java create mode 100644 ubo-common/src/main/resources/xsl/import/wos2mods.xsl diff --git a/ubo-common/src/main/java/org/mycore/ubo/wos/WoSResolver.java b/ubo-common/src/main/java/org/mycore/ubo/wos/WoSResolver.java new file mode 100644 index 000000000..98b9c4f21 --- /dev/null +++ b/ubo-common/src/main/java/org/mycore/ubo/wos/WoSResolver.java @@ -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); + } + } +} diff --git a/ubo-common/src/main/resources/config/ubo-common/mycore.properties b/ubo-common/src/main/resources/config/ubo-common/mycore.properties index eb2f319f2..42cc9d287 100644 --- a/ubo-common/src/main/resources/config/ubo-common/mycore.properties +++ b/ubo-common/src/main/resources/config/ubo-common/mycore.properties @@ -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=... + +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 # @@ -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 diff --git a/ubo-common/src/main/resources/xsl/import/simplify-json-xml.xsl b/ubo-common/src/main/resources/xsl/import/simplify-json-xml.xsl index 83a08dfb2..49420f9b6 100644 --- a/ubo-common/src/main/resources/xsl/import/simplify-json-xml.xsl +++ b/ubo-common/src/main/resources/xsl/import/simplify-json-xml.xsl @@ -9,7 +9,7 @@ - + diff --git a/ubo-common/src/main/resources/xsl/import/wos2mods.xsl b/ubo-common/src/main/resources/xsl/import/wos2mods.xsl new file mode 100644 index 000000000..3eaeb1e49 --- /dev/null +++ b/ubo-common/src/main/resources/xsl/import/wos2mods.xsl @@ -0,0 +1,225 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + abcdefghijklmnopqrstuvwxyz + ABCDEFGHIJKLMNOPQRSTUVWXYZ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + aut + + + + + + + + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WOS: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 930226a9541a1c38001836233c788d8461ffe04c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20L=C3=BCtzenkirchen?= Date: Mon, 30 May 2022 13:34:26 +0200 Subject: [PATCH 2/3] UBO-163 Add a default property for the WoS API key --- .../src/main/resources/config/ubo-common/mycore.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubo-common/src/main/resources/config/ubo-common/mycore.properties b/ubo-common/src/main/resources/config/ubo-common/mycore.properties index 42cc9d287..6f523aa71 100644 --- a/ubo-common/src/main/resources/config/ubo-common/mycore.properties +++ b/ubo-common/src/main/resources/config/ubo-common/mycore.properties @@ -612,7 +612,7 @@ UBO.WebOfScience.Link=http://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39 UBO.WebOfScience.API.BaseURL=https://wos-api.clarivate.com/api/wos/ # Set in local mycore.properties: -# UBO.WebOfScience.API.Key=... +UBO.WebOfScience.API.Key=this_is_a_dummy-set-in-local-mycore.properties MCR.URIResolver.ModuleResolver.wos=org.mycore.ubo.wos.WoSResolver From 0ed0db850d9a1fc85a2e7660d3de45aa1ab6f684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20L=C3=BCtzenkirchen?= Date: Mon, 30 May 2022 13:39:01 +0200 Subject: [PATCH 3/3] Added web of science as data source --- .../src/main/resources/META-INF/resources/newPublication.xed | 1 + .../src/main/resources/config/ubo-common/messages_de.properties | 2 +- .../src/main/resources/config/ubo-common/messages_en.properties | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ubo-common/src/main/resources/META-INF/resources/newPublication.xed b/ubo-common/src/main/resources/META-INF/resources/newPublication.xed index fcd09ba5d..6fecba122 100644 --- a/ubo-common/src/main/resources/META-INF/resources/newPublication.xed +++ b/ubo-common/src/main/resources/META-INF/resources/newPublication.xed @@ -37,6 +37,7 @@ + diff --git a/ubo-common/src/main/resources/config/ubo-common/messages_de.properties b/ubo-common/src/main/resources/config/ubo-common/messages_de.properties index dd074a213..f9346c6cc 100644 --- a/ubo-common/src/main/resources/config/ubo-common/messages_de.properties +++ b/ubo-common/src/main/resources/config/ubo-common/messages_de.properties @@ -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! diff --git a/ubo-common/src/main/resources/config/ubo-common/messages_en.properties b/ubo-common/src/main/resources/config/ubo-common/messages_en.properties index b2f0c77fa..b78db6380 100644 --- a/ubo-common/src/main/resources/config/ubo-common/messages_en.properties +++ b/ubo-common/src/main/resources/config/ubo-common/messages_en.properties @@ -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!