diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 000000000..9a5a1c9c2
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,12 @@
+version: 2
+updates:
+ - package-ecosystem: "maven"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ groups:
+ minor-and-patch:
+ applies-to: version-updates
+ update-types:
+ - "patch"
+ - "minor"
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index a7a1822d0..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-language: java
-# Javadoc exclusions don't work with JDK 1.7.
-script: mvn -Dmaven.javadoc.skip=true clean verify
-jdk:
-- oraclejdk8
-- openjdk7
-- openjdk8
-
-# suggested by travis support.
-sudo: required
-dist: trusty
-group:
-
-sudo: required
diff --git a/CI.Jenkinsfile b/CI.Jenkinsfile
new file mode 100644
index 000000000..6d669cfba
--- /dev/null
+++ b/CI.Jenkinsfile
@@ -0,0 +1,60 @@
+node ("docker-light") {
+ def sourceDir = pwd()
+ try {
+ env.JAVA_HOME = "${tool 'java21'}"
+ env.PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
+ def mavenLocalRepo = "$JENKINS_HOME/maven-local-repositories/executor-$EXECUTOR_NUMBER"
+ stage("Clean up") {
+ step([$class: 'WsCleanup'])
+ sh "rm -rf $mavenLocalRepo"
+ }
+ stage("Checkout Code") {
+ checkout scm
+ }
+ stage("Build") {
+ withMaven(maven: "Basis",
+ mavenLocalRepo: mavenLocalRepo,
+ publisherStrategy: "EXPLICIT") {
+ sh "mvn clean verify"
+ }
+
+ }
+ stage("Test with Docker") {
+ withSonarQubeEnv {
+ mySonarOpts="-Dsonar.login=${env.SONAR_AUTH_TOKEN} -Dsonar.host.url=${env.SONAR_HOST_URL}"
+ if ("${env.CHANGE_BRANCH}" != "null") {
+ mySonarOpts="$mySonarOpts -Dsonar.pullrequest.key=${env.CHANGE_ID} -Dsonar.pullrequest.base=${env.CHANGE_TARGET} -Dsonar.pullrequest.branch=${env.CHANGE_BRANCH}"
+ }
+ echo("Sonar Options are: $mySonarOpts")
+ sh "docker run --rm \
+ --pull always \
+ --volume ${sourceDir}:/source \
+ --volume /opt/maven-basis:/opt/maven-basis \
+ eclipse-temurin:21-jdk-noble \
+ bash -c \"apt-get update && \
+ apt-get install -y git && \
+ pushd /source && \
+ git config --global --add safe.directory /source && \
+ /opt/maven-basis/bin/mvn --batch-mode clean install sonar:sonar $mySonarOpts; \
+ maven_ret=\\\$?; \
+ echo && \
+ echo [INFO] Set file permissions to UID and GID of jenkins user for cleanup. && \
+ chown -R 9960:9960 /source && \
+ exit \\\$maven_ret\""
+ }
+ }
+ postToTeams(true)
+ } catch (e) {
+ currentBuild.result = "FAILED"
+ postToTeams(false)
+ throw e
+ }
+}
+
+def postToTeams(boolean success) {
+ def webhookUrl = "${env.TEAMS_PNC_JENKINS_WEBHOOK_URL}"
+ def color = success ? "#00FF00" : "#FF0000"
+ def status = success ? "SUCCESSFUL" : "FAILED"
+ def message = "*" + status + ":* '${env.JOB_NAME}' - [${env.BUILD_NUMBER}] - ${env.BUILD_URL}"
+ office365ConnectorSend(webhookUrl: webhookUrl, color: color, message: message, status: status)
+}
diff --git a/DEVELOPER.md b/DEVELOPER.md
new file mode 100644
index 000000000..e733bfd8e
--- /dev/null
+++ b/DEVELOPER.md
@@ -0,0 +1,18 @@
+## Developer Notes
+
+#### Deprecation Strategies
+If we remove a field via deprecation, the field can still be passed in, but we will no longer deserialize it. As an example see [PR 204](https://github.com/rosette-api/java/pull/204).
+
+#### Building and Releasing
+To be updated..
+
+
+#### Internal Releasing
+
+To perform an internal release, execute the following commands:
+```
+$ mvn release:clean
+$ mvn release:prepare
+$ mvn release:perform -Drelease-profile=internal-release
+```
+
diff --git a/Jenkinsfile b/Jenkinsfile
index 735084372..5777d9641 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,30 +1,43 @@
node ("docker-light") {
def SOURCEDIR = pwd()
try {
+ env.JAVA_HOME = "${tool 'java21'}"
+ env.PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
+ def mavenLocalRepo = "$JENKINS_HOME/maven-local-repositories/executor-$EXECUTOR_NUMBER"
stage("Clean up") {
step([$class: 'WsCleanup'])
+ sh "rm -rf $mavenLocalRepo"
}
stage("Checkout Code") {
checkout scm
}
+ stage("Build") {
+ withMaven(maven: "Basis",
+ mavenLocalRepo: mavenLocalRepo,
+ publisherStrategy: "EXPLICIT") {
+ sh "mvn clean verify"
+ }
+
+ }
stage("Test with Docker") {
echo "${env.ALT_URL}"
def useUrl = ("${env.ALT_URL}" == "null") ? "${env.BINDING_TEST_URL}" : "${env.ALT_URL}"
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${useUrl}"]) {
- sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source rosetteapi/docker-java"
+ sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source rosette/docker-java"
}
}
- slack(true)
+ postToTeams(true)
} catch (e) {
currentBuild.result = "FAILED"
- slack(false)
+ postToTeams(false)
throw e
}
}
-def slack(boolean success) {
+def postToTeams(boolean success) {
+ def webhookUrl = "${env.TEAMS_PNC_JENKINS_WEBHOOK_URL}"
def color = success ? "#00FF00" : "#FF0000"
def status = success ? "SUCCESSFUL" : "FAILED"
- def message = status + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})"
- slackSend(color: color, channel: "#rapid", message: message)
-}
\ No newline at end of file
+ def message = "*" + status + ":* '${env.JOB_NAME}' - [${env.BUILD_NUMBER}] - ${env.BUILD_URL}"
+ office365ConnectorSend(webhookUrl: webhookUrl, color: color, message: message, status: status)
+}
diff --git a/Jenkinsfile.examples b/Jenkinsfile.examples
index d0b8d4246..fad51cfde 100644
--- a/Jenkinsfile.examples
+++ b/Jenkinsfile.examples
@@ -22,17 +22,18 @@ node {
sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -e VERSION=${PUBLISHED_VERSION} -v ${SOURCEDIR}:/source ${TEST_CONTAINER}"
}
}
- slack(true)
+ postToTeams(true)
} catch (e) {
currentBuild.result = "FAILED"
- slack(false)
+ postToTeams(false)
throw e
}
}
-def slack(boolean success) {
+def postToTeams(boolean success) {
+ def webhookUrl = "${env.TEAMS_PNC_JENKINS_WEBHOOK_URL}"
def color = success ? "#00FF00" : "#FF0000"
def status = success ? "SUCCESSFUL" : "FAILED"
- def message = status + ": Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})"
- slackSend(color: color, channel: "#rapid", message: message)
-}
\ No newline at end of file
+ def message = "*" + status + ":* '${env.JOB_NAME}' - [${env.BUILD_NUMBER}] - ${env.BUILD_URL}"
+ office365ConnectorSend(webhookUrl: webhookUrl, color: color, message: message, status: status)
+}
diff --git a/README.md b/README.md
index c7b230706..a15ed7735 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,35 @@
-[](https://travis-ci.org/rosette-api/java)
-[](https://maven-badges.herokuapp.com/maven-central/com.basistech.rosette/rosette-api-java-binding)
+
+
+
+
+
+
+
-# Java client binding for Rosette API #
+# Analytics by Babel Street
-## Installation ##
-If you use Maven, include this dependency in your `pom.xml`:
+---
+[](https://maven-badges.herokuapp.com/maven-central/com.basistech.rosette/rosette-api-java-binding)
+
+Our product is a full text processing pipeline from data preparation to extracting the most relevant information and
+analysis utilizing precise, focused AI that has built-in human understanding. Text Analytics provides foundational
+linguistic analysis for identifying languages and relating words. The result is enriched and normalized text for
+high-speed search and processing without translation.
+
+Text Analytics extracts events and entities — people, organizations, and places — from unstructured text and adds the
+structure of associating those entities into events that deliver only the necessary information for near real-time
+decision making. Accompanying tools shorten the process of training AI models to recognize domain-specific events.
+
+The product delivers a multitude of ways to sharpen and expand search results. Semantic similarity expands search
+beyond keywords to words with the same meaning, even in other languages. Sentiment analysis and topic extraction help
+filter results to what’s relevant.
+
+## Analytics API Access
+- Analytics Cloud [Sign Up](https://developer.babelstreet.com/signup)
+## Quick Start
+
+#### Maven
```xml
com.basistech.rosette
@@ -14,35 +38,25 @@ If you use Maven, include this dependency in your `pom.xml`:
```
-where `${rosette.api.java.binding.version}` is the [latest version available from Maven Central](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.basistech.rosette%22%20AND%20a%3A%22rosette-api%22).
-
-The version will change as new versions of the binding are released. Note that versions of the form `x.y.Nxx`, where `N` is greater than 100, are internal testing versions; do not use them without consultation with Basis Technology Corp.
-
-If the version you are using is not the latest from Maven Central. Please check for its
-[**compatibilty with api.rosette.com**](https://developer.rosette.com/features-and-functions?java).
-If you have an on-premise version of Rosette API server, please contact support for binding
-compatibility with your installation.
-
-The source code on the master branch is the current state of development; it is not recommended for general use.
-If you prefer to build from source, please use an appropriate release tag.
-
-## Basic Usage ##
-To check out more examples, see [examples](examples/src/main/java/com/basistech/rosette/examples)
-
-## API Documentation ##
-Check out the [documentation](http://rosette-api.github.io/java)
+Set `${rosette.api.java.binding.version}` in the `` block. The latest version available is displayed
+in the Maven Central badge at the top of this page.
-## Release Notes
-See the [Wiki](https://github.com/rosette-api/java/wiki/Release-Notes).
+#### Test Releases
+Versions, of the form `x.y.z`, where `z` is greater than or equal to `100`, are internal testing versions. Do not use
+them without consultation with Babel Street.
-## Docker ##
-A Docker image for running the examples against the compiled source library is available on Docker Hub.
+#### Examples
+View small example programs for each Analytics endpoint in the
+[examples](examples/src/main/java/com/basistech/rosette/examples) directory.
-Command: `docker run -e API_KEY=api-key -v ":/source" rosetteapi/docker-java`
+#### Documentation & Support
+- [Binding API](https://rosette-api.github.io/java/)
+- [Analytics Platform API](https://docs.babelstreet.com/API/en/index-en.html)
+- [Binding Release Notes](https://github.com/rosette-api/java/wiki/Release-Notes)
+- [Analytics Platform Release Notes](https://docs.babelstreet.com/Release/en/rosette-cloud.html)
+- [Support](https://babelstreet.my.site.com/support/s/)
+- [Binding License: Apache 2.0](LICENSE.txt)
-Additional environment settings:
-`-e ALT_URL=`
-`-e FILENAME=`
+## Binding Developer Information
+If you are modifying the binding code, please refer to the [developer README](DEVELOPER.md) file.
-## Additional Information ##
-For more, visit [Rosette API site](https://developer.rosette.com)
diff --git a/all/pom.xml b/all/pom.xml
new file mode 100644
index 000000000..430805806
--- /dev/null
+++ b/all/pom.xml
@@ -0,0 +1,109 @@
+
+
+
+ 4.0.0
+
+ com.basistech.rosette
+ rosette-api-java-binding
+ 1.36.1-SNAPSHOT
+
+ rosette-api-all
+ rosette-api-all
+ Babel Street Analytics API all modules combined
+
+
+ com.basistech
+ common-api
+
+
+ com.basistech.rosette
+ rosette-api
+ ${project.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+ com.basistech
+ adm-json
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+ add-source
+ package
+
+ add-source
+
+
+
+ ../model/target/delombok
+ ../api/src/main/java
+ ../annotations/src/main/java
+
+
+
+
+
+
+ maven-javadoc-plugin
+
+ ../model/target/delombok;../api/src/main/java
+
+
+ com.basistech.rosette
+ rosette-api-annotations
+ ${project.version}
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+
+
+ shade
+
+ shade
+
+ package
+
+ true
+
+
+ com.basistech.*
+
+
+
+
+
+
+
+
+
diff --git a/annotations/bnd.bnd b/annotations/bnd.bnd
deleted file mode 100644
index 099e137e3..000000000
--- a/annotations/bnd.bnd
+++ /dev/null
@@ -1,2 +0,0 @@
-Bundle-Version: ${osgi-version}
-Export-Package: com.basistech.rosette.annotations
diff --git a/annotations/pom.xml b/annotations/pom.xml
index 78d7584c5..4b06d860d 100644
--- a/annotations/pom.xml
+++ b/annotations/pom.xml
@@ -1,6 +1,6 @@
+
+ commons-codec
+ commons-codec
+ ${commons-codec.version}
+ org.apache.httpcomponentshttpclient
- ${http-components-version}
+ ${bt-httpclient-version}
+
+
+ commons-codec
+ commons-codec
+
+ org.apache.httpcomponentshttpmime
- ${http-components-version}
-
-
- com.google.guava
- guava
- compile
+ ${bt-httpmime-version}
+
+
+ org.apache.httpcomponents
+ httpclient
+
+ org.slf4jslf4j-api
- junit
- junit
-
-
- org.mock-server
- mockserver-client-java
- ${mockserver-version}
+ org.junit.jupiter
+ junit-jupiter
+ ${junit.version}testorg.mock-server
- mockserver-core
- ${mockserver-version}
- test
-
-
- org.mock-server
- mockserver-netty
- ${mockserver-version}
+ mockserver-junit-jupiter-no-dependencies
+ ${mockserver.version}test
@@ -100,70 +103,9 @@
-
- biz.aQute.bnd
- bnd-maven-plugin
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
- ${project.build.outputDirectory}/META-INF/MANIFEST.MF
-
-
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
- ${build-helper-maven-plugin.version}
-
-
- reserve-network-port
-
- reserve-network-port
-
- initialize
-
-
- mockServerClient.port
-
-
-
-
-
-
- org.mock-server
- mockserver-maven-plugin
- ${mockserver-version}
-
- ${mockServerClient.port}
- WARN
- ${skip-mockserver}
-
-
-
- process-test-classes
- process-test-classes
-
- runForked
-
-
-
- verify
- verify
-
- stopForked
-
-
-
- org.apache.maven.pluginsmaven-surefire-plugin
-
- -Xmx1024m
-
@@ -176,13 +118,6 @@
-
- src/test/resources
-
- **/*.property
-
- true
- src/test/resources
@@ -194,24 +129,4 @@
-
-
- skip-mockserver-tests
-
- true
-
-
-
-
-
- maven-surefire-plugin
-
- true
-
-
-
-
-
-
-
diff --git a/api/src/main/java/com/basistech/rosette/api/HttpRosetteAPI.java b/api/src/main/java/com/basistech/rosette/api/HttpRosetteAPI.java
index 4bf8a8f10..b0e997b90 100644
--- a/api/src/main/java/com/basistech/rosette/api/HttpRosetteAPI.java
+++ b/api/src/main/java/com/basistech/rosette/api/HttpRosetteAPI.java
@@ -1,5 +1,5 @@
/*
-* Copyright 2017 Basis Technology Corp.
+* Copyright 2024 Basis Technology Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
import com.basistech.rosette.apimodel.PingResponse;
import com.basistech.rosette.apimodel.Request;
import com.basistech.rosette.apimodel.Response;
+import com.basistech.rosette.apimodel.SupportedLanguagePairsResponse;
import com.basistech.rosette.apimodel.SupportedLanguagesResponse;
import com.basistech.rosette.apimodel.jackson.ApiModelMixinModule;
import com.basistech.rosette.apimodel.jackson.DocumentRequestMixin;
@@ -34,7 +35,6 @@
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
-import com.google.common.io.ByteStreams;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders;
@@ -60,6 +60,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -72,20 +73,24 @@
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.Future;
+import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import static java.net.HttpURLConnection.HTTP_OK;
/**
- * Access to the RosetteAPI via HTTP.
+ * Access to the Analytics API via HTTP.
*/
public class HttpRosetteAPI extends AbstractRosetteAPI {
- public static final String DEFAULT_URL_BASE = "https://api.rosette.com/rest/v1";
- public static final String SERVICE_NAME = "RosetteAPI";
+ public static final String DEFAULT_URL_BASE = "https://analytics.babelstreet.com/rest/v1";
+ public static final String SERVICE_NAME = "Babel-Street-Analytics-API";
public static final String BINDING_VERSION = getVersion();
- public static final String USER_AGENT_STR = SERVICE_NAME + "-Java/" + BINDING_VERSION + "/" + System.getProperty("java.version");
+ public static final String USER_AGENT_STR = SERVICE_NAME + "-Java/" + BINDING_VERSION + "/"
+ + System.getProperty("java.version");
private static final Logger LOG = LoggerFactory.getLogger(HttpRosetteAPI.class);
+ private static final String IO_EXCEPTION_MESSAGE = "IO Exception communicating with the Babel Street Analytics API";
+ private static final Pattern TRAILING_SLASHES = Pattern.compile("/+$");
private String urlBase = DEFAULT_URL_BASE;
private int failureRetries = 1;
private ObjectMapper mapper;
@@ -99,23 +104,23 @@ private HttpRosetteAPI() {
}
/**
- * Constructs a Rosette API instance using the builder syntax.
+ * Constructs an Analytics API instance using the builder syntax.
*
- * @param key Rosette API key. This may be null for use with an on-premise deployment
- * of the Rosette API.
- * @param urlToCall Alternate Rosette API URL. {@code null} uses the default, public, URL.
+ * @param key Analytics API key. This may be null for use with an on-premise deployment
+ * of the Analytics API.
+ * @param urlToCall Alternate Analytics API URL. {@code null} uses the default, public, URL.
* @param failureRetries Number of times to retry in case of failure; {@code null} uses the
* default value: 1.
* @param connectionConcurrency Number of concurrent connections. Pass this if have subscribed
* to a plan that supports enhanced concurrency, or if you are using
- * an on-premise deployment of the Rosette API. {@code null} uses the
+ * an on-premise deployment of the Analytics API. {@code null} uses the
* default value: 2.
* @throws HttpRosetteAPIException Problem with the API request
*/
HttpRosetteAPI(String key, String urlToCall, Integer failureRetries,
CloseableHttpClient httpClient, List additionalHeaders,
Integer connectionConcurrency, boolean onlyAcceptKnownFields) throws HttpRosetteAPIException {
- urlBase = urlToCall == null ? urlBase : urlToCall.trim().replaceAll("/+$", "");
+ urlBase = urlToCall == null ? urlBase : TRAILING_SLASHES.matcher(urlToCall.trim()).replaceAll("");
if (failureRetries != null && failureRetries >= 1) {
this.failureRetries = failureRetries;
}
@@ -158,13 +163,26 @@ private static String getVersion() {
* @throws IOException
*/
private static byte[] getBytes(InputStream is) throws IOException {
- return ByteStreams.toByteArray(is);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ byte[] buf = new byte[4096];
+
+ while (true) {
+ int r = is.read(buf);
+ if (r == -1) {
+ out.flush();
+ return out.toByteArray();
+ }
+ out.write(buf, 0, r);
+ }
}
+ @SuppressWarnings("java:HttpClient_must_be_closed") // This library requires keeping the connection open.
private void initClient(String key, List additionalHeaders) {
HttpClientBuilder builder = HttpClients.custom();
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
cm.setMaxTotal(connectionConcurrency);
+ cm.setDefaultMaxPerRoute(connectionConcurrency);
builder.setConnectionManager(cm);
initHeaders(key, additionalHeaders);
@@ -179,7 +197,10 @@ private void initHeaders(String key, List additionalHeaders) {
this.additionalHeaders.add(new BasicHeader(HttpHeaders.USER_AGENT, USER_AGENT_STR));
this.additionalHeaders.add(new BasicHeader(HttpHeaders.ACCEPT_ENCODING, "gzip"));
if (key != null) {
- this.additionalHeaders.add(new BasicHeader("X-RosetteAPI-Key", key));
+ this.additionalHeaders.add(new BasicHeader("X-BabelStreetAPI-Key", key));
+ this.additionalHeaders.add(new BasicHeader("X-BabelStreetAPI-Binding", "java"));
+ this.additionalHeaders.add(new BasicHeader("X-BabelStreetAPI-Binding-Version", BINDING_VERSION));
+ // TODO: Remove in a future release.
this.additionalHeaders.add(new BasicHeader("X-RosetteAPI-Binding", "java"));
this.additionalHeaders.add(new BasicHeader("X-RosetteAPI-Binding-Version", BINDING_VERSION));
}
@@ -198,10 +219,10 @@ public int getFailureRetries() {
}
/**
- * Gets information about the Rosette API, returns name, version, build number and build time.
+ * Gets information about the Analytics API, returns name, version, build number and build time.
*
* @return InfoResponse
- * @throws HttpRosetteAPIException Rosette specific exception
+ * @throws HttpRosetteAPIException Analytics specific exception
* @throws IOException General IO exception
*/
public InfoResponse info() throws IOException, HttpRosetteAPIException {
@@ -209,10 +230,10 @@ public InfoResponse info() throws IOException, HttpRosetteAPIException {
}
/**
- * Pings the Rosette API for a response indicating that the service is available.
+ * Pings the Analytics API for a response indicating that the service is available.
*
* @return PingResponse
- * @throws HttpRosetteAPIException Rosette specific exception
+ * @throws HttpRosetteAPIException Analytics specific exception
* @throws IOException General IO exception
*/
public PingResponse ping() throws IOException, HttpRosetteAPIException {
@@ -220,15 +241,34 @@ public PingResponse ping() throws IOException, HttpRosetteAPIException {
}
/**
- * Gets the set of language and script codes supported by the specified Rosette API endpoint.
+ * Gets the set of language and script codes supported by the specified Analytics API endpoint.
*
* @return SupportedLanguagesResponse
- * @throws HttpRosetteAPIException for an error returned from the Rosette API.
+ * @throws HttpRosetteAPIException for an error returned from the Analytics API.
*/
@Override
public SupportedLanguagesResponse getSupportedLanguages(String endpoint) throws HttpRosetteAPIException {
- if (DOC_ENDPOINTS.contains(endpoint)) {
- return sendGetRequest(urlBase + endpoint + SUPPORTED_LANGUAGES_SUBPATH, SupportedLanguagesResponse.class);
+ if (DOC_ENDPOINTS.contains(endpoint) || NAME_DEDUPLICATION_SERVICE_PATH.equals(endpoint)) {
+ return sendGetRequest(urlBase + endpoint + SUPPORTED_LANGUAGES_SUBPATH,
+ SupportedLanguagesResponse.class);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Gets the set of language, script codes and transliteration scheme pairs supported by the specified Analytics API
+ * endpoint.
+ *
+ * @param endpoint Analytics API endpoint.
+ * @return SupportedLanguagePairsResponse
+ * @throws HttpRosetteAPIException for an error returned from the Analytics API.
+ */
+ @Override
+ public SupportedLanguagePairsResponse getSupportedLanguagePairs(String endpoint) throws HttpRosetteAPIException {
+ if (NAMES_ENDPOINTS.contains(endpoint) && !NAME_DEDUPLICATION_SERVICE_PATH.equals(endpoint)) {
+ return sendGetRequest(urlBase + endpoint + SUPPORTED_LANGUAGES_SUBPATH,
+ SupportedLanguagePairsResponse.class);
} else {
return null;
}
@@ -242,15 +282,16 @@ public SupportedLanguagesResponse getSupportedLanguages(String endpoint) throws
* @param the type of the request object.
* @param the type of the response object.
* @return the response.
- * @throws HttpRosetteAPIException for an error returned from the Rosette API.
+ * @throws HttpRosetteAPIException for an error returned from the Analytics API.
* @throws RosetteRuntimeException for other errors, such as communications problems with HTTP.
*/
@Override
- public ResponseType perform(String endpoint, RequestType request, Class responseClass) throws HttpRosetteAPIException {
+ public ResponseType perform(String endpoint,
+ RequestType request, Class responseClass) throws HttpRosetteAPIException {
try {
return sendPostRequest(request, urlBase + endpoint, responseClass);
} catch (IOException e) {
- throw new RosetteRuntimeException("IO Exception communicating with the Rosette API", e);
+ throw new RosetteRuntimeException(IO_EXCEPTION_MESSAGE, e);
} catch (URISyntaxException e) {
throw new RosetteRuntimeException("Invalid URI", e);
}
@@ -262,15 +303,16 @@ public ResponseType
* @param request the data for the request.
* @param the type of the request object.
* @return the response, {@link com.basistech.rosette.dm.AnnotatedText}.
- * @throws HttpRosetteAPIException for an error returned from the Rosette API.
+ * @throws HttpRosetteAPIException for an error returned from the Analytics API.
* @throws RosetteRuntimeException for other errors, such as communications problems with HTTP.
*/
@Override
- public AnnotatedText perform(String endpoint, RequestType request) throws HttpRosetteAPIException {
+ public AnnotatedText perform(String endpoint, RequestType request)
+ throws HttpRosetteAPIException {
try {
return sendPostRequest(request, urlBase + endpoint, AnnotatedText.class);
} catch (IOException e) {
- throw new RosetteRuntimeException("IO Exception communicating with the Rosette API", e);
+ throw new RosetteRuntimeException(IO_EXCEPTION_MESSAGE, e);
} catch (URISyntaxException e) {
throw new RosetteRuntimeException("Invalid URI", e);
}
@@ -280,16 +322,18 @@ public AnnotatedText perform(String endpoint, Requ
* This method always throws UnsupportedOperationException.
*/
@Override
- public Future performAsync(String endpoint, RequestType request, Class responseClass) throws HttpRosetteAPIException {
+ public Future
+ performAsync(String endpoint, RequestType request, Class responseClass)
+ throws HttpRosetteAPIException {
throw new UnsupportedOperationException("Asynchronous operations are not yet supported");
}
/**
- * Sends a GET request to Rosette API.
+ * Sends a GET request to Analytics API.
*
* Returns a Response.
*
- * @param urlStr Rosette API end point.
+ * @param urlStr Analytics API end point.
* @param clazz Response class
* @return Response
* @throws HttpRosetteAPIException
@@ -305,21 +349,22 @@ private T sendGetRequest(String urlStr, Class clazz) thr
responseHeadersToExtendedInformation(resp, httpResponse);
return resp;
} catch (IOException e) {
- throw new RosetteRuntimeException("IO Exception communicating with the Rosette API", e);
+ throw new RosetteRuntimeException(IO_EXCEPTION_MESSAGE, e);
}
}
/**
- * Sends a POST request to Rosette API.
+ * Sends a POST request to Analytics API.
*
* Returns a Response.
*
- * @param urlStr Rosette API end point.
+ * @param urlStr Analytics API end point.
* @param clazz Response class
* @return Response
* @throws IOException
*/
- private T sendPostRequest(Object request, String urlStr, Class clazz) throws IOException, URISyntaxException {
+ private T sendPostRequest(Object request, String urlStr, Class clazz)
+ throws IOException, URISyntaxException {
ObjectWriter writer = mapper.writer().without(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
boolean notPlainText = false;
if (request instanceof DocumentRequest) {
@@ -359,9 +404,14 @@ private T sendPostRequest(Object request, String urlStr, Class clazz) thr
while (numRetries-- > 0) {
try (CloseableHttpResponse response = httpClient.execute(post)) {
T resp = getResponse(response, clazz);
+ // TODO: Remove in a future release
Header ridHeader = response.getFirstHeader("X-RosetteAPI-DocumentRequest-Id");
if (ridHeader != null && ridHeader.getValue() != null) {
- LOG.debug("DocumentRequest ID " + ridHeader.getValue());
+ LOG.debug("DocumentRequest ID {}", ridHeader.getValue());
+ }
+ Header bsidHeader = response.getFirstHeader("X-BabelStreetAPI-DocumentRequest-Id");
+ if (bsidHeader != null && bsidHeader.getValue() != null) {
+ LOG.debug("DocumentRequest ID {}", bsidHeader.getValue());
}
if (resp instanceof Response) {
responseHeadersToExtendedInformation((Response)resp, response);
@@ -388,7 +438,8 @@ private void responseHeadersToExtendedInformation(T resp, H
if (resp.getExtendedInformation().get(header.getName()) instanceof Set) {
currentSetValue = (Set
@@ -65,19 +78,6 @@
-
- biz.aQute.bnd
- bnd-maven-plugin
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
- ${project.build.outputDirectory}/META-INF/MANIFEST.MF
-
-
- org.codehaus.mojobuild-helper-maven-plugin
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/AddressDeserializer.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/AddressDeserializer.java
new file mode 100644
index 000000000..bede24750
--- /dev/null
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/AddressDeserializer.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2020 Basis Technology Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.basistech.rosette.apimodel.jackson;
+
+import com.basistech.rosette.apimodel.FieldedAddress;
+import com.basistech.rosette.apimodel.IAddress;
+import com.basistech.rosette.apimodel.UnfieldedAddress;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.TreeNode;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.node.TextNode;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+public class AddressDeserializer extends StdDeserializer {
+
+ private static final String UNFIELDED_KEY = "address";
+
+ AddressDeserializer() {
+ super(IAddress.class);
+ }
+
+ @Override
+ public IAddress deserialize(JsonParser jp, DeserializationContext ctxt)
+ throws IOException {
+ ObjectMapper mapper = (ObjectMapper) jp.getCodec();
+ TreeNode root = mapper.readTree(jp);
+ Class extends IAddress> addressClass = FieldedAddress.class;
+ if (root instanceof TextNode) {
+ // We only have a JsonProperty-based constructor, so we can't
+ // have jackson create the object for us.
+ return new UnfieldedAddress(((TextNode) root).textValue());
+ } else {
+ Iterator> iterator = ((ObjectNode)root).fields();
+ if (iterator.hasNext()) {
+ Map.Entry element = iterator.next();
+ if (UNFIELDED_KEY.equals(element.getKey())) {
+ addressClass = UnfieldedAddress.class;
+ }
+ }
+ }
+ return mapper.treeToValue(root, addressClass);
+ }
+}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/AddressMixin.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/AddressMixin.java
new file mode 100644
index 000000000..c1e21f2fa
--- /dev/null
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/AddressMixin.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2022 Basis Technology Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.basistech.rosette.apimodel.jackson;
+
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
+
+@JsonTypeName("Address")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public abstract class AddressMixin {
+
+ @JsonCreator
+ protected AddressMixin(@JsonProperty("house") String house,
+ @JsonProperty("houseNumber") String houseNumber,
+ @JsonProperty("road") String road,
+ @JsonProperty("unit") String unit,
+ @JsonProperty("level") String level,
+ @JsonProperty("staircase") String staircase,
+ @JsonProperty("entrance") String entrance,
+ @JsonProperty("suburb") String suburb,
+ @JsonProperty("cityDistrict") String cityDistrict,
+ @JsonProperty("city") String city,
+ @JsonProperty("island") String island,
+ @JsonProperty("stateDistrict") String stateDistrict,
+ @JsonProperty("state") String state,
+ @JsonProperty("countryRegion") String countryRegion,
+ @JsonProperty("country") String country,
+ @JsonProperty("worldRegion") String worldRegion,
+ @JsonProperty("postCode") String postCode,
+ @JsonProperty("poBox") String poBox,
+ @JsonProperty("extra") Map extra,
+ @JsonProperty("uid") String uid) {
+ //
+ }
+
+ @JsonCreator
+ protected AddressMixin() {
+ //
+ }
+
+ @JsonPOJOBuilder(withPrefix = "")
+ abstract static class AddressBuilderMixin {
+ }
+}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/AddressSimilarityRequestMixin.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/AddressSimilarityRequestMixin.java
new file mode 100644
index 000000000..bb391655f
--- /dev/null
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/AddressSimilarityRequestMixin.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2022 Basis Technology Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.basistech.rosette.apimodel.jackson;
+
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
+
+import com.basistech.rosette.apimodel.IAddress;
+
+@JsonTypeName("AddressSimilarityRequest")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class AddressSimilarityRequestMixin {
+
+ @JsonCreator
+ protected AddressSimilarityRequestMixin(
+ @JsonProperty("profileId") String profileId,
+ @JsonProperty("address1") IAddress address1,
+ @JsonProperty("address2") IAddress address2,
+ @JsonProperty("parameters") Map parameters
+ ) {
+ //
+ }
+
+ @JsonPOJOBuilder(withPrefix = "")
+ abstract static class AddressSimilarityRequestBuilderMixin {
+ }
+}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/AdmRequestMixin.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/AdmRequestMixin.java
index 8ebbd1d1a..9d8cad03a 100644
--- a/json/src/main/java/com/basistech/rosette/apimodel/jackson/AdmRequestMixin.java
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/AdmRequestMixin.java
@@ -1,5 +1,5 @@
/*
-* Copyright 2017 Basis Technology Corp.
+* Copyright 2022 Basis Technology Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,13 +36,12 @@ protected AdmRequestMixin(
@JsonProperty("profileId") String profileId,
@JsonProperty("text") AnnotatedText text,
@JsonProperty("options") Options options,
- @JsonProperty("genre") String genre,
@JsonProperty("language") LanguageCode language
) {
//
}
@JsonPOJOBuilder(withPrefix = "")
- abstract class AdmRequestBuilderMixin {
+ abstract static class AdmRequestBuilderMixin {
}
}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/ApiModelMixinModule.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/ApiModelMixinModule.java
index d73a4269b..16d30a1f3 100644
--- a/json/src/main/java/com/basistech/rosette/apimodel/jackson/ApiModelMixinModule.java
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/ApiModelMixinModule.java
@@ -16,28 +16,44 @@
package com.basistech.rosette.apimodel.jackson;
+import com.basistech.rosette.apimodel.AddressSimilarityRequest;
import com.basistech.rosette.apimodel.AdmRequest;
+import com.basistech.rosette.apimodel.ConfigurationRequest;
import com.basistech.rosette.apimodel.DocumentRequest;
+import com.basistech.rosette.apimodel.FieldedAddress;
+import com.basistech.rosette.apimodel.IAddress;
import com.basistech.rosette.apimodel.Name;
import com.basistech.rosette.apimodel.NameDeduplicationRequest;
+import com.basistech.rosette.apimodel.jackson.recordsimilaritydeserializers.AddressFieldDeserializer;
+import com.basistech.rosette.apimodel.jackson.recordsimilaritydeserializers.DateFieldDeserializer;
+import com.basistech.rosette.apimodel.jackson.recordsimilaritydeserializers.NameFieldDeserializer;
+import com.basistech.rosette.apimodel.jackson.recordsimilaritydeserializers.RecordSimilarityResponseDeserializer;
+import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityResponse;
+import com.basistech.rosette.apimodel.recordsimilarity.records.AddressField;
+import com.basistech.rosette.apimodel.recordsimilarity.records.DateField;
+import com.basistech.rosette.apimodel.recordsimilarity.records.NameField;
import com.basistech.rosette.apimodel.NameSimilarityRequest;
import com.basistech.rosette.apimodel.NameTranslationRequest;
+import com.basistech.rosette.apimodel.UnfieldedAddress;
+import com.basistech.rosette.apimodel.jackson.recordsimilaritydeserializers.RecordSimilarityRequestDeserializer;
+import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityRequest;
import com.basistech.rosette.dm.jackson.AnnotatedDataModelModule;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.module.SimpleDeserializers;
/**
* Jackson module to configure Json serialization and deserialization for the
* Rosette API model.
*/
-@SuppressWarnings("deprecation")
public class ApiModelMixinModule extends AnnotatedDataModelModule {
public ApiModelMixinModule() {
super();
}
+ @Override
public void setupModule(Module.SetupContext context) {
super.setupModule(context);
@@ -45,18 +61,46 @@ public void setupModule(Module.SetupContext context) {
MixinUtil.addMixins(context);
context.setMixInAnnotations(DocumentRequest.class, DocumentRequestMixin.class);
- context.setMixInAnnotations(DocumentRequest.DocumentRequestBuilder.class, DocumentRequestMixin.DocumentRequestBuilderMixin.class);
+ context.setMixInAnnotations(DocumentRequest.DocumentRequestBuilder.class,
+ DocumentRequestMixin.DocumentRequestBuilderMixin.class);
context.setMixInAnnotations(AdmRequest.class, AdmRequestMixin.class);
context.setMixInAnnotations(AdmRequest.AdmRequestBuilder.class, AdmRequestMixin.AdmRequestBuilderMixin.class);
context.setMixInAnnotations(Name.class, NameMixin.class);
context.setMixInAnnotations(Name.NameBuilder.class, NameMixin.NameBuilderMixin.class);
context.setMixInAnnotations(NameSimilarityRequest.class, NameSimilarityRequestMixin.class);
- context.setMixInAnnotations(NameSimilarityRequest.NameSimilarityRequestBuilder.class, NameSimilarityRequestMixin.NameSimilarityRequestBuilderMixin.class);
+ context.setMixInAnnotations(NameSimilarityRequest.NameSimilarityRequestBuilder.class,
+ NameSimilarityRequestMixin.NameSimilarityRequestBuilderMixin.class);
context.setMixInAnnotations(NameTranslationRequest.class, NameTranslationRequestMixin.class);
- context.setMixInAnnotations(NameTranslationRequest.NameTranslationRequestBuilder.class, NameTranslationRequestMixin.NameTranslationRequestBuilderMixin.class);
+ context.setMixInAnnotations(NameTranslationRequest.NameTranslationRequestBuilder.class,
+ NameTranslationRequestMixin.NameTranslationRequestBuilderMixin.class);
context.setMixInAnnotations(NameDeduplicationRequest.class, NameDeduplicationRequestMixin.class);
- context.setMixInAnnotations(NameDeduplicationRequest.NameDeduplicationRequestBuilder.class, NameDeduplicationRequestMixin.NameDeduplicationRequestBuilderMixin.class);
+ context.setMixInAnnotations(NameDeduplicationRequest.NameDeduplicationRequestBuilder.class,
+ NameDeduplicationRequestMixin.NameDeduplicationRequestBuilderMixin.class);
+
+ context.setMixInAnnotations(FieldedAddress.class, FieldedAddressMixin.class);
+ context.setMixInAnnotations(FieldedAddress.FieldedAddressBuilder.class,
+ FieldedAddressMixin.FieldedAddressBuilderMixin.class);
+ context.setMixInAnnotations(UnfieldedAddress.class, UnfieldedAddressMixin.class);
+ context.setMixInAnnotations(UnfieldedAddress.UnfieldedAddressBuilder.class,
+ UnfieldedAddressMixin.UnfieldedAddressBuilderMixin.class);
+
+ context.setMixInAnnotations(AddressSimilarityRequest.class, AddressSimilarityRequestMixin.class);
+ context.setMixInAnnotations(AddressSimilarityRequest.AddressSimilarityRequestBuilder.class,
+ AddressSimilarityRequestMixin.AddressSimilarityRequestBuilderMixin.class);
+ context.setMixInAnnotations(ConfigurationRequest.class, ConfigurationRequestMixin.class);
+ context.setMixInAnnotations(ConfigurationRequest.ConfigurationRequestBuilder.class,
+ ConfigurationRequestMixin.ConfigurationRequestBuilderMixin.class);
+
+ // IAddresses require a custom deserializer
+ SimpleDeserializers deserializers = new SimpleDeserializers();
+ deserializers.addDeserializer(IAddress.class, new AddressDeserializer());
+ deserializers.addDeserializer(NameField.class, new NameFieldDeserializer());
+ deserializers.addDeserializer(DateField.class, new DateFieldDeserializer());
+ deserializers.addDeserializer(AddressField.class, new AddressFieldDeserializer());
+ deserializers.addDeserializer(RecordSimilarityRequest.class, new RecordSimilarityRequestDeserializer());
+ deserializers.addDeserializer(RecordSimilarityResponse.class, new RecordSimilarityResponseDeserializer());
+ context.addDeserializers(deserializers);
}
/**
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/ConfigurationRequestMixin.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/ConfigurationRequestMixin.java
new file mode 100644
index 000000000..09400fec8
--- /dev/null
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/ConfigurationRequestMixin.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2022 Basis Technology Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.basistech.rosette.apimodel.jackson;
+
+import com.basistech.rosette.apimodel.Configuration;
+import com.basistech.util.LanguageCode;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
+
+@JsonTypeName("ConfigurationRequest")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ConfigurationRequestMixin {
+ @JsonCreator
+ protected ConfigurationRequestMixin(
+ @JsonProperty("profileId") String profileId,
+ @JsonProperty("language") LanguageCode language,
+ @JsonProperty("configuration") Configuration configuration
+ ) {
+ //
+ }
+
+ @JsonPOJOBuilder(withPrefix = "")
+ abstract static class ConfigurationRequestBuilderMixin {
+ }
+}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/DocumentRequestMixin.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/DocumentRequestMixin.java
index b02541510..5070277d1 100644
--- a/json/src/main/java/com/basistech/rosette/apimodel/jackson/DocumentRequestMixin.java
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/DocumentRequestMixin.java
@@ -1,5 +1,5 @@
/*
-* Copyright 2017 Basis Technology Corp.
+* Copyright 2022 Basis Technology Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
import com.basistech.util.LanguageCode;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
@@ -30,6 +31,7 @@
//CHECKSTYLE:OFF
@JsonTypeName("DocumentRequest")
+@JsonIgnoreProperties({"genre"})
@JsonInclude(JsonInclude.Include.NON_NULL)
public abstract class DocumentRequestMixin {
@@ -47,14 +49,13 @@ protected DocumentRequestMixin(
@JsonProperty("content") Object content,
@JsonProperty("contentUri") String contentUri,
@JsonProperty("contentType") String contentType,
- @JsonProperty("genre") String genre,
@JsonProperty("options") Options options
) {
//
}
@JsonPOJOBuilder(withPrefix = "")
- abstract class DocumentRequestBuilderMixin {
+ abstract static class DocumentRequestBuilderMixin {
}
@JsonIgnore
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/FieldedAddressMixin.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/FieldedAddressMixin.java
new file mode 100644
index 000000000..a288b7918
--- /dev/null
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/FieldedAddressMixin.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2022 Basis Technology Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.basistech.rosette.apimodel.jackson;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
+
+@JsonTypeName("FieldedAddress")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public abstract class FieldedAddressMixin {
+
+ @JsonCreator
+ protected FieldedAddressMixin(@JsonProperty("house") String house,
+ @JsonProperty("houseNumber") String houseNumber,
+ @JsonProperty("road") String road,
+ @JsonProperty("unit") String unit,
+ @JsonProperty("level") String level,
+ @JsonProperty("staircase") String staircase,
+ @JsonProperty("entrance") String entrance,
+ @JsonProperty("suburb") String suburb,
+ @JsonProperty("cityDistrict") String cityDistrict,
+ @JsonProperty("city") String city,
+ @JsonProperty("island") String island,
+ @JsonProperty("stateDistrict") String stateDistrict,
+ @JsonProperty("state") String state,
+ @JsonProperty("countryRegion") String countryRegion,
+ @JsonProperty("country") String country,
+ @JsonProperty("worldRegion") String worldRegion,
+ @JsonProperty("postCode") String postCode,
+ @JsonProperty("poBox") String poBox) {
+ //
+ }
+
+ @JsonPOJOBuilder(withPrefix = "")
+ abstract static class FieldedAddressBuilderMixin {
+ }
+}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/NameDeduplicationRequestMixin.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/NameDeduplicationRequestMixin.java
index 2afe774e3..0a07ca1f6 100644
--- a/json/src/main/java/com/basistech/rosette/apimodel/jackson/NameDeduplicationRequestMixin.java
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/NameDeduplicationRequestMixin.java
@@ -1,5 +1,5 @@
/*
-* Copyright 2017 Basis Technology Corp.
+* Copyright 2022 Basis Technology Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,6 +41,6 @@ protected NameDeduplicationRequestMixin(
}
@JsonPOJOBuilder(withPrefix = "")
- abstract class NameDeduplicationRequestBuilderMixin {
+ abstract static class NameDeduplicationRequestBuilderMixin {
}
}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/NameSimilarityRequestMixin.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/NameSimilarityRequestMixin.java
index 45e8a5d58..7dac7d791 100644
--- a/json/src/main/java/com/basistech/rosette/apimodel/jackson/NameSimilarityRequestMixin.java
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/NameSimilarityRequestMixin.java
@@ -1,5 +1,5 @@
/*
-* Copyright 2017 Basis Technology Corp.
+* Copyright 2022 Basis Technology Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,10 @@
package com.basistech.rosette.apimodel.jackson;
+import java.util.Map;
+
import com.basistech.rosette.apimodel.Name;
+
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -33,12 +36,13 @@ public abstract class NameSimilarityRequestMixin {
protected NameSimilarityRequestMixin(
@JsonProperty("profileId") String profileId,
@JsonProperty("name1") Name name1,
- @JsonProperty("name2") Name name2
- ) {
+ @JsonProperty("name2") Name name2,
+ @JsonProperty("parameters") Map parameters
+ ) {
//
}
@JsonPOJOBuilder(withPrefix = "")
- abstract class NameSimilarityRequestBuilderMixin {
+ abstract static class NameSimilarityRequestBuilderMixin {
}
}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/NameTranslationRequestMixin.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/NameTranslationRequestMixin.java
index 034341d66..90b0976bb 100644
--- a/json/src/main/java/com/basistech/rosette/apimodel/jackson/NameTranslationRequestMixin.java
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/NameTranslationRequestMixin.java
@@ -1,5 +1,5 @@
/*
-* Copyright 2017 Basis Technology Corp.
+* Copyright 2022 Basis Technology Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,12 +41,13 @@ protected NameTranslationRequestMixin(
@JsonProperty("sourceLanguageOfUse") LanguageCode sourceLanguageOfUse,
@JsonProperty("targetLanguage") LanguageCode targetLanguage,
@JsonProperty("targetScript") ISO15924 targetScript,
- @JsonProperty("targetScheme") TransliterationScheme targetScheme
+ @JsonProperty("targetScheme") TransliterationScheme targetScheme,
+ @JsonProperty("maximumResults") Integer maximumResults
) {
//
}
@JsonPOJOBuilder(withPrefix = "")
- abstract class NameTranslationRequestBuilderMixin {
+ abstract static class NameTranslationRequestBuilderMixin {
}
}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/UnfieldedAddressMixin.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/UnfieldedAddressMixin.java
new file mode 100644
index 000000000..2a2bd6223
--- /dev/null
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/UnfieldedAddressMixin.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2022 Basis Technology Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.basistech.rosette.apimodel.jackson;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
+
+@JsonTypeName("UnfieldedAddress")
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public abstract class UnfieldedAddressMixin {
+
+
+ @JsonCreator
+ protected UnfieldedAddressMixin(@JsonProperty("address") String address) {
+ //
+ }
+
+ @JsonPOJOBuilder(withPrefix = "")
+ abstract static class UnfieldedAddressBuilderMixin {
+ }
+}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/AddressFieldDeserializer.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/AddressFieldDeserializer.java
new file mode 100644
index 000000000..b38c46217
--- /dev/null
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/AddressFieldDeserializer.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2024 Basis Technology Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.basistech.rosette.apimodel.jackson.recordsimilaritydeserializers;
+
+import com.basistech.rosette.apimodel.recordsimilarity.records.AddressField;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
+
+import java.io.IOException;
+
+public class AddressFieldDeserializer extends StdDeserializer {
+ public AddressFieldDeserializer() {
+ super(AddressField.class);
+ }
+
+ @Override
+ public AddressField deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
+ final JsonNode node = jsonParser.getCodec().readTree(jsonParser);
+ if (node.isObject()) {
+ return jsonParser.getCodec().treeToValue(node, AddressField.FieldedAddress.class);
+ } else if (node.isTextual()) {
+ return AddressField.UnfieldedAddress.builder().address(node.textValue()).build();
+ }
+ throw new IOException("Invalid JSON structure: unexpected node type");
+ }
+}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/DateFieldDeserializer.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/DateFieldDeserializer.java
new file mode 100644
index 000000000..422f34252
--- /dev/null
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/DateFieldDeserializer.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2024 Basis Technology Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.basistech.rosette.apimodel.jackson.recordsimilaritydeserializers;
+
+import com.basistech.rosette.apimodel.recordsimilarity.records.DateField;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
+
+import java.io.IOException;
+
+public class DateFieldDeserializer extends StdDeserializer {
+ public DateFieldDeserializer() {
+ super(DateField.class);
+ }
+
+ @Override
+ public DateField deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
+ final JsonNode node = jsonParser.getCodec().readTree(jsonParser);
+ if (node.isObject()) {
+ return jsonParser.getCodec().treeToValue(node, DateField.FieldedDate.class);
+ } else if (node.isTextual()) {
+ return DateField.UnfieldedDate.builder().date(node.textValue()).build();
+ }
+ throw new IOException("Invalid JSON structure: unexpected node type");
+ }
+}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/NameFieldDeserializer.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/NameFieldDeserializer.java
new file mode 100644
index 000000000..8fb372bc0
--- /dev/null
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/NameFieldDeserializer.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2024 Basis Technology Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.basistech.rosette.apimodel.jackson.recordsimilaritydeserializers;
+
+import com.basistech.rosette.apimodel.recordsimilarity.records.NameField;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
+
+import java.io.IOException;
+
+public class NameFieldDeserializer extends StdDeserializer {
+ public NameFieldDeserializer() {
+ super(NameField.class);
+ }
+
+ @Override
+ public NameField deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
+ final JsonNode node = jsonParser.getCodec().readTree(jsonParser);
+ if (node.isObject()) {
+ return jsonParser.getCodec().treeToValue(node, NameField.FieldedName.class);
+ } else if (node.isTextual()) {
+ return NameField.UnfieldedName.builder().text(node.textValue()).build();
+ }
+ throw new IOException("Invalid JSON structure: unexpected node type");
+ }
+}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/RecordSimilarityDeserializerUtilities.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/RecordSimilarityDeserializerUtilities.java
new file mode 100644
index 000000000..2618938e8
--- /dev/null
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/RecordSimilarityDeserializerUtilities.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2024 Basis Technology Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.basistech.rosette.apimodel.jackson.recordsimilaritydeserializers;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityExplainInfo;
+import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityResult;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
+
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotNull;
+
+import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityFieldInfo;
+import com.basistech.rosette.apimodel.recordsimilarity.records.AddressField;
+import com.basistech.rosette.apimodel.recordsimilarity.records.BooleanField;
+import com.basistech.rosette.apimodel.recordsimilarity.records.DateField;
+import com.basistech.rosette.apimodel.recordsimilarity.records.NameField;
+import com.basistech.rosette.apimodel.recordsimilarity.records.NumberField;
+import com.basistech.rosette.apimodel.recordsimilarity.records.RecordFieldType;
+import com.basistech.rosette.apimodel.recordsimilarity.records.RecordSimilarityField;
+import com.basistech.rosette.apimodel.recordsimilarity.records.StringField;
+import com.basistech.rosette.apimodel.recordsimilarity.records.UnknownField;
+
+final class RecordSimilarityDeserializerUtilities {
+
+ private RecordSimilarityDeserializerUtilities() {
+ }
+
+ public static RecordSimilarityResult parseResult(JsonNode node, JsonParser jsonParser) throws IOException {
+ final Double score = node.get("score") != null
+ ? node.get("score").traverse(jsonParser.getCodec()).readValueAs(Double.class)
+ : null;
+ final RecordSimilarityExplainInfo explainInfo = node.get("explainInfo") != null
+ ? node.get("explainInfo").traverse(jsonParser.getCodec()).readValueAs(RecordSimilarityExplainInfo.class)
+ : null;
+ final Map left = node.get("left") != null
+ ? parseRecordForResponse(node.get("left"), jsonParser)
+ : null;
+ final Map right = node.get("right") != null
+ ? parseRecordForResponse(node.get("right"), jsonParser)
+ : null;
+
+ List errorList = Optional.ofNullable(node.get("error"))
+ .map(jsonNode -> StreamSupport.stream(jsonNode.spliterator(), false)
+ .map(JsonNode::asText)
+ .collect(Collectors.toList()))
+ .orElse(null);
+ final List info = Optional.ofNullable(node.get("info"))
+ .map(jsonNode -> StreamSupport.stream(jsonNode.spliterator(), false)
+ .map(JsonNode::asText)
+ .collect(Collectors.toList()))
+ .orElse(null);
+ return RecordSimilarityResult.builder()
+ .score(score)
+ .left(left)
+ .right(right)
+ .explainInfo(explainInfo)
+ .error(errorList)
+ .info(info)
+ .build();
+ }
+
+ static Map parseRecordForResponse(JsonNode jsonNode, JsonParser jsonParser) {
+ final Map recordMap = new HashMap<>();
+ jsonNode.fields().forEachRemaining(entry -> {
+ String fieldName = entry.getKey();
+ try {
+ recordMap.put(fieldName, jsonNode.get(fieldName).traverse(jsonParser.getCodec())
+ .readValueAs(UnknownField.class));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ });
+ return recordMap;
+ }
+
+ static Map parseRecord(
+ JsonNode jsonNode,
+ JsonParser jsonParser,
+ @NotNull @Valid Map fields
+ ) throws IOException {
+ final Iterator> recordsIterator = jsonNode.fields();
+ final Map recordMap = new HashMap<>();
+ while (recordsIterator.hasNext()) {
+ final Map.Entry recordEntry = recordsIterator.next();
+ final String fieldName = recordEntry.getKey();
+ final JsonNode fieldValue = recordEntry.getValue();
+
+ final RecordSimilarityField fieldData;
+
+ if (fields.containsKey(fieldName)) {
+ final RecordSimilarityFieldInfo fieldInfo = fields.get(fieldName);
+ if (fieldInfo.getType() == null) {
+ throw new IllegalArgumentException("Unspecified field type for: " + fieldName);
+ }
+ switch (fieldInfo.getType().toLowerCase(Locale.ENGLISH)) {
+ case RecordFieldType.RNI_DATE:
+ fieldData = fieldValue.traverse(jsonParser.getCodec()).readValueAs(DateField.class);
+ break;
+ case RecordFieldType.RNI_NAME:
+ fieldData = fieldValue.traverse(jsonParser.getCodec()).readValueAs(NameField.class);
+ break;
+ case RecordFieldType.RNI_ADDRESS:
+ fieldData = fieldValue.traverse(jsonParser.getCodec()).readValueAs(AddressField.class);
+ break;
+ case RecordFieldType.RNI_STRING:
+ fieldData = StringField.builder().data(fieldValue.textValue()).build();
+ break;
+ case RecordFieldType.RNI_NUMBER:
+ fieldData = NumberField.builder().data(fieldValue.numberValue()).build();
+ break;
+ case RecordFieldType.RNI_BOOLEAN:
+ // Be sure not to accidentally convert non-boolean values to 'false'
+ fieldData = BooleanField.builder()
+ .data(fieldValue.isBoolean() ? fieldValue.booleanValue() : null)
+ .build();
+ break;
+ default:
+ fieldData = fieldValue.traverse(jsonParser.getCodec()).readValueAs(UnknownField.class);
+ }
+ } else {
+ //treat unmapped field as UnknownField so we can get to scoring,
+ //it won't be counted toward the score anyway
+ fieldData = fieldValue.traverse(jsonParser.getCodec()).readValueAs(UnknownField.class);
+ }
+ recordMap.put(fieldName, fieldData);
+ }
+ return recordMap;
+ }
+}
diff --git a/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/RecordSimilarityRequestDeserializer.java b/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/RecordSimilarityRequestDeserializer.java
new file mode 100644
index 000000000..32b0fb6ab
--- /dev/null
+++ b/json/src/main/java/com/basistech/rosette/apimodel/jackson/recordsimilaritydeserializers/RecordSimilarityRequestDeserializer.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2024 Basis Technology Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.basistech.rosette.apimodel.jackson.recordsimilaritydeserializers;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
+
+import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityFieldInfo;
+import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityProperties;
+import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityRecords;
+import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityRequest;
+import com.basistech.rosette.apimodel.recordsimilarity.records.RecordSimilarityField;
+
+public class RecordSimilarityRequestDeserializer extends StdDeserializer {
+
+ public RecordSimilarityRequestDeserializer() {
+ super(RecordSimilarityRequest.class);
+ }
+
+ @Override
+ public RecordSimilarityRequest deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
+ try (jsonParser) {
+ final JsonNode node = jsonParser.getCodec().readTree(jsonParser);
+ final Map fields = node.get("fields") != null ? node.get("fields").traverse(jsonParser.getCodec()).readValueAs(new TypeReferenceannotations
@@ -61,34 +58,23 @@
jsoncommonapi
+ allexamplesrelease
-
-
-
- com.basistech
- common-api
- 36.2.0
-
-
- com.basistech
- adm-model
- 2.4.4
-
-
- com.basistech
- adm-json
- 2.4.4
-
-
-
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+ org.apache.maven.plugins
+ maven-pmd-plugin
+ org.apache.maven.pluginsmaven-clean-plugin
- ${maven-clean-plugin.version}
@@ -98,55 +84,20 @@
- falseorg.apache.maven.pluginsmaven-compiler-plugin
- ${maven-compiler-plugin.version}
-
- 1.7
- 1.7
- 1.7
-
-
-
- com.basistech
- bbh-maven-plugin
- 1.0.1
-
-
- osgi-version
- validate
-
- osgi-version
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- ${maven-javadoc-plugin.version}
-
-
- attach-javadocs
-
- jar
-
-
-
-
- **/target/generated-sources/annotations/com/basistech/rosette/apimodel/**
-
+ 17
+ 11
+ 11org.apache.maven.pluginsmaven-source-plugin
- ${maven-source-plugin.version}attach-sources
@@ -157,20 +108,6 @@
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
-
- set-dep-properties
- generate-resources
-
- properties
-
-
-
- org.codehaus.mojobuild-helper-maven-plugin
@@ -194,13 +131,14 @@
- biz.aQute.bnd
- bnd-maven-plugin
- ${bnd-maven-plugin.version}
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ ${maven-javadoc-plugin.version}
+ attach-javadocs
- bnd-process
+ jar
diff --git a/release/pom.xml b/release/pom.xml
index bcd30d2a8..7c39985a9 100644
--- a/release/pom.xml
+++ b/release/pom.xml
@@ -19,7 +19,7 @@
com.basistech.rosetterosette-api-java-binding
- 1.11.1-SNAPSHOT
+ 1.36.1-SNAPSHOTcom.basistech.rosetterosette-api-release
diff --git a/release/src/scripts/run_all_examples.sh b/release/src/scripts/run_all_examples.sh
old mode 100644
new mode 100755
index 8fb39bc71..1fb38168f
--- a/release/src/scripts/run_all_examples.sh
+++ b/release/src/scripts/run_all_examples.sh
@@ -1,34 +1,53 @@
#!/usr/bin/env bash
if [ $# -eq 0 ]; then
- echo "Usage: $0 API_KEY" 1>&2
+ echo "Usage: $0 API_KEY [ALT_URL]" 1>&2
exit 1
fi
key=$1
read -d '' examples <
-
-
- Rosette API
-
-
-
- org.apache.maven.skins
- maven-fluido-skin
- ${site-skin-version}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-