Package org.example.customerdao

# Class OrderDAOImpl

java.lang.Object
org.example.customerdao.OrderDAOImpl

All Implemented Interfaces:
  `OrderDAO`, `Deleteable`

public class OrderDAOImpl extends Object implements OrderDAO
This is the OrderDAO Implementation for the Customer DAO component of the Customer Web Application. This will be the primary Order database exposure for the Customer Web Layer.

Since:
  1.0
Author:
  Jonathan Earl

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OrderDAOImpl()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `addOrder(org.example.websecurity.UserCredentials credentials, org.example.customer.Order order)`
  Adds a Order.
  `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.OrderItem>`
  `findAllOrderItems(org.example.websecurity.UserCredentials credentials, org.example.customer.Order order)`
  Finds all Order_Items by Order.
  `List<org.example.customer.Order>`
  `findAllOrders(org.example.websecurity.UserCredentials credentials)`
  Finds all Orders.
  `org.example.customer.Order`
  `findOrderById(org.example.websecurity.UserCredentials credentials, int id)`
  Find Order by Id.
  `List<org.example.customer.Order>`
  `findOrdersByCustomer(org.example.websecurity.UserCredentials credentials, org.example.customer.Customer customer)`
  Find Orders by Customer.
  `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`
  `updateOrder(org.example.websecurity.UserCredentials credentials, org.example.customer.Order order)`
  Updates a Order.

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

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

- ## Constructor Details

  - ### OrderDAOImpl

    public OrderDAOImpl()

- ## Method Details

  - ### setReadOnlyDS

    public void setReadOnlyDS(DataSource readOnlyDS)
    Sets the Read Only DataSource for this DAO Implication.
    Specified by:
      `setReadOnlyDS` in interface `OrderDAO`
    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 `OrderDAO`
    Parameters:
      `readWriteDS` - the readWriteDS to set

  - ### findAllOrders

    public List<org.example.customer.Order> findAllOrders(org.example.websecurity.UserCredentials credentials)
    Finds all Orders.
    Specified by:
      `findAllOrders` in interface `OrderDAO`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
    Returns:
      a list of Orders, this list may be empty

  - ### findAllOrderItems

    public List<org.example.customer.OrderItem> findAllOrderItems(org.example.websecurity.UserCredentials credentials, org.example.customer.Order order)
    Finds all Order_Items by Order.
    Specified by:
      `findAllOrderItems` in interface `OrderDAO`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `order` - the order to search for
    Returns:
      a list of OrderItems, this list may be empty

  - ### findOrderById

    public org.example.customer.Order findOrderById(org.example.websecurity.UserCredentials credentials, int id)
    Find Order by Id.

    This will return null if the Order cannot be found.

    Specified by:
      `findOrderById` in interface `OrderDAO`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `id` - the Order ID to search for
    Returns:
      a Order or null if the Order is not found

  - ### findOrdersByCustomer

    public List<org.example.customer.Order> findOrdersByCustomer(org.example.websecurity.UserCredentials credentials, org.example.customer.Customer customer)
    Find Orders by Customer.
    Specified by:
      `findOrdersByCustomer` in interface `OrderDAO`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `customer` - the Customer to search for
    Returns:
      a list of Orders, this list may be empty

  - ### addOrder

    public int addOrder(org.example.websecurity.UserCredentials credentials, org.example.customer.Order order)
    Adds a Order.
    Specified by:
      `addOrder` in interface `OrderDAO`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `order` - the Order object to add
    Returns:
      the id of the new Order record

  - ### updateOrder

    public void updateOrder(org.example.websecurity.UserCredentials credentials, org.example.customer.Order order)
    Updates a Order.
    Specified by:
      `updateOrder` in interface `OrderDAO`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `order` - the Order object to update

  - ### 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.

    Specified by:
      `deleteEntity` in interface `Deleteable`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `entity` - 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.

    Specified by:
      `deleteEntity` in interface `Deleteable`
    Parameters:
      `credentials` - the UserCredentials for this Database operation
      `id` - the CustomerEntity id to delete

  - ### 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.

    Order are 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

  - ### 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.

    Order are 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