-
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 (#1358)
* CIRC-1932 implement search-slips endpoint skeleton * CIRC-1932 fix code smells * CIRC-1932 merge slips ramls into one * CIRC-1932 fix raml issue * CIRC-1932 include review comments * CIRC-1932 rename schema example
- Loading branch information
1 parent
42738a1
commit 74cbf0f
Showing
12 changed files
with
277 additions
and
130 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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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,32 @@ | ||
#%RAML 1.0 | ||
title: Stuff Slips | ||
version: v0.3 | ||
protocols: [ HTTP, HTTPS ] | ||
baseUri: http://localhost:9130 | ||
|
||
documentation: | ||
- title: API for fetching current staff slips | ||
content: <b>API for staff slips generation</b> | ||
|
||
types: | ||
stuff-slips: !include staff-slips-response.json | ||
|
||
traits: | ||
language: !include raml-util/traits/language.raml | ||
|
||
resourceTypes: | ||
collection-get: !include raml-util/rtypes/collection-get.raml | ||
|
||
/circulation: | ||
/pick-slips: | ||
/{servicePointId}: | ||
type: | ||
collection-get: | ||
exampleCollection: !include examples/staff-slips-response.json | ||
schemaCollection: stuff-slips | ||
/search-slips: | ||
/{servicePointId}: | ||
type: | ||
collection-get: | ||
exampleCollection: !include examples/staff-slips-response.json | ||
schemaCollection: stuff-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
46 changes: 46 additions & 0 deletions
46
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,46 @@ | ||
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.util.concurrent.CompletableFuture; | ||
|
||
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 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.