com.oracle.email.dao

## Class MessageDAO

- java.lang.Object
- - com.oracle.email.dao.BaseDAO
  - - com.oracle.email.dao.MessageDAO

-     public class MessageDAO
      extends com.oracle.email.dao.BaseDAO

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MessageDAO()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `addMessage(com.oracle.email.to.MessageTO messageTO)` This method takes a messageTO and persist it into the Message table.
    `void` | `createTable()` Each DAO class need to define how to create the table
    `boolean` | `deleteMessage(java.lang.String messageId)` To delete a message using the primary key.
    `com.oracle.email.to.MessageTO` | `getMessage(java.lang.String messageId)` This method returns message using the primary key messageId
    `java.util.Hashtable<java.lang.String,java.util.List<com.oracle.email.to.MessageTO>>` | `getMessages(java.lang.String userId)` This method returns all the messages for userId ordered by folder name and sorted by date
    `static void` | `main(java.lang.String[] args)`

    - ### Methods inherited from class com.oracle.email.dao.BaseDAO

      `getHostPort, getKVStore, getStoreName, getTable, getTableAPI, getTableRows, setHostPort, setStoreName`

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

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

- - ### Constructor Detail

    - #### MessageDAO

          public MessageDAO()

  - ### Method Detail

    - #### createTable

          public void createTable()

      Description copied from class: `com.oracle.email.dao.BaseDAO`
      Each DAO class need to define how to create the table
      Specified by:
        `createTable` in class `com.oracle.email.dao.BaseDAO`

    - #### addMessage

          public java.lang.String addMessage(com.oracle.email.to.MessageTO messageTO)
                                      throws com.oracle.email.exception.DAOException

      This method takes a messageTO and persist it into the Message table. After that for all TO, CC, BCC it sets the email to their INBOX folder and for the sender it sets the message to SENT folder.
      Parameters:
        `messageTO` - - with all the information about the message
      Returns:
        - unique messageId
      Throws:
        `com.oracle.email.exception.DAOException` - if message fail to be persisted

    - #### deleteMessage

          public boolean deleteMessage(java.lang.String messageId)

      To delete a message using the primary key.
      Parameters:
        `messageId` - - primary key of Message table
      Returns:
        - true when successful otherwise false

    - #### getMessage

          public com.oracle.email.to.MessageTO getMessage(java.lang.String messageId)

      This method returns message using the primary key messageId
      Parameters:
        `messageId` - - primary key of the Message table
      Returns:
        MessageTO with all the information about the message.

    - #### getMessages

          public java.util.Hashtable<java.lang.String,java.util.List<com.oracle.email.to.MessageTO>> getMessages(java.lang.String userId)

      This method returns all the messages for userId ordered by folder name and sorted by date
      Parameters:
        `userId` - - primary key of user table
      Returns:
        Hashtable with key as folderName and value as list of messages ordered by date

    - #### main

          public static void main(java.lang.String[] args)