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 CategoryDAOThe instance of categoryDAO that will be used to perform actions to the DB -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidInserts an instance of Category in the databasevoidInserts a list of categories in the databaseget(int id) Finds the category identified by id in the databasegetAll()Returns all categories in the database.voidUpdates a category in the database using a new instance of Category.voidremove(int id) Deletes from the database the category identified by id.voidDeletes 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:
getin interfaceCategoryRepository- Specified by:
getin 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:
getAllin 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
-