DAOSessionImpl

com.j0h1.contour.server.dao.impl

## Class DAOSessionImpl

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

- All Implemented Interfaces:
    DAOSession

      public class DAOSessionImpl
      extends AbstractDAO
      implements DAOSession

  Implementations for DAOSession.
  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
    `DAOSessionImpl()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.ArrayList<Session>` | `getCustomSessions(int playerId)` Queries for the 10 best custom sessions (sessions with the highest score) of a specific player in descending order (by score).
    `java.util.ArrayList<Session>` | `getTrackSessions(int playerId, int trackId)` Queries for the 10 best track sessions (sessions with the highest score) of a specific track and player in descending order (by score).
    `void` | `persistCustomSession(Session session, java.lang.String playername, java.lang.String originalData, java.lang.String edgeData, java.lang.String imagename, Image drawing, Image scoreImage)` Persists a custom session to the database.
    `void` | `persistTrackSession(Session session, java.lang.String playername, java.util.ArrayList<Image> drawings, java.util.ArrayList<Image> scoreImages)` Persists a track session 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

    - #### DAOSessionImpl

          public DAOSessionImpl()

  - ### Method Detail

    - #### getTrackSessions

          public java.util.ArrayList<Session> getTrackSessions(int playerId,
                                                               int trackId)
                                                        throws DAOSessionException

      Description copied from interface: `DAOSession`
      Queries for the 10 best track sessions (sessions with the highest score) of a specific track and player in descending order (by score).
      Specified by:
        `getTrackSessions` in interface `DAOSession`
      Parameters:
        `playerId` - If the playerId equals Integer.MAX_VALUE, no player will be specified and the overall top 10 sessions will be queried. If the playerId is specified and bigger than 0, the sessions for the given player are queried.
        `trackId` - ID of Track to find the top 10 sessions for.
      Returns:
        Local or global top 10 track sessions in descending order (by score). If no sessions were found, an empty list is returned.
      Throws:
        `DAOSessionException` - When the query fails, a DAOSessionException is thrown.

    - #### getCustomSessions

          public java.util.ArrayList<Session> getCustomSessions(int playerId)
                                                         throws DAOSessionException

      Description copied from interface: `DAOSession`
      Queries for the 10 best custom sessions (sessions with the highest score) of a specific player in descending order (by score).
      Specified by:
        `getCustomSessions` in interface `DAOSession`
      Parameters:
        `playerId` - ID of player to find the custom sessions from.
      Returns:
        Top 10 custom sessions of a specific player in descending order (by score). If no sessions were found, an empty list is returned.
      Throws:
        `DAOSessionException` - When the query fails, a DAOSessionException is thrown.

    - #### persistTrackSession

          public void persistTrackSession(Session session,
                                          java.lang.String playername,
                                          java.util.ArrayList<Image> drawings,
                                          java.util.ArrayList<Image> scoreImages)
                                   throws DAOSessionException

      Description copied from interface: `DAOSession`
      Persists a track session to the database.
      Specified by:
        `persistTrackSession` in interface `DAOSession`
      Parameters:
        `session` - Session object to be persisted.
        `playername` - Unique name of the player that finished the session.
        `drawings` - List of drawings.
        `scoreImages` - List of generated score images.
      Throws:
        `DAOSessionException` - When persistence fails, a DAOSessionException is thrown.

    - #### persistCustomSession

          public void persistCustomSession(Session session,
                                           java.lang.String playername,
                                           java.lang.String originalData,
                                           java.lang.String edgeData,
                                           java.lang.String imagename,
                                           Image drawing,
                                           Image scoreImage)
                                    throws DAOSessionException

      Description copied from interface: `DAOSession`
      Persists a custom session to the database.
      Specified by:
        `persistCustomSession` in interface `DAOSession`
      Parameters:
        `session` - Session object to be persisted.
        `playername` - Unique name of the player that finished the session.
        `originalData` - Base64 encoded original image data.
        `edgeData` - Base64 encoded edge image data.
        `imagename` - Name of the image the player defined before the session.
        `drawing` - Image object that contains the drawing data.
        `scoreImage` - Image object that contains the score image data and the score achieved for the image.
      Throws:
        `DAOSessionException` - When persistence fails, a DAOSessionException is thrown.