com.vodafone360.people.database.tables
Class GroupsTable

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

public abstract class GroupsTable
extends java.lang.Object

Contains all the functionality related to the Groups database table. The groups table stores the information about each group from the server. This class is never instantiated hence all methods must be static.

Version:
%I%, %G%

Nested Class Summary
static class GroupsTable.Field
          An enumeration of all the field names in the database.
 
Field Summary
private static int COLOR
           
static long GROUP_ALL
          Special ID for the ALL group
protected static long GROUP_CONNECTED_FRIENDS
          Special ID for the connected friends group
protected static long GROUP_ONLINE
          Special ID for the ONLINE contacts group (to be added later)
protected static long GROUP_PHONEBOOK
          Special ID for the phonebook contacts group
private static int GROUPTYPE
           
private static int IMAGEBYTES
           
private static int IMAGEMIMETYPE
           
private static int ISREADONLY
           
private static int ISSMARTGROUP
           
private static int ISSYSTEMGROUP
           
private static int LOCALGROUPID
          Column indices which match the query string returned by getFullQueryList().
private static int NAME
           
private static int REQUIRESLOCALISATION
           
private static int SERVERGROUPID
           
private static java.lang.String TABLE_NAME
          The name of the table as it appears in the database.
private static int USERID
           
 
Constructor Summary
GroupsTable()
           
 
Method Summary
static ServiceStatus addGroupList(java.util.List<GroupItem> groupList, SQLiteDatabase writableDb)
          Adds list of groups to the table
static void create(Context context, SQLiteDatabase writableDb)
          Creates Groups Table and populate it with system groups.
static ServiceStatus deleteAllGroups(SQLiteDatabase writableDb)
          Removes all groups from the table.
static ServiceStatus fetchGroupList(java.util.ArrayList<GroupItem> groupList, SQLiteDatabase readableDb)
          Fetches a list of all the available groups.
private static ContentValues fillUpdateData(GroupItem group)
          Returns a ContentValues object that can be used to insert or modify a group in the table.
private static java.lang.String getFullQueryList()
          Fetches the list of table fields that can be injected into an SQL query statement.
static Cursor getGroupCursor(SQLiteDatabase readableDb)
          Fetches a cursor that can be used for browsing the groups.
static GroupItem getQueryData(Cursor c)
          Fetches the group data from the current record of the given cursor.
private static java.lang.String getQueryStringSql(java.lang.String whereClause)
          Returns a full SQL query statement to fetch a set of groups from the table.
static ServiceStatus populateSystemGroups(Context context, SQLiteDatabase writableDb)
          Populates the table if system groups that are specified in the resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE_NAME

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

See Also:
Constant Field Values

GROUP_ALL

public static final long GROUP_ALL
Special ID for the ALL group

See Also:
Constant Field Values

GROUP_ONLINE

protected static final long GROUP_ONLINE
Special ID for the ONLINE contacts group (to be added later)

See Also:
Constant Field Values

GROUP_PHONEBOOK

protected static final long GROUP_PHONEBOOK
Special ID for the phonebook contacts group

See Also:
Constant Field Values

GROUP_CONNECTED_FRIENDS

protected static final long GROUP_CONNECTED_FRIENDS
Special ID for the connected friends group

See Also:
Constant Field Values

LOCALGROUPID

private static final int LOCALGROUPID
Column indices which match the query string returned by getFullQueryList().

See Also:
Constant Field Values

SERVERGROUPID

private static final int SERVERGROUPID
See Also:
Constant Field Values

GROUPTYPE

private static final int GROUPTYPE
See Also:
Constant Field Values

ISREADONLY

private static final int ISREADONLY
See Also:
Constant Field Values

REQUIRESLOCALISATION

private static final int REQUIRESLOCALISATION
See Also:
Constant Field Values

ISSYSTEMGROUP

private static final int ISSYSTEMGROUP
See Also:
Constant Field Values

ISSMARTGROUP

private static final int ISSMARTGROUP
See Also:
Constant Field Values

USERID

private static final int USERID
See Also:
Constant Field Values

NAME

private static final int NAME
See Also:
Constant Field Values

IMAGEMIMETYPE

private static final int IMAGEMIMETYPE
See Also:
Constant Field Values

IMAGEBYTES

private static final int IMAGEBYTES
See Also:
Constant Field Values

COLOR

private static final int COLOR
See Also:
Constant Field Values
Constructor Detail

GroupsTable

public GroupsTable()
Method Detail

create

public static void create(Context context,
                          SQLiteDatabase writableDb)
                   throws SQLException
Creates Groups Table and populate it with system groups.

Parameters:
context - A context for reading strings from the resources
writeableDb - A writable SQLite database
Throws:
SQLException - If an SQL compilation error occurs

getFullQueryList

private static java.lang.String getFullQueryList()
Fetches the list of table fields that can be injected into an SQL query statement. The getQueryData(Cursor) method can be used to obtain the data from the query.

Returns:
The query string
See Also:
getQueryData(Cursor).

getQueryStringSql

private static java.lang.String getQueryStringSql(java.lang.String whereClause)
Returns a full SQL query statement to fetch a set of groups from the table. The getQueryData(Cursor) method can be used to obtain the data from the query.

Parameters:
whereClause - An SQL where clause (without the "WHERE"). Cannot be null.
Returns:
The query string
See Also:
getQueryData(Cursor).

getQueryData

public static GroupItem getQueryData(Cursor c)
Fetches the group data from the current record of the given cursor.

Parameters:
c - Cursor returned by one of the getFullQueryList() based query methods.
Returns:
Filled in GroupItem object

fillUpdateData

private static ContentValues fillUpdateData(GroupItem group)
Returns a ContentValues object that can be used to insert or modify a group in the table.

Parameters:
group - The source GroupItem object
Returns:
The ContentValues object containing the data.

fetchGroupList

public static ServiceStatus fetchGroupList(java.util.ArrayList<GroupItem> groupList,
                                           SQLiteDatabase readableDb)
Fetches a list of all the available groups.

Parameters:
groupList - A list that will be populated with the result.
readableDb - Readable SQLite database
Returns:
SUCCESS or a suitable error

addGroupList

public static ServiceStatus addGroupList(java.util.List<GroupItem> groupList,
                                         SQLiteDatabase writableDb)
Adds list of groups to the table

Parameters:
groupList - The list to add
writableDb - Writable SQLite database
Returns:
SUCCESS or a suitable error code

deleteAllGroups

public static ServiceStatus deleteAllGroups(SQLiteDatabase writableDb)
Removes all groups from the table. The populateSystemGroups(Context, SQLiteDatabase) function should be called afterwards to ensure the system groups are restored.

Parameters:
writableDb - Writable SQLite database
Returns:
SUCCESS or a suitable error code

getGroupCursor

public static Cursor getGroupCursor(SQLiteDatabase readableDb)
Fetches a cursor that can be used for browsing the groups. The getQueryData(Cursor) method can be used to fetch the data of a particular record in the cursor.

Parameters:
readableDb - Readable SQLite database
Returns:
The cursor, or null if an error occurs

populateSystemGroups

public static ServiceStatus populateSystemGroups(Context context,
                                                 SQLiteDatabase writableDb)
Populates the table if system groups that are specified in the resources.

Parameters:
context - The context for reading the app resources
writableDb - Writable SQLite database for updating the table
Returns:
SUCCESS or a suitable error code


JavaDoc