Package com.masai.Dao

Class BuyerDaoImpl

java.lang.Object
com.masai.Dao.BuyerDaoImpl
All Implemented Interfaces:
BuyerDao

public class BuyerDaoImpl extends Object implements BuyerDao
  • Constructor Details

    • BuyerDaoImpl

      public BuyerDaoImpl()
  • Method Details

    • loginBuyer

      public Buyer loginBuyer(String username, String password)
      Login as a buyer.
      Specified by:
      loginBuyer in interface BuyerDao
      Parameters:
      username - The buyer's username.
      password - The buyer's password.
      Returns:
      The Buyer object representing the logged-in buyer.
      Throws:
      InvalidCredentialsException - If the username or password is invalid.
    • getBalance

      public double getBalance(String username)
      Retrieve buyer balance by username.
      Specified by:
      getBalance in interface BuyerDao
      Parameters:
      username - The username of the buyer.
      Returns:
      The balance of the buyer with the specified username.
    • getBuyerByUsername

      public Buyer getBuyerByUsername(String username)
      Retrieve buyer details by username.
      Specified by:
      getBuyerByUsername in interface BuyerDao
      Parameters:
      username - The username of the buyer.
      Returns:
      The Buyer object representing the buyer with the specified username.
    • registerNewBuyer

      public String registerNewBuyer(Buyer u)
      Register a new buyer.
      Specified by:
      registerNewBuyer in interface BuyerDao
      Parameters:
      buyer - The Buyer object containing the buyer's information.
      Returns:
      A message indicating the success or failure of the registration process.
    • updateBuyerDetails

      public String updateBuyerDetails(Buyer u)
      Update buyer details.
      Specified by:
      updateBuyerDetails in interface BuyerDao
      Parameters:
      buyer - The Buyer object containing the updated buyer's information.
      Returns:
      A message indicating the success or failure of the update process.
    • getAllProductForSell

      public ResultSet getAllProductForSell()
      Retrieve all products available for sale.
      Specified by:
      getAllProductForSell in interface BuyerDao
      Returns:
      A ResultSet containing information about all products available for sale.
      Throws:
      RecordNotFoundException - If no products for sale are found.
    • purchaseReturnItem

      public boolean purchaseReturnItem(int productId, int quantity)
      Purchase return items.
      Specified by:
      purchaseReturnItem in interface BuyerDao
      Parameters:
      productId - The ID of the product to return.
      quantity - The quantity to return.
      Returns:
      True if the return is successful, False otherwise.
    • purchaseItem

      public String purchaseItem(int productId, int quantity)
      Purchase an item.
      Specified by:
      purchaseItem in interface BuyerDao
      Parameters:
      productId - The ID of the product to purchase.
      quantity - The quantity to purchase.
      Returns:
      A message indicating the success or failure of the purchase process.
    • unhideTransactions

      public boolean unhideTransactions(String username)
      Unhide buyer transactions .
      Specified by:
      unhideTransactions in interface BuyerDao
      Parameters:
      username - The username of the buyer.
      Returns:
      True if the transactions are successfully unhidden, False otherwise.
    • hideTransactions

      public boolean hideTransactions(String username)
      Hide buyer transactions .
      Specified by:
      hideTransactions in interface BuyerDao
      Parameters:
      username - The username of the buyer.
      Returns:
      True if the transactions are successfully hidden, False otherwise.
    • viewAllTransactions

      public ResultSet viewAllTransactions()
      View all transactions.
      Specified by:
      viewAllTransactions in interface BuyerDao
      Returns:
      A ResultSet containing information about all transactions.
    • getAllProductsByCategory

      public ResultSet getAllProductsByCategory(String item)
      Retrieve all products by category.
      Specified by:
      getAllProductsByCategory in interface BuyerDao
      Parameters:
      category - The category of the products.
      Returns:
      A ResultSet containing information about all products in the specified category.
      Throws:
      RecordNotFoundException - If no products are found in the specified category.
    • getProductsByProductId

      public ResultSet getProductsByProductId(int id)
      Retrieve product by product ID.
      Specified by:
      getProductsByProductId in interface BuyerDao
      Parameters:
      id - The ID of the product.
      Returns:
      A ResultSet containing information about the product with the specified ID.
      Throws:
      RecordNotFoundException - If no product is found with the specified ID.
    • addAmountToBuyerBalance

      public boolean addAmountToBuyerBalance(double amount, String unsername)
      Adds a specified amount to the buyer's balance.
      Specified by:
      addAmountToBuyerBalance in interface BuyerDao
      Parameters:
      amount - The amount to add to the buyer's balance.
      username - The username of the buyer.
      Returns:
      true if the balance was successfully updated, false otherwise.
    • deleteBuyer

      public boolean deleteBuyer(String username, String password)
      Deletes a buyer based on their username and password.
      Specified by:
      deleteBuyer in interface BuyerDao
      Parameters:
      username - The username of the buyer.
      password - The password of the buyer.
      Returns:
      true if the buyer was successfully deleted, false otherwise.
    • recoverBuyerAcount

      public String recoverBuyerAcount(String username, String password, LocalDate date)
      Recovers a buyer's account based on their username, password, and recovery date.
      Specified by:
      recoverBuyerAcount in interface BuyerDao
      Parameters:
      username - The username of the buyer.
      password - The password of the buyer.
      date - The recovery date of the buyer's account.
      Returns:
      The recovered buyer account as a string.
    • getBuyerAllTransactionbyDateRange

      public ResultSet getBuyerAllTransactionbyDateRange(LocalDate startDate, LocalDate endDate, String username) throws RecordNotFoundException
      Retrieves all transactions of a buyer within a specified date range.
      Specified by:
      getBuyerAllTransactionbyDateRange in interface BuyerDao
      Parameters:
      startDate - The start date of the date range.
      endDate - The end date of the date range.
      username - The username of the buyer.
      Returns:
      A ResultSet containing the transactions within the date range.
      Throws:
      RecordNotFoundException - If no transactions are found within the specified date range.
    • getBuyerAllTransactionByPurchaseDate

      public ResultSet getBuyerAllTransactionByPurchaseDate(String username) throws RecordNotFoundException
      Retrieves all transactions of a buyer based on the purchase date of the transactions.
      Specified by:
      getBuyerAllTransactionByPurchaseDate in interface BuyerDao
      Parameters:
      username - The username of the buyer.
      Returns:
      A ResultSet containing the transactions.
      Throws:
      RecordNotFoundException - If no transactions are found for the buyer.
    • getBuyerAllTransactionByQuantity

      public ResultSet getBuyerAllTransactionByQuantity(String username) throws RecordNotFoundException
      Retrieves all transactions of a buyer based on the quantity of the transactions.
      Specified by:
      getBuyerAllTransactionByQuantity in interface BuyerDao
      Parameters:
      username - The username of the buyer.
      Returns:
      A ResultSet containing the transactions.
      Throws:
      RecordNotFoundException - If no transactions are found for the buyer.
    • getBuyerAllTransactionByGSTPercentage

      public ResultSet getBuyerAllTransactionByGSTPercentage(String username) throws RecordNotFoundException
      Retrieves all transactions of a buyer based on the GST percentage of the transactions.
      Specified by:
      getBuyerAllTransactionByGSTPercentage in interface BuyerDao
      Parameters:
      username - The username of the buyer.
      Returns:
      A ResultSet containing the transactions.
      Throws:
      RecordNotFoundException - If no transactions are found for the buyer.
    • getBuyerAllTransactionByTotalPrice

      public ResultSet getBuyerAllTransactionByTotalPrice(String username) throws RecordNotFoundException
      Retrieves all transactions of a buyer based on the total price of the transactions.
      Specified by:
      getBuyerAllTransactionByTotalPrice in interface BuyerDao
      Parameters:
      username - The username of the buyer.
      Returns:
      A ResultSet containing the transactions.
      Throws:
      RecordNotFoundException - If no transactions are found for the buyer.
    • getAllReturnProduct

      public ResultSet getAllReturnProduct(String username)
      Retrieves all return products for a buyer.
      Specified by:
      getAllReturnProduct in interface BuyerDao
      Parameters:
      username - The username of the buyer.
      Returns:
      A ResultSet containing the return products.
    • getAllReturnProductOfBuyerByType

      public ResultSet getAllReturnProductOfBuyerByType(String username, String type)
      Retrieves all return products of a buyer by the specified type.
      Specified by:
      getAllReturnProductOfBuyerByType in interface BuyerDao
      Parameters:
      username - The username of the buyer.
      type - The type of return products to retrieve.
      Returns:
      A ResultSet containing the return products.