com.vodafone360.people.engine.meprofile
Class SyncMeDbUtils

java.lang.Object
  extended by com.vodafone360.people.engine.meprofile.SyncMeDbUtils

public class SyncMeDbUtils
extends java.lang.Object

This class is a set of utility methods called by SyncMeEngine to save/read data to/from the database.


Field Summary
private static java.lang.String PHOTO_MIME_TYPE
          Mime type for the uploaded thumbnail picture of the me profile.
private static java.lang.Long sMeProfileLocalContactId
          Me profile local contact id.
 
Constructor Summary
SyncMeDbUtils()
           
 
Method Summary
static ServiceStatus fetchMeProfile(DatabaseHelper dbHelper, Contact contact)
          This method reads Me Profile contact from the database.
static java.lang.Long getMeProfileLocalContactId(DatabaseHelper dbHelper)
          This method returns the Me Profile localContactId...
private static boolean populatePhotoDetail(DatabaseHelper dbHelper, Contact meProfile, ContactDetail detail)
          This method reads a photo data from a file into the ContactDetail...
private static void populateWithDeletedContactDetails(DatabaseHelper dbHelper, java.util.List<ContactDetail> contactDetails, java.lang.Long contactId)
          This method adds the deleted details to the detail list sent to server...
private static void populateWithModifiedDetails(DatabaseHelper dbHelper, java.util.ArrayList<ContactDetail> updates, Contact meProfile)
           
private static ServiceStatus processMyContactChanges(DatabaseHelper dbHelper, Contact currentMeProfile, UserProfile profileChanges)
          This method stores the getMyChanges() response to database - contacts part.
private static java.lang.String processMyContactDetailsChanges(DatabaseHelper dbHelper, Contact currentMeProfile, UserProfile profileChanges)
          This method stores the getMyChanges() response to database - details part.
static java.util.ArrayList<ContactDetail> saveContactDetailChanges(DatabaseHelper dbHelper, Contact meProfile)
          A utility method to save the Me Profile contact before sending the updates to backend
static void savePresenceStatusResponse(DatabaseHelper dbHelper, ContactChanges result)
          The utility method to save Contacts/setMe() response for the status text change to the database...
static ServiceStatus setMeProfile(DatabaseHelper dbHelper, Contact meProfile)
          This method create a Me Profile contact in the database.
static void setMeProfileId(java.lang.Long meProfileId)
          This method sets Me Profile localContactId...
static java.lang.String updateMeProfile(DatabaseHelper dbHelper, Contact currentMeProfile, UserProfile profileChanges)
          This method updates current Me Profile with changes from user profile.
static void updateMeProfileDbDetailIds(DatabaseHelper dbHelper, java.util.ArrayList<ContactDetail> uploadedDetails, ContactChanges result)
          The utility method to save Contacts/setMe() response to the database...
static ContactDetail updateStatus(DatabaseHelper dbHelper, java.lang.String statusText)
          The utility method to save the status text change to the database...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sMeProfileLocalContactId

private static java.lang.Long sMeProfileLocalContactId
Me profile local contact id.


PHOTO_MIME_TYPE

private static final java.lang.String PHOTO_MIME_TYPE
Mime type for the uploaded thumbnail picture of the me profile.

See Also:
Constant Field Values
Constructor Detail

SyncMeDbUtils

public SyncMeDbUtils()
Method Detail

setMeProfile

public static ServiceStatus setMeProfile(DatabaseHelper dbHelper,
                                         Contact meProfile)
This method create a Me Profile contact in the database.

Parameters:
dbHelper - DatabaseHelper - the database.
meProfile - Contact - the Me Profile contact
Returns:
ServiceStatus - ServiceStatus.SUCCESS when the new contact is successfully created.

fetchMeProfile

public static ServiceStatus fetchMeProfile(DatabaseHelper dbHelper,
                                           Contact contact)
This method reads Me Profile contact from the database.

Parameters:
dbHelper - DatabaseHelper - the database
contact - Contact - the empty (stub) contact to read into
Returns:
ServiceStatus - ServiceStatus.SUCCESS when the contact is successfully filled, ServiceStatus.ERROR_NOT_FOUND - if the Me Profile needs to be created first.

getMeProfileLocalContactId

public static java.lang.Long getMeProfileLocalContactId(DatabaseHelper dbHelper)
This method returns the Me Profile localContactId...

Parameters:
dbHelper - DatabaseHelper - the database
Returns:
Long - Me Profile localContactId.

setMeProfileId

public static void setMeProfileId(java.lang.Long meProfileId)
This method sets Me Profile localContactId...

Parameters:
meProfileId - Long - localContactID

updateMeProfile

public static java.lang.String updateMeProfile(DatabaseHelper dbHelper,
                                               Contact currentMeProfile,
                                               UserProfile profileChanges)
This method updates current Me Profile with changes from user profile.

Parameters:
dbHelper - DatabaseHelper - database
currentMeProfile - Contact - current me profile, from DB
profileChanges - - the changes to the current Me Profile
Returns:
String - the profile avatar picture url, null if no picture can be found.

processMyContactChanges

private static ServiceStatus processMyContactChanges(DatabaseHelper dbHelper,
                                                     Contact currentMeProfile,
                                                     UserProfile profileChanges)
This method stores the getMyChanges() response to database - contacts part.

Parameters:
dbHelper - DatabaseHelper - database.
currentMeProfile - Contact - me profile contact.
profileChanges - UserProfile - the contact changes.
Returns:
ServiceStatus - SUCCESS if the contact changes have been successfully processed stored.

processMyContactDetailsChanges

private static java.lang.String processMyContactDetailsChanges(DatabaseHelper dbHelper,
                                                               Contact currentMeProfile,
                                                               UserProfile profileChanges)
This method stores the getMyChanges() response to database - details part.

Parameters:
dbHelper - DatabaseHelper - database.
currentMeProfile - Contact - me profile contact.
profileChanges - UserProfile - the contact changes.
Returns:
ServiceStatus - SUCCESS if the contact changes have been successfully processed stored.

updateMeProfileDbDetailIds

public static void updateMeProfileDbDetailIds(DatabaseHelper dbHelper,
                                              java.util.ArrayList<ContactDetail> uploadedDetails,
                                              ContactChanges result)
The utility method to save Contacts/setMe() response to the database...

Parameters:
dbHelper - Database - database
uploadedMeProfile - Contact - me profile which has been uploaded in Contacts/setMe() call
result - ContactChanges - the contents of response Contacts/setMe(). The contact details in response need to be in the same order as they were in setMe() request

updateStatus

public static ContactDetail updateStatus(DatabaseHelper dbHelper,
                                         java.lang.String statusText)
The utility method to save the status text change to the database...

Parameters:
dbHelper - DatabaseHelper - database
statusText - String - status text
Returns:
ContactDetail - the modified or created ContactDetail with key ContactDetail.DetailKeys.PRESENCE_TEXT

savePresenceStatusResponse

public static void savePresenceStatusResponse(DatabaseHelper dbHelper,
                                              ContactChanges result)
The utility method to save Contacts/setMe() response for the status text change to the database...

Parameters:
dbHelper - DatabaseHelper - database.
ContactChanges - result - status text change.

saveContactDetailChanges

public static java.util.ArrayList<ContactDetail> saveContactDetailChanges(DatabaseHelper dbHelper,
                                                                          Contact meProfile)
A utility method to save the Me Profile contact before sending the updates to backend

Parameters:
dbHelper - DataBaseHelper - database
meProfile - - the new me Profile to push to server
Returns:
- ArrayList of ContactDetails to be pushed to server

populateWithModifiedDetails

private static void populateWithModifiedDetails(DatabaseHelper dbHelper,
                                                java.util.ArrayList<ContactDetail> updates,
                                                Contact meProfile)

populatePhotoDetail

private static boolean populatePhotoDetail(DatabaseHelper dbHelper,
                                           Contact meProfile,
                                           ContactDetail detail)
This method reads a photo data from a file into the ContactDetail...

Parameters:
dbHelper - DatabaseHelper - database
meProfile - Contact - me profile contact
detail - ContactDetail - the detail to write the photo into.
Returns:
boolean - TRUE if the details was read successfully.

populateWithDeletedContactDetails

private static void populateWithDeletedContactDetails(DatabaseHelper dbHelper,
                                                      java.util.List<ContactDetail> contactDetails,
                                                      java.lang.Long contactId)
This method adds the deleted details to the detail list sent to server...

Parameters:
dbHelper - DatabaseHelper - database
contactDetails - List - the deleted details list
contactId - Long - Me Profile local contact id.


JavaDoc