com.vodafone360.people.database.tables
Class PresenceTable

java.lang.Object
  extended by com.vodafone360.people.database.tables.PresenceTable

public abstract class PresenceTable
extends java.lang.Object

PresenceTable... The table for storing the presence states of contacts.


Nested Class Summary
private static class PresenceTable.Field
          An enumeration of all the field names in the database, containing ID, LOCAL_CONTACT_ID, USER_ID, NETWORK_ID, NETWORK_STATUS.
 
Field Summary
private static java.lang.String DEFAULT_ERROR_MESSAGE
          The default message for the NullPointerException caused by the null instance of database passed into PresenceTable methods.
private static int LOCAL_CONTACT_ID
          The constants for column indexes in the table: LocalContactId
private static int NETWORK_ID
          The constants for column indexes in the table: NetworkId
private static int NETWORK_STATUS
          The constants for column indexes in the table: Status
static java.lang.String TABLE_NAME
          The name of the table as it appears in the database.
static int USER_ADDED
          The return types for the add/update method: if a new record was added.
private static int USER_ID
          The constants for column indexes in the table: ImAddress
static int USER_NOTADDED
          The return types for the add/update method: if an error happened and prevented the record from being added or updated.
static int USER_UPDATED
          The return types for the add/update method: if an existing record was updated.
 
Constructor Summary
PresenceTable()
           
 
Method Summary
static void create(SQLiteDatabase writableDb)
          This method creates the PresenceTable.
static User getUserPresenceByLocaContactId(long localContactId, SQLiteDatabase readableDatabase)
          This method returns user/me profile presence state.
static int setAllUsersOffline(SQLiteDatabase writableDatabase)
          The method cleans the presence table: deletes all the rows.
static int setAllUsersOfflineExceptForMe(long localContactIdOfMe, SQLiteDatabase writableDatabase)
          The method cleans the presence table: deletes all the rows, except for the given user localContactId ("Me Profile" localContactId)
static int updateUser(User user2Update, SQLiteDatabase writableDatabase)
          This method updates the user with the information from the User wrapper.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE_NAME

public static final java.lang.String TABLE_NAME
The name of the table as it appears in the database.

See Also:
Constant Field Values

USER_ADDED

public static final int USER_ADDED
The return types for the add/update method: if a new record was added.

See Also:
Constant Field Values

USER_UPDATED

public static final int USER_UPDATED
The return types for the add/update method: if an existing record was updated.

See Also:
Constant Field Values

USER_NOTADDED

public static final int USER_NOTADDED
The return types for the add/update method: if an error happened and prevented the record from being added or updated.

See Also:
Constant Field Values

LOCAL_CONTACT_ID

private static final int LOCAL_CONTACT_ID
The constants for column indexes in the table: LocalContactId

See Also:
Constant Field Values

USER_ID

private static final int USER_ID
The constants for column indexes in the table: ImAddress

See Also:
Constant Field Values

NETWORK_ID

private static final int NETWORK_ID
The constants for column indexes in the table: NetworkId

See Also:
Constant Field Values

NETWORK_STATUS

private static final int NETWORK_STATUS
The constants for column indexes in the table: Status

See Also:
Constant Field Values

DEFAULT_ERROR_MESSAGE

private static final java.lang.String DEFAULT_ERROR_MESSAGE
The default message for the NullPointerException caused by the null instance of database passed into PresenceTable methods.

See Also:
Constant Field Values
Constructor Detail

PresenceTable

public PresenceTable()
Method Detail

create

public static void create(SQLiteDatabase writableDb)
                   throws SQLException,
                          java.lang.NullPointerException
This method creates the PresenceTable.

Parameters:
writableDb - - the writable database
Throws:
SQLException - is thrown when request to create a table fails with an SQLException
java.lang.NullPointerException - if the passed in database instance is null

updateUser

public static int updateUser(User user2Update,
                             SQLiteDatabase writableDatabase)
                      throws SQLException,
                             java.lang.NullPointerException
This method updates the user with the information from the User wrapper.

Parameters:
user2Update - - User info to update
writableDatabase - - writable database
Returns:
USER_ADDED if no user with user id like the one in user2Update payload "status.getUserId()" ever existed in this table, USER_UPDATED if the user already existed in the table and has been successfully added, USER_NOT_ADDED - if user was not added.
Throws:
SQLException - if the database layer throws this exception.
java.lang.NullPointerException - if the passed in database instance is null.

getUserPresenceByLocaContactId

public static User getUserPresenceByLocaContactId(long localContactId,
                                                  SQLiteDatabase readableDatabase)
                                           throws SQLException,
                                                  java.lang.NullPointerException
This method returns user/me profile presence state.

Parameters:
localContactId - - me profile localContactId
readableDatabase - - the database to read from
Returns:
user/me profile presence state wrapped in "User" wrapper class, or NULL if the specified localContactId doesn't exist
Throws:
SQLException - if the database layer throws this exception.
java.lang.NullPointerException - if the passed in database instance is null.

setAllUsersOffline

public static int setAllUsersOffline(SQLiteDatabase writableDatabase)
                              throws java.lang.NullPointerException
The method cleans the presence table: deletes all the rows.

Parameters:
writableDatabase - - database to write to.
Returns:
the number of rows affected if a whereClause is passed in, 0 otherwise.
Throws:
java.lang.NullPointerException - if the passed in database instance is null.

setAllUsersOfflineExceptForMe

public static int setAllUsersOfflineExceptForMe(long localContactIdOfMe,
                                                SQLiteDatabase writableDatabase)
                                         throws java.lang.NullPointerException
The method cleans the presence table: deletes all the rows, except for the given user localContactId ("Me Profile" localContactId)

Parameters:
localContactIdOfMe - - the localContactId of the user (long), whose info should not be deleted
writableDatabase - - database to write to.
Returns:
the number of rows affected if a whereClause is passed in, 0 otherwise.
Throws:
java.lang.NullPointerException - if the passed in database instance is null.


JavaDoc