if (originalLead != null) {
ActionContext context = ActionContext.getContext();
Map<String, Object> session = context.getSession();
String entityName = Lead.class.getSimpleName();
Integer recordID = lead.getId();
User loginUser = (User) session
.get(AuthenticationSuccessListener.LOGIN_USER);
changeLogs = new ArrayList<ChangeLog>();
String oldSalutation = getOptionValue(originalLead.getSalutation());
String newSalutation = getOptionValue(lead.getSalutation());
createChangeLog(changeLogs, entityName, recordID,
"menu.salutation.title", oldSalutation, newSalutation,
loginUser);
String oldFirstName = CommonUtil.fromNullToEmpty(originalLead
.getFirst_name());
String newFirstName = CommonUtil.fromNullToEmpty(lead
.getFirst_name());
createChangeLog(changeLogs, entityName, recordID,
"entity.first_name.label", oldFirstName, newFirstName,
loginUser);
String oldLastName = CommonUtil.fromNullToEmpty(originalLead
.getLast_name());
String newLastName = CommonUtil
.fromNullToEmpty(lead.getLast_name());
createChangeLog(changeLogs, entityName, recordID,
"entity.last_name.label", oldLastName, newLastName,
loginUser);
String oldOfficePhone = CommonUtil.fromNullToEmpty(originalLead
.getOffice_phone());
String newOfficePhone = CommonUtil.fromNullToEmpty(lead
.getOffice_phone());
createChangeLog(changeLogs, entityName, recordID,
"entity.office_phone.label", oldOfficePhone,
newOfficePhone, loginUser);
String oldTitle = CommonUtil.fromNullToEmpty(originalLead
.getTitle());
String newTitle = CommonUtil.fromNullToEmpty(lead.getTitle());
createChangeLog(changeLogs, entityName, recordID,
"entity.title.label", oldTitle, newTitle, loginUser);
String oldMobile = CommonUtil.fromNullToEmpty(originalLead
.getMobile());
String newMobile = CommonUtil.fromNullToEmpty(lead.getMobile());
createChangeLog(changeLogs, entityName, recordID,
"entity.mobile.label", oldMobile, newMobile, loginUser);
String oldDepartment = CommonUtil.fromNullToEmpty(originalLead
.getDepartment());
String newDepartment = CommonUtil.fromNullToEmpty(lead
.getDepartment());
createChangeLog(changeLogs, entityName, recordID,
"entity.department.label", oldDepartment, newDepartment,
loginUser);
String oldFax = CommonUtil.fromNullToEmpty(originalLead.getFax());
String newWFax = CommonUtil.fromNullToEmpty(lead.getFax());
createChangeLog(changeLogs, entityName, recordID,
"entity.fax.label", oldFax, newWFax, loginUser);
String oldPrimaryStreet = CommonUtil.fromNullToEmpty(originalLead
.getPrimary_street());
String newPrimaryStreet = CommonUtil.fromNullToEmpty(lead
.getPrimary_street());
createChangeLog(changeLogs, entityName, recordID,
"entity.primary_street.label", oldPrimaryStreet,
newPrimaryStreet, loginUser);
String oldPrimaryState = CommonUtil.fromNullToEmpty(originalLead
.getPrimary_state());
String newPrimaryState = CommonUtil.fromNullToEmpty(lead
.getPrimary_state());
createChangeLog(changeLogs, entityName, recordID,
"entity.primary_state.label", oldPrimaryState,
newPrimaryState, loginUser);
String oldPrimaryPostalCode = CommonUtil
.fromNullToEmpty(originalLead.getPrimary_postal_code());
String newPrimaryPostalCode = CommonUtil.fromNullToEmpty(lead
.getPrimary_postal_code());
createChangeLog(changeLogs, entityName, recordID,
"entity.primary_postal_code.label", oldPrimaryPostalCode,
newPrimaryPostalCode, loginUser);
String oldPrimaryCountry = CommonUtil.fromNullToEmpty(originalLead
.getPrimary_country());
String newPrimaryCountry = CommonUtil.fromNullToEmpty(lead
.getPrimary_country());
createChangeLog(changeLogs, entityName, recordID,
"entity.primary_country.label", oldPrimaryCountry,
newPrimaryCountry, loginUser);
String oldOtherStreet = CommonUtil.fromNullToEmpty(originalLead
.getOther_street());
String newOtherStreet = CommonUtil.fromNullToEmpty(lead
.getOther_street());
createChangeLog(changeLogs, entityName, recordID,
"entity.other_street.label", oldOtherStreet,
newOtherStreet, loginUser);
String oldOtherState = CommonUtil.fromNullToEmpty(originalLead
.getOther_state());
String newOtherState = CommonUtil.fromNullToEmpty(lead
.getOther_state());
createChangeLog(changeLogs, entityName, recordID,
"entity.other_state.label", oldOtherState, newOtherState,
loginUser);
String oldOtherPostalCode = CommonUtil.fromNullToEmpty(originalLead
.getOther_postal_code());
String newOtherPostalCode = CommonUtil.fromNullToEmpty(lead
.getOther_postal_code());
createChangeLog(changeLogs, entityName, recordID,
"entity.other_postal_code.label", oldOtherPostalCode,
newOtherPostalCode, loginUser);
String oldOtherCountry = CommonUtil.fromNullToEmpty(originalLead
.getOther_country());
String newOtherCountry = CommonUtil.fromNullToEmpty(lead
.getOther_country());
createChangeLog(changeLogs, entityName, recordID,
"entity.other_country.label", oldOtherCountry,
newOtherCountry, loginUser);
String oldEmail = CommonUtil.fromNullToEmpty(originalLead
.getEmail());
String newEmail = CommonUtil.fromNullToEmpty(lead.getEmail());
createChangeLog(changeLogs, entityName, recordID,
"entity.email.label", oldEmail, newEmail, loginUser);
String oldNotes = CommonUtil.fromNullToEmpty(originalLead
.getNotes());
String newNotes = CommonUtil.fromNullToEmpty(lead.getNotes());
createChangeLog(changeLogs, entityName, recordID,
"entity.notes.label", oldNotes, newNotes, loginUser);
String oldLeadSource = getOptionValue(originalLead.getLead_source());
String newLeadSource = getOptionValue(lead.getLead_source());
createChangeLog(changeLogs, entityName, recordID,
"menu.leadSource.title", oldLeadSource, newLeadSource,
loginUser);
String oldLeadSourceDescription = CommonUtil
.fromNullToEmpty(originalLead.getLead_source_description());
String newLeadSourceDescription = CommonUtil.fromNullToEmpty(lead
.getLead_source_description());
createChangeLog(changeLogs, entityName, recordID,
"lead.lead_source_description.label",
oldLeadSourceDescription, newLeadSourceDescription,
loginUser);
String oldReferredBy = CommonUtil.fromNullToEmpty(originalLead
.getReferred_by());
String newReferredBy = CommonUtil.fromNullToEmpty(lead
.getLead_source_description());
createChangeLog(changeLogs, entityName, recordID,
"lead.referred_by.label", oldReferredBy, newReferredBy,
loginUser);
String oldAccountName = "";
Account oldAccount = originalLead.getAccount();
if (oldAccount != null) {
oldAccountName = CommonUtil.fromNullToEmpty(oldAccount
.getName());
}
String newAccountName = "";
Account newAccount = lead.getAccount();
if (newAccount != null) {
newAccountName = CommonUtil.fromNullToEmpty(newAccount
.getName());
}
createChangeLog(changeLogs, entityName, recordID,
"entity.account.label", oldAccountName, newAccountName,
loginUser);
boolean oldNotCall = originalLead.isNot_call();
boolean newNotCall = lead.isNot_call();
createChangeLog(changeLogs, entityName, recordID,
"entity.not_call.label", String.valueOf(oldNotCall),
String.valueOf(newNotCall), loginUser);
String oldCampaignName = "";
Campaign oldCampaign = originalLead.getCampaign();
if (oldCampaign != null) {
oldCampaignName = oldCampaign.getName();
}
String newCampaignName = "";
Campaign newCampaign = lead.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 = originalLead.getAssigned_to();
if (oldAssignedTo != null) {
oldAssignedToName = oldAssignedTo.getName();
}
String newAssignedToName = "";
User newAssignedTo = lead.getAssigned_to();
if (newAssignedTo != null) {
newAssignedToName = newAssignedTo.getName();
}
createChangeLog(changeLogs, entityName, recordID,
"entity.assigned_to.label",
CommonUtil.fromNullToEmpty(oldAssignedToName),
CommonUtil.fromNullToEmpty(newAssignedToName), loginUser);