-
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-58: Pick Slips API (part 1) (#69)
* MODTLR-58 Declare new interface in ModuleDescriptor-template.json * MODTLR-59 Create YAML for new API * MODTLR-59 Add servicePointId parameter to YAML * MODTLR-58 Implementation and tests * MODTLR-58 Remove MockMvc * MODTLR-58 Refactoring * MODTLR-58 Extend API test * MODTLR-58 Remove Stream#peek * MODTLR-58 Tests for CqlQuery * MODTLR-58 Tests for CqlQuery * MODTLR-58 Make BulkFetcher a utility class * MODTLR-58 Make BulkFetcher a utility class * MODTLR-58 Fix URL in ModuleDescriptor-template.json * MODTLR-58 Move permissions from module descriptor to system user * MODTLR-58 Fix permission names * MODTLR-58 Add comment for copy number fallback * MODTLR-58 Improve logging * MODTLR-58 Improve logging * MODTLR-58 Remove staff-slips-response.json --------- Co-authored-by: Alexander Kurash <[email protected]>
- Loading branch information
1 parent
c01e3c5
commit a1d6fee
Showing
37 changed files
with
1,646 additions
and
14 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
19 changes: 19 additions & 0 deletions
19
src/main/java/org/folio/client/feign/GetByQueryClient.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,19 @@ | ||
package org.folio.client.feign; | ||
|
||
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.RequestParam; | ||
|
||
@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); | ||
|
||
default T getByQuery(CqlQuery query) { | ||
return getByQuery(query, DEFAULT_LIMIT); | ||
} | ||
} |
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,16 @@ | ||
package org.folio.client.feign; | ||
|
||
import org.folio.domain.dto.Location; | ||
import org.folio.domain.dto.Locations; | ||
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 = "locations", url = "locations", configuration = FeignClientConfiguration.class) | ||
public interface LocationClient extends GetByQueryClient<Locations> { | ||
|
||
@GetMapping("/{id}") | ||
Location findLocation(@PathVariable String id); | ||
|
||
} |
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
33 changes: 33 additions & 0 deletions
33
src/main/java/org/folio/controller/StaffSlipsController.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,33 @@ | ||
package org.folio.controller; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.UUID; | ||
|
||
import org.folio.domain.dto.PickSlipsResponse; | ||
import org.folio.domain.dto.StaffSlip; | ||
import org.folio.rest.resource.PickSlipsApi; | ||
import org.folio.service.impl.PickSlipsService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
@RestController | ||
@Log4j2 | ||
@AllArgsConstructor | ||
public class StaffSlipsController implements PickSlipsApi { | ||
|
||
private final PickSlipsService pickSlipsService; | ||
|
||
@Override | ||
public ResponseEntity<PickSlipsResponse> getPickSlips(UUID servicePointId) { | ||
log.info("getPickSlips:: servicePointId={}", servicePointId); | ||
Collection<StaffSlip> pickSlips = pickSlipsService.getStaffSlips(servicePointId.toString()); | ||
|
||
return ResponseEntity.ok(new PickSlipsResponse() | ||
.pickSlips(new ArrayList<>(pickSlips)) | ||
.totalRecords(pickSlips.size())); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
package org.folio.service; | ||
|
||
import java.util.Collection; | ||
|
||
import org.folio.domain.dto.Tenant; | ||
import org.folio.domain.dto.TenantCollection; | ||
|
||
public interface ConsortiaService { | ||
TenantCollection getAllDataTenants(String consortiumId); | ||
TenantCollection getAllConsortiumTenants(String consortiumId); | ||
Collection<Tenant> getAllConsortiumTenants(); | ||
} |
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,10 @@ | ||
package org.folio.service; | ||
|
||
import java.util.Collection; | ||
|
||
import org.folio.domain.dto.Item; | ||
import org.folio.support.CqlQuery; | ||
|
||
public interface ItemService { | ||
Collection<Item> findItems(CqlQuery query, String idIndex, Collection<String> ids); | ||
} |
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,10 @@ | ||
package org.folio.service; | ||
|
||
import java.util.Collection; | ||
|
||
import org.folio.domain.dto.Location; | ||
import org.folio.support.CqlQuery; | ||
|
||
public interface LocationService { | ||
Collection<Location> findLocations(CqlQuery query); | ||
} |
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,9 @@ | ||
package org.folio.service; | ||
|
||
import java.util.Collection; | ||
|
||
import org.folio.domain.dto.StaffSlip; | ||
|
||
public interface StaffSlipsService { | ||
Collection<StaffSlip> getStaffSlips(String servicePointId); | ||
} |
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,31 @@ | ||
package org.folio.service.impl; | ||
|
||
import java.util.Collection; | ||
|
||
import org.folio.client.feign.ItemClient; | ||
import org.folio.domain.dto.Item; | ||
import org.folio.domain.dto.Items; | ||
import org.folio.service.ItemService; | ||
import org.folio.support.BulkFetcher; | ||
import org.folio.support.CqlQuery; | ||
import org.springframework.stereotype.Service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Log4j2 | ||
public class ItemServiceImpl implements ItemService { | ||
private final ItemClient itemClient; | ||
|
||
@Override | ||
public Collection<Item> findItems(CqlQuery query, String idIndex, Collection<String> ids) { | ||
log.info("findItems:: searching items by query and index: query={}, index={}, ids={}", | ||
query, idIndex, ids.size()); | ||
log.debug("findItems:: ids={}", ids); | ||
Collection<Item> items = BulkFetcher.fetch(itemClient, query, idIndex, ids, Items::getItems); | ||
log.info("findItems:: found {} items", items::size); | ||
return items; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/org/folio/service/impl/LocationServiceImpl.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,28 @@ | ||
package org.folio.service.impl; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import org.folio.client.feign.LocationClient; | ||
import org.folio.domain.dto.Location; | ||
import org.folio.support.CqlQuery; | ||
import org.springframework.stereotype.Service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Log4j2 | ||
public class LocationServiceImpl implements org.folio.service.LocationService { | ||
|
||
private final LocationClient locationClient; | ||
|
||
@Override | ||
public Collection<Location> findLocations(CqlQuery query) { | ||
log.info("findLocations:: searching locations by query: {}", query); | ||
List<Location> locations = locationClient.getByQuery(query).getLocations(); | ||
log.info("findLocations:: found {} locations", locations::size); | ||
return locations; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/org/folio/service/impl/PickSlipsService.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,31 @@ | ||
package org.folio.service.impl; | ||
|
||
import static org.folio.domain.dto.ItemStatus.NameEnum.PAGED; | ||
import static org.folio.domain.dto.Request.RequestTypeEnum.PAGE; | ||
import static org.folio.domain.dto.Request.StatusEnum.OPEN_NOT_YET_FILLED; | ||
|
||
import java.util.EnumSet; | ||
|
||
import org.folio.service.ConsortiaService; | ||
import org.folio.service.ItemService; | ||
import org.folio.service.LocationService; | ||
import org.folio.service.RequestService; | ||
import org.folio.spring.service.SystemUserScopedExecutionService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import lombok.extern.log4j.Log4j2; | ||
|
||
@Service | ||
@Log4j2 | ||
public class PickSlipsService extends StaffSlipsServiceImpl { | ||
|
||
public PickSlipsService(@Autowired LocationService locationService, | ||
@Autowired ItemService itemService, @Autowired RequestService requestService, | ||
@Autowired ConsortiaService consortiaService, | ||
@Autowired SystemUserScopedExecutionService executionService) { | ||
|
||
super(EnumSet.of(PAGED), EnumSet.of(OPEN_NOT_YET_FILLED), EnumSet.of(PAGE), locationService, | ||
itemService, requestService, consortiaService, executionService); | ||
} | ||
} |
Oops, something went wrong.