-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CIRC-1932 implement search-slips endpoint skeleton
- Loading branch information
1 parent
14a61ce
commit 7a72191
Showing
9 changed files
with
276 additions
and
104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#%RAML 1.0 | ||
title: Pick Slips | ||
version: v0.3 | ||
protocols: [ HTTP, HTTPS ] | ||
baseUri: http://localhost:9130 | ||
|
||
documentation: | ||
- title: API for fetching current search slips | ||
content: <b>API for search slips generation</b> | ||
|
||
types: | ||
search-slips: !include pick-slips-response.json | ||
|
||
traits: | ||
language: !include raml-util/traits/language.raml | ||
|
||
resourceTypes: | ||
collection-get: !include raml-util/rtypes/collection-get.raml | ||
|
||
/circulation: | ||
/search-slips: | ||
/{servicePointId}: | ||
type: | ||
collection-get: | ||
exampleCollection: !include examples/pick-slips-response.json | ||
schemaCollection: search-slips |
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
50 changes: 50 additions & 0 deletions
50
src/main/java/org/folio/circulation/resources/SearchSlipsResource.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,50 @@ | ||
package org.folio.circulation.resources; | ||
|
||
import static org.folio.circulation.support.results.Result.ofAsync; | ||
import static org.folio.circulation.support.results.ResultBinding.flatMapResult; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.folio.circulation.domain.MultipleRecords; | ||
import org.folio.circulation.domain.Request; | ||
import org.folio.circulation.support.RouteRegistration; | ||
import org.folio.circulation.support.http.server.JsonHttpResponse; | ||
import org.folio.circulation.support.http.server.WebContext; | ||
import org.folio.circulation.support.results.Result; | ||
|
||
import io.vertx.core.http.HttpClient; | ||
import io.vertx.ext.web.Router; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
public class SearchSlipsResource extends SlipsResource { | ||
private static final Logger log = LogManager.getLogger(MethodHandles.lookup().lookupClass()); | ||
private static final String SEARCH_SLIPS_KEY = "searchSlips"; | ||
private final String rootPath; | ||
|
||
public SearchSlipsResource(String rootPath, HttpClient client) { | ||
super(client); | ||
this.rootPath = rootPath; | ||
} | ||
|
||
@Override | ||
public void register(Router router) { | ||
RouteRegistration routeRegistration = new RouteRegistration(rootPath, router); | ||
routeRegistration.getMany(this::getMany); | ||
} | ||
|
||
protected void getMany(RoutingContext routingContext) { | ||
final WebContext context = new WebContext(routingContext); | ||
|
||
fetchHoldRequests() | ||
.thenApply(flatMapResult(requests -> mapResultToJson(requests, SEARCH_SLIPS_KEY))) | ||
.thenApply(r -> r.map(JsonHttpResponse::ok)) | ||
.thenAccept(context::writeResultToHttpResponse); | ||
} | ||
|
||
private CompletableFuture<Result<MultipleRecords<Request>>> fetchHoldRequests() { | ||
return ofAsync(MultipleRecords.empty()); | ||
} | ||
} |
Oops, something went wrong.