Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .github/workflows/spectral-lint.yml

This file was deleted.

150 changes: 0 additions & 150 deletions HTTP_EXCHANGE_AUTO_REGISTRATION.md

This file was deleted.

95 changes: 81 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Version 2.0. See the file "[LICENSE](LICENSE)" for more information.
* [API documentation](#api-documentation)
* [Code analysis](#code-analysis)
* [Service Point Hold Shelf Period Expiration](#service-point-hold-shelf-period-expiration)
* [Settings Configuration](#settings-configuration)
* [Table: service_point_expiration_period](#table-service_point_expiration_period)
* [Other documentation](#other-documentation)
<!-- TOC -->

Expand Down Expand Up @@ -125,14 +127,79 @@ This module's [API documentation](https://dev.folio.org/reference/api/#mod-dcb).

### Service Point Hold Shelf Period Expiration

When creating a **DCB** transaction with the roles **LENDER** or **BORROWING-PICKUP**,
the creation of the **DCB** service point and its property **hold shelf expiration period**
depends on the values stored in the `service_point_expiration_period` table in the database.
When creating a **DCB** transaction with the roles **LENDER** or **BORROWER**,
the creation of the **DCB** service point and its property **hold shelf expiration period**
depends on the values stored in the `settings` or `service_point_expiration_period` tables in the database.

#### Settings Configuration

The following settings are relevant for the hold shelf expiration period and the can be created using:
```text
POST {{gateway}}/dcb/settings

Headers:
Content-Type: application/json
x-okapi-tenant: {{tenant}}
x-okapi-token: {{token}}

Request Body:
{{request body (examples below)}}
```

- Lender:
```json
{
"id": "0980d067-ac36-4dc7-ab78-d5c6274ef2bc",
"key": "lender.hold-shelf-expiry-period",
"scope": "mod-dcb",
"value": {
"duration": 10,
"intervalId": "Days"
}
}
```

- Borrower:
```json
{
"id": "33ef5144-927f-4fd9-b53a-17815054b4e8",
"key": "borrower.hold-shelf-expiry-period",
"scope": "mod-dcb",
"value": {
"duration": 10,
"intervalId": "Days"
}
}
```

- DCB (Virtual) Service Point:
```json
{
"id": "33ef5144-927f-4fd9-b53a-17815054b4e8",
"key": "dcb.hold-shelf-expiry-period",
"scope": "mod-dcb",
"value": {
"duration": 10,
"intervalId": "Days"
}
}
```

As a fallback, `service_point_expiration_period` table is used to determine the hold shelf expiration period for the
service point. if it's empty, the default value of 10 days will be used.

> **_NOTE:_**
> * Duration is always an integer value.
> * IntervalId is an enum value that can be "Minutes", "Hours", "Days", "Weeks", or "Month". </br> _The value is
> case-sensitive. Parsing failures will be detected and logged, and in case of error - the fallback
> approach will be used._

#### Table: service_point_expiration_period

- If the table is empty, the **hold shelf expiration period** will be set to the default value of **10 Days**.
- If the table contains a value, the stored value will be used instead.

The **F.S.E. team** is responsible for updating the values in this table.
The **F.S.E. team** is responsible for updating the values in this table.
To update the values, the following PL/pgSQL script can be executed:

```sql
Expand Down Expand Up @@ -160,15 +227,15 @@ BEGIN
-- If no record exists, insert one; otherwise, update the existing record
IF raw_id IS NULL THEN
sql_query := format(
'INSERT INTO %I.service_point_expiration_period (id, duration, interval_id)
VALUES (gen_random_uuid(), %L, %L)',
'INSERT INTO %I.service_point_expiration_period (id, duration, interval_id)
VALUES (gen_random_uuid(), %L, %L)',
schema_name, new_duration, new_interval_id
);
ELSE
sql_query := format(
'UPDATE %I.service_point_expiration_period
'UPDATE %I.service_point_expiration_period
SET duration = %L, interval_id = %L
WHERE id = %L',
WHERE id = %L',
schema_name, new_duration, new_interval_id, raw_id
);
END IF;
Expand All @@ -180,15 +247,15 @@ END;
$$
LANGUAGE plpgsql;
```
**Updating Values in the Table**
To update the values, simply modify the new_duration and new_interval_id variables in the DECLARE section
**Updating Values in the Table**
To update the values, simply modify the new_duration and new_interval_id variables in the DECLARE section
of the script to reflect the new values.

**Expiration Period Handling**
**Expiration Period Handling**
For Existing Service Points
When creating a new transaction with an existing DCB service point, the hold shelf expiration period
will be checked.
If the value in the transaction payload differs from the value stored
When creating a new transaction with an existing DCB service point, the hold shelf expiration period
will be checked.
If the value in the transaction payload differs from the value stored
in the database, it will be updated accordingly.

[SonarQube analysis](https://sonarcloud.io/project/overview?id=org.folio:mod-dcb).
Expand Down
69 changes: 69 additions & 0 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,37 @@
}
]
},
{
"id": "dcb.settings",
"version": "1.0",
"handlers": [
{
"methods": ["GET"],
"pathPattern": "/dcb/settings",
"permissionsRequired": ["dcb.settings.collection.get"]
},
{
"methods": ["GET"],
"pathPattern": "/dcb/settings/{id}",
"permissionsRequired": ["dcb.settings.item.get"]
},
{
"methods": ["POST"],
"pathPattern": "/dcb/settings",
"permissionsRequired": ["dcb.settings.item.post"]
},
{
"methods": ["PUT"],
"pathPattern": "/dcb/settings/{id}",
"permissionsRequired": ["dcb.settings.item.put"]
},
{
"methods": ["DELETE"],
"pathPattern": "/dcb/settings/{id}",
"permissionsRequired": ["dcb.settings.item.delete"]
}
]
},
{
"id": "_tenant",
"version": "2.0",
Expand Down Expand Up @@ -365,6 +396,7 @@
"displayName": "DCB module - all permissions",
"description": "All permissions for dcb module",
"subPermissions": [
"dcb.settings.all",
"dcb.transactions.post",
"dcb.transactions.status.put",
"dcb.transactions.status.get",
Expand Down Expand Up @@ -433,6 +465,43 @@
"permissionName": "dcb.shadow_locations.refresh.post",
"displayName": "trigger refresh of shadow locations",
"description": "trigger refresh of shadow locations"
},
{
"permissionName" : "dcb.settings.collection.get",
"displayName" : "mod-dcb - retrieve settings by cql",
"description" : "Get a collection of settings"
},
{
"permissionName" : "dcb.settings.item.get",
"displayName" : "mod-dcb - retrieve a setting by id",
"description" : "Fetch a setting"
},
{
"permissionName" : "dcb.settings.item.put",
"displayName" : "mod-dcb - Update a setting by id",
"description" : "Update a setting"
},
{
"permissionName" : "dcb.settings.item.post",
"displayName" : "mod-dcb - Save a setting",
"description" : "Add a setting"
},
{
"permissionName" : "dcb.settings.item.delete",
"displayName" : "mod-dcb - Remove a setting by id",
"description" : "Delete a setting"
},
{
"permissionName" : "dcb.settings.all",
"displayName" : "mod-dcb - settings all",
"description" : "All permissions for setting",
"subPermissions" : [
"dcb.settings.collection.get",
"dcb.settings.item.get",
"dcb.settings.item.post",
"dcb.settings.item.put",
"dcb.settings.item.delete"
]
}
],
"metadata": {
Expand Down
Loading
Loading