use of com.vodafone360.people.datatypes.UserProfile in project 360-Engine-for-Android by 360.
the class SyncMeDbUtils method processMyContactDetailsChanges.
/**
* This method stores the getMyChanges() response to database - details part.
* @param dbHelper DatabaseHelper - database.
* @param currentMeProfile Contact - me profile contact.
* @param profileChanges UserProfile - the contact changes.
* @return ServiceStatus - SUCCESS if the contact changes have been successfully processed stored.
*/
private static String processMyContactDetailsChanges(final DatabaseHelper dbHelper, final Contact currentMeProfile, final UserProfile profileChanges) {
String ret = null;
final ArrayList<ContactDetail> modifiedDetailList = new ArrayList<ContactDetail>();
final ArrayList<ContactDetail> addedDetailList = new ArrayList<ContactDetail>();
final ArrayList<ContactDetail> deletedDetailList = new ArrayList<ContactDetail>();
for (ContactDetail newDetail : profileChanges.details) {
boolean found = false;
for (int i = 0; i < currentMeProfile.details.size(); i++) {
ContactDetail oldDetail = currentMeProfile.details.get(i);
if (DatabaseHelper.doDetailsMatch(newDetail, oldDetail)) {
found = true;
if (newDetail.deleted != null && newDetail.deleted.booleanValue()) {
deletedDetailList.add(oldDetail);
} else if (DatabaseHelper.hasDetailChanged(oldDetail, newDetail)) {
newDetail.localDetailID = oldDetail.localDetailID;
newDetail.localContactID = oldDetail.localContactID;
newDetail.nativeContactId = oldDetail.nativeContactId;
newDetail.nativeDetailId = oldDetail.nativeDetailId;
modifiedDetailList.add(newDetail);
if (newDetail.key == DetailKeys.PHOTO) {
dbHelper.markMeProfileAvatarChanged();
ret = newDetail.value;
}
}
break;
}
}
// in the response or the deleted flag was false we have to add the new detail to the list
if ((!found) && ((null == newDetail.deleted) || (!newDetail.deleted.booleanValue()))) {
newDetail.localContactID = currentMeProfile.localContactID;
newDetail.nativeContactId = currentMeProfile.nativeContactId;
if (newDetail.key == DetailKeys.PHOTO) {
dbHelper.markMeProfileAvatarChanged();
ret = newDetail.value;
}
addedDetailList.add(newDetail);
}
}
if (!addedDetailList.isEmpty()) {
dbHelper.syncAddContactDetailList(addedDetailList, false, false);
}
if (!modifiedDetailList.isEmpty()) {
dbHelper.syncModifyContactDetailList(modifiedDetailList, false, false);
}
if (!deletedDetailList.isEmpty()) {
dbHelper.syncDeleteContactDetailList(deletedDetailList, false, false);
}
return ret;
}
use of com.vodafone360.people.datatypes.UserProfile in project 360-Engine-for-Android by 360.
the class NowPlusDatatypesTests method testUserProfile.
public void testUserProfile() {
UserProfile input = new UserProfile();
input.userID = 50L;
input.aboutMe = "newAboutMe";
input.contactID = 10L;
input.gender = 1;
input.profilePath = "foo";
input.updated = 2L;
ContactDetail contactDetail = new ContactDetail();
contactDetail.value = "00000000";
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put("userid", input.userID);
hash.put("aboutme", input.aboutMe);
hash.put("contactid", input.contactID);
hash.put("gender", input.gender);
hash.put("profilepath", input.profilePath);
hash.put("updated", input.updated);
UserProfile output = UserProfile.createFromHashtable(hash);
assertEquals(BaseDataType.USER_PROFILE_DATA_TYPE, output.getType());
assertEquals(input.toString(), output.toString());
assertEquals(input.userID, output.userID);
assertEquals(input.aboutMe, output.aboutMe);
assertEquals(input.contactID, output.contactID);
assertEquals(input.gender, output.gender);
assertEquals(input.profilePath, output.profilePath);
assertEquals(input.updated, output.updated);
}
use of com.vodafone360.people.datatypes.UserProfile in project 360-Engine-for-Android by 360.
the class SyncMeEngine method fetchThumbnailUrlFromProfile.
/**
* Fetches the thumbnail URL if there is one in the passed profile.
*
* @param profile The profile which contains the URL of the thumbnail in its details.
*
* @return Returns the thumbnail if it was found as part of the PHOTO-detail or null if the
* passed profile was null, the PHOTO-detail was not found or all of the details in the profile
* are null.
*/
private final String fetchThumbnailUrlFromProfile(final UserProfile profile) {
if (null == profile) {
return null;
}
List<ContactDetail> details = profile.details;
if (null == details) {
return null;
}
Iterator<ContactDetail> iterator = details.iterator();
while (iterator.hasNext()) {
ContactDetail detail = iterator.next();
if (null == detail) {
continue;
}
if (ContactDetail.DetailKeys.PHOTO.equals(detail.key)) {
return detail.value;
}
}
return null;
}
use of com.vodafone360.people.datatypes.UserProfile in project 360-Engine-for-Android by 360.
the class NowPlusDatatypesTests method testContactChanges.
public void testContactChanges() {
List<Contact> contacts = new ArrayList<Contact>();
long currentServerVersion = 1;
long versionAnchor = 2;
int numberOfPages = 3;
long serverRevisionBefore = 4;
long serverRevisionAfter = 5;
Hashtable<String, Object> hashUserProfile = new Hashtable<String, Object>();
ContactChanges input = new ContactChanges();
input.mContacts = contacts;
input.mCurrentServerVersion = ((Long) currentServerVersion).intValue();
input.mVersionAnchor = ((Long) versionAnchor).intValue();
input.mNumberOfPages = numberOfPages;
input.mServerRevisionBefore = ((Long) serverRevisionBefore).intValue();
input.mServerRevisionAfter = ((Long) serverRevisionAfter).intValue();
input.mUserProfile = UserProfile.createFromHashtable(hashUserProfile);
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put("contact", contacts);
hash.put("currentserverrevision", currentServerVersion);
hash.put("serverrevisionanchor", versionAnchor);
hash.put("numpages", numberOfPages);
hash.put("serverrevisionbefore", serverRevisionBefore);
hash.put("serverrevisionafter", serverRevisionAfter);
hash.put("userprofile", hashUserProfile);
ContactChanges helper = new ContactChanges();
ContactChanges output = helper.createFromHashtable(hash);
assertEquals(input.getType(), output.getType());
assertEquals(input.toString(), output.toString());
assertEquals(input.mContacts, output.mContacts);
assertEquals(input.mCurrentServerVersion, output.mCurrentServerVersion);
assertEquals(input.mNumberOfPages, output.mNumberOfPages);
assertEquals(input.mServerRevisionBefore, output.mServerRevisionBefore);
assertEquals(input.mServerRevisionAfter, output.mServerRevisionAfter);
}
use of com.vodafone360.people.datatypes.UserProfile in project 360-Engine-for-Android by 360.
the class HessianDecoderTest method testUserProfileResponse.
@MediumTest
public void testUserProfileResponse() {
// boolean testPassed = true;
List<BaseDataType> ulist = new ArrayList<BaseDataType>();
HessianDecoder hess = new HessianDecoder();
try {
DecodedResponse resp = hess.decodeHessianByteArray(2, testUserProfileData, Type.COMMON, false, EngineId.UNDEFINED);
ulist = resp.mDataTypes;
} catch (IOException e) {
e.printStackTrace();
assertTrue("IOException thrown", false);
}
int size = ulist.size();
assertTrue(size == 1);
assertTrue(ulist.get(0) instanceof UserProfile);
}
Aggregations