public ReservationView( Reservation reservation, ElementActionView deleteActionView, ElementActionView modifyActionView, ElementActionView copyActionView) { this.id = reservation.getId(); this.virtualResourceGroup = reservation.getVirtualResourceGroup().map(g -> g.getName()).orElse("-"); this.sourcePort = new PortView(reservation.getSourcePort()); this.destinationPort = new PortView(reservation.getDestinationPort()); // `<c:out>` strips newlines, so we have to manually HTML escape. this.failedReason = HtmlUtils.htmlEscape(reservation.formattedFailedReason(), "UTF-8"); this.cancelReason = HtmlUtils.htmlEscape(reservation.getCancelReason(), "UTF-8"); this.startDateTime = reservation.getStartDateTime(); this.endDateTime = reservation.getEndDateTime().orElse(null); this.bandwidth = reservation.getBandwidth(); this.userCreated = reservation.getUserCreated(); this.providerConnectionId = reservation.getProviderConnectionId(); this.creationDateTime = reservation.getCreationDateTime(); this.protectionType = reservation.getRequesterConnection().getProtectionType(); this.name = reservation.getName(); NsiRequesterConnection connection = reservation.getRequesterConnection(); this.requesterConnectionId = connection.getConnectionId(); this.ero = presentEro(connection); states = connection.getStates().toShortString(); reservationState = connection.getReservationState(); provisionState = connection.getProvisionState().orElse(null); lifecycleState = connection.getLifecycleState(); dataPlaneActive = connection.isDataPlaneActive(); this.deleteActionView = deleteActionView; this.modifyActionView = modifyActionView; this.copyActionView = copyActionView; }
private static List<String> presentEro(NsiRequesterConnection connection) { if (connection.getEro() == null) { return Collections.emptyList(); } return connection.getEro().stream().map(ero -> ero.getStp()).collect(Collectors.toList()); }