Class CategoryRepositoryImpl
java.lang.Object
it.unimib.unimibmodules.repository.CategoryRepositoryImpl
- All Implemented Interfaces:
CategoryRepository
,CategoryRepositoryReadOnly
@Component("categoryRepository")
public class CategoryRepositoryImpl
extends Object
implements CategoryRepository, CategoryRepositoryReadOnly
Repository for the Category class. Adds business logic to Category instances before
accessing the database via DAO.
- Version:
- 0.4.1
- Author:
- Lorenzo Occhipinti
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CategoryDAO
The instance of categoryDAO that will be used to perform actions to the DB -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Inserts an instance of Category in the databasevoid
Inserts a list of categories in the databaseget
(int id) Finds the category identified by id in the databasegetAll()
Returns all categories in the database.void
Updates a category in the database using a new instance of Category.void
remove
(int id) Deletes from the database the category identified by id.void
Deletes all categories in the database.
-
Field Details
-
categoryDAO
The instance of categoryDAO that will be used to perform actions to the DB
-
-
Constructor Details
-
CategoryRepositoryImpl
-
-
Method Details
-
add
Inserts an instance of Category in the database- Parameters:
category
- an instance of Category
-
addAll
Inserts a list of categories in the database- Parameters:
categoryList
- a list of categories
-
get
Finds the category identified by id in the database- Specified by:
get
in interfaceCategoryRepository
- Specified by:
get
in interfaceCategoryRepositoryReadOnly
- Parameters:
id
- the id of the category to be found- Returns:
- an instance of Category if there is a category identified by id, null otherwise
- Throws:
NotFoundException
- See Also:
-
getAll
Returns all categories in the database.- Specified by:
getAll
in interfaceCategoryRepository
- Returns:
- a list of Category
-
remove
public void remove(int id) Deletes from the database the category identified by id.- Parameters:
id
- the id of the category to be deleted
-
removeAll
public void removeAll()Deletes all categories in the database. -
modify
Updates a category in the database using a new instance of Category.- Parameters:
category
- the new instance of Category
-