Class ProductService

java.lang.Object
com.esprit.services.products.ProductService
All Implemented Interfaces:
IService<Product>

public class ProductService extends Object implements IService<Product>
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • connection

      private final Connection connection
  • Constructor Details

    • ProductService

      public ProductService()
      Performs ProductService operation.
  • Method Details

    • create

      public void create(Product product)
      Specified by:
      create in interface IService<Product>
    • createProductCategoryRelations

      private void createProductCategoryRelations(long productId, List<ProductCategory> categories) throws SQLException
      Throws:
      SQLException
    • read

      public List<Product> read()
      Specified by:
      read in interface IService<Product>
    • getCategoriesForProduct

      private List<ProductCategory> getCategoriesForProduct(Long productId)
    • sort

      public List<Product> sort(String sortBy)
      Performs sort operation.
      Returns:
      the result of the operation
    • update

      public void update(Product product)
      Specified by:
      update in interface IService<Product>
    • updateProductCategoryRelations

      private void updateProductCategoryRelations(Long productId, List<ProductCategory> categories) throws SQLException
      Throws:
      SQLException
    • delete

      public void delete(Product product)
      Specified by:
      delete in interface IService<Product>
    • getProductById

      public Product getProductById(Long productId)
      Retrieves the ProductById value.
      Returns:
      the ProductById value
    • checkAvailableStock

      public boolean checkAvailableStock(Long productId, int requestedQuantity)
      Performs checkAvailableStock operation.
      Returns:
      the result of the operation
    • getProductPrice

      public double getProductPrice(Long productId)
      Retrieves the ProductPrice value.
      Returns:
      the ProductPrice value
    • getProductsByCategory

      public List<Product> getProductsByCategory(Long categoryId)
      Retrieves the ProductsByCategory value.
      Returns:
      the ProductsByCategory value
    • getProductsOrderByQuantityAndStatus

      public List<Product> getProductsOrderByQuantityAndStatus()
      Retrieves the ProductsOrderByQuantityAndStatus value.
      Returns:
      the ProductsOrderByQuantityAndStatus value