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 Summary
Modifier and TypeMethodDescriptiondefault int
addCustomerToAccount
(int customerId, int accountNo, String role) Adds a customer to an existing account as joint holder.boolean
deleteAccount
(int accountNo) Deletes an account by account number.boolean
deleteCustomer
(int customerId) Deletes a customer by ID.boolean
depositToAccount
(int accountNo, BigDecimal amount) Deposits money to an account.getAccount
(int accountNo) Retrieves an account by account number.getAccountsByBranch
(int branchId) Gets all accounts for a specific branch.getAccountsByCustomer
(int customerId) getBranch
(int branchId) Retrieves a branch by ID.getCustomer
(int customerId) Retrieves a customer by ID.getCustomerByEmail
(String email) Retrieves a customer by email address.getCustomersByAccount
(int accountNo) Gets all customers who are holders of an account.getCustomersByBranch
(int branchId) Gets all customers for a specific branch.getEmployee
(int employeeId) Retrieves an employee by ID.getEmployeeByEmail
(String email) Retrieves an employee by email address.getManager
(int employeeId) getSaltForCustomer
(int customerId) Gets the password salt for a customer.getSaltForEmployee
(int employeeId) default List
<TransactionLog> getTransactionHistory
(int accountNo) default List
<TransactionLog> getTransactionHistory
(int accountNo, int limit) Gets transaction history for an account with specified limit.default List
<TransactionLog> getTransactionHistoryByDateRange
(int accountNo, LocalDateTime startDate, LocalDateTime endDate) Gets transaction history for an account within date range.default boolean
logTransaction
(TransactionLog transactionLog) Logs a transaction for audit purposes.default boolean
removeCustomerFromAccount
(int customerId, int accountNo) Removes a customer from a joint account.int
saveAccount
(SavingsAccount account) Saves a new account to storage.void
saveBranch
(Branch branch) Saves a branch to storage.int
saveCustomer
(Customer customer) Saves a new customer to storage.int
saveCustomerWithPassword
(Customer customer, String salt) Saves a new customer with password for login capability.int
saveEmployee
(Employee employee) Saves a new employee to storage.int
saveEmployeeWithPassword
(Employee employee, String salt) Saves a new employee with password for login capability.void
updateAccount
(SavingsAccount account) Updates an existing account.void
updateCustomer
(Customer customer) Updates an existing customer's information.boolean
withdrawFromAccount
(int accountNo, BigDecimal amount) Withdraws money from an account.
-
Method Details
-
saveCustomer
Saves a new customer to storage.- Parameters:
customer
- the customer to save- Returns:
- the generated customer ID
-
saveCustomerWithPassword
Saves a new customer with password for login capability.- Parameters:
customer
- the customer to savesalt
- the password salt for security- Returns:
- the generated customer ID
-
updateCustomer
Updates an existing customer's information.- Parameters:
customer
- the customer to update- Throws:
SQLException
- if database operation fails
-
getCustomer
Retrieves a customer by ID.- Parameters:
customerId
- the customer ID- Returns:
- the customer or null if not found
-
getCustomerByEmail
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
Gets all customers for a specific branch.- Parameters:
branchId
- the branch ID- Returns:
- list of customers in the branch
-
getSaltForCustomer
Gets the password salt for a customer.- Parameters:
customerId
- the customer ID- Returns:
- the password salt or null if not found
-
saveEmployee
Saves a new employee to storage.- Parameters:
employee
- the employee to save- Returns:
- the generated employee ID
-
saveEmployeeWithPassword
Saves a new employee with password for login capability.- Parameters:
employee
- the employee to savesalt
- the password salt for security- Returns:
- the generated employee ID
-
getEmployee
Retrieves an employee by ID.- Parameters:
employeeId
- the employee ID- Returns:
- the employee or null if not found
-
getEmployeeByEmail
Retrieves an employee by email address.- Parameters:
email
- the employee's email- Returns:
- the employee or null if not found
-
getManager
-
getSaltForEmployee
-
saveAccount
Saves a new account to storage.- Parameters:
account
- the account to save- Returns:
- the generated account number
-
getAccount
Retrieves an account by account number.- Parameters:
accountNo
- the account number- Returns:
- the account or null if not found
-
updateAccount
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
Gets all accounts for a specific branch.- Parameters:
branchId
- the branch ID- Returns:
- list of accounts in the branch
-
getAccountsByCustomer
-
withdrawFromAccount
Withdraws money from an account.- Parameters:
accountNo
- the account numberamount
- the amount to withdraw- Returns:
- true if withdrawal was successful, false otherwise
-
depositToAccount
Deposits money to an account.- Parameters:
accountNo
- the account numberamount
- the amount to deposit- Returns:
- true if deposit was successful, false otherwise
-
saveBranch
Saves a branch to storage.- Parameters:
branch
- the branch to save
-
getBranch
Retrieves a branch by ID.- Parameters:
branchId
- the branch ID- Returns:
- the branch or null if not found
-
addCustomerToAccount
Adds a customer to an existing account as joint holder. Default implementation throws UnsupportedOperationException.- Parameters:
customerId
- the customer ID to addaccountNo
- the account numberrole
- 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 removeaccountNo
- the account number- Returns:
- true if removal was successful, false otherwise
- Throws:
UnsupportedOperationException
- if not supported by implementation
-
getCustomersByAccount
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
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
-
getTransactionHistory
Gets transaction history for an account with specified limit. Default implementation throws UnsupportedOperationException.- Parameters:
accountNo
- the account numberlimit
- 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 numberstartDate
- the start dateendDate
- the end date- Returns:
- list of transaction logs
- Throws:
UnsupportedOperationException
- if not supported by implementation
-