Skip to content

Commit

Permalink
MODTLR-79 Fresh schemas, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrVidinieiev committed Nov 19, 2024
1 parent e13278d commit 822d8e8
Show file tree
Hide file tree
Showing 36 changed files with 1,027 additions and 722 deletions.
59 changes: 33 additions & 26 deletions src/main/java/org/folio/service/impl/StaffSlipsServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,19 @@ public class StaffSlipsServiceImpl implements StaffSlipsService {
public Collection<StaffSlip> getStaffSlips(String servicePointId) {
log.info("getStaffSlips:: building staff slips for service point {}", servicePointId);

Map<String, Collection<Location>> relevantLocationsByTenant = findLocations(servicePointId);
Collection<String> relevantLocationIds = relevantLocationsByTenant.values()
Map<String, Collection<Location>> locationsByTenant = findLocations(servicePointId);
Collection<String> locationIds = locationsByTenant.values()
.stream()
.flatMap(Collection::stream)
.map(Location::getId)
.collect(toSet());

Collection<SearchInstance> instances = findInstances(relevantLocationIds);
Collection<SearchItem> itemsInRelevantLocations = getItemsForLocations(instances, relevantLocationIds);
Collection<SearchInstance> instances = findInstances(locationIds);
Collection<SearchItem> itemsInRelevantLocations = getItemsForLocations(instances, locationIds);
Collection<Request> requests = findRequests(itemsInRelevantLocations);
Collection<SearchItem> requestedItems = filterItemsByRequests(itemsInRelevantLocations, requests);
Collection<SearchItem> requestedItems = filterRequestedItems(itemsInRelevantLocations, requests);
Collection<StaffSlipContext> staffSlipContexts = buildStaffSlipContexts(requests, requestedItems,
instances, relevantLocationsByTenant);
instances, locationsByTenant);
Collection<StaffSlip> staffSlips = buildStaffSlips(staffSlipContexts);

log.info("getStaffSlips:: successfully built {} staff slips", staffSlips::size);
Expand Down Expand Up @@ -190,7 +190,7 @@ private Collection<Request> findRequests(Collection<SearchItem> items) {
return requestService.getRequestsFromStorage(query, "itemId", itemIds);
}

private static Collection<SearchItem> filterItemsByRequests(Collection<SearchItem> items,
private static Collection<SearchItem> filterRequestedItems(Collection<SearchItem> items,
Collection<Request> requests) {

log.info("filterItemsByRequests:: filtering out non-requested items");
Expand Down Expand Up @@ -263,7 +263,7 @@ private Collection<ItemContext> buildItemContexts(String tenantId, Collection<St
}

private Collection<ItemContext> buildItemContexts(Collection<String> itemIds,
Map<String, SearchInstance> itemIdToInstance, Collection<Location> matchingLocations) {
Map<String, SearchInstance> itemIdToInstance, Collection<Location> locations) {

Collection<Item> items = inventoryService.findItems(itemIds);

Expand All @@ -279,7 +279,7 @@ private Collection<ItemContext> buildItemContexts(Collection<String> itemIds,
.map(Item::getEffectiveLocationId)
.collect(toSet());

Map<String, Location> locationsById = matchingLocations.stream()
Map<String, Location> locationsById = locations.stream()
.filter(location -> locationIdsOfRequestedItems.contains(location.getId()))
.toList().stream()
.collect(mapById(Location::getId));
Expand Down Expand Up @@ -353,6 +353,10 @@ private Map<String, RequesterContext> buildRequesterContexts(Collection<Request>
Map<String, RequesterContext> requesterContexts = new HashMap<>(requests.size());
for (Request request : requests) {
User requester = requestersById.get(request.getRequesterId());
if (requester == null) {
continue;
}

UserGroup userGroup = userGroupsById.get(requester.getPatronGroup());

Collection<Department> requesterDepartments = requester.getDepartments()
Expand Down Expand Up @@ -569,7 +573,7 @@ private static StaffSlip buildStaffSlip(StaffSlipContext context) {
}

private static StaffSlipItem buildStaffSlipItem(StaffSlipContext context) {
log.info("buildStaffSlipItem:: building staff slip item");
log.debug("buildStaffSlipItem:: building staff slip item");
ItemContext itemContext = context.itemContext();
Item item = itemContext.item();
if (item == null) {
Expand Down Expand Up @@ -609,22 +613,25 @@ private static StaffSlipItem buildStaffSlipItem(StaffSlipContext context) {

SearchInstance instance = itemContext.instance();
if (instance != null) {
String primaryContributor = instance.getContributors()
.stream()
.filter(Contributor::getPrimary)
.findFirst()
.map(Contributor::getName)
.orElse(null);
staffSlipItem.title(instance.getTitle());

String allContributors = instance.getContributors()
.stream()
.map(Contributor::getName)
.collect(joining("; "));
List<Contributor> contributors = instance.getContributors();
if (contributors != null && !contributors.isEmpty()) {
String primaryContributor = contributors.stream()
.filter(Contributor::getPrimary)
.findFirst()
.map(Contributor::getName)
.orElse(null);

staffSlipItem
.title(instance.getTitle())
.primaryContributor(primaryContributor)
.allContributors(allContributors);
String allContributors = contributors.stream()
.map(Contributor::getName)
.collect(joining("; "));

staffSlipItem
.title(instance.getTitle())
.primaryContributor(primaryContributor)
.allContributors(allContributors);
}
}

Location location = itemContext.location();
Expand Down Expand Up @@ -661,7 +668,7 @@ private static StaffSlipItem buildStaffSlipItem(StaffSlipContext context) {
}

private static StaffSlipRequest buildStaffSlipRequest(StaffSlipContext context) {
log.info("buildStaffSlipItem:: building staff slip request");
log.debug("buildStaffSlipItem:: building staff slip request");
RequestContext requestContext = context.requestContext();
Request request = requestContext.request();
if (request == null) {
Expand Down Expand Up @@ -690,7 +697,7 @@ private static StaffSlipRequest buildStaffSlipRequest(StaffSlipContext context)
}

private static StaffSlipRequester buildStaffSlipRequester(StaffSlipContext context) {
log.info("buildStaffSlipItem:: building staff slip requester");
log.debug("buildStaffSlipItem:: building staff slip requester");
RequesterContext requesterContext = context.requesterContext();
User requester = requesterContext.requester();
if (requester == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public UserGroup update(UserGroup userGroup) {

@Override
public Collection<UserGroup> find(Collection<String> ids) {
log.info("find:: fetching userGroups by {} IDs", ids);
log.info("find:: fetching userGroups by {} IDs", ids::size);
log.debug("find:: ids={}", ids);
return BulkFetcher.fetch(userGroupClient, ids, UserGroups::getUsergroups);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/swagger.api/ecs-tlr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ components:
requests:
$ref: 'schemas/requests.json'
searchInstancesResponse:
$ref: schemas/response/searchInstancesResponse.json
$ref: 'schemas/search/searchInstancesResponse.yaml'
searchItemResponse:
$ref: schemas/response/searchItemResponse.json
$ref: 'schemas/search/searchItemResponse.yaml'
user:
$ref: 'schemas/users/user.json'
userTenant:
Expand Down
19 changes: 0 additions & 19 deletions src/main/resources/swagger.api/schemas/alternativeTitle.json

This file was deleted.

16 changes: 0 additions & 16 deletions src/main/resources/swagger.api/schemas/circulationNote.json

This file was deleted.

10 changes: 10 additions & 0 deletions src/main/resources/swagger.api/schemas/common/identifier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type: object
description: "Resource identifier"
additionalProperties: false
properties:
value:
type: string
description: "Resource identifier value"
identifierTypeId:
type: string
description: "Resource identifier type (e.g. Control number, LCCN, Other standard identifier, System control number)"
14 changes: 14 additions & 0 deletions src/main/resources/swagger.api/schemas/common/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type: object
properties:
createdDate:
description: "Date and time when the record was created"
type: string
createdByUserId:
description: "ID of the user who created the record (when available)"
type: string
updatedDate:
description: "Date and time when the record was last updated"
type: string
updatedByUserId:
description: "ID of the user who last updated the record (when available)"
type: string
10 changes: 10 additions & 0 deletions src/main/resources/swagger.api/schemas/common/tags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: "tags"
description: "List of simple tags that can be added to an object"
type: "object"
properties:
tagList:
description: "List of tags"
type: "array"
items:
type: "string"
additionalProperties: false
31 changes: 0 additions & 31 deletions src/main/resources/swagger.api/schemas/contributor.json

This file was deleted.

23 changes: 0 additions & 23 deletions src/main/resources/swagger.api/schemas/electronicAccess.json

This file was deleted.

15 changes: 0 additions & 15 deletions src/main/resources/swagger.api/schemas/identifiers.json

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type: object
description: "An alternative title description"
properties:
alternativeTitleTypeId:
type: string
description: "UUID for an alternative title qualifier"
alternativeTitle:
type: string
description: "An alternative title for the resource"
authorityId:
type: string
description: "UUID of authority record that controls an alternative title"
10 changes: 10 additions & 0 deletions src/main/resources/swagger.api/schemas/search/circulationNote.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
description: "Circulations note for item"
type: object
properties:
note:
type: string
description: "Text to display"
staffOnly:
type: boolean
description: "Flag to restrict display of this note"
default: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type: object
description: Classification object
properties:
classificationNumber:
description: "Classification (e.g. classification scheme, classification schedule)"
type: string
classificationTypeId:
description: "Classification type ID"
type: string
21 changes: 21 additions & 0 deletions src/main/resources/swagger.api/schemas/search/contributor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
type: object
description: "A contributor description"
properties:
name:
type: string
description: "Personal name, corporate name, meeting name"
contributorTypeId:
type: string
description: "ID for the contributor type term defined as a reference table in settings"
contributorTypeText:
type: string
description: "Free text element for adding contributor type terms other than those defined by the MARC code list for relators"
contributorNameTypeId:
type: string
description: "Contributor type terms defined by the MARC code list for relators"
authorityId:
type: string
description: "ID of authority record that controls the contributor"
primary:
type: boolean
description: "Whether this is the primary contributor"
12 changes: 12 additions & 0 deletions src/main/resources/swagger.api/schemas/search/dates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type: object
description: "Instance Dates"
properties:
dateTypeId:
type: string
description: "Date type ID"
date1:
type: string
description: "Date1 value"
date2:
type: string
description: "Date2 value"
Loading

0 comments on commit 822d8e8

Please sign in to comment.