-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:folio-org/mod-orders into EUREKA-…
…561-5
- Loading branch information
Showing
26 changed files
with
1,546 additions
and
281 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,39 @@ | ||
#%RAML 1.0 | ||
title: Claim | ||
baseUri: https://github.com/folio-org/mod-orders | ||
version: v1 | ||
protocols: [ HTTP, HTTPS ] | ||
|
||
documentation: | ||
- title: Pieces Business Logic API | ||
content: <b>API for claiming pieces</b> | ||
|
||
types: | ||
claiming-collection: !include acq-models/mod-orders/schemas/claimingCollection.json | ||
claiming-results: !include acq-models/mod-orders/schemas/claimingResults.json | ||
errors: !include raml-util/schemas/errors.schema | ||
UUID: | ||
type: string | ||
pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$ | ||
|
||
traits: | ||
validate: !include raml-util/traits/validation.raml | ||
|
||
resourceTypes: | ||
post-with-200: !include rtypes/post-json-200.raml | ||
|
||
/pieces/claim: | ||
displayName: Claim pieces | ||
description: | | ||
Claim pieces. The endpoint is used to: | ||
- Claims pieces grouped by organizations | ||
- Triggers jobs in mod-data-export per each organization that contains an integration detail | ||
type: | ||
post-with-200: | ||
requestSchema: claiming-collection | ||
responseSchema: claiming-results | ||
requestExample: !include acq-models/mod-orders/examples/claimingCollection.sample | ||
responseExample: !include acq-models/mod-orders/examples/claimingResults.sample | ||
is: [validate] | ||
post: | ||
description: Claim pieces |
17 changes: 17 additions & 0 deletions
17
src/main/java/org/folio/models/claiming/ClaimingError.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,17 @@ | ||
package org.folio.models.claiming; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ClaimingError { | ||
CANNOT_SEND_CLAIMS_PIECE_IDS_ARE_EMPTY("Cannot send claims, piece ids are empty"), | ||
CANNOT_FIND_PIECES_WITH_LATE_STATUS_TO_PROCESS("Cannot find pieces with LATE status to process"), | ||
CANNOT_RETRIEVE_CONFIG_ENTRIES("Cannot retrieve config entries"), | ||
CANNOT_GROUP_PIECES_BY_VENDOR_MESSAGE("Cannot group pieces by vendor"), | ||
CANNOT_CREATE_JOBS_AND_UPDATE_PIECES("Cannot create jobs and update pieces"), | ||
CANNOT_FIND_A_PIECE_BY_ID("Cannot find a piece by '%s' id"); | ||
|
||
private final String value; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/org/folio/models/claiming/IntegrationDetailField.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,14 @@ | ||
package org.folio.models.claiming; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum IntegrationDetailField { | ||
EXPORT_TYPE_SPECIFIC_PARAMETERS("exportTypeSpecificParameters"), | ||
VENDOR_EDI_ORDERS_EXPORT_CONFIG("vendorEdiOrdersExportConfig"), | ||
CLAIM_PIECE_IDS("claimPieceIds"); | ||
|
||
private final String value; | ||
} |
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
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.rest.impl; | ||
|
||
import io.vertx.core.AsyncResult; | ||
import io.vertx.core.Context; | ||
import io.vertx.core.Future; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.Vertx; | ||
import org.folio.rest.annotations.Validate; | ||
import org.folio.rest.core.models.RequestContext; | ||
import org.folio.rest.jaxrs.model.ClaimingCollection; | ||
import org.folio.rest.jaxrs.resource.PiecesClaim; | ||
import org.folio.service.pieces.PiecesClaimingService; | ||
import org.folio.spring.SpringContextUtil; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import javax.ws.rs.core.Response; | ||
import java.util.Map; | ||
|
||
import static org.folio.orders.utils.ResourcePathResolver.PIECES_CLAIMING_BUSINESS; | ||
import static org.folio.orders.utils.ResourcePathResolver.resourceByIdPath; | ||
import static org.folio.rest.RestConstants.OKAPI_URL; | ||
|
||
public class PiecesClaimingApi extends BaseApi implements PiecesClaim { | ||
|
||
@Autowired | ||
private PiecesClaimingService pieceClaimingService; | ||
|
||
public PiecesClaimingApi() { | ||
SpringContextUtil.autowireDependencies(this, Vertx.currentContext()); | ||
} | ||
|
||
@Override | ||
@Validate | ||
public void postPiecesClaim(ClaimingCollection claimingCollection, Map<String, String> okapiHeaders, | ||
Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) { | ||
var requestContext = new RequestContext(vertxContext, okapiHeaders); | ||
pieceClaimingService.sendClaims(claimingCollection, requestContext) | ||
.onSuccess(claimingResults -> { | ||
var okapiUrl = okapiHeaders.get(OKAPI_URL); | ||
var url = resourceByIdPath(PIECES_CLAIMING_BUSINESS); | ||
var response = buildResponseWithLocation(okapiUrl, url, claimingResults); | ||
asyncResultHandler.handle(Future.succeededFuture(response)); | ||
}) | ||
.onFailure(t -> handleErrorResponse(asyncResultHandler, t)); | ||
} | ||
} |
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
Oops, something went wrong.