View Javadoc

    1   package org.example.customerdao;
    2
    3   /*
    4   * This is free and unencumbered software released into the public domain.
    5   * Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software,
    6   * either in source code form or as a compiled binary, for any purpose, commercial or
    7   * non-commercial, and by any means.
    8   *
    9   * In jurisdictions that recognize copyright laws, the author or authors of this
    10  * software dedicate any and all copyright interest in the software to the public domain.
    11  * We make this dedication for the benefit of the public at large and to the detriment of
    12  * our heirs and successors. We intend this dedication to be an overt act of relinquishment in
    13  * perpetuity of all present and future rights to this software under copyright law.
    14  *
    15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
    16  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
    17  * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES
    18  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    20  *
    21  * For more information, please refer to: https://unlicense.org/
    22  */
    23
    24  import java.util.List;
    25
    26  import javax.sql.DataSource;
    27
    28  import org.example.customer.Product;
    29  import org.example.customer.Supplier;
    30  import org.example.customerdao.utility.Deleteable;
    31  import org.example.websecurity.UserCredentials;
    32
    33
    34  /**
    35   * This is the ProductDAO Interface for the Customer DAO component of the Customer Web Application.
    36   * This will be the primary Product database exposure for the Customer Web Layer.
    37   *
    38   * @author Jonathan Earl
    39   * @since 1.0
    40   *
    41   */
    42  public interface ProductDAO extends Deleteable
    43  {
    44      /**
    45       * Sets the Read Only DataSource for this DAO Implication.
    46       *
    47       * @param readOnlyDS the readOnlyDS to set
    48       */
    49      void setReadOnlyDS(DataSource readOnlyDS);
    50
    51      /**
    52       * Sets the Read/Write DataSource for this DAO Implication.
    53       *
    54       * @param readWriteDS the readWriteDS to set
    55       */
    56      void setReadWriteDS(DataSource readWriteDS);
    57
    58      /**
    59       * Finds all Products.
    60       *
    61       * @param credentials the UserCredentials for this Database operation
    62       * @return a list of Products, this list may be empty
    63       * @throws IllegalArgumentException
    64       *              if there is a connection or permission problem
    65       */
    66      List<Product> findAllProducts(UserCredentials credentials);
    67
    68      /**
    69       * Finds all non discontinued Products.
    70       *
    71       * @param credentials the UserCredentials for this Database operation
    72       * @return a list of active Products, this list may be empty
    73       * @throws IllegalArgumentException
    74       *              if there is a connection or permission problem
    75       */
    76      List<Product> findAllActiveProducts(UserCredentials credentials);
    77
    78      /**
    79       * Find Product by Id.
    80       * <p>
    81       * This will return null if the Product cannot be found.
    82       *
    83       * @param credentials the UserCredentials for this Database operation
    84       * @param id the Product ID to search for
    85       * @return a Product or null if the Product is not found
    86       * @throws IllegalArgumentException
    87       *              if there is a connection or permission problem
    88       */
    89      Product findProductById(UserCredentials credentials, int id);
    90
    91      /**
    92       * Find Products by Supplier.
    93       *
    94       * @param credentials the UserCredentials for this Database operation
    95       * @param supplier the Supplier to search for
    96       * @return a list of Products, this list may be empty
    97       * @throws IllegalArgumentException
    98       *              if there is a connection or permission problem
    99       */
    100     List<Product> findProductsBySupplier(UserCredentials credentials, Supplier supplier);
    101
    102     /**
    103      * Adds a Product.
    104      * <p >
    105      * Only a Manager is permitted to add a Product.
    106      *
    107      *
    108      * @param credentials the UserCredentials for this Database operation
    109      * @param product the Product object to add
    110      * @return the id of the new Product record
    111      * @throws IllegalArgumentException
    112      *              if there is a connection or permission problem
    113      */
    114     int addProduct(UserCredentials credentials, Product product);
    115
    116     /**
    117      * Updates a Product.
    118      * <p >
    119      * Only a Manager is permitted to update a Product.
    120      *
    121      *
    122      * @param credentials the UserCredentials for this Database operation
    123      * @param product the Product object to update
    124      * @throws IllegalArgumentException
    125      *              if there is a connection or permission problem
    126      */
    127     void updateProduct(UserCredentials credentials, Product product);
    128
    129 }