Package storage
Class AbstractDataStorage
java.lang.Object
storage.AbstractDataStorage
- All Implemented Interfaces:
DataStorage
- Direct Known Subclasses:
CollectionStorage
,DatabaseStorage
,MongoDBStorage
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
deleteAccount
(int accountNo) Deletes an account by account number.abstract boolean
deleteCustomer
(int customerId) Deletes a customer by ID.abstract boolean
depositToAccount
(int accountNo, BigDecimal amount) Deposits money to an account.abstract SavingsAccount
getAccount
(int accountNo) Retrieves an account by account number.abstract List
<SavingsAccount> getAccountsByBranch
(int branchId) Gets all accounts for a specific branch.abstract List
<SavingsAccount> getAccountsByCustomer
(int customerId) abstract Branch
getBranch
(int branchId) Retrieves a branch by ID.abstract Customer
getCustomer
(int customerId) Retrieves a customer by ID.abstract Customer
getCustomerByEmail
(String email) Retrieves a customer by email address.getCustomersByBranch
(int branchId) Gets all customers for a specific branch.abstract Employee
getEmployee
(int employeeId) Retrieves an employee by ID.abstract Employee
getEmployeeByEmail
(String email) Retrieves an employee by email address.abstract Manager
getManager
(int employeeId) abstract String
getSaltForCustomer
(int customerId) Gets the password salt for a customer.abstract String
getSaltForEmployee
(int employeeId) protected boolean
isValidEmail
(String email) abstract int
saveAccount
(SavingsAccount account) Saves a new account to storage.abstract void
saveBranch
(Branch branch) Saves a branch to storage.abstract int
saveCustomer
(Customer customer) Saves a new customer to storage.abstract int
saveCustomerWithPassword
(Customer customer, String salt) Saves a new customer with password for login capability.abstract int
saveEmployee
(Employee employee) Saves a new employee to storage.abstract int
saveEmployeeWithPassword
(Employee employee, String salt) Saves a new employee with password for login capability.abstract void
updateAccount
(SavingsAccount account) Updates an existing account.abstract void
updateCustomer
(Customer customer) Updates an existing customer's information.abstract boolean
withdrawFromAccount
(int accountNo, BigDecimal amount) Withdraws money from an account.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface storage.DataStorage
addCustomerToAccount, getCustomersByAccount, getTransactionHistory, getTransactionHistory, getTransactionHistoryByDateRange, logTransaction, removeCustomerFromAccount
-
Constructor Details
-
AbstractDataStorage
public AbstractDataStorage()
-
-
Method Details
-
isValidEmail
-
saveCustomer
Description copied from interface:DataStorage
Saves a new customer to storage.- Specified by:
saveCustomer
in interfaceDataStorage
- Parameters:
customer
- the customer to save- Returns:
- the generated customer ID
-
saveCustomerWithPassword
Saves a new customer with password for login capability.- Specified by:
saveCustomerWithPassword
in interfaceDataStorage
- Parameters:
customer
- the customer to savesalt
- the password salt for security- Returns:
- the generated customer ID
-
getCustomer
Retrieves a customer by ID.- Specified by:
getCustomer
in interfaceDataStorage
- Parameters:
customerId
- the customer ID- Returns:
- the customer or null if not found
-
getCustomerByEmail
Retrieves a customer by email address.- Specified by:
getCustomerByEmail
in interfaceDataStorage
- 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 interfaceDataStorage
- Parameters:
customerId
- the customer ID to delete- Returns:
- true if deletion was successful, false otherwise
-
getCustomersByBranch
Gets all customers for a specific branch.- Specified by:
getCustomersByBranch
in interfaceDataStorage
- Parameters:
branchId
- the branch ID- Returns:
- list of customers in the branch
-
getSaltForCustomer
Gets the password salt for a customer.- Specified by:
getSaltForCustomer
in interfaceDataStorage
- Parameters:
customerId
- the customer ID- Returns:
- the password salt or null if not found
-
saveEmployee
Saves a new employee to storage.- Specified by:
saveEmployee
in interfaceDataStorage
- Parameters:
employee
- the employee to save- Returns:
- the generated employee ID
-
saveEmployeeWithPassword
Saves a new employee with password for login capability.- Specified by:
saveEmployeeWithPassword
in interfaceDataStorage
- Parameters:
employee
- the employee to savesalt
- the password salt for security- Returns:
- the generated employee ID
-
getEmployee
Retrieves an employee by ID.- Specified by:
getEmployee
in interfaceDataStorage
- Parameters:
employeeId
- the employee ID- Returns:
- the employee or null if not found
-
getEmployeeByEmail
Retrieves an employee by email address.- Specified by:
getEmployeeByEmail
in interfaceDataStorage
- Parameters:
email
- the employee's email- Returns:
- the employee or null if not found
-
getManager
- Specified by:
getManager
in interfaceDataStorage
-
getSaltForEmployee
- Specified by:
getSaltForEmployee
in interfaceDataStorage
-
saveAccount
Saves a new account to storage.- Specified by:
saveAccount
in interfaceDataStorage
- Parameters:
account
- the account to save- Returns:
- the generated account number
-
getAccount
Retrieves an account by account number.- Specified by:
getAccount
in interfaceDataStorage
- Parameters:
accountNo
- the account number- Returns:
- the account or null if not found
-
updateAccount
Updates an existing account.- Specified by:
updateAccount
in interfaceDataStorage
- Parameters:
account
- the account to update
-
deleteAccount
public abstract boolean deleteAccount(int accountNo) Deletes an account by account number.- Specified by:
deleteAccount
in interfaceDataStorage
- Parameters:
accountNo
- the account number to delete- Returns:
- true if deletion was successful, false otherwise
-
getAccountsByBranch
Gets all accounts for a specific branch.- Specified by:
getAccountsByBranch
in interfaceDataStorage
- Parameters:
branchId
- the branch ID- Returns:
- list of accounts in the branch
-
getAccountsByCustomer
- Specified by:
getAccountsByCustomer
in interfaceDataStorage
-
saveBranch
Saves a branch to storage.- Specified by:
saveBranch
in interfaceDataStorage
- Parameters:
branch
- the branch to save
-
getBranch
Retrieves a branch by ID.- Specified by:
getBranch
in interfaceDataStorage
- Parameters:
branchId
- the branch ID- Returns:
- the branch or null if not found
-
withdrawFromAccount
Withdraws money from an account.- Specified by:
withdrawFromAccount
in interfaceDataStorage
- Parameters:
accountNo
- the account numberamount
- the amount to withdraw- Returns:
- true if withdrawal was successful, false otherwise
-
depositToAccount
Deposits money to an account.- Specified by:
depositToAccount
in interfaceDataStorage
- Parameters:
accountNo
- the account numberamount
- the amount to deposit- Returns:
- true if deposit was successful, false otherwise
-
updateCustomer
Updates an existing customer's information.- Specified by:
updateCustomer
in interfaceDataStorage
- Parameters:
customer
- the customer to update- Throws:
SQLException
- if database operation fails
-