Class TeamPlayerModel

java.lang.Object
cat.proven.teamplayer.model.TeamPlayerModel

public class TeamPlayerModel extends Object
Author:
Jordi and David
  • Constructor Details

    • TeamPlayerModel

      public TeamPlayerModel()
      Constructor initialize DAO interfaces
  • Method Details

    • findAllTeams

      public List<Team> findAllTeams()
      Retrieves a list of all teams from data source.
      Returns:
      list of all teams or null if there aren't teams
    • findTeamById

      public Team findTeamById(long id)
      Retrieves the team given id
      Parameters:
      id - the id to search a specific team
      Returns:
      the team with the given id or null in case of error
    • findTeamByName

      public Team findTeamByName(String name) throws ParameterNull
      Retrieves the team given name
      Parameters:
      name - the name to search a specific team
      Returns:
      the team with the given name or null in case not found
      Throws:
      ParameterNull - if the given name is NULL a exception will be throw
    • findTeamsByCategory

      public List<Team> findTeamsByCategory(String category) throws ParameterNull
      Retrieves a list with given category
      Parameters:
      category - the categoy to search teams
      Returns:
      a list of teams given a category, null list in case not found
      Throws:
      ParameterNull - if given category is NULL a exception will be throw
    • addTeam

      public int addTeam(Team team) throws DuplicateExeception, ParameterNull
      Adds a team to the data source. It prevents null objects, teams with null name and duplicates
      Parameters:
      team - the team to add
      Returns:
      1 if successfully added, or -1 otherwise
      Throws:
      DuplicateExeception - if team name already exists a exception will be throw
      ParameterNull - if parameter given is null
    • modifyTeam

      public int modifyTeam(Team team) throws ParameterNull
      Modifies a team given a Team
      Parameters:
      team - the team to modify
      Returns:
      1 if successfully modified or -1 in case of error
      Throws:
      ParameterNull - if team given is null a exception will be throw
    • removeTeam

      public int removeTeam(Team team) throws ParameterNull
      Removes a team given Team
      Parameters:
      team - the team to remove
      Returns:
      1 if successfully removed or -1 in case of error
      Throws:
      ParameterNull - if team given is null a exception will be throw
    • findPlayerById

      public Player findPlayerById(long id)
      Retrieves a single player given a id
      Parameters:
      id - is the id of the player to search.
      Returns:
      a player if exits or null in case not found
    • findPlayerByFullName

      public Player findPlayerByFullName(String fullname) throws ParameterNull
      Retrieves a single player given a fullname
      Parameters:
      fullname - is the full name of the player to search
      Returns:
      a list of players with the given full name
      Throws:
      ParameterNull - if fullname given is null a exception will be throw
    • findPlayersByTeam

      public List<Player> findPlayersByTeam(Team team) throws ParameterNull
      Retrieves a list of player that belongs to the given team
      Parameters:
      team - is the team of the players to search
      Returns:
      a list of players that belongs to the given team or null in case not found
      Throws:
      ParameterNull - if team given is null a exception will be throw
    • addPlayer

      public int addPlayer(Player player) throws DuplicateExeception, ParameterNull
      Adds a player given a Player
      Parameters:
      player - is the player to add
      Returns:
      1 if successfully added or -1 otherwise
      Throws:
      DuplicateExeception - if team name given is null or if player already exists in data source a exception will be throw
      ParameterNull - if player given is null a exception will be throw
    • modifyPlayer

      public int modifyPlayer(Player player) throws ParameterNull
      Modifies a player given Player
      Parameters:
      player - is the player to modify
      Returns:
      1 if successfully modified or -1 otherwise
      Throws:
      ParameterNull - if team name given is null a exception will be throw
    • enrolPlayerToTeam

      public int enrolPlayerToTeam(Team team, Player player) throws ParameterNull, AlreadyEnrolled
      Enrols a player given to the team given
      Parameters:
      team - is the team to join the player introduced
      player - is the player that will join to the team introduced
      Returns:
      1 if the player is enrolled in the team or -1 otherwise
      Throws:
      ParameterNull - if team or player given are null
      AlreadyEnrolled - if player is already enrolled a exception will be throw
    • unenrolPlayerToTeam

      public int unenrolPlayerToTeam(Team team, Player player) throws ParameterNull
      Unenrols a player given to the team given
      Parameters:
      team - is the team to unenrol the player introduced
      player - is the player that will unenrol the team introduced
      Returns:
      1 if the player is unenrolled of the team or -1 otherwise
      Throws:
      ParameterNull - if team or player given are null a exception will be throw