Search in sources :

Example 1 with Alert

use of org.folio.rest.acq.model.Alert in project mod-gobi by folio-org.

the class Mapper method mapPurchaseOrderLine.

private void mapPurchaseOrderLine(List<CompletableFuture<?>> futures, CompositePoLine pol, Document doc) {
    Optional.ofNullable(mappings.get(Mapping.Field.ALERTS)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> {
        Alert alert = new Alert();
        alert.setAlert((String) o);
        List<Alert> alerts = new ArrayList<>();
        alerts.add(alert);
        pol.setAlerts(alerts);
    }).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.CANCELLATION_RESTRICTION)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> pol.setCancellationRestriction((Boolean) o)).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.PO_LINE_ORDER_FORMAT)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> pol.setOrderFormat(CompositePoLine.OrderFormat.fromValue((String) o))).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.COLLECTION)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> pol.setCollection((Boolean) o)).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.PO_LINE_DESCRIPTION)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> pol.setPoLineDescription((String) o)).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.PO_LINE_PAYMENT_STATUS)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> pol.setPaymentStatus(CompositePoLine.PaymentStatus.fromValue((String) o))).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.PUBLICATION_DATE)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> pol.setPublicationDate((String) o)).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.PUBLISHER)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> pol.setPublisher((String) o)).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.PURCHASE_ORDER_ID)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> pol.setPurchaseOrderId((String) o)).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.RECEIPT_DATE)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> pol.setReceiptDate((Date) o)).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.RUSH)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> pol.setRush((Boolean) o)).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.TAGS)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> {
        Tags tags = new Tags();
        List<String> tagList = new ArrayList<>();
        tagList.add((String) o);
        tags.setTagList(tagList);
        pol.setTags(tags);
    }).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.PO_LINE_RECEIPT_STATUS)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> pol.setReceiptStatus(CompositePoLine.ReceiptStatus.fromValue((String) o))).exceptionally(Mapper::logException)));
}
Also used : Tags(org.folio.rest.acq.model.Tags) Date(java.util.Date) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Contributor(org.folio.rest.acq.model.Contributor) StringUtils(org.apache.commons.lang3.StringUtils) Ongoing(org.folio.rest.acq.model.Ongoing) Location(org.folio.rest.acq.model.Location) Document(org.w3c.dom.Document) Map(java.util.Map) Claim(org.folio.rest.acq.model.Claim) ReferenceNumberItem(org.folio.rest.acq.model.ReferenceNumberItem) JsonObject(io.vertx.core.json.JsonObject) ZoneOffset(java.time.ZoneOffset) BigDecimal(scala.math.BigDecimal) ReportingCode(org.folio.rest.acq.model.ReportingCode) ProductIdentifier(org.folio.rest.acq.model.ProductIdentifier) Details(org.folio.rest.acq.model.Details) AcquisitionMethod(org.folio.rest.acq.model.AcquisitionMethod) Eresource(org.folio.rest.acq.model.Eresource) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) Organization(org.folio.rest.acq.model.Organization) Optional(java.util.Optional) HelperUtils.extractFundCode(org.folio.gobi.HelperUtils.extractFundCode) VendorDetail(org.folio.rest.acq.model.VendorDetail) LocalDateTime(java.time.LocalDateTime) CompletableFuture(java.util.concurrent.CompletableFuture) CompositePurchaseOrder(org.folio.rest.acq.model.CompositePurchaseOrder) CompositePoLine(org.folio.rest.acq.model.CompositePoLine) ArrayList(java.util.ArrayList) Alert(org.folio.rest.acq.model.Alert) HelperUtils.extractExpenseClassFromFundCode(org.folio.gobi.HelperUtils.extractExpenseClassFromFundCode) License(org.folio.rest.acq.model.License) PostGobiOrdersHelper(org.folio.rest.impl.PostGobiOrdersHelper) NodeList(org.w3c.dom.NodeList) INVALID_ISBN_PRODUCT_ID_TYPE(org.folio.gobi.HelperUtils.INVALID_ISBN_PRODUCT_ID_TYPE) DateTime(org.joda.time.DateTime) DiscountType(org.folio.rest.acq.model.Cost.DiscountType) Consumer(java.util.function.Consumer) IsbnUtil(org.folio.isbn.IsbnUtil) FundDistribution(org.folio.rest.acq.model.FundDistribution) Mapping(org.folio.rest.mappings.model.Mapping) Physical(org.folio.rest.acq.model.Physical) FUND_CODE_EXPENSE_CLASS_SEPARATOR(org.folio.gobi.HelperUtils.FUND_CODE_EXPENSE_CLASS_SEPARATOR) Cost(org.folio.rest.acq.model.Cost) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) Alert(org.folio.rest.acq.model.Alert) List(java.util.List) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) Tags(org.folio.rest.acq.model.Tags)

Aggregations

JsonObject (io.vertx.core.json.JsonObject)1 LocalDateTime (java.time.LocalDateTime)1 ZoneOffset (java.time.ZoneOffset)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletableFuture.completedFuture (java.util.concurrent.CompletableFuture.completedFuture)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 StringUtils (org.apache.commons.lang3.StringUtils)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 FUND_CODE_EXPENSE_CLASS_SEPARATOR (org.folio.gobi.HelperUtils.FUND_CODE_EXPENSE_CLASS_SEPARATOR)1 INVALID_ISBN_PRODUCT_ID_TYPE (org.folio.gobi.HelperUtils.INVALID_ISBN_PRODUCT_ID_TYPE)1 HelperUtils.extractExpenseClassFromFundCode (org.folio.gobi.HelperUtils.extractExpenseClassFromFundCode)1