From 565b4d9bfd6dc656699e4d39cd4fbab22a33ed4c Mon Sep 17 00:00:00 2001 From: Oleksandr Vidinieiev Date: Mon, 9 Dec 2024 14:04:38 +0200 Subject: [PATCH] MODTLR-98 Remove redundant changes --- .../listener/kafka/KafkaEventListener.java | 29 +-- .../org/folio/service/ConsortiaService.java | 5 - .../org/folio/service/UserTenantsService.java | 1 - .../service/impl/ConsortiaServiceImpl.java | 35 ---- .../folio/service/impl/LoanEventHandler.java | 40 ----- src/main/resources/swagger.api/ecs-tlr.yaml | 2 - .../resources/swagger.api/schemas/loan.json | 166 ------------------ 7 files changed, 5 insertions(+), 273 deletions(-) delete mode 100644 src/main/java/org/folio/service/impl/LoanEventHandler.java delete mode 100644 src/main/resources/swagger.api/schemas/loan.json diff --git a/src/main/java/org/folio/listener/kafka/KafkaEventListener.java b/src/main/java/org/folio/listener/kafka/KafkaEventListener.java index dc0f9a05..f6e7b840 100644 --- a/src/main/java/org/folio/listener/kafka/KafkaEventListener.java +++ b/src/main/java/org/folio/listener/kafka/KafkaEventListener.java @@ -5,14 +5,12 @@ import java.nio.charset.StandardCharsets; import java.util.Optional; -import org.folio.domain.dto.Loan; import org.folio.domain.dto.Request; import org.folio.domain.dto.RequestsBatchUpdate; import org.folio.domain.dto.User; import org.folio.domain.dto.UserGroup; import org.folio.exception.KafkaEventDeserializationException; import org.folio.service.KafkaEventHandler; -import org.folio.service.impl.LoanEventHandler; import org.folio.service.impl.RequestBatchUpdateEventHandler; import org.folio.service.impl.RequestEventHandler; import org.folio.service.impl.UserEventHandler; @@ -36,22 +34,18 @@ public class KafkaEventListener { private static final ObjectMapper objectMapper = new ObjectMapper(); private final RequestEventHandler requestEventHandler; - private final LoanEventHandler loanEventHandler; private final UserGroupEventHandler userGroupEventHandler; private final UserEventHandler userEventHandler; private final SystemUserScopedExecutionService systemUserScopedExecutionService; private final RequestBatchUpdateEventHandler requestBatchEventHandler; - @Autowired - public KafkaEventListener(RequestEventHandler requestEventHandler, - LoanEventHandler loanEventHandler, - RequestBatchUpdateEventHandler requestBatchEventHandler, - SystemUserScopedExecutionService systemUserScopedExecutionService, - UserGroupEventHandler userGroupEventHandler, - UserEventHandler userEventHandler) { + public KafkaEventListener(@Autowired RequestEventHandler requestEventHandler, + @Autowired RequestBatchUpdateEventHandler requestBatchEventHandler, + @Autowired SystemUserScopedExecutionService systemUserScopedExecutionService, + @Autowired UserGroupEventHandler userGroupEventHandler, + @Autowired UserEventHandler userEventHandler) { this.requestEventHandler = requestEventHandler; - this.loanEventHandler = loanEventHandler; this.systemUserScopedExecutionService = systemUserScopedExecutionService; this.userGroupEventHandler = userGroupEventHandler; this.requestBatchEventHandler = requestBatchEventHandler; @@ -82,19 +76,6 @@ public void handleRequestBatchUpdateEvent(String eventString, MessageHeaders mes log.info("handleRequestBatchUpdateEvent:: event consumed: {}", event::getId); } - @KafkaListener( - topicPattern = "${folio.environment}\\.\\w+\\.circulation\\.loan", - groupId = "${spring.kafka.consumer.group-id}" - ) - public void handleLoanEvent(String eventString, MessageHeaders messageHeaders) { - log.debug("handleLoanEvent:: event: {}", () -> eventString); - KafkaEvent event = deserialize(eventString, messageHeaders, Loan.class); - log.info("handleLoanEvent:: event received: {}", event::getId); - log.info("handleLoanEvent:: event: {}", eventString); - handleEvent(event, loanEventHandler); - log.info("handleLoanEvent:: event consumed: {}", event::getId); - } - private void handleEvent(KafkaEvent event, KafkaEventHandler handler) { try { systemUserScopedExecutionService.executeAsyncSystemUserScoped(CENTRAL_TENANT_ID, diff --git a/src/main/java/org/folio/service/ConsortiaService.java b/src/main/java/org/folio/service/ConsortiaService.java index 932c54cb..562d9749 100644 --- a/src/main/java/org/folio/service/ConsortiaService.java +++ b/src/main/java/org/folio/service/ConsortiaService.java @@ -6,11 +6,6 @@ import org.folio.domain.dto.TenantCollection; public interface ConsortiaService { - TenantCollection getAllDataTenants(String consortiumId); - -// boolean isCurrentTenantCentral(); - -// T executeInTenant(String tenantId, Callable action); TenantCollection getAllConsortiumTenants(String consortiumId); Collection getAllConsortiumTenants(); } diff --git a/src/main/java/org/folio/service/UserTenantsService.java b/src/main/java/org/folio/service/UserTenantsService.java index bdfaaecc..67de47e4 100644 --- a/src/main/java/org/folio/service/UserTenantsService.java +++ b/src/main/java/org/folio/service/UserTenantsService.java @@ -4,6 +4,5 @@ public interface UserTenantsService { UserTenant findFirstUserTenant(); - String getCentralTenantId(); } diff --git a/src/main/java/org/folio/service/impl/ConsortiaServiceImpl.java b/src/main/java/org/folio/service/impl/ConsortiaServiceImpl.java index 7f44b824..e328de0b 100644 --- a/src/main/java/org/folio/service/impl/ConsortiaServiceImpl.java +++ b/src/main/java/org/folio/service/impl/ConsortiaServiceImpl.java @@ -11,7 +11,6 @@ import org.folio.domain.dto.UserTenant; import org.folio.service.ConsortiaService; import org.folio.service.UserTenantsService; -import org.folio.spring.service.SystemUserScopedExecutionService; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; @@ -24,11 +23,6 @@ public class ConsortiaServiceImpl implements ConsortiaService { private final ConsortiaClient consortiaClient; private final UserTenantsService userTenantsService; - @Override - public TenantCollection getAllDataTenants(String consortiumId) { - return consortiaClient.getConsortiaTenants(consortiumId); - } - @Override public TenantCollection getAllConsortiumTenants(String consortiumId) { return consortiaClient.getConsortiaTenants(consortiumId); @@ -46,33 +40,4 @@ public Collection getAllConsortiumTenants() { log.info("getAllConsortiumTenants:: found {} consortium tenants", tenants::size); return tenants; } - -// @Override -// public boolean isCurrentTenantCentral() { -// var userTenant = userTenantsService.findFirstUserTenant(); -// var centralTenantId = userTenant.getCentralTenantId(); -// var currentTenantId = userTenant.getTenantId(); -// -// if (centralTenantId == null || currentTenantId == null) { -// log.warn("isCurrentTenantCentral:: Cannot determine central tenant or current tenant"); -// return false; -// } -// -// return centralTenantId.equals(currentTenantId); -// } -// -// @Override -// public T executeInTenant(String tenantId, Callable action) { -// if (isCurrentTenantCentral()) { -// try { -// return action.call(); -// } catch (Exception e) { -// log.info("executeInTenant:: Failed to execute in Central tenant"); -// return null; -// } -// } else { -// return systemUserScopedExecutionService.executeSystemUserScoped( -// tenantId, action); -// } -// } } diff --git a/src/main/java/org/folio/service/impl/LoanEventHandler.java b/src/main/java/org/folio/service/impl/LoanEventHandler.java deleted file mode 100644 index dc2dc630..00000000 --- a/src/main/java/org/folio/service/impl/LoanEventHandler.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.folio.service.impl; - -import static org.folio.support.KafkaEvent.EventType.CREATED; -import static org.folio.support.KafkaEvent.EventType.UPDATED; - -import org.folio.domain.dto.Loan; -import org.folio.service.KafkaEventHandler; -import org.folio.support.KafkaEvent; -import org.springframework.stereotype.Service; - -import lombok.AllArgsConstructor; -import lombok.extern.log4j.Log4j2; - -@AllArgsConstructor -@Service -@Log4j2 -public class LoanEventHandler implements KafkaEventHandler { - - @Override - public void handle(KafkaEvent event) { - log.info("handle:: processing loan event: {}", event::getId); - if (event.getType() == CREATED) { - handleLoanCreationEvent(event); - } else if (event.getType() == UPDATED) { - handleLoanUpdateEvent(event); - } else { - log.info("handle:: ignoring event {} of unsupported type: {}", event::getId, event::getType); - } - log.info("handle:: loan event processed: {}", event::getId); - } - - private void handleLoanCreationEvent(KafkaEvent event) { - log.info("handleLoanUpdateEvent:: handling loan creation event: {}", event::getId); - } - - private void handleLoanUpdateEvent(KafkaEvent event) { - log.info("handleLoanUpdateEvent:: handling loan update event: {}", event::getId); - } - -} diff --git a/src/main/resources/swagger.api/ecs-tlr.yaml b/src/main/resources/swagger.api/ecs-tlr.yaml index b1d4460c..dd60c16e 100644 --- a/src/main/resources/swagger.api/ecs-tlr.yaml +++ b/src/main/resources/swagger.api/ecs-tlr.yaml @@ -103,8 +103,6 @@ components: $ref: 'schemas/request.json' requests: $ref: 'schemas/requests.json' - loan: - $ref: 'schemas/loan.json' searchInstancesResponse: $ref: 'schemas/search/searchInstancesResponse.yaml' searchItemResponse: diff --git a/src/main/resources/swagger.api/schemas/loan.json b/src/main/resources/swagger.api/schemas/loan.json deleted file mode 100644 index 1ab9653f..00000000 --- a/src/main/resources/swagger.api/schemas/loan.json +++ /dev/null @@ -1,166 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-04/schema#", - "type": "object", - "title": "Loan", - "description": "Links the item with the patron and applies certain conditions based on policies", - "properties": { - "id": { - "description": "Unique ID (generated UUID) of the loan", - "type": "string" - }, - "userId": { - "description": "ID of the patron the item was lent to. Required for open loans, not required for closed loans (for anonymization).", - "type": "string" - }, - "proxyUserId": { - "description": "ID of the user representing a proxy for the patron", - "type": "string", - "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - }, - "itemId": { - "description": "ID of the item lent to the patron", - "type": "string" - }, - "itemEffectiveLocationIdAtCheckOut": { - "description": "The effective location, at the time of checkout, of the item loaned to the patron.", - "type": "string", - "$ref": "uuid.json" - }, - "status": { - "description": "Overall status of the loan", - "type": "object", - "properties": { - "name": { - "description": "Name of the status (currently can be any value, values commonly used are Open and Closed)", - "type": "string" - } - } - }, - "loanDate": { - "description": "Date time when the loan began (typically represented according to rfc3339 section-5.6. Has not had the date-time format validation applied as was not supported at point of introduction and would now be a breaking change)", - "type": "string" - }, - "dueDate": { - "description": "Date time when the item is due to be returned", - "type": "string", - "format": "date-time" - }, - "returnDate": { - "description": "Date time when the item is returned and the loan ends (typically represented according to rfc3339 section-5.6. Has not had the date-time format validation applied as was not supported at point of introduction and would now be a breaking change)", - "type": "string" - }, - "systemReturnDate" : { - "description": "Date time when the returned item is actually processed", - "type": "string", - "format": "date-time" - }, - "action": { - "description": "Last action performed on a loan (currently can be any value, values commonly used are checkedout and checkedin)", - "type": "string" - }, - "actionComment": { - "description": "Comment to last action performed on a loan", - "type": "string" - }, - "itemStatus": { - "description": "Last item status used in relation to this loan (currently can be any value, values commonly used are Checked out and Available)", - "type": "string" - }, - "renewalCount": { - "description": "Count of how many times a loan has been renewed (incremented by the client)", - "type": "integer" - }, - "loanPolicyId": { - "description": "ID of last policy used in relation to this loan", - "type": "string" - }, - "checkoutServicePointId": { - "description": "ID of the Service Point where the last checkout occured", - "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", - "type": "string" - }, - "checkinServicePointId": { - "description": "ID of the Service Point where the last checkin occured", - "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", - "type": "string" - }, - "patronGroupIdAtCheckout": { - "description": "Patron Group Id at checkout", - "type": "string" - }, - "dueDateChangedByRecall": { - "description": "Indicates whether or not this loan had its due date modified by a recall on the loaned item", - "type": "boolean" - }, - "isDcb": { - "description": "Indicates whether or not this loan is associated for DCB use case", - "type": "boolean" - }, - "declaredLostDate" : { - "description": "Date and time the item was declared lost during this loan", - "type": "string", - "format": "date-time" - }, - "claimedReturnedDate": { - "description": "Date and time the item was claimed returned for this loan", - "type": "string", - "format": "date-time" - }, - "overdueFinePolicyId": { - "description": "ID of overdue fines policy at the time the item is check-in or renewed", - "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", - "type": "string" - }, - "lostItemPolicyId": { - "description": "ID of lost item policy which determines when the item ages to lost and the associated fees or the associated fees if the patron declares the item lost.", - "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", - "type": "string" - }, - "metadata": { - "description": "Metadata about creation and changes to loan, provided by the server (client should not provide)", - "type": "object", - "$ref": "metadata.json" - }, - "agedToLostDelayedBilling": { - "description": "Aged to Lost Delayed Billing processing", - "type": "object", - "properties": { - "lostItemHasBeenBilled": { - "description": "Indicates if the aged to lost fee has been billed (for use where delayed billing is set up)", - "type": "boolean" - }, - "dateLostItemShouldBeBilled": { - "description": "Indicates when the aged to lost fee should be billed (for use where delayed billing is set up)", - "type": "string", - "format": "date-time" - }, - "agedToLostDate": { - "description": "Date and time the item was aged to lost for this loan", - "type": "string", - "format": "date-time" - } - } - }, - "reminders" : { - "description": "Information about reminders for overdue loan", - "type": "object", - "properties": { - "lastFeeBilled": { - "description": "Information about the most recent reminder fee billing", - "type": "object", - "properties": { - "number": { - "description": "Last reminder fee billed, sequence number", - "type": "integer" - }, - "date": { - "description": "Last reminder fee billed, date", - "type": "string", - "format": "date-time" - } - } - } - } - } - } -} \ No newline at end of file