View Javadoc

    1   package org.example.customerdao.utility;
    2
    3   import org.example.customer.utility.CustomerEntity;
    4
    5   /*
    6   * This is free and unencumbered software released into the public domain.
    7   * Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software,
    8   * either in source code form or as a compiled binary, for any purpose, commercial or
    9   * non-commercial, and by any means.
    10  *
    11  * In jurisdictions that recognize copyright laws, the author or authors of this
    12  * software dedicate any and all copyright interest in the software to the public domain.
    13  * We make this dedication for the benefit of the public at large and to the detriment of
    14  * our heirs and successors. We intend this dedication to be an overt act of relinquishment in
    15  * perpetuity of all present and future rights to this software under copyright law.
    16  *
    17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
    18  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
    19  * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES
    20  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    22  *
    23  * For more information, please refer to: https://unlicense.org/
    24  */
    25
    26  import org.example.websecurity.UserCredentials;
    27
    28  /**
    29   * This is the Deletable interface for the DAO components of the
    30   * Customer Web Application.
    31   *
    32   * @author Jonathan Earl
    33   * @since 1.0
    34   *
    35   */
    36  public interface Deleteable
    37  {
    38      /**
    39       * This method will determine if a CustomerEntity record can be deleted.
    40       * <p>
    41       * Only <strong>Managers</strong> can delete CustomerEntity records.
    42       *
    43       * @param credentials the UserCredentials for this Database operation
    44       * @param id the if of the object to delete
    45       * @return true if the object is deleteable
    46       */
    47      boolean isDeleteable(UserCredentials credentials, int id);
    48
    49      /**
    50       * Checks to see if a Product has Orders, if not the Product is deleteable.
    51       * <p>
    52       * Only <strong>Managers</strong> can delete CustomerEntity records.
    53       *
    54       * @param credentials the UserCredentials for this Database operation
    55       * @param entity the CustomerEntity object to check
    56       * @return true  if the CustomerEntity is deleteable
    57       * @throws IllegalArgumentException
    58       *              if there is a connection or permission problem
    59       */
    60      boolean isDeleteable(UserCredentials credentials, CustomerEntity entity);
    61
    62      /**
    63       * Deletes an CustomerEntity.
    64       * <p >
    65       * Only a Manager is permitted to delete a CustomerEntity.
    66       * <p>
    67       * If this CustomerEntity fails to meet the criteria for deletion,
    68       * the delete will fail.
    69       *
    70       * @param credentials the UserCredentials for this Database operation
    71       * @param entity the CustomerEntity object to delete
    72       * @throws IllegalArgumentException
    73       *              if there is a connection or permission problem
    74       * @throws NonDeleteableRecordException if this CustomerEntity cannot be deleted
    75       */
    76      void deleteEntity(UserCredentials credentials, CustomerEntity entity)
    77         throws NonDeleteableRecordException;
    78
    79      /**
    80       * Deletes a CuUstomerEntity by id.
    81       * <p >
    82       * Only a Manager is permitted to delete a CustomerEntity.
    83       *
    84       * @param credentials the UserCredentials for this Database operation
    85       * @param id the CustomerEntity id to delete
    86       * @throws IllegalArgumentException
    87       *              if there is a connection or permission problem
    88       * @throws NonDeleteableRecordException if this CustomerEntity cannot be deleted
    89       */
    90      void deleteEntity(UserCredentials credentials, int id)
    91         throws NonDeleteableRecordException;
    92  }