com.vodafone360.people.engine.presence
Class ChatDbUtils

java.lang.Object
  extended by com.vodafone360.people.engine.presence.ChatDbUtils

public class ChatDbUtils
extends java.lang.Object


Field Summary
protected static java.lang.String COLUMNS
           
 
Constructor Summary
ChatDbUtils()
           
 
Method Summary
protected static void cleanOldConversationsExceptForContact(long localContactId, DatabaseHelper dbHelper)
          This method deletes conversations older than 1 week except for those with current contact
protected static void convertUserIds(ChatMessage msg, DatabaseHelper databaseHelper)
           
protected static void deleteConversationById(java.lang.String conversationId, DatabaseHelper dbHelper)
          This method deletes the conversation with the given id from the ConversationsTable
private static void fillInContactDetails(ChatMessage msg, ActivitiesTable.TimelineSummaryItem item, DatabaseHelper databaseHelper, ActivitiesTable.TimelineSummaryItem.Type incoming)
          Remove hard code
protected static void fillMessageByLocalContactIdAndNetworkId(ChatMessage chatMessage, DatabaseHelper databaseHelper)
          This method copies the conversation id and user id into the supplied ChatMessage based on its mNetworkId and mLocalContactId
protected static void findUserIdForMessageByLocalContactIdAndNetworkId(ChatMessage msg, DatabaseHelper databaseHelper)
          This method finds the user id (360 UserId or 3rd-party network id) and sets it into the supplied chat message
static int getNumberOfUnreadChatMessagesForContactAndNetwork(long localContactId, java.lang.String network, DatabaseHelper dbHelper)
          This method returns the number of unread chat messages for this contact
protected static void saveChatMessageAsATimeline(ChatMessage message, ActivitiesTable.TimelineSummaryItem.Type type, DatabaseHelper databaseHelper)
          This method saves the supplied
protected static void updateUnsentChatMessage(DatabaseHelper dbHelper)
          This method updates the last outgoing chat message as unsent in ActivitiesTable, and removes the conversation id of this message from the ConversationsTable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLUMNS

protected static final java.lang.String COLUMNS
See Also:
Constant Field Values
Constructor Detail

ChatDbUtils

public ChatDbUtils()
Method Detail

convertUserIds

protected static void convertUserIds(ChatMessage msg,
                                     DatabaseHelper databaseHelper)

saveChatMessageAsATimeline

protected static void saveChatMessageAsATimeline(ChatMessage message,
                                                 ActivitiesTable.TimelineSummaryItem.Type type,
                                                 DatabaseHelper databaseHelper)
This method saves the supplied

Parameters:
msg -
type -
databaseHelper -

fillInContactDetails

private static void fillInContactDetails(ChatMessage msg,
                                         ActivitiesTable.TimelineSummaryItem item,
                                         DatabaseHelper databaseHelper,
                                         ActivitiesTable.TimelineSummaryItem.Type incoming)
Remove hard code

Parameters:
msg -
item -
databaseHelper -
incoming -

fillMessageByLocalContactIdAndNetworkId

protected static void fillMessageByLocalContactIdAndNetworkId(ChatMessage chatMessage,
                                                              DatabaseHelper databaseHelper)
This method copies the conversation id and user id into the supplied ChatMessage based on its mNetworkId and mLocalContactId

Parameters:
chatMessage - ChatMessage
databaseHelper - Databasehelper

findUserIdForMessageByLocalContactIdAndNetworkId

protected static void findUserIdForMessageByLocalContactIdAndNetworkId(ChatMessage msg,
                                                                       DatabaseHelper databaseHelper)
This method finds the user id (360 UserId or 3rd-party network id) and sets it into the supplied chat message

Parameters:
msg - ChatMessage - the supplied chat message
databaseHelper - DatabaseHelper - the database

deleteConversationById

protected static void deleteConversationById(java.lang.String conversationId,
                                             DatabaseHelper dbHelper)
This method deletes the conversation with the given id from the ConversationsTable

Parameters:
conversationId - String - the conversation id
dbHelper - DatabaseHelper - the database

cleanOldConversationsExceptForContact

protected static void cleanOldConversationsExceptForContact(long localContactId,
                                                            DatabaseHelper dbHelper)
This method deletes conversations older than 1 week except for those with current contact

Parameters:
localContactId - long- current contact mLocalContactId
dbHelper - DatabaseHelper - the database

getNumberOfUnreadChatMessagesForContactAndNetwork

public static int getNumberOfUnreadChatMessagesForContactAndNetwork(long localContactId,
                                                                    java.lang.String network,
                                                                    DatabaseHelper dbHelper)
This method returns the number of unread chat messages for this contact

Parameters:
localContactId - long - the contact's mLocalContactId
network - String - the specified network, @see SocialNetwork
dbHelper - Database - the database
Returns:
int - the number of unread chat messages for the specified contact

updateUnsentChatMessage

protected static void updateUnsentChatMessage(DatabaseHelper dbHelper)
This method updates the last outgoing chat message as unsent in ActivitiesTable, and removes the conversation id of this message from the ConversationsTable. So that next time when user tries to send a message a new conversation id will be requested. The message sending might fail because the conversation id might have expired (PAND-204).

Parameters:
dbHelper - DatabaseHelper - database


JavaDoc