Search in sources :

Example 1 with PO_LINE_NUMBER

use of org.folio.orders.utils.ResourcePathResolver.PO_LINE_NUMBER in project mod-orders by folio-org.

the class PurchaseOrderLineHelper method createPoLine.

/**
 * Creates PO Line assuming its content is valid and all restriction checks have been already passed
 * @param compPoLine {@link CompositePoLine} to be created
 * @param compOrder associated {@link CompositePurchaseOrder} object
 * @return completable future which might hold {@link CompositePoLine} on success or an exception if any issue happens
 */
public CompletableFuture<CompositePoLine> createPoLine(CompositePoLine compPoLine, CompositePurchaseOrder compOrder, RequestContext requestContext) {
    // The id is required because sub-objects are being created first
    if (isEmpty(compPoLine.getId())) {
        compPoLine.setId(UUID.randomUUID().toString());
    }
    compPoLine.setPurchaseOrderId(compOrder.getId());
    updateEstimatedPrice(compPoLine);
    PoLineCommonUtil.updateLocationsQuantity(compPoLine.getLocations());
    JsonObject line = mapFrom(compPoLine);
    List<CompletableFuture<Void>> subObjFuts = new ArrayList<>();
    subObjFuts.add(createAlerts(compPoLine, line, requestContext));
    subObjFuts.add(createReportingCodes(compPoLine, line, requestContext));
    return allOf(subObjFuts.toArray(new CompletableFuture[0])).thenCompose(v -> generateLineNumber(compOrder, requestContext)).thenAccept(lineNumber -> line.put(PO_LINE_NUMBER, lineNumber)).thenCompose(v -> createPoLineSummary(compPoLine, line, requestContext));
}
Also used : OrderInvoiceRelationService(org.folio.service.orders.OrderInvoiceRelationService) EN(org.folio.rest.RestConstants.EN) URL_WITH_LANG_PARAM(org.folio.orders.utils.HelperUtils.URL_WITH_LANG_PARAM) StringUtils(org.apache.commons.lang3.StringUtils) PoLineCommonUtil(org.folio.orders.utils.PoLineCommonUtil) Matcher(java.util.regex.Matcher) HelperUtils.verifyProtectedFieldsChanged(org.folio.orders.utils.HelperUtils.verifyProtectedFieldsChanged) Map(java.util.Map) JsonObject(io.vertx.core.json.JsonObject) ORDER_CONFIG_MODULE_NAME(org.folio.orders.utils.HelperUtils.ORDER_CONFIG_MODULE_NAME) StringUtils.isEmpty(org.apache.commons.lang3.StringUtils.isEmpty) Errors(org.folio.rest.jaxrs.model.Errors) Alert(org.folio.rest.jaxrs.model.Alert) ErrorCodes(org.folio.rest.core.exceptions.ErrorCodes) ConfigurationEntriesService(org.folio.service.configuration.ConfigurationEntriesService) REPORTING_CODES(org.folio.orders.utils.ResourcePathResolver.REPORTING_CODES) OPEN(org.folio.rest.jaxrs.model.CompositePurchaseOrder.WorkflowStatus.OPEN) CompletionStage(java.util.concurrent.CompletionStage) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) Eresource(org.folio.rest.jaxrs.model.Eresource) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) HttpClientInterface(org.folio.rest.tools.client.interfaces.HttpClientInterface) PO_LINES_STORAGE(org.folio.orders.utils.ResourcePathResolver.PO_LINES_STORAGE) ExpenseClassValidationService(org.folio.service.finance.expenceclass.ExpenseClassValidationService) RestClient(org.folio.rest.core.RestClient) UPDATE(org.folio.orders.utils.ProtectedOperationType.UPDATE) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) FolioVertxCompletableFuture(org.folio.completablefuture.FolioVertxCompletableFuture) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) OrderFormat(org.folio.rest.jaxrs.model.CompositePoLine.OrderFormat) ResourcePathResolver.resourcesPath(org.folio.orders.utils.ResourcePathResolver.resourcesPath) SequenceNumbers(org.folio.rest.acq.model.SequenceNumbers) Physical(org.folio.rest.jaxrs.model.Physical) ALERTS(org.folio.orders.utils.ResourcePathResolver.ALERTS) PO_LINE_NUMBER(org.folio.orders.utils.ResourcePathResolver.PO_LINE_NUMBER) HelperUtils(org.folio.orders.utils.HelperUtils) RequestEntry(org.folio.rest.core.models.RequestEntry) PostResponseType(org.folio.rest.core.PostResponseType) HelperUtils.combineCqlExpressions(org.folio.orders.utils.HelperUtils.combineCqlExpressions) JsonArray(io.vertx.core.json.JsonArray) ResourcePathResolver.resourceByIdPath(org.folio.orders.utils.ResourcePathResolver.resourceByIdPath) PoLineCollection(org.folio.rest.jaxrs.model.PoLineCollection) OrderWorkflowType(org.folio.service.orders.OrderWorkflowType) EVENT_PAYLOAD(org.folio.helper.AbstractHelper.EVENT_PAYLOAD) Cost(org.folio.rest.jaxrs.model.Cost) JsonObject.mapFrom(io.vertx.core.json.JsonObject.mapFrom) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) PurchaseOrderStorageService(org.folio.service.orders.PurchaseOrderStorageService) PoNumberHelper.buildPoLineNumber(org.folio.helper.PoNumberHelper.buildPoLineNumber) HelperUtils.collectResultsOnSuccess(org.folio.orders.utils.HelperUtils.collectResultsOnSuccess) PoLine(org.folio.rest.jaxrs.model.PoLine) ProtectionService(org.folio.service.ProtectionService) CollectionUtils.isEqualCollection(org.apache.commons.collections4.CollectionUtils.isEqualCollection) LOCATION_CAN_NOT_BE_MODIFIER_AFTER_OPEN(org.folio.rest.core.exceptions.ErrorCodes.LOCATION_CAN_NOT_BE_MODIFIER_AFTER_OPEN) HelperUtils.operateOnObject(org.folio.orders.utils.HelperUtils.operateOnObject) HelperUtils.deletePoLine(org.folio.orders.utils.HelperUtils.deletePoLine) Predicate(java.util.function.Predicate) CompletionException(java.util.concurrent.CompletionException) UUID(java.util.UUID) FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) ID(org.folio.helper.AbstractHelper.ID) List(java.util.List) CollectionUtils.isNotEmpty(org.apache.commons.collections4.CollectionUtils.isNotEmpty) Response(javax.ws.rs.core.Response) CompositePoLineValidationService(org.folio.service.orders.CompositePoLineValidationService) ReportingCode(org.folio.rest.jaxrs.model.ReportingCode) EncumbranceService(org.folio.service.finance.transaction.EncumbranceService) Optional(java.util.Optional) Parameter(org.folio.rest.jaxrs.model.Parameter) ORDER_ID(org.folio.helper.AbstractHelper.ORDER_ID) Pattern(java.util.regex.Pattern) AcquisitionsUnitsService(org.folio.service.AcquisitionsUnitsService) ProtectedOperationType(org.folio.orders.utils.ProtectedOperationType) HttpException(org.folio.rest.core.exceptions.HttpException) ProductId(org.folio.rest.jaxrs.model.ProductId) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) PENDING(org.folio.rest.jaxrs.model.CompositePurchaseOrder.WorkflowStatus.PENDING) POLineProtectedFieldsUtil(org.folio.orders.utils.POLineProtectedFieldsUtil) Title(org.folio.rest.jaxrs.model.Title) TitlesService(org.folio.service.titles.TitlesService) CompletableFuture.allOf(java.util.concurrent.CompletableFuture.allOf) CompositePurchaseOrder(org.folio.rest.jaxrs.model.CompositePurchaseOrder) RequestContext(org.folio.rest.core.models.RequestContext) HelperUtils.getPoLineLimit(org.folio.orders.utils.HelperUtils.getPoLineLimit) DELETE(org.folio.orders.utils.ProtectedOperationType.DELETE) EncumbranceWorkflowStrategyFactory(org.folio.service.finance.transaction.EncumbranceWorkflowStrategyFactory) InventoryManager(org.folio.service.inventory.InventoryManager) RestConstants(org.folio.rest.RestConstants) EncumbranceWorkflowStrategy(org.folio.service.finance.transaction.EncumbranceWorkflowStrategy) Iterator(java.util.Iterator) MessageAddress(org.folio.orders.events.handlers.MessageAddress) CLOSED(org.folio.rest.jaxrs.model.CompositePurchaseOrder.WorkflowStatus.CLOSED) Error(org.folio.rest.jaxrs.model.Error) Collectors.toList(java.util.stream.Collectors.toList) HelperUtils.calculateEstimatedPrice(org.folio.orders.utils.HelperUtils.calculateEstimatedPrice) HttpMethod(io.vertx.core.http.HttpMethod) PurchaseOrderLineService(org.folio.service.orders.PurchaseOrderLineService) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) FolioVertxCompletableFuture(org.folio.completablefuture.FolioVertxCompletableFuture) CompletableFuture(java.util.concurrent.CompletableFuture) ArrayList(java.util.ArrayList) JsonObject(io.vertx.core.json.JsonObject)

Aggregations

HttpMethod (io.vertx.core.http.HttpMethod)1 JsonArray (io.vertx.core.json.JsonArray)1 JsonObject (io.vertx.core.json.JsonObject)1 JsonObject.mapFrom (io.vertx.core.json.JsonObject.mapFrom)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletableFuture.allOf (java.util.concurrent.CompletableFuture.allOf)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 CompletionException (java.util.concurrent.CompletionException)1 CompletionStage (java.util.concurrent.CompletionStage)1 Predicate (java.util.function.Predicate)1 Matcher (java.util.regex.Matcher)1