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