Package storage

Class AbstractDataStorage

java.lang.Object
storage.AbstractDataStorage
All Implemented Interfaces:
DataStorage
Direct Known Subclasses:
CollectionStorage, DatabaseStorage, MongoDBStorage

public abstract class AbstractDataStorage extends Object implements DataStorage
  • Constructor Details

    • AbstractDataStorage

      public AbstractDataStorage()
  • Method Details

    • isValidEmail

      protected boolean isValidEmail(String email)
    • saveCustomer

      public abstract int saveCustomer(Customer customer)
      Description copied from interface: DataStorage
      Saves a new customer to storage.
      Specified by:
      saveCustomer in interface DataStorage
      Parameters:
      customer - the customer to save
      Returns:
      the generated customer ID
    • saveCustomerWithPassword

      public abstract int saveCustomerWithPassword(Customer customer, String salt)
      Saves a new customer with password for login capability.
      Specified by:
      saveCustomerWithPassword in interface DataStorage
      Parameters:
      customer - the customer to save
      salt - the password salt for security
      Returns:
      the generated customer ID
    • getCustomer

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

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

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

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

      public abstract String getSaltForCustomer(int customerId)
      Gets the password salt for a customer.
      Specified by:
      getSaltForCustomer in interface DataStorage
      Parameters:
      customerId - the customer ID
      Returns:
      the password salt or null if not found
    • saveEmployee

      public abstract int saveEmployee(Employee employee)
      Saves a new employee to storage.
      Specified by:
      saveEmployee in interface DataStorage
      Parameters:
      employee - the employee to save
      Returns:
      the generated employee ID
    • saveEmployeeWithPassword

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

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

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

      public abstract Manager getManager(int employeeId)
      Specified by:
      getManager in interface DataStorage
    • getSaltForEmployee

      public abstract String getSaltForEmployee(int employeeId)
      Specified by:
      getSaltForEmployee in interface DataStorage
    • saveAccount

      public abstract int saveAccount(SavingsAccount account)
      Saves a new account to storage.
      Specified by:
      saveAccount in interface DataStorage
      Parameters:
      account - the account to save
      Returns:
      the generated account number
    • getAccount

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

      public abstract void updateAccount(SavingsAccount account)
      Updates an existing account.
      Specified by:
      updateAccount in interface DataStorage
      Parameters:
      account - the account to update
    • deleteAccount

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

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

      public abstract List<SavingsAccount> getAccountsByCustomer(int customerId)
      Specified by:
      getAccountsByCustomer in interface DataStorage
    • saveBranch

      public abstract void saveBranch(Branch branch)
      Saves a branch to storage.
      Specified by:
      saveBranch in interface DataStorage
      Parameters:
      branch - the branch to save
    • getBranch

      public abstract Branch getBranch(int branchId)
      Retrieves a branch by ID.
      Specified by:
      getBranch in interface DataStorage
      Parameters:
      branchId - the branch ID
      Returns:
      the branch or null if not found
    • withdrawFromAccount

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

      public abstract boolean depositToAccount(int accountNo, BigDecimal amount)
      Deposits money to an account.
      Specified by:
      depositToAccount in interface DataStorage
      Parameters:
      accountNo - the account number
      amount - the amount to deposit
      Returns:
      true if deposit was successful, false otherwise
    • updateCustomer

      public abstract void updateCustomer(Customer customer) throws SQLException
      Updates an existing customer's information.
      Specified by:
      updateCustomer in interface DataStorage
      Parameters:
      customer - the customer to update
      Throws:
      SQLException - if database operation fails