DAOSession

com.j0h1.contour.server.dao

## Interface DAOSession

- All Known Implementing Classes:
    DAOSessionImpl

      public interface DAOSession

  Defines database access methods concerning Session objects.
  Author:
    Johannes Riedmann

- - ### Method Summary

    All Methods Instance Methods Abstract 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.

- - ### Method Detail

    - #### getTrackSessions

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

      Queries for the 10 best track sessions (sessions with the highest score) of a specific track and player in descending order (by score).
      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

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

      Queries for the 10 best custom sessions (sessions with the highest score) of a specific player in descending order (by score).
      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

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

      Persists a track session to the database.
      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

          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

      Persists a custom session to the database.
      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.