diff --git a/inception/inception-external-search-pubmed/pom.xml b/inception/inception-external-search-pubmed/pom.xml index 70a2c4a52d0..17d0c12bd89 100644 --- a/inception/inception-external-search-pubmed/pom.xml +++ b/inception/inception-external-search-pubmed/pom.xml @@ -90,6 +90,10 @@ com.fasterxml.jackson.core jackson-annotations + + com.fasterxml.jackson.core + jackson-databind + com.fasterxml.jackson.dataformat jackson-dataformat-xml diff --git a/inception/inception-external-search-pubmed/src/main/java/de/tudarmstadt/ukp/inception/externalsearch/pubmed/pmcoa/PmcOaClient.java b/inception/inception-external-search-pubmed/src/main/java/de/tudarmstadt/ukp/inception/externalsearch/pubmed/pmcoa/PmcOaClient.java index 6a6ad19bae7..a020025c47a 100644 --- a/inception/inception-external-search-pubmed/src/main/java/de/tudarmstadt/ukp/inception/externalsearch/pubmed/pmcoa/PmcOaClient.java +++ b/inception/inception-external-search-pubmed/src/main/java/de/tudarmstadt/ukp/inception/externalsearch/pubmed/pmcoa/PmcOaClient.java @@ -17,10 +17,12 @@ */ package de.tudarmstadt.ukp.inception.externalsearch.pubmed.pmcoa; +import java.io.IOException; import java.util.Map; import org.springframework.http.HttpMethod; import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter; +import org.springframework.web.client.HttpClientErrorException.NotFound; import org.springframework.web.client.RestTemplate; import de.tudarmstadt.ukp.inception.externalsearch.pubmed.traits.PubMedProviderTraits; @@ -40,14 +42,25 @@ public PmcOaClient() restTemplate.getMessageConverters().add(new MappingJackson2XmlHttpMessageConverter()); } - public byte[] bioc(PubMedProviderTraits aTraits, String aID) + public byte[] bioc(PubMedProviderTraits aTraits, String aID) throws IOException { - var variables = Map.of( // - PARAM_ID, aID); + try { + var variables = Map.of( // + PARAM_ID, aID); - var response = restTemplate.exchange(BIOC_URL, HttpMethod.GET, null, byte[].class, - variables); + var response = restTemplate.exchange(BIOC_URL, HttpMethod.GET, null, byte[].class, + variables); - return response.getBody(); + return response.getBody(); + } + catch (NotFound e) { + throw new IOException("BioC version of document [" + aID + "] not found at [" + + BIOC_URL.replace("{id}", aID) + + "]. The Open Access files and BioC versions are not updated as " + + "quickly as the PMC website itself is updated. It may take a couple of days until " + + "a particular file is available as BioC. Another reason could be that the document you " + + "are looking for is not included in the Open Access set. Try adding " + + "`\"open access\"[filter]` without \"`\" to your search to filter by Open Access files."); + } } } diff --git a/inception/inception-external-search-pubmed/src/main/java/de/tudarmstadt/ukp/inception/externalsearch/pubmed/traits/PubMedProviderTraits.java b/inception/inception-external-search-pubmed/src/main/java/de/tudarmstadt/ukp/inception/externalsearch/pubmed/traits/PubMedProviderTraits.java index c2a52c61449..9e2e704ba28 100644 --- a/inception/inception-external-search-pubmed/src/main/java/de/tudarmstadt/ukp/inception/externalsearch/pubmed/traits/PubMedProviderTraits.java +++ b/inception/inception-external-search-pubmed/src/main/java/de/tudarmstadt/ukp/inception/externalsearch/pubmed/traits/PubMedProviderTraits.java @@ -19,6 +19,13 @@ import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +//The @JsonSerialize annotation avoid the "InvalidDefinitionException: No serializer found" +//exception without having to set SerializationFeature.FAIL_ON_EMPTY_BEANS +@JsonSerialize +@JsonIgnoreProperties(ignoreUnknown = true) public class PubMedProviderTraits implements Serializable { diff --git a/inception/inception-ui-external-search/src/main/java/de/tudarmstadt/ukp/inception/app/ui/externalsearch/DocumentDetailsPage.java b/inception/inception-ui-external-search/src/main/java/de/tudarmstadt/ukp/inception/app/ui/externalsearch/DocumentDetailsPage.java index 6f0910bf520..6617897aeaf 100644 --- a/inception/inception-ui-external-search/src/main/java/de/tudarmstadt/ukp/inception/app/ui/externalsearch/DocumentDetailsPage.java +++ b/inception/inception-ui-external-search/src/main/java/de/tudarmstadt/ukp/inception/app/ui/externalsearch/DocumentDetailsPage.java @@ -23,8 +23,6 @@ import static de.tudarmstadt.ukp.inception.app.ui.externalsearch.DocumentDetailsPage.PAGE_PARAM_DOCUMENT_ID; import static de.tudarmstadt.ukp.inception.app.ui.externalsearch.DocumentDetailsPage.PAGE_PARAM_REPOSITORY_ID; -import java.io.IOException; - import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.model.LoadableDetachableModel; import org.apache.wicket.request.mapper.parameter.PageParameters; @@ -95,7 +93,7 @@ private String getDocumentText() try { return externalSearchService.getDocumentText(repo, collectionId, documentId); } - catch (IOException e) { + catch (Exception e) { return "ERROR: " + e.getMessage(); } } @@ -105,7 +103,7 @@ private ExternalSearchResult getDocumentResult() try { return externalSearchService.getDocumentResult(repo, collectionId, documentId); } - catch (IOException e) { + catch (Exception e) { return new ExternalSearchResult(repo, collectionId, documentId); } } diff --git a/inception/inception-ui-external-search/src/main/java/de/tudarmstadt/ukp/inception/app/ui/externalsearch/ResultRowView.html b/inception/inception-ui-external-search/src/main/java/de/tudarmstadt/ukp/inception/app/ui/externalsearch/ResultRowView.html index ac3793f9ea9..a1b160a25e9 100644 --- a/inception/inception-ui-external-search/src/main/java/de/tudarmstadt/ukp/inception/app/ui/externalsearch/ResultRowView.html +++ b/inception/inception-ui-external-search/src/main/java/de/tudarmstadt/ukp/inception/app/ui/externalsearch/ResultRowView.html @@ -19,11 +19,11 @@ -
-
- +
+
+
- +
@@ -33,12 +33,12 @@
-
- +
+ - + diff --git a/inception/inception-ui-external-search/src/main/java/de/tudarmstadt/ukp/inception/app/ui/externalsearch/SearchPage.html b/inception/inception-ui-external-search/src/main/java/de/tudarmstadt/ukp/inception/app/ui/externalsearch/SearchPage.html index 7a8b0c51650..261f4f32306 100644 --- a/inception/inception-ui-external-search/src/main/java/de/tudarmstadt/ukp/inception/app/ui/externalsearch/SearchPage.html +++ b/inception/inception-ui-external-search/src/main/java/de/tudarmstadt/ukp/inception/app/ui/externalsearch/SearchPage.html @@ -16,6 +16,19 @@ limitations under the License. --> + + + + +
@@ -40,7 +53,7 @@
- +
[Results table]