Package org.example.customerdao

# Class SupplierDAOImpl

java.lang.Object
org.example.customerdao.SupplierDAOImpl

All Implemented Interfaces:
  `SupplierDAO`, `Deleteable`

public class SupplierDAOImpl extends Object implements SupplierDAO
This is the SupplierDAO Implementation for the Customer DAO component of the Customer Web Application. This will be the primary Supplier database exposure for the Customer Web Layer.

Since:
  1.0
Author:
  Jonathan Earl

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SupplierDAOImpl()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `addSupplier(org.example.websecurity.UserCredentials credentials, org.example.customer.Supplier supplier)`
  Adds a Supplier.
  `void`
  `deleteEntity(org.example.websecurity.UserCredentials credentials, int id)`
  Deletes a CuUstomerEntity by id.
  `void`
  `deleteEntity(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.Supplier`
  `findSupplierById(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.
  `boolean`
  `isDeleteable(org.example.websecurity.UserCredentials credentials, int id)`
  This method will determine if a CustomerEntity record can be deleted.
  `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.
  `void`
  `setReadOnlyDS(DataSource readOnlyDS)`
  Sets the Read Only DataSource for this DAO Implication.
  `void`
  `setReadWriteDS(DataSource readWriteDS)`
  Sets the Read/Write DataSource for this DAO Implication.
  `void`
  `updateSupplier(org.example.websecurity.UserCredentials credentials, org.example.customer.Supplier supplier)`
  Updates a Supplier.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### SupplierDAOImpl

    public SupplierDAOImpl()

- ## Method Details

  - ### setReadOnlyDS

    public void setReadOnlyDS(DataSource readOnlyDS)
    Sets the Read Only DataSource for this DAO Implication.
    Specified by:
      `setReadOnlyDS` in interface `SupplierDAO`
    Parameters:
      `readOnlyDS` - the readOnlyDS to set

  - ### setReadWriteDS

    public void setReadWriteDS(DataSource readWriteDS)
    Sets the Read/Write DataSource for this DAO Implication.
    Specified by:
      `setReadWriteDS` in interface `SupplierDAO`
    Parameters:
      `readWriteDS` - the readWriteDS to set

  - ### findAllSuppliers

    public List<org.example.customer.Supplier> findAllSuppliers(org.example.websecurity.UserCredentials credentials)
    Finds all Suppliers.
    Specified by:
      `findAllSuppliers` in interface `SupplierDAO`
    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:
      `findSupplierById` in interface `SupplierDAO`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `id` - 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:
      `findSuppliersByCompanyName` in interface `SupplierDAO`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `name` - 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:
      `addSupplier` in interface `SupplierDAO`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `supplier` - 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:
      `updateSupplier` in interface `SupplierDAO`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `supplier` - 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:
      `isDeleteable` in interface `Deleteable`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `entity` - 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:
      `isDeleteable` in interface `Deleteable`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `id` - 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:
      `deleteEntity` in interface `Deleteable`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `entity` - 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:
      `deleteEntity` in interface `Deleteable`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `id` - the CustomerEntity id to delete
    Throws:
      `NonDeleteableRecordException` - if this CustomerEntity cannot be deleted