use of org.folio.rest.acq.model.Tags 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)));
}
use of org.folio.rest.acq.model.Tags in project mod-gobi by folio-org.
the class Mapper method mapCompositePOLine.
private CompletableFuture<CompositePurchaseOrder> mapCompositePOLine(Document doc, CompositePurchaseOrder compPO, PostGobiOrdersHelper postGobiOrdersHelper) {
CompletableFuture<CompositePurchaseOrder> future = new CompletableFuture<>();
Details detail = new Details();
Cost cost = new Cost();
Location location = new Location();
Eresource eresource = new Eresource();
FundDistribution fundDistribution = new FundDistribution();
VendorDetail vendorDetail = new VendorDetail();
Claim claim = new Claim();
Physical physical = new Physical();
Contributor contributor = new Contributor();
ReportingCode reportingCode = new ReportingCode();
License license = new License();
Tags tags = new Tags();
AcquisitionMethod acquisitionMethod = new AcquisitionMethod();
List<CompletableFuture<?>> futures = new ArrayList<>();
mapCost(futures, cost, doc);
mapDetail(futures, detail, doc, postGobiOrdersHelper);
mapFundDistribution(futures, fundDistribution, doc, postGobiOrdersHelper);
mapLocation(futures, location, doc);
mapVendorDetail(futures, vendorDetail, doc);
mapClaims(futures, claim, doc);
mapContributor(futures, contributor, doc);
mapReportingCodes(futures, reportingCode, doc);
mapVendorDependentFields(futures, eresource, physical, compPO, claim, doc);
mapLicense(futures, license, doc);
mapTags(futures, tags, doc);
mapAcquisitionMethod(futures, acquisitionMethod, doc, postGobiOrdersHelper);
CompositePoLine pol = compPO.getCompositePoLines().get(0);
if (pol.getOrderFormat().equals(CompositePoLine.OrderFormat.ELECTRONIC_RESOURCE)) {
mapEresource(futures, eresource, doc);
} else {
mapPhysical(futures, physical, doc);
}
CompletableFuture.allOf(futures.toArray(new CompletableFuture<?>[0])).thenAccept(v -> {
compPO.setTotalItems(location.getQuantity());
setObjectIfPresent(detail, o -> pol.setDetails((Details) o));
setObjectIfPresent(cost, o -> pol.setCost((Cost) o));
setObjectIfPresent(license, o -> eresource.setLicense((License) o));
if (pol.getOrderFormat().equals(CompositePoLine.OrderFormat.ELECTRONIC_RESOURCE)) {
setObjectIfPresent(eresource, o -> pol.setEresource((Eresource) o));
} else {
setObjectIfPresent(physical, o -> pol.setPhysical((Physical) o));
}
setObjectIfPresent(vendorDetail, o -> pol.setVendorDetail((VendorDetail) o));
setObjectIfPresent(location, o -> {
List<Location> locations = new ArrayList<>();
locations.add(location);
pol.setLocations(locations);
});
setObjectIfPresent(contributor, o -> {
List<Contributor> contributors = new ArrayList<>();
contributors.add(contributor);
pol.setContributors(contributors);
});
setObjectIfPresent(reportingCode, o -> {
List<ReportingCode> reportingCodes = new ArrayList<>();
reportingCodes.add(reportingCode);
pol.setReportingCodes(reportingCodes);
});
setObjectIfPresent(claim, o -> {
List<Claim> claims = new ArrayList<>();
claims.add(claim);
pol.setClaims(claims);
});
setObjectIfPresent(fundDistribution, o -> {
if (StringUtils.isNotEmpty(fundDistribution.getFundId())) {
pol.setFundDistribution(Collections.singletonList(fundDistribution));
}
});
setObjectIfPresent(tags, o -> pol.setTags(tags));
setObjectIfPresent(acquisitionMethod, o -> pol.setAcquisitionMethod(acquisitionMethod.getId()));
future.complete(compPO);
}).exceptionally(t -> {
logger.error("Exception creating Composite PO", t);
future.completeExceptionally(t);
return null;
});
return future;
}
Aggregations