Search in sources :

Example 1 with ProductIdentifier

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

the class Mapper method mapDetail.

private void mapDetail(List<CompletableFuture<?>> futures, Details detail, Document doc, PostGobiOrdersHelper postGobiOrdersHelper) {
    // Adding a new entry to product id only if the product ID and product id
    // type are present
    // as both of them are together are mandatory to create an inventory
    // instance
    Optional.ofNullable(mappings.get(Mapping.Field.PRODUCT_ID)).ifPresent(field -> futures.add(field.resolve(doc).thenCompose(o -> {
        ProductIdentifier productId = new ProductIdentifier();
        productId.setProductId(o.toString());
        return Optional.ofNullable(mappings.get(Mapping.Field.PRODUCT_ID_TYPE)).map(prodIdType -> resolveProductIdType(prodIdType, doc, productId, postGobiOrdersHelper).thenAccept(typeId -> {
            productId.setProductIdType((String) typeId);
            Optional.ofNullable(mappings.get(Mapping.Field.PRODUCT_QUALIFIER)).ifPresent(qualifierField -> qualifierField.resolve(doc).thenAccept(qualifier -> productId.setQualifier((String) qualifier)));
            detail.setProductIds(Collections.singletonList(productId));
        }).exceptionally(Mapper::logException)).orElse(completedFuture(null));
    }).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.RECEIVING_NOTE)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> detail.setReceivingNote((String) o)).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.SUBSCRIPTION_FROM)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> detail.setSubscriptionFrom((Date) o)).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.SUBSCRIPTION_INTERVAL)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> detail.setSubscriptionInterval((Integer) o)).exceptionally(Mapper::logException)));
    Optional.ofNullable(mappings.get(Mapping.Field.SUBSCRIPTION_TO)).ifPresent(field -> futures.add(field.resolve(doc).thenAccept(o -> detail.setSubscriptionTo((Date) 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) ProductIdentifier(org.folio.rest.acq.model.ProductIdentifier)

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