Class ExchangeService

java.lang.Object
com.plannaplan.services.ExchangeService

@Service
public class ExchangeService
extends java.lang.Object
Service to manage Exchanges
  • Constructor Details

  • Method Details

    • save

      public Exchange save​(Exchange exchange)
      Parameters:
      exchange - Instance to save in database
      Returns:
      Exchange Instance contains database id
    • getById

      public java.util.Optional<Exchange> getById​(java.lang.Long id)
      Parameters:
      id - Id of exchange in database
      Returns:
      Optional Exchange if found
    • getAllExchanges

      public java.util.List<Exchange> getAllExchanges()
      Returns:
      list of all exchanges in database
    • getByUserId

      public java.util.List<Exchange> getByUserId​(java.lang.Long id)
      Parameters:
      id - Id of user
      Returns:
      List of exchanges that belong to user
    • deleteExchange

      public void deleteExchange​(Exchange entity)
      Parameters:
      entity - Exchange entity which we would like to delete
    • checkForExchange

      public java.util.Optional<Exchange> checkForExchange​(Assignment assignment, Groups group)
      Parameters:
      assignment - Assignment to trade for
      group - 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

      public java.util.List<MatchData> getMatches()
      Returns:
      list of matches found in database