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)));
}
Aggregations