Search in sources :

Example 1 with ReportingCode

use of org.folio.rest.jaxrs.model.ReportingCode in project mod-orders by folio-org.

the class HelperUtils method convertToPoLine.

public static PoLine convertToPoLine(CompositePoLine compPoLine) {
    JsonObject pol = JsonObject.mapFrom(compPoLine);
    pol.remove(ALERTS);
    pol.remove(REPORTING_CODES);
    PoLine poLine = pol.mapTo(PoLine.class);
    poLine.setAlerts(compPoLine.getAlerts().stream().map(Alert::getId).collect(toList()));
    poLine.setReportingCodes(compPoLine.getReportingCodes().stream().map(ReportingCode::getId).collect(toList()));
    return poLine;
}
Also used : PoLine(org.folio.rest.jaxrs.model.PoLine) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) JsonObject(io.vertx.core.json.JsonObject) Alert(org.folio.rest.jaxrs.model.Alert) ReportingCode(org.folio.rest.jaxrs.model.ReportingCode)

Example 2 with ReportingCode

use of org.folio.rest.jaxrs.model.ReportingCode in project mod-orders by folio-org.

the class PurchaseOrderLineHelper method createReportingCodes.

private CompletableFuture<Void> createReportingCodes(CompositePoLine compPOL, JsonObject line, RequestContext requestContext) {
    List<CompletableFuture<String>> futures = new ArrayList<>();
    List<ReportingCode> reportingCodes = compPOL.getReportingCodes();
    if (null != reportingCodes) {
        RequestEntry rqEntry = new RequestEntry(resourcesPath(REPORTING_CODES));
        reportingCodes.forEach(reportingObject -> {
            futures.add(restClient.post(rqEntry, reportingObject, requestContext, ReportingCode.class).thenApply(ReportingCode::getId));
        });
    }
    return collectResultsOnSuccess(futures).thenAccept(reportingIds -> line.put(REPORTING_CODES, reportingIds)).exceptionally(t -> {
        logger.error("failed to create Reporting Codes", t);
        throw new CompletionException(t.getCause());
    });
}
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) CompletionException(java.util.concurrent.CompletionException) ArrayList(java.util.ArrayList) RequestEntry(org.folio.rest.core.models.RequestEntry) ReportingCode(org.folio.rest.jaxrs.model.ReportingCode)

Example 3 with ReportingCode

use of org.folio.rest.jaxrs.model.ReportingCode in project mod-orders by folio-org.

the class OpenCompositeOrderManager method convertToPoLine.

public PoLine convertToPoLine(CompositePoLine compPoLine) {
    JsonObject pol = JsonObject.mapFrom(compPoLine);
    pol.remove(ALERTS);
    pol.remove(REPORTING_CODES);
    PoLine poLine = pol.mapTo(PoLine.class);
    poLine.setAlerts(compPoLine.getAlerts().stream().map(Alert::getId).collect(toList()));
    poLine.setReportingCodes(compPoLine.getReportingCodes().stream().map(ReportingCode::getId).collect(toList()));
    return poLine;
}
Also used : PoLine(org.folio.rest.jaxrs.model.PoLine) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) JsonObject(io.vertx.core.json.JsonObject) Alert(org.folio.rest.jaxrs.model.Alert) ReportingCode(org.folio.rest.jaxrs.model.ReportingCode)

Aggregations

JsonObject (io.vertx.core.json.JsonObject)3 Alert (org.folio.rest.jaxrs.model.Alert)3 CompositePoLine (org.folio.rest.jaxrs.model.CompositePoLine)3 PoLine (org.folio.rest.jaxrs.model.PoLine)3 ReportingCode (org.folio.rest.jaxrs.model.ReportingCode)3 HttpMethod (io.vertx.core.http.HttpMethod)1 JsonArray (io.vertx.core.json.JsonArray)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