Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val currentTime = System.currentTimeMillis()
- // generate voyage waypoints from voyage proposal waypoints
- val voyageWaypoints = vp.waypoints.map { wp =>
- val key = VoyageWaypoint.Key(wp.key.voyage_id, wp.key.step)
- VoyageWaypoint(
- key, wp.location, VoyageWaypointState.NotReached, wp.est_arrival_time, None, None, None, None,
- wp.distance, wp.duration, wp.accum_distance, wp.accum_duration, wp.br_ids, wp.br_actions,
- wp.br_actions.map {
- case WaypointAction.NoneCancelled => WaypointActionTaken.NoneCancelled
- case _ => WaypointActionTaken.NoneYet
- }
- )
- }
- bookingRequestDao.findBookingRequestsByIds(vp.booking_request_ids.toSet)(simpleDbOps).map { bookingRequests =>
- val voyagePassengers: List[VoyagePassenger] = vp.booking_request_ids.map { bookingId =>
- VoyagePassenger(
- VoyagePassenger.Key(vp.voyage_id, bookingId),
- PassengerState.NotCheckedIn, // TODO Sandro: is this correct?
- bookingRequests.find(_.booking_id == bookingId).fold(0) {
- br => br.cab_parameters.fold(0)(cab => cab.pax)
- }, 0, None, 0, 0, false
- )
- }
- val voyage = Voyage(
- vp.id, vp.cab_id, reply.reply_time, currentTime, vp.voyage_sharing_factor, vp.voyage_sharing_value,
- vp.total_distance, vp.total_duration, 0, Option(currentTime), None, VoyageState.OnVoyageMoving,
- vp.ticket_string, vp.ticket_colour, vp.est_meter_fare, vp.fare, vp.booking_request_ids, 0,
- None, voyageWaypoints, voyagePassengers
- )
- voyageDao.insertVoyage(voyage)(simpleDbOps).onFailure { case error: Throwable =>
- val errMsg = s"Failed to insert Voyage into Voyage table after receiving an Accepted voyage proposal response."
- Logger.error(errMsg, error)
- }(simpleCpuOps)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement