DAOImageImpl

com.j0h1.contour.server.dao.impl

## Class DAOImageImpl

- java.lang.Object
- - com.j0h1.contour.server.dao.AbstractDAO
  - - com.j0h1.contour.server.dao.impl.DAOImageImpl

- All Implemented Interfaces:
    DAOImage

      public class DAOImageImpl
      extends AbstractDAO
      implements DAOImage

  Implementations for DAOImage.
  Author:
    Johannes Riedmann

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private java.sql.Connection` | `connection`
    `private DatabaseManager` | `dbm`
    `private java.sql.PreparedStatement` | `prep`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DAOImageImpl()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.ArrayList<Image>` | `findEdgeImagesByTrackId(int trackId, java.lang.String language)` Queries for a list of edge images of a specific track and language.
    `Image` | `getDrawingByImageIdAndSessionId(int imageId, int sessionId)` Queries for the user drawing data for specific image in a specific session.
    `Image` | `getEdgeImageByImageId(int imageId)` Queries for the edge image data for a given imageId.
    `Image` | `getOriginalImageByImageId(int imageId)` Queries for the original image data for a given imageId.
    `Image` | `getScoreImageByImageIdAndSessionId(int imageId, int sessionId)` Queries for the score image data for specific image in a specific session.
    `java.util.ArrayList<Image>` | `getSessionDetails(int sessionId, java.lang.String language)` Retrieves the meta data (no image data) of all images persisted for a specific session in a given language (for the image names to be displayed in the correct language).
    `int` | `persist(java.lang.String titleEN, java.lang.String titleDE, java.lang.String originalContent, java.lang.String edgeContent)` Persists an new image to the database.

    - ### Methods inherited from class com.j0h1.contour.server.dao.AbstractDAO

      `closeConnection, openConnection, setAutoCommit`

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

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

- - ### Field Detail

    - #### connection

          private java.sql.Connection connection

    - #### prep

          private java.sql.PreparedStatement prep

    - #### dbm

          private DatabaseManager dbm

  - ### Constructor Detail

    - #### DAOImageImpl

          public DAOImageImpl()

  - ### Method Detail

    - #### findEdgeImagesByTrackId

          public java.util.ArrayList<Image> findEdgeImagesByTrackId(int trackId,
                                                                    java.lang.String language)
                                                             throws DAOImageException

      Description copied from interface: `DAOImage`
      Queries for a list of edge images of a specific track and language.
      Specified by:
        `findEdgeImagesByTrackId` in interface `DAOImage`
      Parameters:
        `trackId` - TrackId of the Track the edge images are assigned to.
        `language` - Language code ("en"/"de"), that defines if the image name should be returned in english ("en") or german ("de").
      Returns:
        List of edge images in a given track in a specific language. Empty List if no Images were found.
      Throws:
        `DAOImageException` - When the query fails, a DAOImageException is thrown.

    - #### getSessionDetails

          public java.util.ArrayList<Image> getSessionDetails(int sessionId,
                                                              java.lang.String language)
                                                       throws DAOImageException

      Description copied from interface: `DAOImage`
      Retrieves the meta data (no image data) of all images persisted for a specific session in a given language (for the image names to be displayed in the correct language).
      Specified by:
        `getSessionDetails` in interface `DAOImage`
      Parameters:
        `sessionId` - Id of the session to retreive details image metadata from.
        `language` - Language code ("en"/"de) to get the image names in the specified language.
      Returns:
        Meta data of a session containing the images with the achieved scores. If no image meta data is found, an empty list is returned.
      Throws:
        `DAOImageException` - When the query fails, a DAOImageException is thrown.

    - #### persist

          public int persist(java.lang.String titleEN,
                             java.lang.String titleDE,
                             java.lang.String originalContent,
                             java.lang.String edgeContent)
                      throws DAOImageException

      Description copied from interface: `DAOImage`
      Persists an new image to the database.
      Specified by:
        `persist` in interface `DAOImage`
      Parameters:
        `titleEN` - German name of the image.
        `titleDE` - English name of the image.
        `originalContent` - Original image data.
        `edgeContent` - Edge image data.
      Returns:
        The generated ID of the image.
      Throws:
        `DAOImageException` - When the persistence process fails, a DAOImageException is thrown.

    - #### getOriginalImageByImageId

          public Image getOriginalImageByImageId(int imageId)
                                          throws DAOImageException

      Description copied from interface: `DAOImage`
      Queries for the original image data for a given imageId.
      Specified by:
        `getOriginalImageByImageId` in interface `DAOImage`
      Parameters:
        `imageId` - ID of the image to get the original data from.
      Returns:
        Image object that contains the original image data for a given imageId. If image is not found, an empty Image object is returned.
      Throws:
        `DAOImageException` - When the query fails, a DAOImageException is thrown.

    - #### getEdgeImageByImageId

          public Image getEdgeImageByImageId(int imageId)
                                      throws DAOImageException

      Description copied from interface: `DAOImage`
      Queries for the edge image data for a given imageId.
      Specified by:
        `getEdgeImageByImageId` in interface `DAOImage`
      Parameters:
        `imageId` - ID of the image to get the edge data from.
      Returns:
        Image object that contains the edge image data for a given imageId. If image is not found, an empty Image object is returned.
      Throws:
        `DAOImageException` - When the query fails, a DAOImageException is thrown.

    - #### getDrawingByImageIdAndSessionId

          public Image getDrawingByImageIdAndSessionId(int imageId,
                                                       int sessionId)
                                                throws DAOImageException

      Description copied from interface: `DAOImage`
      Queries for the user drawing data for specific image in a specific session.
      Specified by:
        `getDrawingByImageIdAndSessionId` in interface `DAOImage`
      Parameters:
        `imageId` - ID of the image to get the drawing data from.
        `sessionId` - Id of the session, the drawing of the image was done.
      Returns:
        Image object that contains the drawing data for a given imageId and sessionId. If image is not found, an empty Image object is returned.
      Throws:
        `DAOImageException` - When the query fails, a DAOImageException is thrown.

    - #### getScoreImageByImageIdAndSessionId

          public Image getScoreImageByImageIdAndSessionId(int imageId,
                                                          int sessionId)
                                                   throws DAOImageException

      Description copied from interface: `DAOImage`
      Queries for the score image data for specific image in a specific session.
      Specified by:
        `getScoreImageByImageIdAndSessionId` in interface `DAOImage`
      Parameters:
        `imageId` - ID of the image to get the score image data from.
        `sessionId` - Id of the session, the score image of the drawing was generated.
      Returns:
        Image object that contains the score image data for a given imageId and sessionId. If image is not found, an empty Image object is returned.
      Throws:
        `DAOImageException` - When the query fails, a DAOImageException is thrown.