use of it.unibo.dronesecurity.userapplication.shipping.courier.entities.Order in project DroneSecurity by mirko-felice.
the class OrdersController method performDelivery.
@FXML
private void performDelivery() {
final Optional<Order> selectedOrder = this.getSelectedOrder();
selectedOrder.ifPresentOrElse(order -> {
// TODO how to check ???
if (order instanceof PlacedOrder) {
final JsonObject body = new JsonObject().put(OrderConstants.ORDER_KEY, order).put(OrderConstants.COURIER_KEY, UserHelper.getLoggedUser().getUsername());
VertxHelper.WEB_CLIENT.post(PORT, HOST, PERFORM_DELIVERY_URI).putHeader("Content-Type", "application/json").sendBuffer(body.toBuffer()).onSuccess(h -> Platform.runLater(() -> {
((Stage) this.performDeliveryButton.getScene().getWindow()).close();
final URL fileUrl = getClass().getResource(MONITORING_FILENAME);
final FXMLLoader fxmlLoader = new FXMLLoader(fileUrl);
FXHelper.initializeWindow(Modality.NONE, "Monitoring...", fxmlLoader).ifPresent(Stage::show);
}));
} else
AlertUtils.showErrorAlert("You can NOT deliver an order that isn't placed.");
}, NOT_SELECTED_RUNNABLE);
}
Aggregations