|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vodafone360.people.database.tables.NativeChangeLogTable
public abstract class NativeChangeLogTable
Contains all the functionality related to the native contact change log database table. This table is used to persist database changes that have not yet been synced to the native Android phonebook. This class is never instantiated hence all methods must be static.
Nested Class Summary | |
---|---|
static class |
NativeChangeLogTable.ContactChangeInfo
Wraps up the data present in the change log table |
static class |
NativeChangeLogTable.ContactChangeType
Enumerates the type of changes supported by this table, including: DELETE_CONTACT: A contact has been deleted from the database and needs to be deleted in the native. |
private static class |
NativeChangeLogTable.Field
An enumeration of all the field names in the database. |
Field Summary | |
---|---|
private static int |
DETAILKEY
|
private static int |
LOCALCONTACTID
|
private static int |
LOCALDETAILID
|
private static int |
NATIVECHANGEID
Column indices for database queries |
private static int |
NATIVECONTACTID
|
private static int |
NATIVEDETAILID
|
private static java.lang.String |
QUERY_DELETED_CONTACT_NATIVE_ID
|
private static java.lang.String |
QUERY_DELETED_CONTACTS_NATIVE_IDS
SELECT NativeContactId FROM NativeChangeLog WHERE ChangeType = 0 ORDER BY NativeContactId |
private static java.lang.String |
QUERY_DELETED_DETAILS
Query string to get a list of deleted details for a provided type and local id. |
static java.lang.String |
QUERY_MODIFIED_CONTACTS_LOCAL_IDS
SELECT NativeContactId FROM NativeChangeLog WHERE ChangeType = 0 ORDER BY NativeContactId |
static java.lang.String |
QUERY_MODIFIED_CONTACTS_LOCAL_IDS_NO_ORDERBY
|
private static java.lang.String |
TABLE_NAME
Name of the table as it appears in the database |
private static java.lang.String |
TEMP_CONTACT_CHANGE_LOG_ID
Secondary key which links to the primary key of the change log table |
private static java.lang.String |
TEMP_CONTACT_CHANGE_TABLE
Name of a temporary table created and used to batch the deletion of sync data from the change log table. |
private static java.lang.String |
TEMP_CONTACT_CHANGE_TABLE_ID
Primary key for the temporary table |
private static int |
TYPE
|
Constructor Summary | |
---|---|
NativeChangeLogTable()
|
Method Summary | |
---|---|
private static boolean |
addContactChange(NativeChangeLogTable.ContactChangeInfo info,
SQLiteDatabase writableDb)
Inserts a contact change into the table. |
static boolean |
addDeletedContactChange(java.lang.Long localContactId,
java.lang.Integer nativeContactId,
SQLiteDatabase writableDb)
Inserts "Delete Contact" operation into the change log. |
static boolean |
addDeletedContactDetailChange(ContactDetail detail,
SQLiteDatabase writableDb)
Inserts "Delete Contact Detail" operation into the change log. |
static void |
create(SQLiteDatabase writableDb)
Create Server Change Log Table. |
static boolean |
fetchContactChangeLog(NativeChangeLogTable.ContactChangeType type,
java.util.List<NativeChangeLogTable.ContactChangeInfo> nativeInfoList,
SQLiteDatabase readableDb)
Fetches a list of changes from the table for a specific type. |
static Cursor |
fetchContactChangeLogCursor(NativeChangeLogTable.ContactChangeType type,
SQLiteDatabase readableDb)
Fetches a list of changes from the table for a specific type. |
static long |
fetchNoOfChanges(NativeChangeLogTable.ContactChangeType type,
SQLiteDatabase readableDb)
Fetches the number of changes listed in the table. |
static long |
getDeletedContactNativeId(long localContactId,
SQLiteDatabase readableDb)
|
static long[] |
getDeletedContactsNativeIds(SQLiteDatabase readableDb)
Gets the list of native ids for the deleted contacts. |
static ContactChange[] |
getDeletedDetails(long localContactId,
SQLiteDatabase readableDb)
Gets the list of deleted details as a ContactChange array. |
static long[] |
getModifiedContactsLocalIds(SQLiteDatabase readableDb)
|
static NativeChangeLogTable.ContactChangeInfo |
getQueryData(Cursor c)
Fetches change log information from a cursor at the current position. |
private static java.lang.String |
getQueryStringSql(java.lang.String whereClause)
Fetches a comma separated list of table fields which can be used in an SQL SELECT statement as the query projection. |
static boolean |
isContactChangeInList(long nativeContactId,
NativeChangeLogTable.ContactChangeType type,
SQLiteDatabase readableDb)
|
static boolean |
isContactChangeInList(java.lang.Long localContactId,
NativeChangeLogTable.ContactChangeType type,
SQLiteDatabase readableDb)
Determines if a specific contact and change type exists in the change log. |
private static boolean |
isContactDetailChangeInList(java.lang.Long localDetailId,
NativeChangeLogTable.ContactChangeType type,
SQLiteDatabase readableDb)
Determines if a specific contact detail and change type exists in the change log. |
static boolean |
removeContactChanges(java.lang.Long localContactId,
SQLiteDatabase writableDb)
Removes all changes from the change log associated with a particular contact. |
static boolean |
removeContactDetailChanges(java.lang.Long localDetailId,
SQLiteDatabase writableDb)
Removes all changes from the change log associated with a particular contact detail. |
static boolean |
syncDeleteNativeChangeLog(java.util.List<java.lang.Long> changeIdList,
SQLiteDatabase writableDb)
Removes a list of changes from the change log table. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String TABLE_NAME
private static final java.lang.String TEMP_CONTACT_CHANGE_TABLE
private static final java.lang.String TEMP_CONTACT_CHANGE_TABLE_ID
private static final java.lang.String TEMP_CONTACT_CHANGE_LOG_ID
private static final java.lang.String QUERY_DELETED_DETAILS
getDeletedDetails(long, SQLiteDatabase)
private static final int NATIVECHANGEID
private static final int TYPE
private static final int LOCALCONTACTID
private static final int NATIVECONTACTID
private static final int LOCALDETAILID
private static final int NATIVEDETAILID
private static final int DETAILKEY
public static final java.lang.String QUERY_MODIFIED_CONTACTS_LOCAL_IDS
public static final java.lang.String QUERY_MODIFIED_CONTACTS_LOCAL_IDS_NO_ORDERBY
private static final java.lang.String QUERY_DELETED_CONTACTS_NATIVE_IDS
private static final java.lang.String QUERY_DELETED_CONTACT_NATIVE_ID
Constructor Detail |
---|
public NativeChangeLogTable()
Method Detail |
---|
public static void create(SQLiteDatabase writableDb) throws SQLException
writeableDb
- A writable SQLite database
SQLException
- If an SQL compilation error occursprivate static java.lang.String getQueryStringSql(java.lang.String whereClause)
getQueryData(Cursor)
method can used to fetch data from the
cursor.
whereClause
- A where clause (without the where) to filter the
result. Cannot be null.
public static NativeChangeLogTable.ContactChangeInfo getQueryData(Cursor c)
getQueryStringSql(String)
method should be used to make the
query.
c
- The cursor from the query
public static boolean addDeletedContactChange(java.lang.Long localContactId, java.lang.Integer nativeContactId, SQLiteDatabase writableDb)
localContactId
- Local contact ID from the Contacts tablenativeContactId
- Native contact ID. If this is null it is assumed
that the contact hasn't yet been synced with the native
phonebook, so the new contact change is removed from the log
and the function returns.writableDb
- Writable SQLite database
public static boolean addDeletedContactDetailChange(ContactDetail detail, SQLiteDatabase writableDb)
detail
- Must have a valid local contact ID, local detail ID and
key. Will not be added to the change log if the contact native
ID is null.writableDb
- Writable SQLite database
private static boolean addContactChange(NativeChangeLogTable.ContactChangeInfo info, SQLiteDatabase writableDb)
info
- contact change info. This must have a valid type field and
depending on type other fields may also be required (see
NativeChangeLogTable.ContactChangeType
).writableDb
- Writable SQLite database
public static boolean isContactChangeInList(java.lang.Long localContactId, NativeChangeLogTable.ContactChangeType type, SQLiteDatabase readableDb)
localContactId
- Local contact ID from the Contacts tabletype
- The change type to findreadableDb
- Readable SQLite database
public static boolean isContactChangeInList(long nativeContactId, NativeChangeLogTable.ContactChangeType type, SQLiteDatabase readableDb)
nativeContactId
- type
- readableDb
-
private static boolean isContactDetailChangeInList(java.lang.Long localDetailId, NativeChangeLogTable.ContactChangeType type, SQLiteDatabase readableDb)
localDetailId
- Local contact detail ID from ContactDetail tabletype
- The change type to findreadableDb
- Readable SQLite database
public static boolean removeContactChanges(java.lang.Long localContactId, SQLiteDatabase writableDb)
localContactId
- Local contact ID from the Contacts tablewritableDb
- Writable SQLite database
public static boolean removeContactDetailChanges(java.lang.Long localDetailId, SQLiteDatabase writableDb)
localDetailId
- Local contact detail ID from the Contact details
tablewritableDb
- Writable SQLite database
public static long fetchNoOfChanges(NativeChangeLogTable.ContactChangeType type, SQLiteDatabase readableDb)
type
- The type of change to count, if null all change types are
includedreadableDb
- Readable SQLite database
public static boolean syncDeleteNativeChangeLog(java.util.List<java.lang.Long> changeIdList, SQLiteDatabase writableDb)
changeIdList
- A list of contact change IDs (can be obtained from
NativeChangeLogTable.ContactChangeInfo.mNativeChangeId
.writableDb
- Writable SQLite database
public static Cursor fetchContactChangeLogCursor(NativeChangeLogTable.ContactChangeType type, SQLiteDatabase readableDb)
type
- The type of change to return (cannot be null)readableDb
- Readable SQLite database
getQueryData(Cursor)
if
successful, null otherwisepublic static boolean fetchContactChangeLog(NativeChangeLogTable.ContactChangeType type, java.util.List<NativeChangeLogTable.ContactChangeInfo> nativeInfoList, SQLiteDatabase readableDb)
type
- The type of change to returncontactChangeList
- The list to be populatedreadableDb
- Readable SQLite database
public static long[] getModifiedContactsLocalIds(SQLiteDatabase readableDb)
readableDb
-
public static long[] getDeletedContactsNativeIds(SQLiteDatabase readableDb)
readableDb
- the db to query from
public static ContactChange[] getDeletedDetails(long localContactId, SQLiteDatabase readableDb)
localContactId
- the local contact id to queryreadableDb
- the db to query from
ContactChange
public static long getDeletedContactNativeId(long localContactId, SQLiteDatabase readableDb)
localContactId
- readableDb
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaDoc