Package cat.proven.teamplayer.model
Class TeamPlayerModel
java.lang.Object
cat.proven.teamplayer.model.TeamPlayerModel
- Author:
- Jordi and David
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Adds a player given a Playerint
Adds a team to the data source.int
enrolPlayerToTeam(Team team, Player player)
Enrols a player given to the team givenRetrieves a list of all teams from data source.findPlayerByFullName(String fullname)
Retrieves a single player given a fullnamefindPlayerById(long id)
Retrieves a single player given a idfindPlayersByTeam(Team team)
Retrieves a list of player that belongs to the given teamfindTeamById(long id)
Retrieves the team given idfindTeamByName(String name)
Retrieves the team given namefindTeamsByCategory(String category)
Retrieves a list with given categoryint
modifyPlayer(Player player)
Modifies a player given Playerint
modifyTeam(Team team)
Modifies a team given a Teamint
removeTeam(Team team)
Removes a team given Teamint
unenrolPlayerToTeam(Team team, Player player)
Unenrols a player given to the team given
-
Constructor Details
-
TeamPlayerModel
public TeamPlayerModel()Constructor initialize DAO interfaces
-
-
Method Details
-
findAllTeams
Retrieves a list of all teams from data source.- Returns:
- list of all teams or null if there aren't teams
-
findTeamById
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
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
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
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 throwParameterNull
- if parameter given is null
-
modifyTeam
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
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
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
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
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
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 throwParameterNull
- if player given is null a exception will be throw
-
modifyPlayer
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
Enrols a player given to the team given- Parameters:
team
- is the team to join the player introducedplayer
- 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 nullAlreadyEnrolled
- if player is already enrolled a exception will be throw
-
unenrolPlayerToTeam
Unenrols a player given to the team given- Parameters:
team
- is the team to unenrol the player introducedplayer
- 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
-