From 3df94fc5122778264defc62f492d397fd2a1ace0 Mon Sep 17 00:00:00 2001 From: Bohdan Suprun Date: Fri, 24 Jul 2020 16:19:19 +0300 Subject: [PATCH 1/4] CIRCSTORE-223: Add loan.status.name b-tree index. --- .../templates/db_scripts/schema.json | 6 ++++++ .../java/org/folio/rest/api/LoansApiTest.java | 20 +++++++++++++++++++ .../support/builders/LoanRequestBuilder.java | 10 +++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/main/resources/templates/db_scripts/schema.json b/src/main/resources/templates/db_scripts/schema.json index f23367db2..61f3b7d8a 100644 --- a/src/main/resources/templates/db_scripts/schema.json +++ b/src/main/resources/templates/db_scripts/schema.json @@ -101,6 +101,12 @@ "tOps": "ADD", "caseSensitive": false, "removeAccents": false + }, + { + "fieldName": "status.name", + "tOps": "ADD", + "caseSensitive": false, + "removeAccents": true } ], "fullTextIndex": [ diff --git a/src/test/java/org/folio/rest/api/LoansApiTest.java b/src/test/java/org/folio/rest/api/LoansApiTest.java index 1cb92ffd9..dcdbd043f 100644 --- a/src/test/java/org/folio/rest/api/LoansApiTest.java +++ b/src/test/java/org/folio/rest/api/LoansApiTest.java @@ -12,6 +12,8 @@ import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.notNullValue; @@ -23,12 +25,14 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.List; import java.util.TimeZone; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.stream.Collectors; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; @@ -1322,6 +1326,22 @@ public void cannotProvideAdditionalPropertiesInLoanStatus() hasMessageContaining("Unrecognized field"))); } + @Test + public void canSearchByLoanStatus() throws Exception { + final IndividualResource openLoan = loansClient.create( + new LoanRequestBuilder().open().checkedOut()); + + loansClient.create(new LoanRequestBuilder().closed().checkedOut()); + + final List openLoans = loansClient.getMany("status.name==Open") + .getRecords().stream() + .map(json -> json.getString("id")) + .collect(Collectors.toList()); + + assertThat(openLoans, hasSize(1)); + assertThat(openLoans, hasItem(openLoan.getId())); + } + private JsonObject loanRequest() { return new LoanRequestBuilder().create(); } diff --git a/src/test/java/org/folio/rest/support/builders/LoanRequestBuilder.java b/src/test/java/org/folio/rest/support/builders/LoanRequestBuilder.java index 7c241bfbb..60d27b0fa 100644 --- a/src/test/java/org/folio/rest/support/builders/LoanRequestBuilder.java +++ b/src/test/java/org/folio/rest/support/builders/LoanRequestBuilder.java @@ -169,7 +169,7 @@ public static LoanRequestBuilder from(JsonObject example) { final DateTime claimedReturnedDate = example.containsKey("claimedReturnedDate") ? DateTime.parse(example.getString("claimedReturnedDate")) : null; - + final JsonObject agedToLostDelayedBilling = example.containsKey("agedToLostDelayedBilling") ? example.getJsonObject("agedToLostDelayedBilling") : null; @@ -278,7 +278,7 @@ public JsonObject create() { if (claimedReturnedDate != null) { request.put("claimedReturnedDate", claimedReturnedDate.toString()); } - + if (agedToLostDelayedBilling != null) { request.put("agedToLostDelayedBilling", agedToLostDelayedBilling); } @@ -817,7 +817,7 @@ public LoanRequestBuilder withClaimedReturnedDate(DateTime claimedReturnedDate) claimedReturnedDate, this.agedToLostDelayedBilling); } - + public LoanRequestBuilder withAgedToLostDelayedBilling(JsonObject agedToLostDelayedBilling) { return new LoanRequestBuilder( this.id, @@ -842,4 +842,8 @@ public LoanRequestBuilder withAgedToLostDelayedBilling(JsonObject agedToLostDela this.claimedReturnedDate, agedToLostDelayedBilling); } + + public LoanRequestBuilder checkedOut() { + return withAction("checkedout").withItemStatus("Checked out"); + } } From 2cc9a5a0bfb035d00f3ddd831b3b44b426d93f84 Mon Sep 17 00:00:00 2001 From: Marc Johnson Date: Thu, 30 Jul 2020 16:38:47 +0100 Subject: [PATCH 2/4] Update news to reflect 12.0.2 release CIRCSTORE-229 --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index aca83a2e3..fe44589aa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +## 12.0.2 2020-07-30 + +* Introduces b-tree index for `status.name` property on `loan` records (CIRCSTORE-223) + ## 12.0.1 2020-07-15 * Introduces b-tree index for `requestType` property on `request` records (CIRCSTORE-219) From c1ba2645717a8c2bf327e55b40775202c3bc5fd5 Mon Sep 17 00:00:00 2001 From: Marc Johnson Date: Thu, 30 Jul 2020 16:39:53 +0100 Subject: [PATCH 3/4] [maven-release-plugin] prepare release v12.0.2 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 924434b3d..38b4c1be3 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 mod-circulation-storage org.folio - 12.0.2-SNAPSHOT + 12.0.2 Apache License 2.0 @@ -98,7 +98,7 @@ https://github.com/folio-org/mod-circulation-storage scm:git:git://github.com:folio-org/mod-circulation-storage.git scm:git:git@github.com:folio-org/mod-circulation-storage.git - v12.0.0 + v12.0.2 From 36627bd6281aeca872a5089273c2f6bbfcbdd436 Mon Sep 17 00:00:00 2001 From: Marc Johnson Date: Thu, 30 Jul 2020 16:39:53 +0100 Subject: [PATCH 4/4] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 38b4c1be3..12396c40a 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 mod-circulation-storage org.folio - 12.0.2 + 12.0.3-SNAPSHOT Apache License 2.0 @@ -98,7 +98,7 @@ https://github.com/folio-org/mod-circulation-storage scm:git:git://github.com:folio-org/mod-circulation-storage.git scm:git:git@github.com:folio-org/mod-circulation-storage.git - v12.0.2 + v12.0.0