Class CarpoolingServiceImpl
java.lang.Object
net.andresbustamante.yafoot.core.services.impl.CarpoolingServiceImpl
- All Implemented Interfaces:
CarpoolingService
-
Constructor Summary
ConstructorsConstructorDescriptionCarpoolingServiceImpl
(CarDao carDAO, MatchDao matchDAO, org.springframework.amqp.rabbit.core.RabbitTemplate rabbitTemplate) -
Method Summary
Modifier and TypeMethodDescriptionfindAvailableCarsByMatch
(Match match) Finds the list of cars available to carpool for a given match.void
processCarSeatRequest
(Match match, Player player, Car car, UserContext ctx) 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.void
processTransportationChange
(Match match, Car oldCar, Car newCar, UserContext ctx) If a player changes of transportation it updates the carpooling options for passengers previously confirmed.void
updateCarpoolingInformation
(Match match, Player player, Car car, boolean isCarConfirmed, UserContext ctx) Update the car used for a registration.
-
Constructor Details
-
CarpoolingServiceImpl
-
-
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 interfaceCarpoolingService
- 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 interfaceCarpoolingService
- Parameters:
match
- Match to updateplayer
- Player to updatecar
- Car to use for the registrationisCarConfirmed
- Indicates whether the user wants to accept and confirm a seat for carpoolctx
- 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 interfaceCarpoolingService
- Parameters:
match
- The match selected by the playerplayer
- Player asking for a seatcar
- Car selected by the playerctx
- 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 interfaceCarpoolingService
- Parameters:
match
- The match to processoldCar
- Car used for the existing registrationnewCar
- 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
-