Class SupplierDAOImpl
- All Implemented Interfaces:
SupplierDAO,Deleteable
- Since:
- 1.0
- Author:
- Jonathan Earl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintaddSupplier(org.example.websecurity.UserCredentials credentials, org.example.customer.Supplier supplier) Adds a Supplier.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.Supplier> findAllSuppliers(org.example.websecurity.UserCredentials credentials) Finds all Suppliers.org.example.customer.SupplierfindSupplierById(org.example.websecurity.UserCredentials credentials, int id) Find Supplier by Id.List<org.example.customer.Supplier> findSuppliersByCompanyName(org.example.websecurity.UserCredentials credentials, String name) Find Suppliers by Company 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.voidupdateSupplier(org.example.websecurity.UserCredentials credentials, org.example.customer.Supplier supplier) Updates a Supplier.
-
Constructor Details
-
SupplierDAOImpl
public SupplierDAOImpl()
-
-
Method Details
-
setReadOnlyDS
Sets the Read Only DataSource for this DAO Implication.- Specified by:
setReadOnlyDSin interfaceSupplierDAO- Parameters:
readOnlyDS- the readOnlyDS to set
-
setReadWriteDS
Sets the Read/Write DataSource for this DAO Implication.- Specified by:
setReadWriteDSin interfaceSupplierDAO- Parameters:
readWriteDS- the readWriteDS to set
-
findAllSuppliers
public List<org.example.customer.Supplier> findAllSuppliers(org.example.websecurity.UserCredentials credentials) Finds all Suppliers.- Specified by:
findAllSuppliersin interfaceSupplierDAO- Parameters:
credentials- the UserCredentials for this Database operation- Returns:
- a list of Suppliers, this list may be empty
-
findSupplierById
public org.example.customer.Supplier findSupplierById(org.example.websecurity.UserCredentials credentials, int id) Find Supplier by Id.This will return null if the Supplier cannot be found.
- Specified by:
findSupplierByIdin interfaceSupplierDAO- Parameters:
credentials- the UserCredentials for this Database operationid- the Supplier ID to search for- Returns:
- a Supplier or null if the Supplier is not found
-
findSuppliersByCompanyName
public List<org.example.customer.Supplier> findSuppliersByCompanyName(org.example.websecurity.UserCredentials credentials, String name) Find Suppliers by Company name.This will use a Wild Card search to find any Supplier with the provided string and a portion of their Company name.
- Specified by:
findSuppliersByCompanyNamein interfaceSupplierDAO- Parameters:
credentials- the UserCredentials for this Database operationname- the string to search for- Returns:
- a list if Suppliers, this list may be empty
-
addSupplier
public int addSupplier(org.example.websecurity.UserCredentials credentials, org.example.customer.Supplier supplier) Adds a Supplier.Only a Manager is permitted to add a Supplier.
- Specified by:
addSupplierin interfaceSupplierDAO- Parameters:
credentials- the UserCredentials for this Database operationsupplier- the Supplier object to add- Returns:
- the id of the new Supplier record
-
updateSupplier
public void updateSupplier(org.example.websecurity.UserCredentials credentials, org.example.customer.Supplier supplier) Updates a Supplier.Only a Manager is permitted to update a Supplier.
- Specified by:
updateSupplierin interfaceSupplierDAO- Parameters:
credentials- the UserCredentials for this Database operationsupplier- the Supplier object to update
-
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.
Suppliers with Products 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
-
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.
Suppliers with Products 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
-
deleteEntity
public void deleteEntity(org.example.websecurity.UserCredentials credentials, org.example.customer.utility.CustomerEntity entity) throws NonDeleteableRecordException 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.
Suppliers with Products are not deleteable.
- Specified by:
deleteEntityin interfaceDeleteable- Parameters:
credentials- the UserCredentials for this Database operationentity- the CustomerEntity object to delete- Throws:
NonDeleteableRecordException- if this CustomerEntity cannot be deleted
-
deleteEntity
public void deleteEntity(org.example.websecurity.UserCredentials credentials, int id) throws NonDeleteableRecordException Deletes a CuUstomerEntity by id.Only a Manager is permitted to delete a CustomerEntity.
Suppliers with Products are not deleteable.
- Specified by:
deleteEntityin interfaceDeleteable- Parameters:
credentials- the UserCredentials for this Database operationid- the CustomerEntity id to delete- Throws:
NonDeleteableRecordException- if this CustomerEntity cannot be deleted
-