Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODTLR-79: Pick Slips API (part 2) #78

Merged
merged 13 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,28 @@
]
},
{
"id": "staff-slips",
"id": "tlr-staff-slips",
"version": "1.0",
"handlers": [
{
"methods": ["GET"],
"pathPattern": "/tlr/staff-slips/pick-slips/{servicePointId}",
"permissionsRequired": ["tlr.staff-slips.pick-slips.get"],
"permissionsRequired": ["tlr.pick-slips.collection.get"],
"modulePermissions": [
"user-tenants.collection.get"
"user-tenants.collection.get",
"search.instances.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"
]
}
]
Expand Down Expand Up @@ -228,7 +241,7 @@
"description": "Get ECS TLR allowed service points"
},
{
"permissionName": "tlr.staff-slips.pick-slips.get",
"permissionName": "tlr.pick-slips.collection.get",
"displayName": "ecs-tlr - pick slips",
"description": "Get pick slips"
},
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/folio/client/feign/AddressTypeClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.folio.client.feign;

import org.folio.domain.dto.AddressTypes;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;

@FeignClient(name = "address-types", url = "addresstypes", configuration = FeignClientConfiguration.class)
public interface AddressTypeClient extends GetByQueryClient<AddressTypes> {

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

import org.folio.domain.dto.Departments;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;

@FeignClient(name = "departments", url = "departments", configuration = FeignClientConfiguration.class)
public interface DepartmentClient extends GetByQueryClient<Departments> {

}
4 changes: 3 additions & 1 deletion src/main/java/org/folio/client/feign/GetByQueryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@

@FeignClient(name="get-by-query", configuration = FeignClientConfiguration.class)
public interface GetByQueryClient<T> {

int DEFAULT_LIMIT = 1000;

@GetMapping
T getByQuery(@RequestParam CqlQuery query, @RequestParam int limit);
T getByQuery(@RequestParam CqlQuery query, @RequestParam(defaultValue = "1000") int limit);

default T getByQuery(CqlQuery query) {
return getByQuery(query, DEFAULT_LIMIT);
}

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

import org.folio.domain.dto.LoanTypes;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;

@FeignClient(name = "loan-types", url = "loan-types", configuration = FeignClientConfiguration.class)
public interface LoanTypeClient extends GetByQueryClient<LoanTypes> {

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

import org.folio.domain.dto.Campuses;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;

@FeignClient(name = "campuses", url = "location-units/campuses", configuration = FeignClientConfiguration.class)
public interface LocationCampusClient extends GetByQueryClient<Campuses> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.folio.client.feign;

import org.folio.domain.dto.Institutions;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;

@FeignClient(name = "institutions", url = "location-units/institutions", configuration = FeignClientConfiguration.class)
public interface LocationInstitutionClient extends GetByQueryClient<Institutions> {

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

import org.folio.domain.dto.Libraries;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;

@FeignClient(name = "libraries", url = "location-units/libraries", configuration = FeignClientConfiguration.class)
public interface LocationLibraryClient extends GetByQueryClient<Libraries> {

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

import org.folio.domain.dto.MaterialTypes;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;

@FeignClient(name = "material-types", url = "material-types", configuration = FeignClientConfiguration.class)
public interface MaterialTypeClient extends GetByQueryClient<MaterialTypes> {

}
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package org.folio.client.feign;

import org.folio.domain.dto.SearchInstancesResponse;
import org.folio.domain.dto.SearchItemResponse;
import org.folio.spring.config.FeignClientConfiguration;
import org.folio.support.CqlQuery;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = "search", url = "search", configuration = FeignClientConfiguration.class)
public interface SearchClient {
@FeignClient(name = "search", url = "search/instances", configuration = FeignClientConfiguration.class)
public interface SearchInstanceClient extends GetByQueryClient<SearchInstancesResponse> {

@GetMapping("/instances")
@GetMapping
SearchInstancesResponse searchInstances(@RequestParam("query") CqlQuery cql,
@RequestParam("expandAll") Boolean expandAll);
@RequestParam("expandAll") Boolean expandAll, @RequestParam("limit") int limit);

@GetMapping("/instances?query=id=={instanceId}&expandAll=true")
@GetMapping("?query=id=={instanceId}&expandAll=true")
SearchInstancesResponse searchInstance(@PathVariable("instanceId") String instanceId);

@GetMapping("/consortium/item/{itemId}")
SearchItemResponse searchItem(@PathVariable("itemId") String itemId);

@Override
// max limit for instance search is 500
@GetMapping("?expandAll=true&limit=500&query={query}")
SearchInstancesResponse getByQuery(@PathVariable CqlQuery query);
}
17 changes: 17 additions & 0 deletions src/main/java/org/folio/client/feign/SearchItemClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.folio.client.feign;

import org.folio.domain.dto.SearchInstancesResponse;
import org.folio.domain.dto.SearchItemResponse;
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 = "search-item", url = "search/consortium/item",
configuration = FeignClientConfiguration.class)
public interface SearchItemClient extends GetByQueryClient<SearchInstancesResponse> {

@GetMapping("/{itemId}")
SearchItemResponse searchItem(@PathVariable("itemId") String itemId);

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

import org.folio.domain.dto.ServicePoint;
import org.folio.domain.dto.ServicePoints;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -9,7 +10,7 @@
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(name = "service-points", url = "service-points", configuration = FeignClientConfiguration.class)
public interface ServicePointClient {
public interface ServicePointClient extends GetByQueryClient<ServicePoints> {

@PostMapping
ServicePoint postServicePoint(@RequestBody ServicePoint servicePoint);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/folio/client/feign/UserClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.folio.client.feign;

import org.folio.domain.dto.User;
import org.folio.domain.dto.Users;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
Expand All @@ -11,7 +12,7 @@
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(name = "users", url = "users", configuration = FeignClientConfiguration.class)
public interface UserClient {
public interface UserClient extends GetByQueryClient<Users> {

@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
User postUser(@RequestBody User user);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/folio/client/feign/UserGroupClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.folio.client.feign;

import org.folio.domain.dto.UserGroup;
import org.folio.domain.dto.UserGroups;
import org.folio.spring.config.FeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
Expand All @@ -10,7 +11,7 @@
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(name = "groups", url = "groups", configuration = FeignClientConfiguration.class)
public interface UserGroupClient {
public interface UserGroupClient extends GetByQueryClient<UserGroups> {

@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
UserGroup postUserGroup(@RequestBody UserGroup userGroup);
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/folio/service/AddressTypeService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.folio.service;

import java.util.Collection;

import org.folio.domain.dto.AddressType;

public interface AddressTypeService {
Collection<AddressType> findAddressTypes(Collection<String> ids);
}
9 changes: 9 additions & 0 deletions src/main/java/org/folio/service/DepartmentService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.folio.service;

import java.util.Collection;

import org.folio.domain.dto.Department;

public interface DepartmentService {
Collection<Department> findDepartments(Collection<String> ids);
}
21 changes: 21 additions & 0 deletions src/main/java/org/folio/service/InventoryService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.folio.service;

import java.util.Collection;

import org.folio.domain.dto.Campus;
import org.folio.domain.dto.Institution;
import org.folio.domain.dto.Item;
import org.folio.domain.dto.Library;
import org.folio.domain.dto.LoanType;
import org.folio.domain.dto.MaterialType;
import org.folio.support.CqlQuery;

public interface InventoryService {
Collection<Item> findItems(CqlQuery query, String idIndex, Collection<String> ids);
Collection<Item> findItems(Collection<String> ids);
Collection<MaterialType> findMaterialTypes(Collection<String> ids);
Collection<LoanType> findLoanTypes(Collection<String> ids);
Collection<Library> findLibraries(Collection<String> ids);
Collection<Campus> findCampuses(Collection<String> ids);
Collection<Institution> findInstitutions(Collection<String> ids);
}
10 changes: 0 additions & 10 deletions src/main/java/org/folio/service/ItemService.java

This file was deleted.

11 changes: 11 additions & 0 deletions src/main/java/org/folio/service/SearchService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.folio.service;

import java.util.Collection;

import org.folio.domain.dto.SearchInstance;
import org.folio.support.CqlQuery;

public interface SearchService {
Collection<SearchInstance> searchInstances(CqlQuery commonQuery, String idIndex,
Collection<String> ids);
}
3 changes: 3 additions & 0 deletions src/main/java/org/folio/service/ServicePointService.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.folio.service;

import java.util.Collection;

import org.folio.domain.dto.ServicePoint;

public interface ServicePointService {
ServicePoint find(String id);
Collection<ServicePoint> find(Collection<String> servicePointIds);
ServicePoint create(ServicePoint servicePoint);
}
3 changes: 3 additions & 0 deletions src/main/java/org/folio/service/UserGroupService.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.folio.service;

import java.util.Collection;

import org.folio.domain.dto.UserGroup;

public interface UserGroupService {
UserGroup create(UserGroup userGroup);
UserGroup update(UserGroup userGroup);
Collection<UserGroup> find(Collection<String> ids);
}
3 changes: 3 additions & 0 deletions src/main/java/org/folio/service/UserService.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.folio.service;

import java.util.Collection;

import org.folio.domain.dto.User;

public interface UserService {
User find(String userId);
User create(User user);
User update(User user);
Collection<User> find(Collection<String> userIds);
}
28 changes: 28 additions & 0 deletions src/main/java/org/folio/service/impl/AddressTypeServiceImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.folio.service.impl;

import java.util.Collection;

import org.folio.client.feign.AddressTypeClient;
import org.folio.domain.dto.AddressType;
import org.folio.domain.dto.AddressTypes;
import org.folio.service.AddressTypeService;
import org.folio.support.BulkFetcher;
import org.springframework.stereotype.Service;

import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;

@Service
@RequiredArgsConstructor
@Log4j2
public class AddressTypeServiceImpl implements AddressTypeService {

private final AddressTypeClient addressTypeClient;

@Override
public Collection<AddressType> findAddressTypes(Collection<String> ids) {
log.info("findAddressTypes:: fetching address types by {} IDs", ids.size());
log.debug("findAddressTypes:: ids={}", ids);
return BulkFetcher.fetch(addressTypeClient, ids, AddressTypes::getAddressTypes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import org.apache.commons.lang3.StringUtils;
import org.folio.client.feign.CirculationClient;
import org.folio.client.feign.SearchClient;
import org.folio.client.feign.SearchItemClient;
import org.folio.domain.dto.AllowedServicePointsRequest;
import org.folio.domain.dto.AllowedServicePointsResponse;
import org.folio.domain.dto.SearchItemResponse;
Expand All @@ -21,7 +21,7 @@
@Service
public class AllowedServicePointsForItemLevelRequestService extends AllowedServicePointsServiceImpl {

public AllowedServicePointsForItemLevelRequestService(SearchClient searchClient,
public AllowedServicePointsForItemLevelRequestService(SearchItemClient searchClient,
CirculationClient circulationClient, UserService userService,
SystemUserScopedExecutionService executionService, RequestService requestService,
EcsTlrRepository ecsTlrRepository) {
Expand All @@ -32,7 +32,7 @@ public AllowedServicePointsForItemLevelRequestService(SearchClient searchClient,

@Override
protected Collection<String> getLendingTenants(AllowedServicePointsRequest request) {
SearchItemResponse item = searchClient.searchItem(request.getItemId());
SearchItemResponse item = searchItemClient.searchItem(request.getItemId());
if (StringUtils.isNotEmpty(item.getTenantId())) {
request.setInstanceId(item.getInstanceId());
return List.of(item.getTenantId());
Expand Down
Loading