-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODTLR-10 Basic implementation and tests
- Loading branch information
1 parent
d0cb1c0
commit 2805baa
Showing
20 changed files
with
745 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.folio.client; | ||
|
||
import org.folio.domain.dto.Request; | ||
import org.folio.spring.config.FeignClientConfiguration; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
|
||
@FeignClient(name = "circulation", url = "${folio.okapi-url}", configuration = FeignClientConfiguration.class) | ||
public interface CirculationClient { | ||
|
||
@PostMapping("/circulation/requests") | ||
Request createTitleLevelRequest(Request request); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/org/folio/service/TenantScopedExecutionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.folio.service; | ||
|
||
import java.util.concurrent.Callable; | ||
|
||
public interface TenantScopedExecutionService { | ||
|
||
<T> T execute(String tenantId, Callable<T> action); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/org/folio/service/impl/TenantScopedExecutionServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.folio.service.impl; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.Callable; | ||
|
||
import org.folio.service.TenantScopedExecutionService; | ||
import org.folio.spring.FolioExecutionContext; | ||
import org.folio.spring.FolioModuleMetadata; | ||
import org.folio.spring.integration.XOkapiHeaders; | ||
import org.folio.spring.scope.FolioExecutionContextSetter; | ||
import org.springframework.stereotype.Service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Log4j2 | ||
public class TenantScopedExecutionServiceImpl implements TenantScopedExecutionService { | ||
|
||
private final FolioModuleMetadata moduleMetadata; | ||
private final FolioExecutionContext executionContext; | ||
|
||
@Override | ||
public <T> T execute(String tenantId, Callable<T> action) { | ||
log.info("execute:: tenantId={}", tenantId); | ||
Map<String, Collection<String>> headers = executionContext.getAllHeaders(); | ||
headers.put(XOkapiHeaders.TENANT, List.of(tenantId)); | ||
|
||
try (var x = new FolioExecutionContextSetter(moduleMetadata, headers)) { | ||
return action.call(); | ||
} catch (Exception e) { | ||
log.error("execute:: tenantId={}", tenantId, e); | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/resources/swagger.api/schemas/override-blocks.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"type": "object", | ||
"description": "Blocks to override (e.g. during checkout or renewal)", | ||
"properties": { | ||
"itemNotLoanableBlock": { | ||
"description": "'Item not loanable' block", | ||
"type": "object", | ||
"properties": { | ||
"dueDate": { | ||
"description": "Due date for a new loan", | ||
"type": "string", | ||
"format": "date-time" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": [ | ||
"dueDate" | ||
] | ||
}, | ||
"patronBlock": { | ||
"description": "Automated patron block", | ||
"type": "object", | ||
"additionalProperties": false | ||
}, | ||
"itemLimitBlock": { | ||
"description": "Item limit block", | ||
"type": "object", | ||
"additionalProperties": false | ||
}, | ||
"renewalBlock": { | ||
"description": "Renewal block", | ||
"type": "object", | ||
"additionalProperties": false | ||
}, | ||
"renewalDueDateRequiredBlock": { | ||
"description": "Override renewal block which requires due date field", | ||
"type": "object", | ||
"properties": { | ||
"dueDate": { | ||
"description": "Due date for a new loan", | ||
"type": "string", | ||
"format": "date-time" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": [ | ||
"dueDate" | ||
] | ||
}, | ||
"comment": { | ||
"description": "Reason for override", | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/resources/swagger.api/schemas/request-search-index.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"description": "Request fields used for search", | ||
"type": "object", | ||
"properties": { | ||
"callNumberComponents": { | ||
"type": "object", | ||
"description": "Effective call number components", | ||
"properties": { | ||
"callNumber": { | ||
"type": "string", | ||
"description": "Effective Call Number is an identifier assigned to an item or its holding and associated with the item." | ||
}, | ||
"prefix": { | ||
"type": "string", | ||
"description": "Effective Call Number Prefix is the prefix of the identifier assigned to an item or its holding and associated with the item." | ||
}, | ||
"suffix": { | ||
"type": "string", | ||
"description": "Effective Call Number Suffix is the suffix of the identifier assigned to an item or its holding and associated with the item." | ||
} | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"shelvingOrder": { | ||
"type": "string", | ||
"description": "A system generated normalization of the call number that allows for call number sorting in reports and search results" | ||
}, | ||
"pickupServicePointName": { | ||
"description": "The name of the request pickup service point", | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} |
Oops, something went wrong.