Skip to content

Commit c3ea355

Browse files
Merge pull request #63 from textkernel/fix-delete-multiple
Fix for TxClient.deleteMultipleDocuments()
2 parents faaa580 + d16a46d commit c3ea355

File tree

10 files changed

+131
-68
lines changed

10 files changed

+131
-68
lines changed

.github/pull_request_template.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- **This description will be used to generate release notes when the PR is merged**
2+
- add the label `ignore-for-release` to prevent this PR from being linked to a release
3+
- Please fill out the description of what was changed/added/fixed in this PR
4+
- Be sure to link any issues
5+
- Increment the version in the pom.xml and README.md if you want a release & maven publish to happen upon merge

.github/release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- ignore-for-release
5+
categories:
6+
- title: Changes
7+
labels:
8+
- "*"

.github/workflows/build.yml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,57 +8,7 @@ on:
88
- master
99

1010
jobs:
11-
get_javadocs_status:
12-
name: get-javadocs-status
13-
runs-on: ubuntu-latest
14-
steps:
15-
- uses: actions/checkout@v2
16-
with:
17-
fetch-depth: 10 # important for use of HEAD^2
18-
# find the last commit message on the source branch
19-
- name: Get last commit message
20-
shell: bash
21-
run: echo "##[set-output name=commitMsg;]$(git log --format=%B -n 1 HEAD^2)"
22-
id: extract_message
23-
outputs:
24-
# create an output that tells the following jobs whether or not we need to generate javadocs
25-
generate_javadocs: ${{ steps.extract_message.outputs.commitMsg != '--- auto-generation of javadocs ---' }}
26-
27-
publish-javadocs:
28-
needs: get_javadocs_status
29-
# only run this if we have not generated javadocs in last commit
30-
if: ${{ needs.get_javadocs_status.outputs.generate_javadocs == 'true' }}
31-
runs-on: ubuntu-latest
32-
steps:
33-
- uses: actions/checkout@v2
34-
- name: Set up JDK 1.8
35-
uses: actions/setup-java@v1
36-
with:
37-
java-version: 1.8
38-
# extract the PR source branch name from the env variable where we can use it later
39-
- name: Extract branch name
40-
shell: bash
41-
run: echo "##[set-output name=branch;]$(echo ${GITHUB_HEAD_REF#refs/heads/})"
42-
id: extract_branch
43-
# generate the javadocs into the target/site/apidocs folder (default)
44-
- name: Generate javadocs with Maven
45-
run: mvn javadoc:javadoc
46-
# publish the generated javadocs into the /docs folder on a new commit in this branch
47-
- name: Publish javadocs to GitHub Pages
48-
uses: JamesIves/[email protected]
49-
with:
50-
branch: ${{ steps.extract_branch.outputs.branch }}
51-
folder: target/site/apidocs
52-
target-folder: docs
53-
git-config-name: Continuous Integration
54-
git-config-email: [email protected]
55-
commit-message: --- auto-generation of javadocs ---
56-
token: ${{ secrets.JAVADOCS_CI_TOKEN }}
57-
5811
build:
59-
needs: get_javadocs_status
60-
# only run this if we have already generated javadocs in last commit
61-
if: ${{ needs.get_javadocs_status.outputs.generate_javadocs == 'false' }}
6212
runs-on: ubuntu-latest
6313
steps:
6414
- uses: actions/checkout@v2
@@ -70,10 +20,8 @@ jobs:
7020
run: mvn -B compile --file pom.xml
7121

7222
unit-tests:
73-
needs: get_javadocs_status
7423
runs-on: ubuntu-latest
7524
# only run this if we have already generated javadocs in last commit
76-
if: ${{ needs.get_javadocs_status.outputs.generate_javadocs == 'false' }}
7725
steps:
7826
- name: Checkout the latest code
7927
uses: actions/checkout@v2
Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,63 @@
11
# This workflow will build a package using Maven and then publish it to Maven Central when a release is created
22
# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path
33

4-
name: maven-publish
4+
name: create-release
55

66
on:
7-
release:
8-
types: [published]
7+
push:
8+
branches:
9+
- master
910
workflow_dispatch: #add this option in case of a failure and we need to re-run
1011

1112
jobs:
12-
build:
13-
13+
get-version-tag:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
- name: Get version
19+
id: package_version
20+
uses: PERES-Richard/[email protected]
21+
outputs:
22+
version_tag: v${{ steps.package_version.outputs.version }}
23+
check-tag-exists:
24+
needs: get-version-tag
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: mukunku/[email protected]
28+
id: check_tag
29+
with:
30+
tag: ${{ needs.get-version-tag.outputs.version_tag }}
31+
outputs:
32+
should_create_release: ${{ steps.check_tag.outputs.exists != 'true' }}
33+
create-release:
34+
needs: [check-tag-exists, get-version-tag]
35+
if: ${{ needs.check-tag-exists.outputs.should_create_release == 'true' }}
36+
runs-on: ubuntu-latest
37+
permissions:
38+
contents: write
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v2
42+
- name: Release
43+
uses: softprops/action-gh-release@v2
44+
with:
45+
generate_release_notes: true
46+
make_latest: 'true'
47+
tag_name: ${{ needs.get-version-tag.outputs.version_tag }}
48+
name: ${{ needs.get-version-tag.outputs.version_tag }}
49+
maven-publish:
50+
needs: [create-release, check-tag-exists]
51+
if: ${{ needs.check-tag-exists.outputs.should_create_release == 'true' }}
1452
runs-on: ubuntu-latest
15-
1653
steps:
1754
- uses: actions/checkout@v2
1855
- name: Set up JDK 1.8
1956
uses: actions/setup-java@v1
2057
with:
2158
java-version: 1.8
22-
2359
- name: Build with Maven
2460
run: mvn -B package -DskipTests --file pom.xml
25-
2661
- name: Set up Apache Maven Central
2762
uses: actions/setup-java@v1
2863
with: # running setup-java again overwrites the settings.xml
@@ -32,7 +67,6 @@ jobs:
3267
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
3368
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY_TK }} # Value of the GPG private key to import
3469
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
35-
3670
- name: Publish to Apache Maven Central
3771
run: mvn -B clean deploy -DskipTests
3872
env:

.github/workflows/docs-publish.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This workflow will generate javadocs, build, and test a package using Maven
2+
3+
name: docs-publish
4+
5+
on:
6+
push:
7+
branches:
8+
- master
9+
workflow_dispatch: #add this option in case of a failure and we need to re-run
10+
11+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
12+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up JDK 1.8
23+
uses: actions/setup-java@v1
24+
with:
25+
java-version: 1.8
26+
# generate the javadocs into the target/site/apidocs folder (default)
27+
- name: Generate javadocs with Maven
28+
run: mvn javadoc:javadoc
29+
# upload the generated docs into an artifact that can be used by the job below
30+
- name: Upload Artifacts
31+
uses: actions/upload-pages-artifact@v3
32+
with:
33+
path: target/site/apidocs
34+
deploy:
35+
needs: build
36+
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
37+
permissions:
38+
pages: write # to deploy to Pages
39+
id-token: write # to verify the deployment originates from an appropriate source
40+
41+
# Deploy to the github-pages environment
42+
environment:
43+
name: github-pages
44+
url: ${{ steps.deployment.outputs.page_url }}
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: Deploy to GitHub Pages
48+
id: deployment
49+
uses: actions/deploy-pages@v4

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The official Java SDK for the Textkernel Tx v10 API for resume/CV and job parsin
1313
### Gradle Users
1414
Add this dependency to your project's build file:
1515
```
16-
implementation "com.textkernel:tx-java:2.3.3"
16+
implementation "com.textkernel:tx-java:2.3.4"
1717
```
1818

1919
### Maven Users
@@ -22,13 +22,13 @@ Add this dependency to your project's POM:
2222
<dependency>
2323
<groupId>com.textkernel</groupId>
2424
<artifactId>tx-java</artifactId>
25-
<version>2.3.3</version>
25+
<version>2.3.4</version>
2626
</dependency>
2727
```
2828

2929
### Others
3030
You'll need to manually install the following JARs:
31-
- The Textkernel Tx JAR from https://repo1.maven.org/maven2/com/textkernel/tx-java/2.3.3/tx-java-2.3.3.jar
31+
- The Textkernel Tx JAR from https://repo1.maven.org/maven2/com/textkernel/tx-java/2.3.4/tx-java-2.3.4.jar
3232
- [Google Gson][gson_url] from https://repo1.maven.org/maven2/com/google/code/gson/gson/2.9.0/gson-2.9.0.jar
3333
- [Square OkHttp][okhttp_url] from https://repo1.maven.org/maven2/com/squareup/okhttp3/okhttp/4.12.0/okhttp-4.12.0.jar
3434

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.textkernel</groupId>
55
<artifactId>tx-java</artifactId>
66

7-
<version>2.3.3</version>
7+
<version>2.3.4</version>
88

99
<packaging>jar</packaging>
1010
<name>Textkernel Tx Java SDK</name>

src/main/java/com/textkernel/tx/TxClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,9 @@ public DeleteDocumentResponse deleteDocument(String indexId, String documentId)
571571
* @throws TxException Thrown when an API error occurs
572572
*/
573573
public DeleteMultipleDocumentsResponse deleteMultipleDocuments(String indexId, List<String> documentIds) throws TxException {
574-
RequestBody requestBody = createJsonBody(documentIds);
574+
DeleteMultipleDocumentsRequest request = new DeleteMultipleDocumentsRequest();
575+
request.DocumentIds = documentIds;
576+
RequestBody requestBody = createJsonBody(request);
575577
Request apiRequest = new Request.Builder()
576578
.url(_endpoints.multipleDocuments(indexId))
577579
.delete(requestBody)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright © 2023 Textkernel BV. All rights reserved.
2+
// This file is provided for use by, or on behalf of, Textkernel licensees
3+
// within the terms of their license of Textkernel products or Textkernel customers
4+
// within the Terms of Service pertaining to the Textkernel SaaS products.
5+
6+
package com.textkernel.tx.models.api.indexes;
7+
8+
import java.util.List;
9+
10+
/**
11+
* Request body to delete multiple indexed documents
12+
*/
13+
public class DeleteMultipleDocumentsRequest {
14+
15+
/** The document IDs to delete */
16+
public List<String> DocumentIds;
17+
}

src/test/java/com/textkernel/tx/integration/ParsingTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void testLargeDocumentParse() {
6666
Client.parseResume(new ParseRequest(new Document(new byte[40_000_000], LocalDate.now()), null));
6767
});
6868

69-
String expected = "Request body too large.";
69+
String expected = "Request body was too large";
7070
assertEquals(expected, e.getMessage().substring(0, expected.length()));
7171
}
7272

@@ -614,7 +614,7 @@ public void TestProfessionNormalization() throws Exception {
614614
assertNotNull(response.Value.ResumeData.EmploymentHistory.Positions.get(0).NormalizedProfession.ISCO);
615615
assertNotNull(response.Value.ResumeData.EmploymentHistory.Positions.get(0).NormalizedProfession.ONET);
616616
assertNotNull(response.Value.ResumeData.EmploymentHistory.Positions.get(0).NormalizedProfession.ONET.Version);
617-
assertEquals("2010", response.Value.ResumeData.EmploymentHistory.Positions.get(0).NormalizedProfession.ONET.Version);
617+
assertEquals("2019", response.Value.ResumeData.EmploymentHistory.Positions.get(0).NormalizedProfession.ONET.Version);
618618
assertNotEquals(0, response.Value.ResumeData.EmploymentHistory.Positions.get(0).NormalizedProfession.Confidence);
619619

620620
assertNotNull(response.Value.ResumeData.EmploymentHistory.Positions.get(1).NormalizedProfession);

0 commit comments

Comments
 (0)