Package ru.bgcrm.dao.message

# Class MessageDAO

java.lang.Object
ru.bgcrm.dao.CommonDAO
ru.bgcrm.dao.message.MessageDAO

Direct Known Subclasses:
  `MessageSearchDAO`

public class MessageDAO extends CommonDAO
Message DAO.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class ru.bgcrm.dao.CommonDAO

  `CommonDAO.ObjectExtractor<T>, CommonDAO.RecordUpdater<T extends Id>`

- ## Field Summary

  ### Fields inherited from class ru.bgcrm.dao.CommonDAO

  `con, log, SQL_AND, SQL_DELETE, SQL_DELETE_FROM, SQL_DESC, SQL_DISTINCT, SQL_FROM, SQL_GROUP_BY, SQL_INNER_JOIN, SQL_INSERT_IGNORE_INTO, SQL_INSERT_INTO, SQL_LEFT_JOIN, SQL_LIMIT, SQL_ON_DUP_KEY_UPDATE, SQL_ORDER_BY, SQL_REPLACE, SQL_SELECT, SQL_SELECT_ALL_FROM, SQL_SELECT_COUNT_ROWS, SQL_SET, SQL_UNION_ALL, SQL_UPDATE, SQL_VALUES, SQL_VALUES_1, SQL_VALUES_2, SQL_VALUES_3, SQL_VALUES_4, SQL_VALUES_5, SQL_WHERE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MessageDAO(Connection con)`
  `MessageDAO(Connection con, DynActionForm form)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `deleteMessage(int id)`
  Deletes all message related entities and attached files.
  `void`
  `deleteProcessMessages(int processId)`
  Delete process related messages and all related to them entities.
  `static String`
  `getIsolationJoin(DynActionForm form)`
  `Message`
  `getMessageById(int id)`
  Selects a message by ID.
  `Message`
  `getMessageBySystemId(int typeId, String systemId)`
  Selects a message by system ID.
  `static Message`
  `getMessageFromRs(ResultSet rs, String prefix)`
  `Set<Integer>`
  `getMessageTags(int messageId)`
  Selects message tags.
  `List<Message>`
  `getProcessMessageList(int processId, int beforeMessageId)`
  Retrieves process message list, sorted by ID.
  `List<Message>`
  `getProcessMessageList(Set<Integer> processIds, String text)`
  Searches messages in processes.
  `Map<Integer,Set<Integer>>`
  `getProcessMessageTagMap(int processId)`
  `Map<Integer,Set<Integer>>`
  `getProcessMessageTagMap(Collection<Integer> processIds)`
  `List<Message>`
  `getUnsendMessageList(int type, int maxCount)`
  `void`
  `searchMessageList(Pageable<Message> searchResult, Integer processId, Integer typeId, Integer direction, Boolean processed, Boolean withAttach, Date dateFrom, Date dateTo, String from)`
  Deprecated.
  `void`
  `searchMessageList(Pageable<Message> searchResult, Integer processId, Integer typeId, Integer direction, Boolean processed, Boolean withAttach, Date dateFrom, Date dateTo, String from, boolean reverseOrder)`
  Deprecated.
  `void`
  `searchMessageList(Pageable<Message> searchResult, Integer processId, Integer typeId, Integer direction, Boolean processed, Boolean withAttach, Date dateFrom, Date dateTo, String from, boolean reverseOrder, Set<Integer> tagIds)`
  Deprecated.
  `void`
  `searchMessageList(Pageable<Message> searchResult, Collection<Integer> processIds, Integer typeId, Integer direction, Boolean processed, Boolean withAttach, Date dateFrom, Date dateTo, String from, boolean reverseOrder, Set<Integer> tagIds)`
  Deprecated.
  `void`
  `searchMessageList(Pageable<Message> searchResult, Collection<Integer> processIds, Set<Integer> typeIds, Integer direction, Boolean processed, Boolean withAttach, Date dateFrom, Date dateTo, String from, boolean reverseOrder, Set<Integer> tagIds)`
  Deprecated.
  `void`
  `toggleMessageTags(int messageId, Set<Integer> tagIds, boolean add)`
  Adds or removes message tags
  `void`
  `updateMessage(Message message)`
  Updates message entity.
  `void`
  `updateMessageProcess(Message message)`
  Marks a message as processed (related to process).
  `void`
  `updateMessageTags(int messageId, Set<Integer> tagIds, boolean positiveOnly)`
  Updates message tags

  ### Methods inherited from class ru.bgcrm.dao.CommonDAO

  `deleteById, foundRows, getById, getGroupedIds, getGroupedIds, getIds, getIds, getPageLimit, getPeriodSql, lastInsertId, setPeriodParamValue, setRecordCount, update, updateColumn, updateIds, updateIds, updateOrInsert`

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

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

- ## Constructor Details

  - ### MessageDAO

    public MessageDAO(Connection con)

  - ### MessageDAO

    public MessageDAO(Connection con, DynActionForm form)

- ## Method Details

  - ### getMessageById

    public Message getMessageById(int id) throws SQLException
    Selects a message by ID.
    Parameters:
      `id` -
    Returns:
    Throws:
      `SQLException`

  - ### getMessageBySystemId

    public Message getMessageBySystemId(int typeId, String systemId) throws SQLException
    Selects a message by system ID.
    Parameters:
      `typeId` -
      `systemId` -
    Returns:
    Throws:
      `SQLException`

  - ### updateMessage

    public void updateMessage(Message message) throws SQLException
    Updates message entity.
    Parameters:
      `message` -
    Throws:
      `SQLException`

  - ### updateMessageProcess

    public void updateMessageProcess(Message message) throws SQLException
    Marks a message as processed (related to process).
    Parameters:
      `message` -
    Throws:
      `SQLException`

  - ### updateMessageTags

    public void updateMessageTags(int messageId, Set<Integer> tagIds, boolean positiveOnly) throws SQLException
    Updates message tags
    Parameters:
      `messageId` - the message ID
      `tagIds` - the tag IDs
      `positiveOnly` - only positive tags will be deleted before insertion
    Throws:
      `SQLException`

  - ### toggleMessageTags

    public void toggleMessageTags(int messageId, Set<Integer> tagIds, boolean add) throws SQLException
    Adds or removes message tags
    Parameters:
      `messageId` - the message ID
      `tagIds` - the tag IDs
      `add` - add or delete
    Throws:
      `SQLException`

  - ### getMessageTags

    public Set<Integer> getMessageTags(int messageId) throws SQLException
    Selects message tags.
    Parameters:
      `messageId` -
    Returns:
    Throws:
      `SQLException`

  - ### deleteMessage

    public void deleteMessage(int id) throws Exception
    Deletes all message related entities and attached files.
    Parameters:
      `id` - the message ID.
    Throws:
      `SQLException`
      `Exception`

  - ### deleteProcessMessages

    public void deleteProcessMessages(int processId) throws SQLException
    Delete process related messages and all related to them entities.
    Parameters:
      `processId` - process ID.
    Throws:
      `SQLException`

  - ### getUnsendMessageList

    public List<Message> getUnsendMessageList(int type, int maxCount)

  - ### searchMessageList

    @Deprecated public void searchMessageList(Pageable<Message> searchResult, Integer processId, Integer typeId, Integer direction, Boolean processed, Boolean withAttach, Date dateFrom, Date dateTo, String from)
    Deprecated.
    Use `MessageSearchDAO`.

  - ### searchMessageList

    @Deprecated public void searchMessageList(Pageable<Message> searchResult, Integer processId, Integer typeId, Integer direction, Boolean processed, Boolean withAttach, Date dateFrom, Date dateTo, String from, boolean reverseOrder)
    Deprecated.
    Use `MessageSearchDAO`.

  - ### searchMessageList

    @Deprecated public void searchMessageList(Pageable<Message> searchResult, Integer processId, Integer typeId, Integer direction, Boolean processed, Boolean withAttach, Date dateFrom, Date dateTo, String from, boolean reverseOrder, Set<Integer> tagIds)
    Deprecated.
    Use `MessageSearchDAO`.

  - ### searchMessageList

    @Deprecated public void searchMessageList(Pageable<Message> searchResult, Collection<Integer> processIds, Integer typeId, Integer direction, Boolean processed, Boolean withAttach, Date dateFrom, Date dateTo, String from, boolean reverseOrder, Set<Integer> tagIds)
    Deprecated.
    Use `MessageSearchDAO`.

  - ### searchMessageList

    @Deprecated public void searchMessageList(Pageable<Message> searchResult, Collection<Integer> processIds, Set<Integer> typeIds, Integer direction, Boolean processed, Boolean withAttach, Date dateFrom, Date dateTo, String from, boolean reverseOrder, Set<Integer> tagIds)
    Deprecated.
    Use `MessageSearchDAO`.

  - ### getProcessMessageList

    public List<Message> getProcessMessageList(int processId, int beforeMessageId) throws Exception
    Retrieves process message list, sorted by ID.
    Parameters:
      `processId` - process ID.
      `beforeMessageId` - if > 0 - filter from message ID.
    Returns:
    Throws:
      `Exception`

  - ### getProcessMessageTagMap

    public Map<Integer,Set<Integer>> getProcessMessageTagMap(int processId) throws SQLException
    Throws:
      `SQLException`

  - ### getProcessMessageTagMap

    public Map<Integer,Set<Integer>> getProcessMessageTagMap(Collection<Integer> processIds) throws SQLException
    Throws:
      `SQLException`

  - ### getProcessMessageList

    public List<Message> getProcessMessageList(Set<Integer> processIds, String text) throws Exception
    Searches messages in processes.
    Parameters:
      `processIds` - process IDs.
      `text` - message substring.
    Returns:
    Throws:
      `Exception`

  - ### getIsolationJoin

    public static String getIsolationJoin(DynActionForm form)

  - ### getMessageFromRs

    public static Message getMessageFromRs(ResultSet rs, String prefix) throws SQLException
    Throws:
      `SQLException`