Class UserRepositoryImpl
java.lang.Object
it.unimib.unimibmodules.repository.UserRepositoryImpl
- All Implemented Interfaces:
UserRepository,UserRepositoryReadOnly
@Component("userRepository")
public class UserRepositoryImpl
extends Object
implements UserRepository, UserRepositoryReadOnly
Repository for the User. Adds business logic to User instances before actually accessing
the database via DAO.
- Version:
- 0.4.1
- Author:
- Gianlorenzo Martini
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionInserts an instance of User in the databasevoidInserts a list of users in the databaseget(int id) Finds the user identified by id in the databasegetAll()Returns all users in the database.booleanTells if the user identified by compilationCode exists in the database.getByCodeEntity(String code) Finds the user identified by compilationCode in the databasegetByUsername(String username) Finds the user identified by username in the databasevoidUpdates a user in the database using a new instance of User.voidremove(int id) Deletes from the database the user identified by id.voidDeletes all users in the database.
-
Field Details
-
userDAO
The instance of UserDAO that will be used to perform actions to the DB
-
-
Constructor Details
-
UserRepositoryImpl
-
-
Method Details
-
add
Inserts an instance of User in the database- Specified by:
addin interfaceUserRepository- Parameters:
user- an instance of User- Returns:
- the saved entity
- See Also:
-
addAll
Inserts a list of users in the database- Parameters:
userList- a list of Users
-
get
Finds the user identified by id in the database- Specified by:
getin interfaceUserRepository- Specified by:
getin interfaceUserRepositoryReadOnly- Parameters:
id- the id of the user to be found- Returns:
- an instance of User if there is a user identified by id, null otherwise
- Throws:
NotFoundException- if no user identified by the id has been found- See Also:
-
getByCode
Tells if the user identified by compilationCode exists in the database.- Specified by:
getByCodein interfaceUserRepository- Parameters:
code- the code of the user to be found- Returns:
- an instance of User if there is a user identified by code, null otherwise
- Throws:
NotFoundException- if no user identified by the id has been found- See Also:
-
getByCodeEntity
Finds the user identified by compilationCode in the database- Specified by:
getByCodeEntityin interfaceUserRepository- Parameters:
code- the code of the user to be found- Returns:
- an instance of User if there is a user identified by code, null otherwise
- Throws:
NotFoundException- if no user identified by the id has been found- See Also:
-
getByUsername
Finds the user identified by username in the database- Specified by:
getByUsernamein interfaceUserRepository- Parameters:
username- the id of the user to be found- Returns:
- an instance of User if there is a user identified by id, null otherwise
- Throws:
NotFoundException- if no user identified by the id has been found- See Also:
-
getAll
Returns all users in the database.- Returns:
- a list of Users
-
remove
Deletes from the database the user identified by id.- Parameters:
id- the id of the user to be deleted- Throws:
NotFoundException- if no user identified by the id has been found
-
removeAll
public void removeAll()Deletes all users in the database. -
modify
Updates a user in the database using a new instance of User.- Parameters:
user- the new instance of User
-