From c62b9e07237cbaf971837b5f4a650ed37b8ea4a2 Mon Sep 17 00:00:00 2001 From: Philipp Kuntschik Date: Wed, 21 Nov 2018 18:50:22 +0100 Subject: [PATCH 1/2] add: generic class allowing to connect to any AnnotationService --- .../api/client/GenericAnnotatorClient.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/java/main/com/weblyzard/api/client/GenericAnnotatorClient.java diff --git a/src/java/main/com/weblyzard/api/client/GenericAnnotatorClient.java b/src/java/main/com/weblyzard/api/client/GenericAnnotatorClient.java new file mode 100644 index 00000000..fc7c9731 --- /dev/null +++ b/src/java/main/com/weblyzard/api/client/GenericAnnotatorClient.java @@ -0,0 +1,35 @@ +package com.weblyzard.api.client; + +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import com.weblyzard.api.model.document.Document; +import com.weblyzard.api.service.AnnotationService; + +/** + * Provide access to the Recognyze named entity linking Web service + * + * @author Philipp Kuntschik + * @author Albert Weichselbraun + */ +public class GenericAnnotatorClient extends BasicClient implements AnnotationService { + + + private static final String ANNOTATE_DOCUMENT_SERVICE_URL = "/rest/annotate_document"; + + public GenericAnnotatorClient(WebserviceClientConfig c) { + super(c, "/annotator"); + } + + @Override + public Document annotateDocument(Document data) { + + try (Response response = super.getTarget(ANNOTATE_DOCUMENT_SERVICE_URL) + .request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(data))) { + + super.checkResponseStatus(response); + Document result = response.readEntity(Document.class); + return result; + } + } +} From f114413da2c16bbe559d2973d87b8d08e21d5e7a Mon Sep 17 00:00:00 2001 From: Philipp Kuntschik Date: Thu, 22 Nov 2018 08:36:03 +0100 Subject: [PATCH 2/2] chg: javadoc --- .../main/com/weblyzard/api/client/GenericAnnotatorClient.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/java/main/com/weblyzard/api/client/GenericAnnotatorClient.java b/src/java/main/com/weblyzard/api/client/GenericAnnotatorClient.java index fc7c9731..df1c5668 100644 --- a/src/java/main/com/weblyzard/api/client/GenericAnnotatorClient.java +++ b/src/java/main/com/weblyzard/api/client/GenericAnnotatorClient.java @@ -7,7 +7,9 @@ import com.weblyzard.api.service.AnnotationService; /** - * Provide access to the Recognyze named entity linking Web service + * Provide access to Web services implementing the AnnotationService interface. + * + * @see AnnotationService * * @author Philipp Kuntschik * @author Albert Weichselbraun