Package org.example.customerdao
Class CustomerDAOImpl
java.lang.Object
org.example.customerdao.CustomerDAOImpl
- All Implemented Interfaces:
CustomerDAO,Deleteable
This is the CustomerDAO Implementation for the Customer DAO component of the Customer Web Application.
This will be the primary Customer database exposure for the Customer Web Layer.
- Since:
- 1.0
- Author:
- Jonathan Earl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintaddCustomer(org.example.websecurity.UserCredentials credentials, org.example.customer.Customer customer) Adds a Customer.voiddeleteEntity(org.example.websecurity.UserCredentials credentials, int id) Deletes a CuUstomerEntity by id.voiddeleteEntity(org.example.websecurity.UserCredentials credentials, org.example.customer.utility.CustomerEntity entity) Deletes an CustomerEntity.List<org.example.customer.Customer> findAllCustomers(org.example.websecurity.UserCredentials credentials) Finds all Customers.org.example.customer.CustomerfindCustomerById(org.example.websecurity.UserCredentials credentials, int id) Find Customer by Id.List<org.example.customer.Customer> findCustomersByName(org.example.websecurity.UserCredentials credentials, String firstName, String lastName) Find Customers by Name.booleanisDeleteable(org.example.websecurity.UserCredentials credentials, int id) This method will determine if a CustomerEntity record can be deleted.booleanisDeleteable(org.example.websecurity.UserCredentials credentials, org.example.customer.utility.CustomerEntity entity) Checks to see if a Product has Orders, if not the Product is deleteable.voidsetReadOnlyDS(DataSource readOnlyDS) Sets the Read Only DataSource for this DAO Implication.voidsetReadWriteDS(DataSource readWriteDS) Sets the Read/Write DataSource for this DAO Implication.voidupdateCustomer(org.example.websecurity.UserCredentials credentials, org.example.customer.Customer customer) Updates a Customer.
-
Constructor Details
-
CustomerDAOImpl
public CustomerDAOImpl()
-
-
Method Details
-
setReadOnlyDS
Sets the Read Only DataSource for this DAO Implication.- Specified by:
setReadOnlyDSin interfaceCustomerDAO- Parameters:
readOnlyDS- the readOnlyDS to set
-
setReadWriteDS
Sets the Read/Write DataSource for this DAO Implication.- Specified by:
setReadWriteDSin interfaceCustomerDAO- Parameters:
readWriteDS- the readWriteOnlyDS to set
-
findAllCustomers
public List<org.example.customer.Customer> findAllCustomers(org.example.websecurity.UserCredentials credentials) Finds all Customers.- Specified by:
findAllCustomersin interfaceCustomerDAO- Parameters:
credentials- the UserCredentials for this Database operation- Returns:
- a list of Customers, this list may be empty
-
findCustomerById
public org.example.customer.Customer findCustomerById(org.example.websecurity.UserCredentials credentials, int id) Find Customer by Id.This will return null if the Customer cannot be found.
- Specified by:
findCustomerByIdin interfaceCustomerDAO- Parameters:
credentials- the UserCredentials for this Database operationid- the Customer ID to search for- Returns:
- a Customer or null if the Customer is not found
-
findCustomersByName
public List<org.example.customer.Customer> findCustomersByName(org.example.websecurity.UserCredentials credentials, String firstName, String lastName) Find Customers by Name.- Specified by:
findCustomersByNamein interfaceCustomerDAO- Parameters:
credentials- the UserCredentials for this Database operationfirstName- the first name to search forlastName- the last name to search for- Returns:
- a list of Customers, this list may be empty
-
addCustomer
public int addCustomer(org.example.websecurity.UserCredentials credentials, org.example.customer.Customer customer) Adds a Customer.Only a Manager is permitted to add a Customer.
- Specified by:
addCustomerin interfaceCustomerDAO- Parameters:
credentials- the UserCredentials for this Database operationcustomer- the Customer object to add- Returns:
- the id of the new Customer record
-
updateCustomer
public void updateCustomer(org.example.websecurity.UserCredentials credentials, org.example.customer.Customer customer) Updates a Customer.Only a Manager is permitted to update a Customer.
- Specified by:
updateCustomerin interfaceCustomerDAO- Parameters:
credentials- the UserCredentials for this Database operationcustomer- the Customer object to update
-
isDeleteable
public boolean isDeleteable(org.example.websecurity.UserCredentials credentials, int id) This method will determine if a CustomerEntity record can be deleted.Only Managers can delete CustomerEntity records.
Customers with Orders are not deleteable.
- Specified by:
isDeleteablein interfaceDeleteable- Parameters:
credentials- the UserCredentials for this Database operationid- the if of the object to delete- Returns:
- true if the object is deleteable
-
isDeleteable
public boolean isDeleteable(org.example.websecurity.UserCredentials credentials, org.example.customer.utility.CustomerEntity entity) Checks to see if a Product has Orders, if not the Product is deleteable.Only Managers can delete CustomerEntity records.
Customers with Orders are not deleteable.
- Specified by:
isDeleteablein interfaceDeleteable- Parameters:
credentials- the UserCredentials for this Database operationentity- the CustomerEntity object to check- Returns:
- true if the CustomerEntity is deleteable
-
deleteEntity
public void deleteEntity(org.example.websecurity.UserCredentials credentials, org.example.customer.utility.CustomerEntity entity) Deletes an CustomerEntity.Only a Manager is permitted to delete a CustomerEntity.
If this CustomerEntity fails to meet the criteria for deletion, the delete will fail.
Customers with Orders are not deleteable.
- Specified by:
deleteEntityin interfaceDeleteable- Parameters:
credentials- the UserCredentials for this Database operationentity- the CustomerEntity object to delete
-
deleteEntity
public void deleteEntity(org.example.websecurity.UserCredentials credentials, int id) Deletes a CuUstomerEntity by id.Only a Manager is permitted to delete a CustomerEntity.
Customers with Orders are not deleteable.
- Specified by:
deleteEntityin interfaceDeleteable- Parameters:
credentials- the UserCredentials for this Database operationid- the CustomerEntity id to delete
-