Skip to content

Commit

Permalink
Merge pull request #89 from folio-org/tmp-release-1.0.2
Browse files Browse the repository at this point in the history
MODTLR-117 Release 1.0.2
  • Loading branch information
roman-barannyk authored Dec 12, 2024
2 parents 9126528 + a22f0d9 commit 7081542
Show file tree
Hide file tree
Showing 47 changed files with 2,295 additions and 1,431 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.0.2 2024-12-12
* Copy Secure Patron name when cloning users (MODTLR-116)
* Support for intermediate requests (MODTLR-98)
* Search Slips API (MODTLR-75)

## 1.0.1 2024-11-30
* Merge `ecs-tlr-feature` branch into `master` (MODTLR-69)
* Create pickup service point in lending tenant (MODTLR-17)
Expand Down
34 changes: 31 additions & 3 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"users.item.post",
"inventory-storage.service-points.item.get",
"inventory-storage.service-points.collection.get",
"inventory-storage.service-points.item.post"
"inventory-storage.service-points.item.post",
"user-tenants.collection.get"
]
},
{
Expand Down Expand Up @@ -123,7 +124,6 @@
"permissionsRequired": ["tlr.pick-slips.collection.get"],
"modulePermissions": [
"user-tenants.collection.get",
"search.instances.collection.get",
"circulation-storage.requests.item.get",
"circulation-storage.requests.collection.get",
"users.item.get",
Expand All @@ -135,7 +135,31 @@
"addresstypes.item.get",
"addresstypes.collection.get",
"inventory-storage.service-points.item.get",
"inventory-storage.service-points.collection.get"
"inventory-storage.service-points.collection.get",
"inventory-storage.instances.item.get",
"inventory-storage.instances.collection.get"
]
},
{
"methods": ["GET"],
"pathPattern": "/tlr/staff-slips/search-slips/{servicePointId}",
"permissionsRequired": ["tlr.search-slips.collection.get"],
"modulePermissions": [
"user-tenants.collection.get",
"circulation-storage.requests.item.get",
"circulation-storage.requests.collection.get",
"users.item.get",
"users.collection.get",
"usergroups.item.get",
"usergroups.collection.get",
"departments.item.get",
"departments.collection.get",
"addresstypes.item.get",
"addresstypes.collection.get",
"inventory-storage.service-points.item.get",
"inventory-storage.service-points.collection.get",
"inventory-storage.instances.item.get",
"inventory-storage.instances.collection.get"
]
}
]
Expand Down Expand Up @@ -244,6 +268,10 @@
"permissionName": "tlr.pick-slips.collection.get",
"displayName": "ecs-tlr - pick slips",
"description": "Get pick slips"
}, {
"permissionName": "tlr.search-slips.collection.get",
"displayName": "ecs-tlr - search slips",
"description": "Get search slips"
},
{
"permissionName": "tlr.ecs-request-external.post",
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<groupId>org.folio</groupId>
<artifactId>mod-tlr</artifactId>
<name>mod-tlr</name>
<version>1.0.2-SNAPSHOT</version>
<version>1.0.3-SNAPSHOT</version>
<description>FOLIO mod-tlr module</description>
<packaging>jar</packaging>

Expand Down
16 changes: 16 additions & 0 deletions src/main/java/org/folio/client/feign/HoldingClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.folio.client.feign;

import org.folio.domain.dto.HoldingsRecord;
import org.folio.domain.dto.HoldingsRecords;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@FeignClient(name = "holdings", url = "holdings-storage/holdings", configuration = FeignClientConfiguration.class)
public interface HoldingClient extends GetByQueryClient<HoldingsRecords> {

@GetMapping("/{id}")
HoldingsRecord get(@PathVariable String id);

}
3 changes: 2 additions & 1 deletion src/main/java/org/folio/client/feign/InstanceClient.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package org.folio.client.feign;

import org.folio.domain.dto.Instances;
import org.folio.domain.dto.InventoryInstance;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

@FeignClient(name = "instances", url = "instance-storage/instances", configuration = FeignClientConfiguration.class)
public interface InstanceClient {
public interface InstanceClient extends GetByQueryClient<Instances> {

@GetMapping("/{id}")
InventoryInstance get(@PathVariable String id);
Expand Down
19 changes: 17 additions & 2 deletions src/main/java/org/folio/controller/StaffSlipsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import java.util.UUID;

import org.folio.domain.dto.PickSlipsResponse;
import org.folio.domain.dto.SearchSlipsResponse;
import org.folio.domain.dto.StaffSlip;
import org.folio.rest.resource.PickSlipsApi;
import org.folio.rest.resource.StaffSlipsApi;
import org.folio.service.impl.PickSlipsService;
import org.folio.service.impl.SearchSlipsService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.AllArgsConstructor;
Expand All @@ -17,9 +20,11 @@
@RestController
@Log4j2
@AllArgsConstructor
public class StaffSlipsController implements PickSlipsApi {
@RequestMapping("/tlr/staff-slips")
public class StaffSlipsController implements StaffSlipsApi {

private final PickSlipsService pickSlipsService;
private final SearchSlipsService searchSlipsService;

@Override
public ResponseEntity<PickSlipsResponse> getPickSlips(UUID servicePointId) {
Expand All @@ -30,4 +35,14 @@ public ResponseEntity<PickSlipsResponse> getPickSlips(UUID servicePointId) {
.pickSlips(new ArrayList<>(pickSlips))
.totalRecords(pickSlips.size()));
}

@Override
public ResponseEntity<SearchSlipsResponse> getSearchSlips(UUID servicePointId) {
log.info("getSearchSlips:: servicePointId={}", servicePointId);
Collection<StaffSlip> searchSlips = searchSlipsService.getStaffSlips(servicePointId.toString());

return ResponseEntity.ok(new SearchSlipsResponse()
.searchSlips(new ArrayList<>(searchSlips))
.totalRecords(searchSlips.size()));
}
}
4 changes: 4 additions & 0 deletions src/main/java/org/folio/domain/entity/EcsTlrEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ public class EcsTlrEntity {
private UUID secondaryRequestId;
private String secondaryRequestTenantId;
private UUID secondaryRequestDcbTransactionId;
private UUID intermediateRequestId;
private String intermediateRequestTenantId;
private UUID intermediateRequestDcbTransactionId;

}
5 changes: 4 additions & 1 deletion src/main/java/org/folio/service/DcbService.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
import org.folio.domain.entity.EcsTlrEntity;

public interface DcbService {
void createTransactions(EcsTlrEntity ecsTlr, Request secondaryRequest);
void createLendingTransaction(EcsTlrEntity ecsTlr);
void createBorrowingTransaction(EcsTlrEntity ecsTlr, Request request);
void createBorrowerTransaction(EcsTlrEntity ecsTlr, Request request);
void createBorrowingPickupTransaction(EcsTlrEntity ecsTlr, Request request);
void createPickupTransaction(EcsTlrEntity ecsTlr, Request request);
TransactionStatusResponse getTransactionStatus(UUID transactionId, String tenantId);
TransactionStatusResponse updateTransactionStatus(UUID transactionId,
TransactionStatus.StatusEnum newStatus, String tenantId);
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/folio/service/InventoryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.Collection;

import org.folio.domain.dto.Campus;
import org.folio.domain.dto.HoldingsRecord;
import org.folio.domain.dto.Instance;
import org.folio.domain.dto.Institution;
import org.folio.domain.dto.Item;
import org.folio.domain.dto.Library;
Expand All @@ -12,7 +14,9 @@

public interface InventoryService {
Collection<Item> findItems(CqlQuery query, String idIndex, Collection<String> ids);
Collection<Item> findItems(Collection<String> ids);
Collection<HoldingsRecord> findHoldings(CqlQuery query, String idIndex, Collection<String> ids);
Collection<HoldingsRecord> findHoldings(Collection<String> ids);
Collection<Instance> findInstances(Collection<String> ids);
Collection<MaterialType> findMaterialTypes(Collection<String> ids);
Collection<LoanType> findLoanTypes(Collection<String> ids);
Collection<Library> findLibraries(Collection<String> ids);
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/folio/service/RequestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@
import org.folio.domain.dto.InventoryItem;
import org.folio.domain.dto.ReorderQueue;
import org.folio.domain.dto.Request;
import org.folio.domain.entity.EcsTlrEntity;
import org.folio.support.CqlQuery;

public interface RequestService {
RequestWrapper createPrimaryRequest(Request request, String borrowingTenantId);
RequestWrapper createPrimaryRequest(Request request, String primaryRequestTenantId,
String secondaryRequestTenantId);

RequestWrapper createSecondaryRequest(Request request, String borrowingTenantId,
Collection<String> lendingTenantIds);
RequestWrapper createSecondaryRequest(Request request, String primaryRequestTenantId,
Collection<String> secondaryRequestTenantIds);

CirculationItem createCirculationItem(EcsTlrEntity ecsTlr, Request secondaryRequest,
String borrowingTenantId, String lendingTenantId);
RequestWrapper createIntermediateRequest(Request intermediateRequest,
String primaryRequestTenantId, String intermediateRequestTenantId,
String secondaryRequestTenantId);

CirculationItem updateCirculationItemOnRequestCreation(CirculationItem circulationItem,
Request secondaryRequest);

InventoryItem getItemFromStorage(String itemId, String tenantId);

InventoryInstance getInstanceFromStorage(String instanceId, String tenantId);

Request getRequestFromStorage(String requestId, String tenantId);
Request getRequestFromStorage(String requestId);
Collection<Request> getRequestsFromStorage(CqlQuery query, String idIndex, Collection<String> ids);
Collection<Request> getRequestsFromStorage(CqlQuery query);
Request updateRequestInStorage(Request request, String tenantId);
List<Request> getRequestsQueueByInstanceId(String instanceId, String tenantId);
List<Request> getRequestsQueueByInstanceId(String instanceId);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/folio/service/TenantService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.folio.domain.entity.EcsTlrEntity;

public interface TenantService {
String getBorrowingTenant(EcsTlrEntity ecsTlr);
String getPrimaryRequestTenantId(EcsTlrEntity ecsTlr);

List<String> getLendingTenants(EcsTlrEntity ecsTlr);
List<String> getSecondaryRequestTenants(EcsTlrEntity ecsTlr);
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ private AllowedServicePointsResponse getForCreate(AllowedServicePointsRequest re
Map<String, AllowedServicePointsInner> recall = new HashMap<>();
for (String tenantId : getLendingTenants(request)) {
var servicePoints = getAllowedServicePointsFromTenant(request, patronGroupId, tenantId);
log.info("getForCreate:: service points from {}: {}", tenantId, servicePoints);

combineAndFilterDuplicates(page, servicePoints.getPage());
combineAndFilterDuplicates(hold, servicePoints.getHold());
combineAndFilterDuplicates(recall, servicePoints.getRecall());
Expand Down
70 changes: 58 additions & 12 deletions src/main/java/org/folio/service/impl/DcbServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package org.folio.service.impl;

import static org.folio.domain.dto.DcbTransaction.RoleEnum.BORROWER;
import static org.folio.domain.dto.DcbTransaction.RoleEnum.BORROWING_PICKUP;
import static org.folio.domain.dto.DcbTransaction.RoleEnum.LENDER;
import static org.folio.domain.dto.DcbTransaction.RoleEnum.PICKUP;

import java.util.UUID;

import org.folio.client.feign.DcbEcsTransactionClient;
import org.folio.client.feign.DcbTransactionClient;
import org.folio.domain.dto.DcbItem;
import org.folio.domain.dto.DcbTransaction;
import org.folio.domain.dto.DcbTransaction.RoleEnum;
import org.folio.domain.dto.Request;
import org.folio.domain.dto.TransactionStatus;
import org.folio.domain.dto.TransactionStatusResponse;
Expand Down Expand Up @@ -43,27 +46,53 @@ public void createLendingTransaction(EcsTlrEntity ecsTlr) {
DcbTransaction transaction = new DcbTransaction()
.requestId(ecsTlr.getSecondaryRequestId().toString())
.role(LENDER);
final UUID lendingTransactionId = createTransaction(transaction, ecsTlr.getSecondaryRequestTenantId());
ecsTlr.setSecondaryRequestDcbTransactionId(lendingTransactionId);
final UUID transactionId = createTransaction(transaction, ecsTlr.getSecondaryRequestTenantId());
ecsTlr.setSecondaryRequestDcbTransactionId(transactionId);
log.info("createTransactions:: lending transaction {} for ECS TLR {} created",
() -> lendingTransactionId, ecsTlr::getId);
() -> transactionId, ecsTlr::getId);
}

@Override
public void createBorrowingTransaction(EcsTlrEntity ecsTlr, Request request) {
log.info("createBorrowingTransaction:: creating borrowing transaction for ECS TLR {}", ecsTlr::getId);
public void createBorrowerTransaction(EcsTlrEntity ecsTlr, Request request) {
log.info("createBorrowerTransaction:: creating borrower transaction for ECS TLR {}", ecsTlr::getId);
DcbTransaction transaction = buildTransaction(request, BORROWER, ecsTlr.getIntermediateRequestId());
final UUID transactionId = createTransaction(transaction, ecsTlr.getIntermediateRequestTenantId());
ecsTlr.setIntermediateRequestDcbTransactionId(transactionId);
log.info("createBorrowerTransaction:: borrower transaction {} for ECS TLR {} created",
() -> transactionId, ecsTlr::getId);
}

@Override
public void createBorrowingPickupTransaction(EcsTlrEntity ecsTlr, Request request) {
log.info("createBorrowingPickupTransaction:: creating borrowing-pickup transaction for ECS TLR {}",
ecsTlr::getId);
DcbTransaction transaction = buildTransaction(request, BORROWING_PICKUP, ecsTlr.getPrimaryRequestId());
final UUID transactionId = createTransaction(transaction, ecsTlr.getPrimaryRequestTenantId());
ecsTlr.setPrimaryRequestDcbTransactionId(transactionId);
log.info("createBorrowingPickupTransaction:: borrowing-pickup transaction {} for ECS TLR {} created",
() -> transactionId, ecsTlr::getId);
}

@Override
public void createPickupTransaction(EcsTlrEntity ecsTlr, Request request) {
log.info("createPickupTransaction:: creating pickup transaction for ECS TLR {}", ecsTlr.getId());
DcbTransaction transaction = buildTransaction(request, PICKUP, ecsTlr.getPrimaryRequestId());
final UUID transactionId = createTransaction(transaction, ecsTlr.getPrimaryRequestTenantId());
ecsTlr.setPrimaryRequestDcbTransactionId(transactionId);
log.info("createPickupTransaction:: pickup transaction {} for ECS TLR {} created",
() -> transactionId, ecsTlr::getId);
}

private DcbTransaction buildTransaction(Request request, RoleEnum role, UUID requestId) {
DcbItem dcbItem = new DcbItem()
.id(request.getItemId())
.title(request.getInstance().getTitle())
.barcode(request.getItem().getBarcode());
DcbTransaction transaction = new DcbTransaction()
.requestId(ecsTlr.getPrimaryRequestId().toString())

return new DcbTransaction()
.requestId(requestId.toString())
.item(dcbItem)
.role(BORROWER);
final UUID borrowingTransactionId = createTransaction(transaction, ecsTlr.getPrimaryRequestTenantId());
ecsTlr.setPrimaryRequestDcbTransactionId(borrowingTransactionId);
log.info("createBorrowingTransaction:: borrowing transaction {} for ECS TLR {} created",
() -> borrowingTransactionId, ecsTlr::getId);
.role(role);
}

private UUID createTransaction(DcbTransaction transaction, String tenantId) {
Expand Down Expand Up @@ -97,4 +126,21 @@ public TransactionStatusResponse updateTransactionStatus(UUID transactionId,
transactionId.toString(), new TransactionStatus().status(newStatus)));
}

@Override
public void createTransactions(EcsTlrEntity ecsTlr, Request secondaryRequest) {
log.info("createTransactions:: creating transactions for ECS TLR {}", ecsTlr::getId);
if (secondaryRequest.getItemId() == null) {
log.info("createDcbTransactions:: secondary request has no item ID");
return;
}
createLendingTransaction(ecsTlr);
log.info("createTransactions:: intermediate request ID: {}", ecsTlr::getIntermediateRequestId);
if (ecsTlr.getIntermediateRequestId() == null) {
createBorrowingPickupTransaction(ecsTlr, secondaryRequest);
} else {
createBorrowerTransaction(ecsTlr, secondaryRequest);
createPickupTransaction(ecsTlr, secondaryRequest);
}
}

}
Loading

0 comments on commit 7081542

Please sign in to comment.