if (originalContact != null) {
ActionContext context = ActionContext.getContext();
Map<String, Object> session = context.getSession();
String entityName = Contact.class.getSimpleName();
Integer recordID = contact.getId();
User loginUser = (User) session
.get(AuthenticationSuccessListener.LOGIN_USER);
changeLogs = new ArrayList<ChangeLog>();
String oldSalutation = getOptionValue(originalContact
.getSalutation());
String newSalutation = getOptionValue(contact.getSalutation());
createChangeLog(changeLogs, entityName, recordID,
"menu.salutation.title", oldSalutation, newSalutation,
loginUser);
String oldFirstName = CommonUtil.fromNullToEmpty(originalContact
.getFirst_name());
String newFirstName = CommonUtil.fromNullToEmpty(contact
.getFirst_name());
createChangeLog(changeLogs, entityName, recordID,
"entity.first_name.label", oldFirstName, newFirstName,
loginUser);
String oldLastName = CommonUtil.fromNullToEmpty(originalContact
.getLast_name());
String newLastName = CommonUtil.fromNullToEmpty(contact
.getLast_name());
createChangeLog(changeLogs, entityName, recordID,
"entity.last_name.label", oldLastName, newLastName,
loginUser);
String oldOfficePhone = CommonUtil.fromNullToEmpty(originalContact
.getOffice_phone());
String newOfficePhone = CommonUtil.fromNullToEmpty(contact
.getOffice_phone());
createChangeLog(changeLogs, entityName, recordID,
"entity.office_phone.label", oldOfficePhone,
newOfficePhone, loginUser);
String oldTitle = CommonUtil.fromNullToEmpty(originalContact
.getTitle());
String newTitle = CommonUtil.fromNullToEmpty(contact.getTitle());
createChangeLog(changeLogs, entityName, recordID,
"entity.title.label", oldTitle, newTitle, loginUser);
String oldMobile = CommonUtil.fromNullToEmpty(originalContact
.getMobile());
String newMobile = CommonUtil.fromNullToEmpty(contact.getMobile());
createChangeLog(changeLogs, entityName, recordID,
"entity.mobile.label", oldMobile, newMobile, loginUser);
String oldDepartment = CommonUtil.fromNullToEmpty(originalContact
.getDepartment());
String newDepartment = CommonUtil.fromNullToEmpty(contact
.getDepartment());
createChangeLog(changeLogs, entityName, recordID,
"entity.department.label", oldDepartment, newDepartment,
loginUser);
String oldFax = CommonUtil
.fromNullToEmpty(originalContact.getFax());
String newWFax = CommonUtil.fromNullToEmpty(contact.getFax());
createChangeLog(changeLogs, entityName, recordID,
"entity.fax.label", oldFax, newWFax, loginUser);
String oldSkypeId = CommonUtil.fromNullToEmpty(originalContact
.getSkype_id());
String newSkypeId = CommonUtil.fromNullToEmpty(contact
.getSkype_id());
createChangeLog(changeLogs, entityName, recordID,
"contact.skype_id.label", oldSkypeId, newSkypeId, loginUser);
String oldWebsite = CommonUtil.fromNullToEmpty(originalContact
.getWebsite());
String newWebsite = CommonUtil
.fromNullToEmpty(contact.getWebsite());
createChangeLog(changeLogs, entityName, recordID,
"entity.website.label", oldWebsite, newWebsite, loginUser);
String oldPrimaryStreet = CommonUtil
.fromNullToEmpty(originalContact.getPrimary_street());
String newPrimaryStreet = CommonUtil.fromNullToEmpty(contact
.getPrimary_street());
createChangeLog(changeLogs, entityName, recordID,
"entity.primary_street.label", oldPrimaryStreet,
newPrimaryStreet, loginUser);
String oldPrimaryState = CommonUtil.fromNullToEmpty(originalContact
.getPrimary_state());
String newPrimaryState = CommonUtil.fromNullToEmpty(contact
.getPrimary_state());
createChangeLog(changeLogs, entityName, recordID,
"entity.primary_state.label", oldPrimaryState,
newPrimaryState, loginUser);
String oldPrimaryPostalCode = CommonUtil
.fromNullToEmpty(originalContact.getPrimary_postal_code());
String newPrimaryPostalCode = CommonUtil.fromNullToEmpty(contact
.getPrimary_postal_code());
createChangeLog(changeLogs, entityName, recordID,
"entity.primary_postal_code.label", oldPrimaryPostalCode,
newPrimaryPostalCode, loginUser);
String oldPrimaryCountry = CommonUtil
.fromNullToEmpty(originalContact.getPrimary_country());
String newPrimaryCountry = CommonUtil.fromNullToEmpty(contact
.getPrimary_country());
createChangeLog(changeLogs, entityName, recordID,
"entity.primary_country.label", oldPrimaryCountry,
newPrimaryCountry, loginUser);
String oldOtherStreet = CommonUtil.fromNullToEmpty(originalContact
.getOther_street());
String newOtherStreet = CommonUtil.fromNullToEmpty(contact
.getOther_street());
createChangeLog(changeLogs, entityName, recordID,
"entity.other_street.label", oldOtherStreet,
newOtherStreet, loginUser);
String oldOtherState = CommonUtil.fromNullToEmpty(originalContact
.getOther_state());
String newOtherState = CommonUtil.fromNullToEmpty(contact
.getOther_state());
createChangeLog(changeLogs, entityName, recordID,
"entity.other_state.label", oldOtherState, newOtherState,
loginUser);
String oldOtherPostalCode = CommonUtil
.fromNullToEmpty(originalContact.getOther_postal_code());
String newOtherPostalCode = CommonUtil.fromNullToEmpty(contact
.getOther_postal_code());
createChangeLog(changeLogs, entityName, recordID,
"entity.other_postal_code.label", oldOtherPostalCode,
newOtherPostalCode, loginUser);
String oldOtherCountry = CommonUtil.fromNullToEmpty(originalContact
.getOther_country());
String newOtherCountry = CommonUtil.fromNullToEmpty(contact
.getOther_country());
createChangeLog(changeLogs, entityName, recordID,
"entity.other_country.label", oldOtherCountry,
newOtherCountry, loginUser);
String oldEmail = CommonUtil.fromNullToEmpty(originalContact
.getEmail());
String newEmail = CommonUtil.fromNullToEmpty(contact.getEmail());
createChangeLog(changeLogs, entityName, recordID,
"entity.email.label", oldEmail, newEmail, loginUser);
String oldOrigo = CommonUtil.fromNullToEmpty(originalContact
.getOrigo());
String newOrigo = CommonUtil.fromNullToEmpty(contact.getOrigo());
createChangeLog(changeLogs, entityName, recordID,
"entity.origo.label", oldOrigo, newOrigo, loginUser);
String oldHeight = String.valueOf(originalContact.getHeight());
String newHeight = String.valueOf(contact.getHeight());
createChangeLog(changeLogs, entityName, recordID,
"entity.height.label", oldHeight, newHeight, loginUser);
String oldWeight = String.valueOf(originalContact.getWeight());
String newWeight = String.valueOf(contact.getWeight());
createChangeLog(changeLogs, entityName, recordID,
"entity.weight.label", oldWeight, newWeight, loginUser);
String oldRelationship = CommonUtil.fromNullToEmpty(originalContact
.getRelationship());
String newRelationship = CommonUtil.fromNullToEmpty(contact
.getRelationship());
createChangeLog(changeLogs, entityName, recordID,
"entity.relationship.label", oldRelationship,
newRelationship, loginUser);
String oldCharacter = CommonUtil.fromNullToEmpty(originalContact
.getCharacter());
String newCharacter = CommonUtil.fromNullToEmpty(contact
.getCharacter());
createChangeLog(changeLogs, entityName, recordID,
"entity.character.label", oldCharacter, newCharacter,
loginUser);
String oldInterest = CommonUtil.fromNullToEmpty(originalContact
.getInterest());
String newInterest = CommonUtil.fromNullToEmpty(contact
.getInterest());
createChangeLog(changeLogs, entityName, recordID,
"entity.interest.label", oldInterest, newInterest,
loginUser);
String oldTaboo = CommonUtil.fromNullToEmpty(originalContact
.getTaboo());
String newTaboo = CommonUtil.fromNullToEmpty(contact.getTaboo());
createChangeLog(changeLogs, entityName, recordID,
"entity.taboo.label", oldTaboo, newTaboo, loginUser);
String oldReligious = getOptionValue(originalContact.getReligious());
String newReligious = getOptionValue(contact.getReligious());
createChangeLog(changeLogs, entityName, recordID,
"entity.religious.label", oldReligious, newReligious,
loginUser);
String oldHabit = CommonUtil.fromNullToEmpty(originalContact
.getHabit());
String newHabit = CommonUtil.fromNullToEmpty(contact.getHabit());
createChangeLog(changeLogs, entityName, recordID,
"entity.habit.label", oldHabit, newHabit, loginUser);
String oldDiet = CommonUtil.fromNullToEmpty(originalContact
.getDiet());
String newDiet = CommonUtil.fromNullToEmpty(contact.getDiet());
createChangeLog(changeLogs, entityName, recordID,
"entity.diet.label", oldDiet, newDiet, loginUser);
String oldNotes = CommonUtil.fromNullToEmpty(originalContact
.getNotes());
String newNotes = CommonUtil.fromNullToEmpty(contact.getNotes());
createChangeLog(changeLogs, entityName, recordID,
"entity.notes.label", oldNotes, newNotes, loginUser);
String oldReportToName = "";
Contact oldReportTo = originalContact.getReport_to();
if (oldReportTo != null) {
oldReportToName = CommonUtil.fromNullToEmpty(oldReportTo
.getName());
}
String newReportToName = "";
Contact newReportTo = contact.getReport_to();
if (newReportTo != null) {
newReportToName = CommonUtil.fromNullToEmpty(newReportTo
.getName());
}
createChangeLog(changeLogs, entityName, recordID,
"contact.report_to.label", oldReportToName,
newReportToName, loginUser);
String oldAccountName = "";
Account oldAccount = originalContact.getAccount();
if (oldAccount != null) {
oldAccountName = CommonUtil.fromNullToEmpty(oldAccount
.getName());
}
String newAccountName = "";
Account newAccount = contact.getAccount();
if (newAccount != null) {
newAccountName = CommonUtil.fromNullToEmpty(newAccount
.getName());
}
createChangeLog(changeLogs, entityName, recordID,
"entity.account.label", oldAccountName, newAccountName,
loginUser);
boolean oldNotCall = originalContact.isNot_call();
boolean newNotCall = contact.isNot_call();
createChangeLog(changeLogs, entityName, recordID,
"entity.not_call.label", String.valueOf(oldNotCall),
String.valueOf(newNotCall), loginUser);
String oldLeadSource = getOptionValue(originalContact
.getLeadSource());
String newLeadSource = getOptionValue(contact.getLeadSource());
createChangeLog(changeLogs, entityName, recordID,
"menu.leadSource.title", oldLeadSource, newLeadSource,
loginUser);
String oldCampaignName = "";
Campaign oldCampaign = originalContact.getCampaign();
if (oldCampaign != null) {
oldCampaignName = oldCampaign.getName();
}
String newCampaignName = "";
Campaign newCampaign = contact.getCampaign();
if (newCampaign != null) {
newCampaignName = newCampaign.getName();
}
createChangeLog(changeLogs, entityName, recordID,
"entity.campaign.label",
CommonUtil.fromNullToEmpty(oldCampaignName),
CommonUtil.fromNullToEmpty(newCampaignName), loginUser);
String oldAssignedToName = "";
User oldAssignedTo = originalContact.getAssigned_to();
if (oldAssignedTo != null) {
oldAssignedToName = oldAssignedTo.getName();
}
String newAssignedToName = "";
User newAssignedTo = contact.getAssigned_to();
if (newAssignedTo != null) {
newAssignedToName = newAssignedTo.getName();
}
createChangeLog(changeLogs, entityName, recordID,
"entity.assigned_to.label",
CommonUtil.fromNullToEmpty(oldAssignedToName),
CommonUtil.fromNullToEmpty(newAssignedToName), loginUser);