Class CarpoolingServiceImpl

java.lang.Object
net.andresbustamante.yafoot.core.services.impl.CarpoolingServiceImpl
All Implemented Interfaces:
CarpoolingService

@Service public class CarpoolingServiceImpl extends Object implements CarpoolingService
  • Constructor Details

    • CarpoolingServiceImpl

      public CarpoolingServiceImpl(CarDao carDAO, MatchDao matchDAO, org.springframework.amqp.rabbit.core.RabbitTemplate rabbitTemplate)
  • Method Details

    • findAvailableCarsByMatch

      @Transactional(readOnly=true) public List<Car> findAvailableCarsByMatch(Match match) throws DatabaseException
      Description copied from interface: CarpoolingService
      Finds the list of cars available to carpool for a given match.
      Specified by:
      findAvailableCarsByMatch in interface CarpoolingService
      Parameters:
      match - Match to search
      Returns:
      The list of cars registered for the match
      Throws:
      DatabaseException
    • updateCarpoolingInformation

      @Transactional public void updateCarpoolingInformation(Match match, Player player, Car car, boolean isCarConfirmed, UserContext ctx) throws ApplicationException
      Description copied from interface: CarpoolingService
      Update the car used for a registration. If the user performing the action is the owner of the car, the car is confirmed for this match. Elsewhere, an exception is thrown.
      Specified by:
      updateCarpoolingInformation in interface CarpoolingService
      Parameters:
      match - Match to update
      player - Player to update
      car - Car to use for the registration
      isCarConfirmed - Indicates whether the user wants to accept and confirm a seat for carpool
      ctx - Context of the user performing this action
      Throws:
      ApplicationException - If the context does not belong to the owner of the car
    • processCarSeatRequest

      @Transactional(propagation=REQUIRED) public void processCarSeatRequest(Match match, Player player, Car car, UserContext ctx)
      Description copied from interface: CarpoolingService
      If the carpooling feature is enabled for the input match, it sends an email message asking for a place to the driver of the input car for this match.
      Specified by:
      processCarSeatRequest in interface CarpoolingService
      Parameters:
      match - The match selected by the player
      player - Player asking for a seat
      car - Car selected by the player
      ctx - Context of the user performing this action
    • processTransportationChange

      @Transactional(propagation=REQUIRED) public void processTransportationChange(Match match, Car oldCar, Car newCar, UserContext ctx) throws ApplicationException
      Description copied from interface: CarpoolingService
      If a player changes of transportation it updates the carpooling options for passengers previously confirmed. If a new car is chosen to assist to a match and it belongs to the same owner, it transfers the passengers already confirmed for the old car to the new one. If there is not enough seats, an exception is thrown to prevent the user from this problem. If a new car is chosen but it belongs to another player or no new car is chosen, it resets the existing confirmations and removes the car for passengers' registrations.
      Specified by:
      processTransportationChange in interface CarpoolingService
      Parameters:
      match - The match to process
      oldCar - Car used for the existing registration
      newCar - Car used for the transportation update. It can belong to another player.
      ctx - Context of the user performing this action
      Throws:
      ApplicationException - If a transfer of passengers is not possible from the old car to the new one