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 Details

    • categoryDAO

      private final CategoryDAO categoryDAO
      The instance of categoryDAO that will be used to perform actions to the DB
  • Constructor Details

    • CategoryRepositoryImpl

      @Autowired public CategoryRepositoryImpl(CategoryDAO categoryDAO)
  • Method Details

    • add

      public void add(Category category)
      Inserts an instance of Category in the database
      Parameters:
      category - an instance of Category
    • addAll

      public void addAll(List<Category> categoryList)
      Inserts a list of categories in the database
      Parameters:
      categoryList - a list of categories
    • get

      public Category get(int id) throws NotFoundException
      Finds the category identified by id in the database
      Specified by:
      get in interface CategoryRepository
      Specified by:
      get in interface CategoryRepositoryReadOnly
      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

      public Iterable<Category> getAll()
      Returns all categories in the database.
      Specified by:
      getAll in interface CategoryRepository
      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

      public void modify(Category category)
      Updates a category in the database using a new instance of Category.
      Parameters:
      category - the new instance of Category