Package com.plannaplan.services
Class ExchangeService
java.lang.Object
com.plannaplan.services.ExchangeService
@Service
public class ExchangeService
extends java.lang.Object
Service to manage Exchanges
-
Constructor Summary
Constructors Constructor Description ExchangeService()
-
Method Summary
Modifier and Type Method Description java.util.Optional<Exchange>
checkForExchange(Assignment assignment, Groups group)
void
deleteExchange(Exchange entity)
java.util.List<Exchange>
getAllExchanges()
java.util.Optional<Exchange>
getById(java.lang.Long id)
java.util.List<Exchange>
getByUserId(java.lang.Long id)
java.util.List<MatchData>
getMatches()
void
performExchange()
method to perform Exchange algorythm.Exchange
save(Exchange exchange)
-
Constructor Details
-
ExchangeService
public ExchangeService()
-
-
Method Details
-
save
- Parameters:
exchange
- Instance to save in database- Returns:
- Exchange Instance contains database id
-
getById
- Parameters:
id
- Id of exchange in database- Returns:
- Optional Exchange if found
-
getAllExchanges
- Returns:
- list of all exchanges in database
-
getByUserId
- Parameters:
id
- Id of user- Returns:
- List of exchanges that belong to user
-
deleteExchange
- Parameters:
entity
- Exchange entity which we would like to delete
-
checkForExchange
- Parameters:
assignment
- Assignment to trade forgroup
- Desired group- Returns:
- Optional with Exchange if exist
-
performExchange
public void performExchange()method to perform Exchange algorythm. It search for matches and swap assignments between latests user commisions if it can be performed. After swap we block users matches that contains switched groups. After algorythm email is being sent to all users with information about performed exchanges -
getMatches
- Returns:
- list of matches found in database
-