Skip to content

Commit

Permalink
Merge branch 'master' into CIRCSTORE-377
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-barannyk authored Oct 26, 2023
2 parents c77c5db + e021361 commit c99d037
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 37 deletions.
30 changes: 30 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
## 17.1.0 2023-10-12
* Add notice triggering event `Due date - with reminder fee` (CIRCSTORE-452)
* Add missing descriptions to JSON-schemas (CIRCSTORE-409)
* Change `instaceId` index - remove accents (CIRCSTORE-453)
* Add b-tree index of action for `loan` table (CIRCSTORE-272)
* Create constraints only if they don't exist (CIRCSTORE-445)
* Return single error for invalid request policy (CIRCSTORE-451)
* Validate allowed service points on POST and PUT (CIRCSTORE-429)
* Allow to create Actual cost record without Expiration date (CIRCSTORE-447)
* Add allowed pickup service points to request policy schema (CIRCSTORE-424)
* Fix slow response for CQL searching - requests (CIRCSTORE-411)
* Migrate to Java 17 (CIRCSTORE-430)
* Add metadata object information to circ rules editor screen (CIRCSTORE-410)
* Modify circulation DTOs to include source field (CIRCSTORE-431)
* Use new RMB readonly APIs (CIRCSTORE-359)
* Implement GET, POST and DELETE endpoints for checkout lock (CIRCSTORE-416)
* Add sessionId to scheduled notice and patron action session (CIRCSTORE-421)
* Update request seach index when service point is updated (CIRCSTORE-408)
* Add property `loan.reminders` (CIRCSTORE-414)
* Use GitHub Workflows api-lint and api-schema-lint and api-doc (CIRCSTORE-415)
* Change spelling of `fulfilmentPreference` (CIRSTORE-413)
* Add logging to abstract request migration service (CIRCSTORE-400)
* Handle item update events (CIRCSTORE-407)
* Implement search fields migration (CIRCSTORE-400)
* Search index fields migration script skeleton (CIRCSTORE-399)
* Add effective call number, shelving order and pickup service point name fields to the request schema (CIRCSTORE-398)
* Add b-tree indices to DB schema (CIRCSTORE-402)
* Create index for Actual Cost Record `status` field (CIRCSTORE-397)
* Add default configuration handling for not initialized TLR settings (CIRCSTORE-412)

## 16.0.0 2023-02-15
* Use folio-kafka-wrapper service to work with KafkaAdminClient (CIRCSTORE-369)
* Add TLR requests expiration logic and queue recalculation (CIRCSTORE-368)
Expand Down
2 changes: 1 addition & 1 deletion descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@
},
{
"id": "scheduled-notice-storage",
"version": "0.5",
"version": "0.6",
"handlers": [
{
"methods": ["GET"],
Expand Down
24 changes: 12 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>mod-circulation-storage</artifactId>
<groupId>org.folio</groupId>
<version>16.1.0-SNAPSHOT</version>
<version>17.2.0-SNAPSHOT</version>
<licenses>
<license>
<name>Apache License 2.0</name>
Expand All @@ -28,14 +28,21 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<ramlfiles_path>${basedir}/ramls</ramlfiles_path>
<vertx-version>4.3.5</vertx-version>
<raml-module-builder-version>35.0.4</raml-module-builder-version>
<vertx-version>4.4.6</vertx-version>
<raml-module-builder-version>35.1.0</raml-module-builder-version>
<spring.version>5.3.23</spring.version>
<argLine />
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>2.20.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-stack-depchain</artifactId>
Expand All @@ -46,14 +53,7 @@
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>1.17.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>2.17.2</version>
<version>1.19.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -185,7 +185,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<artifactId>log4j-slf4j2-impl</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
Expand Down
2 changes: 1 addition & 1 deletion ramls/scheduled-notice-storage.raml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#%RAML 1.0
title: Scheduled Notice Storage
version: v0.5
version: v0.6
protocols: [ HTTP, HTTPS ]
baseUri: http://localhost:9130

Expand Down
1 change: 1 addition & 0 deletions ramls/scheduled-notice.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"Due date",
"Overdue fine returned",
"Overdue fine renewed",
"Due date - with reminder fee",
"Aged to lost",
"Aged to lost - fine charged",
"Aged to lost & item returned - fine adjusted",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.folio.service.migration;

import static io.vertx.core.Future.succeededFuture;
import static java.util.stream.Collectors.toMap;
import static java.util.stream.Collectors.toSet;
import static org.folio.support.JsonPropertyWriter.write;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
Expand Down Expand Up @@ -87,7 +87,7 @@ private static void saveServicePointNames(Batch<RequestSearchMigrationContext> b
servicePoints.size());

Map<String, String> servicePointIdToName = servicePoints.stream()
.collect(toMap(ServicePoint::getId, ServicePoint::getName, (a, b) -> a));
.collect(HashMap::new, (m, v) -> m.put(v.getId(), v.getName()), HashMap::putAll);

batch.getRequestMigrationContexts().forEach(ctx ->
ctx.setPickupServicePointName(servicePointIdToName.get(ctx.getPickupServicePointId())));
Expand Down Expand Up @@ -119,10 +119,12 @@ private static void saveCallNumbers(Batch<RequestSearchMigrationContext> batch,
log.info("saveCallNumbers:: batch={}, items=Collection({} elements)", batch, items.size());

Map<String, CallNumberComponents> itemIdToCallNumberComponents = items.stream()
.collect(toMap(Item::getId, Item::getEffectiveCallNumberComponents, (a, b) -> a));
.collect(HashMap::new, (m, v) -> m.put(v.getId(), v.getEffectiveCallNumberComponents()),
HashMap::putAll);

Map<String, String> itemIdToShelvingOrder = items.stream()
.collect(toMap(Item::getId, Item::getEffectiveShelvingOrder, (a, b) -> a));
.collect(HashMap::new, (m, v) -> m.put(v.getId(), v.getEffectiveShelvingOrder()),
HashMap::putAll);

batch.getRequestMigrationContexts().forEach(ctx -> {
ctx.setCallNumberComponents(itemIdToCallNumberComponents.get(ctx.getItemId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -112,7 +113,8 @@ private static void saveHoldingsRecordIds(Batch<TlrMigrationContext> batch,
Collection<Item> items) {

Map<String, String> itemIdToHoldingsRecordId = items.stream()
.collect(toMap(Item::getId, Item::getHoldingsRecordId, (a, b) -> a));
.collect(HashMap::new, (m, v) -> m.put(v.getId(), v.getHoldingsRecordId()),
HashMap::putAll);

batch.getRequestMigrationContexts().forEach(ctx ->
ctx.setHoldingsRecordId(itemIdToHoldingsRecordId.get(ctx.getItemId())));
Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/templates/db_scripts/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@
"caseSensitive": false,
"removeAccents": false,
"sqlExpression": "(jsonb->'agedToLostDelayedBilling'->>'dateLostItemShouldBeBilled')"
},
{
"fieldName": "action",
"tOps": "ADD",
"caseSensitive": false,
"removeAccents": true
}
],
"fullTextIndex": [
Expand Down Expand Up @@ -267,7 +273,7 @@
"fieldName": "instanceId",
"tOps": "ADD",
"caseSensitive": false,
"removeAccents": false
"removeAccents": true
},
{
"fieldName": "searchIndex.pickupServicePointName",
Expand Down
88 changes: 72 additions & 16 deletions src/test/java/org/folio/rest/api/TenantRefApiTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ public class TenantRefApiTests {
private static final String FAIL_SECOND_CALL_SCENARIO = "Test scenario";
private static final String FIRST_CALL_MADE_SCENARIO_STATE = "First call made";
private static final String DEFAULT_UUID = "00000000-0000-4000-8000-000000000000";
private static final String REQUEST_ID_MISSING_HOLDINGS_RECORD_ID =
"6110e6ab-1d84-4bc5-a88e-e984acca9744";
private static final String REQUEST_ID_MISSING_EFFECTIVE_SHELVING_ORDER =
"45496a79-e1f3-412e-9076-fc5c4ee893f9";
private static final String REQUEST_ID_MISSING_EFFECTIVE_CALL_NUMBER_COMPONENTS =
"ddcee62b-c41f-4036-a1d7-5a039d259e87";
private static final String REQUEST_ID_MISSING_CALL_NUMBER =
"f999719d-ca7e-44ce-9f75-9071c856e5d7";
private static final String REQUEST_ID_MISSING_PREFIX = "6ad37eb7-591b-46f3-9902-c1992ca41158";
private static final String REQUEST_ID_MISSING_SUFFIX = "ecd86aab-a0ac-4d3c-bb90-0df390b1c6c4";
private static final String REQUEST_ID_MISSING_PICKUP_SERVICE_POINT_NAME =
"87a7dfd9-8fdb-4b0d-9529-14912b484860";

private static StubMapping itemStorageStub;
private static StubMapping holdingsStorageStub;
Expand Down Expand Up @@ -269,7 +281,6 @@ private void tlrMigrationFailsWhenRemoteCallFails(TestContext context, Async asy
});
}

////
@Test
public void requestSearchMigrationFailsWhenItemStorageCallFails(TestContext context) {
Async async = context.async();
Expand All @@ -293,7 +304,6 @@ private void requestSearchMigrationFailsWhenRemoteCallFails(TestContext context,
async.complete();
});
}
///

@Test
public void useDefaultValuesForInstanceIdAndHoldingsRecordIdWhenItemWasNotFound(TestContext context) {
Expand Down Expand Up @@ -507,23 +517,43 @@ private void validateRequestSearchMigrationResult(TestContext context, Async asy

private void validateRequestSearchMigrationResult(TestContext context, JsonObject requestAfter) {
JsonObject requestBefore = requestsBeforeMigration.get(getId(requestAfter));
String requestId = requestBefore.getString("id");

context.assertNotNull(requestBefore);
context.assertNotNull(requestAfter);

if (requestBefore.containsKey("pickupServicePointId")) {
context.assertEquals("testSpName", requestAfter.getJsonObject("searchIndex")
.getString("pickupServicePointName"));
if (!REQUEST_ID_MISSING_PICKUP_SERVICE_POINT_NAME.equals(requestId)) {
context.assertEquals("testSpName", requestAfter.getJsonObject("searchIndex")
.getString("pickupServicePointName"));
}
}

if (!REQUEST_ID_MISSING_EFFECTIVE_SHELVING_ORDER.equals(requestId)) {
context.assertEquals("testShelvingOrder", requestAfter.getJsonObject("searchIndex")
.getString("shelvingOrder"));
}

if (!REQUEST_ID_MISSING_EFFECTIVE_CALL_NUMBER_COMPONENTS.equals(requestId) &&
!REQUEST_ID_MISSING_CALL_NUMBER.equals(requestId)) {

context.assertEquals("testCallNumber", requestAfter.getJsonObject("searchIndex")
.getJsonObject("callNumberComponents").getString("callNumber"));
}

if (!REQUEST_ID_MISSING_EFFECTIVE_CALL_NUMBER_COMPONENTS.equals(requestId) &&
!REQUEST_ID_MISSING_PREFIX.equals(requestId)) {

context.assertEquals("testPrefix", requestAfter.getJsonObject("searchIndex")
.getJsonObject("callNumberComponents").getString("prefix"));
}

context.assertEquals("testShelvingOrder", requestAfter.getJsonObject("searchIndex")
.getString("shelvingOrder"));
context.assertEquals("testCallNumber", requestAfter.getJsonObject("searchIndex")
.getJsonObject("callNumberComponents").getString("callNumber"));
context.assertEquals("testPrefix", requestAfter.getJsonObject("searchIndex")
.getJsonObject("callNumberComponents").getString("prefix"));
context.assertEquals("testSuffix", requestAfter.getJsonObject("searchIndex")
.getJsonObject("callNumberComponents").getString("suffix"));
if (!REQUEST_ID_MISSING_EFFECTIVE_CALL_NUMBER_COMPONENTS.equals(requestId) &&
!REQUEST_ID_MISSING_SUFFIX.equals(requestId)) {

context.assertEquals("testSuffix", requestAfter.getJsonObject("searchIndex")
.getJsonObject("callNumberComponents").getString("suffix"));
}
}

static void deleteTenant(TenantClient tenantClient) {
Expand All @@ -544,18 +574,39 @@ private static void mockEndpoints() {

requestsBeforeMigration.values()
.forEach(request -> {
final String requestId = request.getString("id");
final String holdingsRecordId = randomId();
final String servicePointId = request.getString("pickupServicePointId");

items.add(new JsonObject()
JsonObject item = new JsonObject()
.put("id", request.getString("itemId"))
.put("holdingsRecordId", holdingsRecordId)
.put("effectiveShelvingOrder", "testShelvingOrder")
.put("effectiveCallNumberComponents", new JsonObject()
.put("callNumber", "testCallNumber")
.put("prefix", "testPrefix")
.put("suffix", "testSuffix")
));
);
items.add(item);

if (REQUEST_ID_MISSING_HOLDINGS_RECORD_ID.equals(requestId)) {
item.remove("holdingsRecordId");
}
if (REQUEST_ID_MISSING_EFFECTIVE_SHELVING_ORDER.equals(requestId)) {
item.remove("effectiveShelvingOrder");
}
if (REQUEST_ID_MISSING_EFFECTIVE_CALL_NUMBER_COMPONENTS.equals(requestId)) {
item.remove("effectiveCallNumberComponents");
}
if (REQUEST_ID_MISSING_CALL_NUMBER.equals(requestId)) {
item.getJsonObject("effectiveCallNumberComponents").remove("callNumber");
}
if (REQUEST_ID_MISSING_PREFIX.equals(requestId)) {
item.getJsonObject("effectiveCallNumberComponents").remove("prefix");
}
if (REQUEST_ID_MISSING_SUFFIX.equals(requestId)) {
item.getJsonObject("effectiveCallNumberComponents").remove("suffix");
}

holdingRecords.add(new JsonObject()
.put("id", holdingsRecordId)
Expand All @@ -565,9 +616,14 @@ private static void mockEndpoints() {
boolean servicePointDoesNotExists = servicePoints.stream()
.noneMatch(sp -> sp.getString("id").equals(servicePointId));
if (servicePointDoesNotExists) {
servicePoints.add(new JsonObject()
JsonObject servicePoint = new JsonObject()
.put("id", servicePointId)
.put("name", "testSpName"));
.put("name", "testSpName");
servicePoints.add(servicePoint);
if ("87a7dfd9-8fdb-4b0d-9529-14912b484860".equals(request.getString("id"))) {
// request with pickup service point missing a name
servicePoint.remove("name");
}
}
}
});
Expand Down
Loading

0 comments on commit c99d037

Please sign in to comment.