|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vodafone360.people.database.tables.ContactsTable
public abstract class ContactsTable
Contains all the functionality related to the Contacts database table. This
table only contains high level information for a contact. Each contact
contains many contact details (see ContactDetailsTable
), these
details include name, phone number, address, etc. This class is never
instantiated hence all methods must be static.
Nested Class Summary | |
---|---|
static class |
ContactsTable.ContactIdInfo
Contains ID information used to identify a contact. |
private static class |
ContactsTable.Field
An enumeration of all the field names in the database. |
Field Summary | |
---|---|
private static int |
ABOUTME
|
private static int |
CONTACTID
|
private static int |
FRIEND
|
private static int |
GENDER
|
private static int |
LOCALID
Column indices which match the query string returned by getQueryStringSql(String) . |
private static int |
NATIVE_CONTACTID
|
private static java.lang.String |
QUERY_CONTACT_NATIVE_ID_FROM_LOCAL_ID
SQL query string to get the contact native id from its local id. |
private static java.lang.String |
QUERY_NATIVE_CONTACTS_IDS
SELECT NativeContactId FROM ContactsTable WHERE NativeContactId IS NOT NULL ORDER BY NativeContactId |
private static java.lang.String |
SQL_STRING_LOCAL_ID_EQUAL_QUESTION_MARK
String equal to "LocalId = ?" |
private static int |
SYNCTOPHONE
|
static java.lang.String |
TABLE_NAME
The name of the table as it appears in the database. |
private static int |
UPDATED
|
private static int |
USERID
|
Constructor Summary | |
---|---|
ContactsTable()
|
Method Summary | |
---|---|
static ServiceStatus |
addContact(Contact contact,
SQLiteDatabase writeableDb)
Adds a contact to the table. |
static long |
addContact(ContentValues contact,
SQLiteDatabase writeableDb)
Adds the provided contact. |
static void |
create(SQLiteDatabase writeableDb)
Create Contacts Table. |
static ServiceStatus |
deleteContact(long localContactID,
SQLiteDatabase writeableDb)
Deletes a contact from the Contacts table. |
static ServiceStatus |
fetchContact(long localContactId,
Contact contact,
SQLiteDatabase readableDb)
Fetches a contact from the database. |
static ContactsTable.ContactIdInfo |
fetchContactIdFromNative(int nativeContactId,
SQLiteDatabase readableDb)
Searches for a contact based on native ID and if found, returns the ID information |
static java.util.List<Contact> |
fetchContactList(SQLiteDatabase readableDB)
Fetches a List with Contacts from Database Uses the persistence helper to build the objects The Contactdetails are not read, only the contacts |
static ServiceStatus |
fetchContactServerIdList(java.util.ArrayList<java.lang.Long> orderedServerIdList,
SQLiteDatabase readableDb)
Returns a complete list of server IDs from the Contacts table in ascending order. |
static java.lang.Long |
fetchLocalFromNativeId(java.lang.Integer nativeContactId,
SQLiteStatement statement)
Finds a native ID in the table |
static SQLiteStatement |
fetchLocalFromNativeIdStatement(SQLiteDatabase readableDb)
Provides a statement that can be used to find a contact native ID in the table |
static java.lang.Long |
fetchLocalFromServerId(java.lang.Long contactServerId,
SQLiteStatement statement)
Searches the table for a contact server ID and if found, returns the local ID |
static SQLiteStatement |
fetchLocalFromServerIdStatement(SQLiteDatabase readableDb)
Provides a statement that can be used to find a contact server ID in the table |
static long |
fetchLocalIdFromUserId(java.lang.Long userId,
SQLiteDatabase readableDb)
|
private static java.lang.Integer |
fetchNativeFromLocalId(java.lang.Long localContactId,
SQLiteStatement statement)
Returns the native ID associated with a contact |
private static SQLiteStatement |
fetchNativeFromLocalIdStatement(SQLiteDatabase readableDb)
Provides a statement that can be used to find a contact native ID in the table |
static java.lang.Long |
fetchServerId(java.lang.Long localContactId,
SQLiteDatabase readableDb)
Finds the server ID associated with a contact |
protected static boolean |
fetchSyncToPhone(long localContactId,
SQLiteDatabase readableDb)
Fetches the syncToPhone flag for a particular contact. |
static long |
fetchUserIdFromLocalContactId(java.lang.Long localContactId,
SQLiteDatabase readableDb)
|
private static ContentValues |
fillUpdateData(Contact contact)
Returns a ContentValues object that can be used to insert or modify a contact 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 long |
getNativeContactId(long localContactId,
SQLiteDatabase readableDb)
Gets the native contact id. |
static long[] |
getNativeContactsIds(SQLiteDatabase readableDb)
Gets a list of native ids for the contacts. |
static ContentValues |
getNativeContentValues(ContactChange contactChange)
Gets the native related ContentValues for the provided ContactChange. |
private static void |
getQueryData(Cursor c,
Contact contact)
Reads a cursor at its current position to populate a Contact object |
private static java.lang.String |
getQueryStringSql(java.lang.String whereClause)
Returns a full SQL query statement to fetch the contact information. |
static ServiceStatus |
modifyContact(Contact contact,
SQLiteDatabase writableDb)
Updates contact information. |
static boolean |
modifyContactServerId(long localContactId,
java.lang.Long serverId,
java.lang.Long userId,
SQLiteDatabase writeableDb)
Modifies the contact server ID and user ID stored in the contacts table. |
static Cursor |
openContactsCursor(SQLiteDatabase readableDb)
Selects all contacts from the contacts table |
static boolean |
setNativeContactId(long localContactId,
long nativeContactId,
SQLiteDatabase writableDb)
Sets the native contact id for a contact. |
static ServiceStatus |
syncSetNativeIds(java.util.List<ContactsTable.ContactIdInfo> contactIdList,
SQLiteDatabase writableDb)
Updates the native IDs for a list of contacts. |
static ServiceStatus |
syncSetServerIds(java.util.List<DatabaseHelper.ServerIdInfo> serverIdList,
java.util.List<ContactsTable.ContactIdInfo> dupList,
SQLiteDatabase writableDb)
Updates the server and user IDs for a list of contacts. |
static ContactsTable.ContactIdInfo |
validateContactId(long localContactId,
SQLiteDatabase readableDb)
Validates a contact exists and returns the relevant contact id information. |
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 int LOCALID
getQueryStringSql(String)
.
private static final int CONTACTID
private static final int USERID
private static final int ABOUTME
private static final int FRIEND
private static final int GENDER
private static final int UPDATED
private static final int NATIVE_CONTACTID
private static final int SYNCTOPHONE
private static final java.lang.String QUERY_NATIVE_CONTACTS_IDS
private static final java.lang.String QUERY_CONTACT_NATIVE_ID_FROM_LOCAL_ID
private static final java.lang.String SQL_STRING_LOCAL_ID_EQUAL_QUESTION_MARK
Constructor Detail |
---|
public ContactsTable()
Method Detail |
---|
public static void create(SQLiteDatabase writeableDb) throws SQLException
writeableDb
- A writable SQLite database
SQLException
- If an SQL compilation error occursprivate static java.lang.String getFullQueryList()
getQueryData(Cursor, Contact)
method can be used
to obtain the data from the query.
private static java.lang.String getQueryStringSql(java.lang.String whereClause)
getQueryData(Cursor, Contact)
method can be used to obtain the
data from the query.
whereClause
- An SQL where clause (without the "WHERE"). Cannot be
null.
private static void getQueryData(Cursor c, Contact contact)
c
- A cursor returned from a SELECT query on the projection returned
by getFullQueryList()
.contact
- An newly constructed Contact object that will be filled
in.private static ContentValues fillUpdateData(Contact contact)
contact
- The source contact object
public static ContactsTable.ContactIdInfo validateContactId(long localContactId, SQLiteDatabase readableDb)
localContactId
- The local Id of the contact to findreadableDb
- Readable database object
public static ServiceStatus deleteContact(long localContactID, SQLiteDatabase writeableDb)
localContactID
- The primary key ID of the contactwriteableDb
- Writeable SQLite database
public static boolean modifyContactServerId(long localContactId, java.lang.Long serverId, java.lang.Long userId, SQLiteDatabase writeableDb)
localContactId
- The primary key ID of the contactserverId
- The new server IDuserId
- The nwe user IDwriteableDb
- Writeable SQLite database
public static ContactsTable.ContactIdInfo fetchContactIdFromNative(int nativeContactId, SQLiteDatabase readableDb)
nativeContactId
- The native contact ID to search forreadableDb
- Readable SQLite database
public static ServiceStatus addContact(Contact contact, SQLiteDatabase writeableDb)
fillUpdateData(Contact)
for
which fields from the Contact object are read.
contact
- The source Contact objectwriteableDb
- Writeable SQLite database
public static java.lang.Long fetchServerId(java.lang.Long localContactId, SQLiteDatabase readableDb)
localContactId
- The primary key ID of the contact to findreadableDb
- Readable SQLite database
public static ServiceStatus modifyContact(Contact contact, SQLiteDatabase writableDb)
fillUpdateData(Contact)
for
which fields from the Contact object are read.
contact
- The source contact objectwriteableDb
- Writeable SQLite database
public static ServiceStatus fetchContact(long localContactId, Contact contact, SQLiteDatabase readableDb)
localContactId
- The primary key ID of the contact to findcontact
- A newly created contact object that will be populated by
this function.readableDb
- Readable SQLite database
public static ServiceStatus fetchContactServerIdList(java.util.ArrayList<java.lang.Long> orderedServerIdList, SQLiteDatabase readableDb)
orderedServerIdList
- A list that will be populated with the ordered
server IDsreadableDb
- Readable SQLite database
public static SQLiteStatement fetchLocalFromServerIdStatement(SQLiteDatabase readableDb)
readableDb
- Readable SQLite database
fetchLocalFromServerId(Long, SQLiteStatement)
public static java.lang.Long fetchLocalFromServerId(java.lang.Long contactServerId, SQLiteStatement statement)
contactServerId
- The server IDstatement
- The statement returned by
fetchLocalFromServerIdStatement(SQLiteDatabase)
fetchLocalFromServerIdStatement(SQLiteDatabase)
public static ServiceStatus syncSetServerIds(java.util.List<DatabaseHelper.ServerIdInfo> serverIdList, java.util.List<ContactsTable.ContactIdInfo> dupList, SQLiteDatabase writableDb)
ContactIdInfo#mergedLocalId
).
serverIdList
- A list of ServerIdInfo objects. For each object, the
local ID must match a local contact ID in the table. The
Server ID and User ID will be used for the update.dupList
- On return this will be populated with a list of contacts
which have server IDs already present in the table.writeableDb
- Writeable SQLite database
public static ServiceStatus syncSetNativeIds(java.util.List<ContactsTable.ContactIdInfo> contactIdList, SQLiteDatabase writableDb)
contactIdList
- A list of ContactIdInfo objects. For each object,
the local ID must match a local contact ID in the table. The
Native ID will be used for the update. Other fields are
unused.writeableDb
- Writeable SQLite database
public static SQLiteStatement fetchLocalFromNativeIdStatement(SQLiteDatabase readableDb)
readableDb
- Readable SQLite database
fetchLocalFromNativeId(Integer, SQLiteStatement)
public static java.lang.Long fetchLocalFromNativeId(java.lang.Integer nativeContactId, SQLiteStatement statement)
nativeContactId
- The native ID to findstatement
- The statement returned by
fetchLocalFromNativeIdStatement(SQLiteDatabase)
.
fetchLocalFromNativeIdStatement(SQLiteDatabase)
protected static boolean fetchSyncToPhone(long localContactId, SQLiteDatabase readableDb)
localContactId
- The primary key ID of the contact to findreadableDb
- Readable SQLite database
private static SQLiteStatement fetchNativeFromLocalIdStatement(SQLiteDatabase readableDb)
readableDb
- Readable SQLite database
fetchNativeFromLocalId(Long, SQLiteStatement)
private static java.lang.Integer fetchNativeFromLocalId(java.lang.Long localContactId, SQLiteStatement statement)
localContactId
- The primary key ID of the contact to findstatement
- The statement provided by
fetchNativeFromLocalIdStatement(SQLiteDatabase)
.
fetchNativeFromLocalIdStatement(SQLiteDatabase)
public static long fetchLocalIdFromUserId(java.lang.Long userId, SQLiteDatabase readableDb)
public static long fetchUserIdFromLocalContactId(java.lang.Long localContactId, SQLiteDatabase readableDb)
public static Cursor openContactsCursor(SQLiteDatabase readableDb)
readableDb
- A readable Database
public static java.util.List<Contact> fetchContactList(SQLiteDatabase readableDB)
readableDB
- A readable Database
public static long[] getNativeContactsIds(SQLiteDatabase readableDb)
readableDb
- the people database to query from
public static ContentValues getNativeContentValues(ContactChange contactChange)
contactChange
- the ContactChange from which to extract the native values
public static long addContact(ContentValues contact, SQLiteDatabase writeableDb)
contact
- the ContentValues representing the contact to add
public static long getNativeContactId(long localContactId, SQLiteDatabase readableDb)
localContactId
- the local id of the contactreadDatabase
- the database to read from
public static boolean setNativeContactId(long localContactId, long nativeContactId, SQLiteDatabase writableDb)
localContactId
- the local contact idnativeContactId
- the native contact id to setwritableDb
- the database where to write
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaDoc