use of org.folio.rest.jaxrs.model.Alert 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.Alert in project mod-orders by folio-org.
the class PurchaseOrderLineHelper method createAlerts.
private CompletableFuture<Void> createAlerts(CompositePoLine compPOL, JsonObject line, RequestContext requestContext) {
List<CompletableFuture<String>> futures = new ArrayList<>();
List<Alert> alerts = compPOL.getAlerts();
if (null != alerts) {
RequestEntry rqEntry = new RequestEntry(resourcesPath(ALERTS));
alerts.forEach(alertObject -> {
futures.add(restClient.post(rqEntry, alertObject, requestContext, Alert.class).thenApply(Alert::getId));
});
}
return collectResultsOnSuccess(futures).thenAccept(ids -> line.put(ALERTS, ids)).exceptionally(t -> {
logger.error("failed to create Alerts", t);
throw new CompletionException(t.getCause());
});
}
use of org.folio.rest.jaxrs.model.Alert 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