Advertisement
Guest User

Untitled

a guest
Feb 27th, 2014
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 2.00 KB | None | 0 0
  1.         val currentTime = System.currentTimeMillis()
  2.  
  3.         // generate voyage waypoints from voyage proposal waypoints
  4.         val voyageWaypoints = vp.waypoints.map { wp =>
  5.           val key = VoyageWaypoint.Key(wp.key.voyage_id, wp.key.step)
  6.           VoyageWaypoint(
  7.               key, wp.location, VoyageWaypointState.NotReached, wp.est_arrival_time, None, None, None, None,
  8.               wp.distance, wp.duration, wp.accum_distance, wp.accum_duration, wp.br_ids, wp.br_actions,
  9.               wp.br_actions.map {
  10.                 case WaypointAction.NoneCancelled => WaypointActionTaken.NoneCancelled
  11.                 case _                            => WaypointActionTaken.NoneYet
  12.               }
  13.             )
  14.         }
  15.  
  16.         bookingRequestDao.findBookingRequestsByIds(vp.booking_request_ids.toSet)(simpleDbOps).map { bookingRequests =>
  17.           val voyagePassengers: List[VoyagePassenger] = vp.booking_request_ids.map { bookingId =>
  18.             VoyagePassenger(
  19.               VoyagePassenger.Key(vp.voyage_id, bookingId),
  20.               PassengerState.NotCheckedIn, // TODO Sandro: is this correct?
  21.               bookingRequests.find(_.booking_id == bookingId).fold(0) {
  22.                 br => br.cab_parameters.fold(0)(cab => cab.pax)
  23.               }, 0, None, 0, 0, false
  24.             )
  25.           }
  26.  
  27.           val voyage = Voyage(
  28.             vp.id, vp.cab_id, reply.reply_time, currentTime, vp.voyage_sharing_factor, vp.voyage_sharing_value,
  29.             vp.total_distance, vp.total_duration, 0, Option(currentTime), None, VoyageState.OnVoyageMoving,
  30.             vp.ticket_string, vp.ticket_colour, vp.est_meter_fare, vp.fare, vp.booking_request_ids, 0,
  31.             None, voyageWaypoints, voyagePassengers
  32.           )
  33.           voyageDao.insertVoyage(voyage)(simpleDbOps).onFailure { case error: Throwable =>
  34.             val errMsg = s"Failed to insert Voyage into Voyage table after receiving an Accepted voyage proposal response."
  35.             Logger.error(errMsg, error)
  36.           }(simpleCpuOps)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement