Package storage

Interface DataStorage

All Known Implementing Classes:
AbstractDataStorage, CollectionStorage, DatabaseStorage, MongoDBStorage

public interface DataStorage
Interface defining data storage operations for the banking system. Provides contract for customer, employee, account, and transaction operations. Supports multiple storage implementations (database, collection, mongoDB).
Author:
TAMIL MUGHILAN
  • Method Details

    • saveCustomer

      int saveCustomer(Customer customer)
      Saves a new customer to storage.
      Parameters:
      customer - the customer to save
      Returns:
      the generated customer ID
    • saveCustomerWithPassword

      int saveCustomerWithPassword(Customer customer, String salt)
      Saves a new customer with password for login capability.
      Parameters:
      customer - the customer to save
      salt - the password salt for security
      Returns:
      the generated customer ID
    • updateCustomer

      void updateCustomer(Customer customer) throws SQLException
      Updates an existing customer's information.
      Parameters:
      customer - the customer to update
      Throws:
      SQLException - if database operation fails
    • getCustomer

      Customer getCustomer(int customerId)
      Retrieves a customer by ID.
      Parameters:
      customerId - the customer ID
      Returns:
      the customer or null if not found
    • getCustomerByEmail

      Customer getCustomerByEmail(String email)
      Retrieves a customer by email address.
      Parameters:
      email - the customer's email
      Returns:
      the customer or null if not found
    • deleteCustomer

      boolean deleteCustomer(int customerId)
      Deletes a customer by ID.
      Parameters:
      customerId - the customer ID to delete
      Returns:
      true if deletion was successful, false otherwise
    • getCustomersByBranch

      List<Customer> getCustomersByBranch(int branchId)
      Gets all customers for a specific branch.
      Parameters:
      branchId - the branch ID
      Returns:
      list of customers in the branch
    • getSaltForCustomer

      String getSaltForCustomer(int customerId)
      Gets the password salt for a customer.
      Parameters:
      customerId - the customer ID
      Returns:
      the password salt or null if not found
    • saveEmployee

      int saveEmployee(Employee employee)
      Saves a new employee to storage.
      Parameters:
      employee - the employee to save
      Returns:
      the generated employee ID
    • saveEmployeeWithPassword

      int saveEmployeeWithPassword(Employee employee, String salt)
      Saves a new employee with password for login capability.
      Parameters:
      employee - the employee to save
      salt - the password salt for security
      Returns:
      the generated employee ID
    • getEmployee

      Employee getEmployee(int employeeId)
      Retrieves an employee by ID.
      Parameters:
      employeeId - the employee ID
      Returns:
      the employee or null if not found
    • getEmployeeByEmail

      Employee getEmployeeByEmail(String email)
      Retrieves an employee by email address.
      Parameters:
      email - the employee's email
      Returns:
      the employee or null if not found
    • getManager

      Manager getManager(int employeeId)
    • getSaltForEmployee

      String getSaltForEmployee(int employeeId)
    • saveAccount

      int saveAccount(SavingsAccount account)
      Saves a new account to storage.
      Parameters:
      account - the account to save
      Returns:
      the generated account number
    • getAccount

      SavingsAccount getAccount(int accountNo)
      Retrieves an account by account number.
      Parameters:
      accountNo - the account number
      Returns:
      the account or null if not found
    • updateAccount

      void updateAccount(SavingsAccount account)
      Updates an existing account.
      Parameters:
      account - the account to update
    • deleteAccount

      boolean deleteAccount(int accountNo)
      Deletes an account by account number.
      Parameters:
      accountNo - the account number to delete
      Returns:
      true if deletion was successful, false otherwise
    • getAccountsByBranch

      List<SavingsAccount> getAccountsByBranch(int branchId)
      Gets all accounts for a specific branch.
      Parameters:
      branchId - the branch ID
      Returns:
      list of accounts in the branch
    • getAccountsByCustomer

      List<SavingsAccount> getAccountsByCustomer(int customerId)
    • withdrawFromAccount

      boolean withdrawFromAccount(int accountNo, BigDecimal amount)
      Withdraws money from an account.
      Parameters:
      accountNo - the account number
      amount - the amount to withdraw
      Returns:
      true if withdrawal was successful, false otherwise
    • depositToAccount

      boolean depositToAccount(int accountNo, BigDecimal amount)
      Deposits money to an account.
      Parameters:
      accountNo - the account number
      amount - the amount to deposit
      Returns:
      true if deposit was successful, false otherwise
    • saveBranch

      void saveBranch(Branch branch)
      Saves a branch to storage.
      Parameters:
      branch - the branch to save
    • getBranch

      Branch getBranch(int branchId)
      Retrieves a branch by ID.
      Parameters:
      branchId - the branch ID
      Returns:
      the branch or null if not found
    • addCustomerToAccount

      default int addCustomerToAccount(int customerId, int accountNo, String role)
      Adds a customer to an existing account as joint holder. Default implementation throws UnsupportedOperationException.
      Parameters:
      customerId - the customer ID to add
      accountNo - the account number
      role - the customer's role (PRIMARY, JOINT)
      Returns:
      the result status
      Throws:
      UnsupportedOperationException - if not supported by implementation
    • removeCustomerFromAccount

      default boolean removeCustomerFromAccount(int customerId, int accountNo)
      Removes a customer from a joint account. Default implementation throws UnsupportedOperationException.
      Parameters:
      customerId - the customer ID to remove
      accountNo - the account number
      Returns:
      true if removal was successful, false otherwise
      Throws:
      UnsupportedOperationException - if not supported by implementation
    • getCustomersByAccount

      default List<Customer> getCustomersByAccount(int accountNo)
      Gets all customers who are holders of an account. Default implementation throws UnsupportedOperationException.
      Parameters:
      accountNo - the account number
      Returns:
      list of account holders
      Throws:
      UnsupportedOperationException - if not supported by implementation
    • logTransaction

      default boolean logTransaction(TransactionLog transactionLog)
      Logs a transaction for audit purposes. Default implementation returns true (no-op).
      Parameters:
      transactionLog - the transaction log to save
      Returns:
      true if logging was successful, false otherwise
    • getTransactionHistory

      default List<TransactionLog> getTransactionHistory(int accountNo)
    • getTransactionHistory

      default List<TransactionLog> getTransactionHistory(int accountNo, int limit)
      Gets transaction history for an account with specified limit. Default implementation throws UnsupportedOperationException.
      Parameters:
      accountNo - the account number
      limit - maximum number of records to retrieve
      Returns:
      list of transaction logs
      Throws:
      UnsupportedOperationException - if not supported by implementation
    • getTransactionHistoryByDateRange

      default List<TransactionLog> getTransactionHistoryByDateRange(int accountNo, LocalDateTime startDate, LocalDateTime endDate)
      Gets transaction history for an account within date range. Default implementation throws UnsupportedOperationException.
      Parameters:
      accountNo - the account number
      startDate - the start date
      endDate - the end date
      Returns:
      list of transaction logs
      Throws:
      UnsupportedOperationException - if not supported by implementation