Skip to content

Commit 626c138

Browse files
authored
Merge pull request folio-org#1603 from folio-org/CIRC-2308-use-at-location
CIRC-2308 use at location (not to be merged until CIRCSTORE-578 is merged)
2 parents 20dd8e4 + 582f8b7 commit 626c138

33 files changed

+1029
-17
lines changed

descriptors/ModuleDescriptor-template.json

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
},
202202
{
203203
"id": "circulation",
204-
"version": "14.6",
204+
"version": "14.7",
205205
"handlers": [
206206
{
207207
"methods": [
@@ -272,6 +272,26 @@
272272
"circulation.renew-loan.all"
273273
]
274274
},
275+
{
276+
"methods": [
277+
"POST"
278+
],
279+
"pathPattern": "/circulation/pickup-by-barcode-for-use-at-location",
280+
"permissionsRequired": ["circulation.pickup-by-barcode-for-use-at-location.post"],
281+
"modulePermissions": [
282+
"circulation.usage-at-location.all"
283+
]
284+
},
285+
{
286+
"methods": [
287+
"POST"
288+
],
289+
"pathPattern": "/circulation/hold-by-barcode-for-use-at-location",
290+
"permissionsRequired": ["circulation.hold-by-barcode-for-use-at-location.post"],
291+
"modulePermissions": [
292+
"circulation.usage-at-location.all"
293+
]
294+
},
275295
{
276296
"methods": [
277297
"GET"
@@ -1442,6 +1462,16 @@
14421462
"displayName": "circulation - renew loan using id",
14431463
"description": "renew a loan using IDs for item and loanee"
14441464
},
1465+
{
1466+
"permissionName": "circulation.pickup-by-barcode-for-use-at-location.post",
1467+
"displayName": "circulation - pick up from hold shelf for use at location",
1468+
"description": "pick up item of an existing loan from hold shelf for use at location (i.e. in reading room)"
1469+
},
1470+
{
1471+
"permissionName": "circulation.hold-by-barcode-for-use-at-location.post",
1472+
"displayName": "circulation - put item on hold shelf for another use at location",
1473+
"description": "put the item of an existing loan on the hold shelf for later use at location (i.e. in reading room)"
1474+
},
14451475
{
14461476
"permissionName": "circulation.loans.collection.get",
14471477
"displayName": "circulation - get loan collection",
@@ -1726,6 +1756,8 @@
17261756
"circulation.check-in-by-barcode.post",
17271757
"circulation.renew-by-barcode.post",
17281758
"circulation.renew-by-id.post",
1759+
"circulation.hold-by-barcode-for-use-at-location.post",
1760+
"circulation.pickup-by-barcode-for-use-at-location.post",
17291761
"circulation.loans.collection.get",
17301762
"circulation.loans.item.get",
17311763
"circulation.loans.item.post",
@@ -2110,6 +2142,23 @@
21102142
"visible": false,
21112143
"replaces": ["circulation.renew-loan"]
21122144
},
2145+
{
2146+
"permissionName": "circulation.usage-at-location.all",
2147+
"displayName" : "Put item on hold or pick it up for use at location",
2148+
"description" : "Permissions needed to take an item on or off hold shelf for use at location",
2149+
"subPermissions": [
2150+
"circulation-storage.loans.item.put",
2151+
"circulation-storage.loans.item.get",
2152+
"circulation-storage.loans.collection.get",
2153+
"circulation-storage.loan-policies.item.get",
2154+
"circulation-storage.loan-policies.collection.get",
2155+
"circulation.internal.fetch-items.collection.get",
2156+
"users.item.get",
2157+
"users.collection.get",
2158+
"pubsub.publish.post"
2159+
],
2160+
"visible": false
2161+
},
21132162
{
21142163
"permissionName": "perms.circulation.loans.anonymize.all",
21152164
"displayName" : "module permissions for one op",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"errors": [
3+
{
4+
"message": "TBD",
5+
"parameters": [
6+
{
7+
"key": "itemId",
8+
"value": "91719676-e7b5-4f83-bdab-cb70dd10c1e3"
9+
}
10+
]
11+
}
12+
]
13+
}

ramls/for-use-at-location-shelf.raml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#%RAML 1.0
2+
title: Change usage status of items to be used at location (ie reading room)
3+
version: v0.1
4+
protocols: [ HTTP, HTTPS ]
5+
baseUri: http://localhost:9130
6+
7+
documentation:
8+
- title: API for changing usage status of items used at location
9+
content: <b>Change usage status API</b>
10+
11+
types:
12+
errors: !include raml-util/schemas/errors.schema
13+
14+
traits:
15+
validate: !include raml-util/traits/validation.raml
16+
17+
/circulation:
18+
/hold-by-barcode-for-use-at-location:
19+
post:
20+
is: [validate]
21+
body:
22+
application/json:
23+
type: !include hold-for-use-at-location-request.json
24+
responses:
25+
200:
26+
description: "The at-location usage status of the loaned item set to held"
27+
422:
28+
description: "Unable to change the usage status for the loan"
29+
body:
30+
application/json:
31+
type: errors
32+
example: !include examples/at-location-usage-status-change-error.json
33+
404:
34+
description: "The loan is not found"
35+
500:
36+
description: "Internal server error, e.g. due to misconfiguration"
37+
body:
38+
text/plain:
39+
example: "Internal server error, contact administrator"
40+
41+
/pickup-by-barcode-for-use-at-location:
42+
post:
43+
is: [validate]
44+
body:
45+
application/json:
46+
type: !include pickup-for-use-at-location-request.json
47+
responses:
48+
200:
49+
description: "The at-location usage status of the loaned item set to in-use"
50+
422:
51+
description: "Unable to change the usage status for the loan"
52+
body:
53+
application/json:
54+
type: errors
55+
example: !include examples/at-location-usage-status-change-error.json
56+
404:
57+
description: "The loan is not found"
58+
500:
59+
description: "Internal server error, e.g. due to misconfiguration"
60+
body:
61+
text/plain:
62+
example: "Internal server error, contact administrator"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"type": "object",
4+
"description": "Request to switch status of use at location to 'Held'",
5+
"properties": {
6+
"itemBarcode": {
7+
"description": "Barcode of the item being in use at location",
8+
"type": "string"
9+
}
10+
},
11+
"required": [
12+
"itemBarcode"
13+
]
14+
}

ramls/loan.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,26 @@
281281
}
282282
}
283283
},
284+
"forUseAtLocation": {
285+
"description": "Status of loan/item that is to be used in the library",
286+
"type": "object",
287+
"properties": {
288+
"status": {
289+
"description": "Indicates if the item is currently used by or being held for the patron",
290+
"type": "string",
291+
"enum": [
292+
"In use",
293+
"Held",
294+
"Returned"
295+
]
296+
},
297+
"statusDate": {
298+
"description": "Date and time the status was registered",
299+
"type": "string",
300+
"format": "date-time"
301+
}
302+
}
303+
},
284304
"loanDate": {
285305
"description": "Date and time when the loan began",
286306
"type": "string",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"type": "object",
4+
"description": "Request to switch status of use at location to 'In use'",
5+
"properties": {
6+
"itemBarcode": {
7+
"description": "Barcode of the item lent to the patron for use at location",
8+
"type": "string"
9+
},
10+
"userBarcode": {
11+
"description": "Barcode of the user (representing the patron)",
12+
"type": "string"
13+
}
14+
},
15+
"required": [
16+
"itemBarcode",
17+
"userBarcode"
18+
]
19+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"type": "object",
4+
"description": "Request to switch status of use at location to 'Held'",
5+
"properties": {
6+
"itemBarcode": {
7+
"description": "Barcode of the item lent to the patron for use at location",
8+
"type": "string"
9+
}
10+
},
11+
"required": [
12+
"itemBarcode"
13+
]
14+
}

src/main/java/org/folio/circulation/CirculationVerticle.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
import org.folio.circulation.resources.handlers.LoanRelatedFeeFineClosedHandlerResource;
5353
import org.folio.circulation.resources.renewal.RenewByBarcodeResource;
5454
import org.folio.circulation.resources.renewal.RenewByIdResource;
55+
import org.folio.circulation.resources.foruseatlocation.HoldByBarcodeResource;
56+
import org.folio.circulation.resources.foruseatlocation.PickupByBarcodeResource;
5557
import org.folio.circulation.support.logging.LogHelper;
5658
import org.folio.circulation.support.logging.Logging;
5759

@@ -97,7 +99,8 @@ public void start(Promise<Void> startFuture) {
9799

98100
new RenewByBarcodeResource(client).register(router);
99101
new RenewByIdResource(client).register(router);
100-
102+
new HoldByBarcodeResource(client).register(router);
103+
new PickupByBarcodeResource(client).register(router);
101104
new AllowedServicePointsResource(client).register(router);
102105
new LoanCollectionResource(client).register(router);
103106
new RequestCollectionResource(client).register(router);

src/main/java/org/folio/circulation/domain/EventType.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ public enum EventType {
1010
LOAN_DUE_DATE_CHANGED,
1111
LOAN_CLOSED,
1212
LOG_RECORD,
13-
LOAN_RELATED_FEE_FINE_CLOSED
13+
LOAN_RELATED_FEE_FINE_CLOSED,
14+
ITEM_HELD_FOR_USE_AT_LOCATION,
15+
ITEM_PICKED_UP_FOR_USE_AT_LOCATION
1416
}

src/main/java/org/folio/circulation/domain/Loan.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import static org.folio.circulation.domain.representations.LoanProperties.ACTION_COMMENT;
2222
import static org.folio.circulation.domain.representations.LoanProperties.AGED_TO_LOST_DATE;
2323
import static org.folio.circulation.domain.representations.LoanProperties.AGED_TO_LOST_DELAYED_BILLING;
24+
import static org.folio.circulation.domain.representations.LoanProperties.AT_LOCATION_USE_STATUS;
25+
import static org.folio.circulation.domain.representations.LoanProperties.AT_LOCATION_USE_STATUS_DATE;
2426
import static org.folio.circulation.domain.representations.LoanProperties.BILL_DATE;
2527
import static org.folio.circulation.domain.representations.LoanProperties.BILL_NUMBER;
2628
import static org.folio.circulation.domain.representations.LoanProperties.CHECKIN_SERVICE_POINT_ID;
@@ -30,6 +32,7 @@
3032
import static org.folio.circulation.domain.representations.LoanProperties.DATE_LOST_ITEM_SHOULD_BE_BILLED;
3133
import static org.folio.circulation.domain.representations.LoanProperties.DECLARED_LOST_DATE;
3234
import static org.folio.circulation.domain.representations.LoanProperties.DUE_DATE;
35+
import static org.folio.circulation.domain.representations.LoanProperties.FOR_USE_AT_LOCATION;
3336
import static org.folio.circulation.domain.representations.LoanProperties.ITEM_LOCATION_ID_AT_CHECKOUT;
3437
import static org.folio.circulation.domain.representations.LoanProperties.ITEM_STATUS;
3538
import static org.folio.circulation.domain.representations.LoanProperties.LAST_FEE_BILLED;
@@ -207,6 +210,17 @@ public String getAction() {
207210
return getProperty(representation, ACTION);
208211
}
209212

213+
public Loan changeStatusOfUsageAtLocation(String usageStatus) {
214+
log.debug("changeStatusOfUsageAtLocation:: parameters usageStatus: {}", usageStatus);
215+
writeByPath(representation, usageStatus, FOR_USE_AT_LOCATION, AT_LOCATION_USE_STATUS);
216+
writeByPath(representation, ClockUtil.getZonedDateTime().toString(), FOR_USE_AT_LOCATION, AT_LOCATION_USE_STATUS_DATE);
217+
return this;
218+
}
219+
220+
public boolean isForUseAtLocation() {
221+
return representation.containsKey(FOR_USE_AT_LOCATION);
222+
}
223+
210224
private void changeCheckInServicePointId(UUID servicePointId) {
211225
log.debug("changeCheckInServicePointId:: parameters servicePointId: {}", servicePointId);
212226
write(representation, "checkinServicePointId", servicePointId);
@@ -736,7 +750,6 @@ private void changeClaimedReturnedDate(ZonedDateTime claimedReturnedDate) {
736750
public Loan closeLoan(LoanAction action) {
737751
log.debug("closeLoan:: parameters action: {}", action);
738752
changeStatus(LoanStatus.CLOSED);
739-
740753
changeAction(action);
741754
removeActionComment();
742755

0 commit comments

Comments
 (0)