|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vodafone360.people.database.tables.ContactDetailsTable
public abstract class ContactDetailsTable
Provides a wrapper for all the operations on the Contact Details Table. Class is never instantiated, all methods and fields are static.
Nested Class Summary | |
---|---|
static class |
ContactDetailsTable.Field
Associates a constant with a field string in the People database. |
static class |
ContactDetailsTable.NativeIdInfo
Holds the Native Contact information that is stored in the database for a contact detail. |
Field Summary | |
---|---|
private static int |
COLUMN_ALT
|
private static int |
COLUMN_KEY
|
private static int |
COLUMN_KEYTYPE
|
private static int |
COLUMN_LOCALCONTACTID
|
private static int |
COLUMN_LOCALDETAILID
Identifies the columns of the data returned by getFullQueryList() |
private static int |
COLUMN_NATIVE_SYNC_CONTACT_ID
|
private static int |
COLUMN_NATIVECONTACTID
|
private static int |
COLUMN_NATIVEDETAILID
|
private static int |
COLUMN_NATIVEVAL1
|
private static int |
COLUMN_NATIVEVAL2
|
private static int |
COLUMN_NATIVEVAL3
|
private static int |
COLUMN_ORDER
|
private static int |
COLUMN_SERVER_SYNC
|
private static int |
COLUMN_SERVERDETAILID
|
private static int |
COLUMN_UPDATED
|
private static int |
COLUMN_VALUE
|
private static int |
DATA_QUERY_LENGTH
Equals the number of comma separated items returned by getFullQueryList() . |
private static java.lang.String |
QUERY_CONTACT_DETAILS_BY_LOCAL_ID
SELECT LocalContactId, DetailLocalId, NativeDetailId, NativeContactIdDup, Key, Type, StringVal, OrderNo FROM ContactDetails. |
private static java.lang.String |
QUERY_NATIVE_SYNCABLE_CONTACT_DETAILS_BY_LOCAL_ID
|
static java.lang.String |
QUERY_NATIVE_SYNCABLE_CONTACTS_LOCAL_IDS
SELECT DISTINCT LocalId FROM ContactDetails WHERE NativeSyncId IS NULL OR NativeSyncId <> -1 |
private static java.lang.String |
SQL_STRING_LOCAL_ID_EQUAL_QUESTION_MARK
LocalId = ? |
static java.lang.String |
TABLE_NAME
Name of the table in the people database. |
Constructor Summary | |
---|---|
ContactDetailsTable()
|
Method Summary | |
---|---|
static ServiceStatus |
addContactDetail(ContactDetail detail,
boolean syncToServer,
boolean syncToNative,
SQLiteDatabase writeableDb)
Adds a new contact detail to the table. |
static boolean |
addNativeContactDetails(ContactChange[] contactChange,
SQLiteDatabase writeableDb)
Adds the provided contact details to the ContactDetail table. |
static void |
create(SQLiteDatabase writeableDb)
Creates the contact detail table. |
static ServiceStatus |
deleteDetailByContactId(long localContactId,
SQLiteDatabase writeableDb)
Deletes all the contact details associated with a contact |
static boolean |
deleteDetailByDetailId(long localDetailId,
SQLiteDatabase writeableDb)
Removes a contact detail from the table |
static boolean |
doContactsMatch(Contact c,
long localContactId,
java.util.List<ContactDetailsTable.NativeIdInfo> detailIdList,
SQLiteDatabase readableDb)
Compares the details given with a specific contact in the database. |
static ServiceStatus |
fetchContactDetails(java.lang.Long localContactId,
java.util.List<ContactDetail> detailList,
SQLiteDatabase readableDb)
Fetch details for a given contact |
static boolean |
fetchContactDetailsForNative(java.util.List<ContactDetail> detailList,
ContactDetail.DetailKeys[] keyList,
boolean byDetailId,
int firstIndex,
int count,
SQLiteDatabase readableDb)
Fetches all contact details that need to be synced with the native contacts database |
static ServiceStatus |
fetchContactInfo(java.lang.String phoneNumber,
ContactDetail phoneDetail,
ContactDetail nameDetail,
SQLiteDatabase readableDb)
Finds a phone contact detail which matches a given telephone number. |
static ContactDetail |
fetchDetail(long localContactId,
ContactDetail.DetailKeys key,
SQLiteDatabase readableDb)
Fetches the first contact detail found for a contact and key. |
static ContactDetail |
fetchDetail(long localDetailId,
SQLiteDatabase readableDb)
Fetches a contact detail from the table |
static boolean |
fetchPreferredDetail(long localContactID,
int keyVal,
ContactDetail altDetail,
SQLiteDatabase readableDb)
Fetches the preferred detail to use in the contact summary when the name or status field are blank. |
private static ContentValues |
fillUpdateData(ContactDetail detail,
boolean syncToServer,
boolean syncToNative)
Extracts the suitable content values from a contact detail which can be used to update or insert a record in the table. |
static java.lang.String |
findChatIdByLocalContactIdAndNetwork(java.lang.String networkName,
long localContactId,
SQLiteDatabase readableDb)
This method finds the chat id corresponding to the wanted Alt, LocalContactId and Key fields |
private static Cursor |
findDetailByKey(java.lang.String value,
ContactDetail.DetailKeys key,
SQLiteDatabase readableDb)
Returns a cursor of all the contact details that match a specific key and value. |
static long |
findLocalContactIdByKey(java.lang.String networkName,
java.lang.String value,
ContactDetail.DetailKeys key,
SQLiteDatabase readableDb)
This method finds the localContactId corresponding to the wanted Key and StringVal fields. |
static boolean |
findNativeContact(Contact c,
SQLiteDatabase writableDb)
Searches the contact details table for a contact from the native phonebook. |
private static ServiceStatus |
fixPreferredDetail(long localContactId,
ContactDetail.DetailKeys key,
SQLiteDatabase writableDb)
Ensures that for a given key there is at least one preferred detail. |
static ServiceStatus |
fixPreferredValues(long localContactId,
SQLiteDatabase writableDb)
Fixes the phone numbers and emails of a contact to ensure that at least one of each is a preferred detail. |
static ContactChange[] |
getContactChanges(long localId,
boolean nativeSyncableOnly,
SQLiteDatabase readableDb)
Gets an array of ContactChange from the contact's local id. |
private static java.lang.String |
getFullQueryList()
Fetches the list of table fields that can be injected into an SQL query statement. |
static ContactDetail |
getQueryData(Cursor c)
Returns the contact detail for the current record in the cursor. |
private static int |
getQueryDataLength()
Returns the number of comma separated items returned by getFullQueryList() . |
static java.lang.String |
getQueryStringSql(java.lang.String whereClause)
Returns the SQL for doing a raw query on the contact details table. |
static int |
mapContactChangeFlagToInternalOrder(int flag)
Maps a ContactChange flag to a ContactDetail order. |
static int |
mapContactChangeFlagToInternalType(int flag)
Maps a ContactChange flag to a ContactDetail key type. |
static int |
mapContactChangeKeyToInternalKey(int key)
Maps a ContactChange key to a ContactDetail key. |
static int |
mapInternalKeyToContactChangeKey(int key)
Maps ContactDetail key to ContactChange key. |
static int |
mapInternalTypeAndOrderToContactChangeFlag(int type,
int order)
Maps a ContactDetail type and an order to the ContactChange flag equivalent. |
static ServiceStatus |
modifyDetail(ContactDetail detail,
boolean syncToServer,
boolean syncToNative,
SQLiteDatabase writeableDb)
Updates an existing contact detail in the table. |
static boolean |
modifyDetailNativeId(ContactDetail detail,
SQLiteDatabase writeableDb)
Updates the detail native contact information stored with the record |
static boolean |
modifyDetailServerId(long localId,
java.lang.Long serverId,
SQLiteDatabase writeableDb)
Updates the detail server ID stored with the record |
static void |
prepareNativeContactDetailInsert(ContactChange contactChange,
ContentValues values)
Fills a ContentValues object with the provided ContactChange to later be used for database insert. |
static boolean |
removePreferred(java.lang.Long localContactID,
ContactDetail.DetailKeys key,
SQLiteDatabase writableDb)
Remove all preferred details from contact for a particular key. |
static boolean |
setDetailSyncedWithNative(long localDetailId,
long nativeContactId,
long nativeDetailId,
boolean isNewlySynced,
SQLiteDatabase writableDb)
Sets the detail as synchronized with native side. |
static Cursor |
syncNativeFetchContactChanges(SQLiteDatabase readableDb,
boolean newContacts)
Fetches all the details that have changed and need to be synced with the native. |
static int |
syncNativeFetchNoOfChanges(SQLiteDatabase readableDb)
Retrieves the total number of details that have changed and need to be synced with the native database. |
static boolean |
syncNativeGetNextNewContactDetails(Cursor c,
java.util.List<Contact> contactList,
int maxContactsToFetch)
Returns the next batch of contacts which need to be added on the native database. |
static Cursor |
syncServerFetchContactChanges(SQLiteDatabase readableDb,
boolean newContacts)
Fetches all the details that have changed and need to be synced with the server. |
static int |
syncServerFetchNoOfChanges(SQLiteDatabase db)
Retrieves the total number of details that have changed and need to be synced with the server. |
static void |
syncServerGetNextNewContactDetails(Cursor c,
java.util.List<Contact> contactList,
int maxContactsToFetch)
Returns the next batch of contacts which need to be added on the server. |
static ServiceStatus |
syncSetNativeIds(java.util.List<ContactDetailsTable.NativeIdInfo> nativeIdList,
SQLiteDatabase writableDb)
Set native detail ID for all those details which require an ID. |
static ServiceStatus |
syncSetServerIds(java.util.List<DatabaseHelper.ServerIdInfo> serverIdList,
SQLiteDatabase writableDb)
Set contact detail server ID for all those details which require a server ID. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String TABLE_NAME
private static final java.lang.String QUERY_CONTACT_DETAILS_BY_LOCAL_ID
#getContactChanges(long, SQLiteDatabase)
private static final java.lang.String QUERY_NATIVE_SYNCABLE_CONTACT_DETAILS_BY_LOCAL_ID
public static final java.lang.String QUERY_NATIVE_SYNCABLE_CONTACTS_LOCAL_IDS
private static final int DATA_QUERY_LENGTH
getFullQueryList()
.
private static final int COLUMN_LOCALDETAILID
private static final int COLUMN_SERVERDETAILID
private static final int COLUMN_LOCALCONTACTID
private static final int COLUMN_KEY
private static final int COLUMN_KEYTYPE
private static final int COLUMN_VALUE
private static final int COLUMN_ALT
private static final int COLUMN_ORDER
private static final int COLUMN_UPDATED
private static final int COLUMN_NATIVECONTACTID
private static final int COLUMN_NATIVEDETAILID
private static final int COLUMN_NATIVEVAL1
private static final int COLUMN_NATIVEVAL2
private static final int COLUMN_NATIVEVAL3
private static final int COLUMN_SERVER_SYNC
private static final int COLUMN_NATIVE_SYNC_CONTACT_ID
private static final java.lang.String SQL_STRING_LOCAL_ID_EQUAL_QUESTION_MARK
Constructor Detail |
---|
public ContactDetailsTable()
Method Detail |
---|
public static void create(SQLiteDatabase writeableDb) throws SQLException
writeableDb
- The SQLite database
SQLException
- If the table already exists or the database is
corruptprivate static java.lang.String getFullQueryList()
getQueryData(Cursor)
method can be used to obtain
the data from the query.
public static java.lang.String getQueryStringSql(java.lang.String whereClause)
getQueryData(Cursor)
method can be used for fetching the data
from the resulting cursor.
whereClause
- The SQL constraint (cannot be empty or null)
private static int getQueryDataLength()
getFullQueryList()
.
public static ContactDetail getQueryData(Cursor c)
getFullQueryList()
.
The
- cursor obtained from doing the query
private static ContentValues fillUpdateData(ContactDetail detail, boolean syncToServer, boolean syncToNative)
detail
- The contact detailsyncToServer
- If true the detail needs to be synced to the server,
otherwise no sync requiredsyncToNative
- If true the detail needs to be synced with the
native, otherwise no sync required
public static ContactDetail fetchDetail(long localDetailId, SQLiteDatabase readableDb)
localDetailId
- The local ID of the required detailreadableDb
- The readable SQLite database object
public static boolean deleteDetailByDetailId(long localDetailId, SQLiteDatabase writeableDb)
localDetailId
- The local ID identifying the detailwriteableDb
- A writable SQLite database object.
public static ServiceStatus deleteDetailByContactId(long localContactId, SQLiteDatabase writeableDb)
localContactId
- The local contact ID identifying the contactwriteableDb
- A writable SQLite database object.
public static ServiceStatus addContactDetail(ContactDetail detail, boolean syncToServer, boolean syncToNative, SQLiteDatabase writeableDb)
detail
- The new detailsyncToServer
- Mark the new detail so it will be synced to the
serversyncToNative
- Mark the new detail so it will be synced to the
native databasewriteableDb
- A writable SQLite database object.
public static ServiceStatus modifyDetail(ContactDetail detail, boolean syncToServer, boolean syncToNative, SQLiteDatabase writeableDb)
detail
- The modified detail.syncToServer
- Mark the new detail so it will be synced to the
serversyncToNative
- Mark the new detail so it will be synced to the
native databasewriteableDb
- A writable SQLite database object.
public static boolean modifyDetailServerId(long localId, java.lang.Long serverId, SQLiteDatabase writeableDb)
localId
- The local detail ID identifying the recordserverId
- The new server IDwriteableDb
- A writable SQLite database object.
public static boolean modifyDetailNativeId(ContactDetail detail, SQLiteDatabase writeableDb)
detail
- The contact detail which contacts the new native
information and the local ID of the detail to be modified.writeableDb
- A writable SQLite database object.
public static boolean fetchContactDetailsForNative(java.util.List<ContactDetail> detailList, ContactDetail.DetailKeys[] keyList, boolean byDetailId, int firstIndex, int count, SQLiteDatabase readableDb)
detailList
- A list that will be populated with the contact details.keyList
- A list of keys to filter the resultbyDetailId
- true to order the details by native detail ID, false to
order by native contact IDfirstIndex
- The index of the first record to fetchcount
- The number of records to fetch (or -1 to fetch all)readableDb
- A readable SQLite database object.
public static ContactDetail fetchDetail(long localContactId, ContactDetail.DetailKeys key, SQLiteDatabase readableDb)
localContactId
- The local contact IDkey
- The contact detail key valuereadableDb
- A readable SQLite database object.
public static ServiceStatus fetchContactInfo(java.lang.String phoneNumber, ContactDetail phoneDetail, ContactDetail nameDetail, SQLiteDatabase readableDb)
phoneNumber
- The number to findphoneDetail
- An empty contact detail where the resulting phone
contact detail will be stored.nameDetail
- An empty contact detail where the resulting name
contact detail will be stored.readableDb
- A readable SQLite database object.
public static ServiceStatus fetchContactDetails(java.lang.Long localContactId, java.util.List<ContactDetail> detailList, SQLiteDatabase readableDb)
localContactId
- The local ID of the contactdetailList
- A list which will be populated with the detailsreadableDb
- A readable SQLite database object.
public static ServiceStatus syncSetServerIds(java.util.List<DatabaseHelper.ServerIdInfo> serverIdList, SQLiteDatabase writableDb)
serverIdList
- The list of contact details. This list should include
all details even the ones which don't have server IDs.writableDb
- A writable SQLite database object
public static ServiceStatus syncSetNativeIds(java.util.List<ContactDetailsTable.NativeIdInfo> nativeIdList, SQLiteDatabase writableDb)
serverIdList
- The list of contact details. This list should include
all details even the ones which don't have native IDs.writableDb
- A writable SQLite database object
public static boolean fetchPreferredDetail(long localContactID, int keyVal, ContactDetail altDetail, SQLiteDatabase readableDb)
localContactID
- The local contact IDkeyVal
- The key to fetch (normally either VCARD_PHONE or
VCARD_EMAIL).altDetail
- A contact detail object where the result will be stored.readableDb
- A readable SQLite database object
public static ServiceStatus fixPreferredValues(long localContactId, SQLiteDatabase writableDb)
localContactId
- The local Id of the contactwritableDb
- A writable SQLite database object
private static ServiceStatus fixPreferredDetail(long localContactId, ContactDetail.DetailKeys key, SQLiteDatabase writableDb)
localContactId
- The local ID of the contact.key
- The key to fix.writableDb
- A writable SQLite database object
private static Cursor findDetailByKey(java.lang.String value, ContactDetail.DetailKeys key, SQLiteDatabase readableDb)
findNativeContact(Contact, SQLiteDatabase)
method to find all the contacts by name, phone number or email.
value
- The string value to match.key
- The key to match.readableDb
- A readable SQLite database object
public static long findLocalContactIdByKey(java.lang.String networkName, java.lang.String value, ContactDetail.DetailKeys key, SQLiteDatabase readableDb) throws SQLException
value
- - StringValkey
- - KeyreadableDb
- A readable SQLite database object
SQLException
public static java.lang.String findChatIdByLocalContactIdAndNetwork(java.lang.String networkName, long localContactId, SQLiteDatabase readableDb) throws java.lang.NullPointerException, SQLException
networkName
- - network name (google,MSN)localContactId
- - localContactId of the contcatreadableDb
- A readable SQLite database object
java.lang.NullPointerException
SQLException
public static boolean doContactsMatch(Contact c, long localContactId, java.util.List<ContactDetailsTable.NativeIdInfo> detailIdList, SQLiteDatabase readableDb)
c
- Contact to comparelocalContactId
- Contact in the database to compare withdetailIdList
- A list which will be populated if a match is found.readableDb
- A readable SQLite database object
public static boolean findNativeContact(Contact c, SQLiteDatabase writableDb)
c
- The contact to matchwritableDb
- A writable SQLite database object
public static Cursor syncServerFetchContactChanges(SQLiteDatabase readableDb, boolean newContacts)
syncSetServerIds(List, SQLiteDatabase)
method is used to mark
the details as up to date, once the sync has completed.
readableDb
- A readable SQLite database objectnewContacts
- true if details associated with new contacts should be
returned, otherwise modified details are returned.
syncServerGetNextNewContactDetails(Cursor, List, int)
method.public static void syncServerGetNextNewContactDetails(Cursor c, java.util.List<Contact> contactList, int maxContactsToFetch)
syncServerFetchContactChanges(SQLiteDatabase, boolean)
method is used to retrieve the cursor initially, then this function can
be called many times until all the contacts have been fetched. When the
list returned from this method is empty the cursor has reached the end
and the sync is complete.
c
- The cursor (see description above)contactList
- Will be filled with contacts that need to be added to
the servermaxContactsToFetch
- Maximum number of contacts to return in the
list. The function can be called in a loop until all the
contacts have been retrieved.public static int syncServerFetchNoOfChanges(SQLiteDatabase db)
db
- Readable SQLiteDatabase object.
public static Cursor syncNativeFetchContactChanges(SQLiteDatabase readableDb, boolean newContacts)
syncSetNativeIds(List, SQLiteDatabase)
method is used to mark
the details as up to date, once the sync has completed.
readableDb
- A readable SQLite database objectnewContacts
- true if details associated with new contacts should be
returned, otherwise modified details are returned.
syncNativeGetNextNewContactDetails(Cursor, List, int)
method.public static boolean syncNativeGetNextNewContactDetails(Cursor c, java.util.List<Contact> contactList, int maxContactsToFetch)
syncNativeFetchContactChanges(SQLiteDatabase, boolean)
method is
used to retrieve the cursor initially, then this function can be called
many times until all the contacts have been fetched. When the list
returned from this method is empty the cursor has reached the end and the
sync is complete.
c
- The cursor (see description above)contactList
- Will be filled with contacts that need to be added to
the nativemaxContactsToFetch
- Maximum number of contacts to return in the
list. The function can be called in a loop until all the
contacts have been retrieved.
public static int syncNativeFetchNoOfChanges(SQLiteDatabase readableDb) throws SQLException
readableDb
- A readable SQLite database object
SQLException
public static boolean removePreferred(java.lang.Long localContactID, ContactDetail.DetailKeys key, SQLiteDatabase writableDb)
localContactID
- Identifies the contact in the databasekey
- The contact detail key (phone, email, address, etc.)writableDb
- A writable SQLite database objectpublic static int mapContactChangeFlagToInternalType(int flag)
flag
- the ContactChange flag to convert
ContactChange#FLAG_XXX
,
ContactDetail#DetailKeyTypes
public static int mapContactChangeFlagToInternalOrder(int flag)
flag
- the ContactChange flag to convert
ContactChange#FLAG_XXX
,
ContactDetail#ORDER_XXX
public static int mapContactChangeKeyToInternalKey(int key)
key
- the ContactChange key to convert
ContactChange#KEY_XXX
,
ContactDetail#DetailKeys
public static int mapInternalKeyToContactChangeKey(int key)
key
- the ContactDetail key to convert
ContactChange#KEY_XXX
,
ContactDetail#DetailKeys
public static int mapInternalTypeAndOrderToContactChangeFlag(int type, int order)
type
- the ContactDetail typeorder
- the ContactDetail order
ContactChange#FLAG_XXX
,
ContactDetail#ORDER_XXX
,
ContactDetail#DetailKeyTypes
public static void prepareNativeContactDetailInsert(ContactChange contactChange, ContentValues values)
contactChange
- the ContactChange to get the values fromvalues
- the ContentValues object to fillpublic static boolean addNativeContactDetails(ContactChange[] contactChange, SQLiteDatabase writeableDb)
contactChange
- the contact detailswriteableDb
- the db where to write
ContactChange
public static ContactChange[] getContactChanges(long localId, boolean nativeSyncableOnly, SQLiteDatabase readableDb)
localId
- the local id of the contact to get
ContactChange
public static boolean setDetailSyncedWithNative(long localDetailId, long nativeContactId, long nativeDetailId, boolean isNewlySynced, SQLiteDatabase writableDb)
localContactId
- the local id of the detailnativeContactId
- the native contact (only needed for added details i.e. isNewlySynced = true)nativeDetailId
- the native detail id (only needed for added details i.e. isNewlySynced = true)writableDb
- the db where to writeisNewlySynced
- true if the detail as not been synchronized before, false if this is an update
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaDoc