if (originalCall != null) {
ActionContext context = ActionContext.getContext();
Map<String, Object> session = context.getSession();
String entityName = Call.class.getSimpleName();
Integer recordID = call.getId();
User loginUser = (User) session
.get(AuthenticationSuccessListener.LOGIN_USER);
changeLogs = new ArrayList<ChangeLog>();
String oldSubject = CommonUtil.fromNullToEmpty(originalCall
.getSubject());
String newSubject = CommonUtil.fromNullToEmpty(call.getSubject());
createChangeLog(changeLogs, entityName, recordID,
"entity.subject.label", oldSubject, newSubject, loginUser);
String oldStatus = getOptionValue(originalCall.getStatus());
String newStatus = getOptionValue(call.getStatus());
createChangeLog(changeLogs, entityName, recordID,
"entity.status.label", oldStatus, newStatus, loginUser);
SimpleDateFormat dateFormat = new SimpleDateFormat(
Constant.DATE_EDIT_FORMAT);
String oldStartDateValue = "";
Date oldStartDate = originalCall.getStart_date();
if (oldStartDate != null) {
oldStartDateValue = dateFormat.format(oldStartDate);
}
String newStartDateValue = "";
Date newStartDate = call.getStart_date();
if (newStartDate != null) {
newStartDateValue = dateFormat.format(newStartDate);
}
createChangeLog(changeLogs, entityName, recordID,
"entity.start_date.label", oldStartDateValue,
newStartDateValue, loginUser);
String oldRelatedObject = CommonUtil.fromNullToEmpty(originalCall
.getRelated_object());
String newRelatedObject = CommonUtil.fromNullToEmpty(call
.getRelated_object());
createChangeLog(changeLogs, entityName, recordID,
"entity.related_object.label", oldRelatedObject,
newRelatedObject, loginUser);
String oldRelatedRecord = String.valueOf(originalCall
.getRelated_record());
String newRelatedRecord = String.valueOf(call.getRelated_record());
createChangeLog(changeLogs, entityName, recordID,
"entity.related_record.label", oldRelatedRecord,
newRelatedRecord, loginUser);
boolean oldReminderEmail = originalCall.isReminder_email();
boolean newReminderEmail = call.isReminder_email();
createChangeLog(changeLogs, entityName, recordID,
"entity.reminder.label", String.valueOf(oldReminderEmail),
String.valueOf(newReminderEmail), loginUser);
String oldReminderOption = getOptionValue(originalCall
.getReminder_option_email());
String newReminderOption = getOptionValue(call
.getReminder_option_email());
createChangeLog(changeLogs, entityName, recordID,
"entity.reminder_option_email_name.label",
oldReminderOption, newReminderOption, loginUser);
String oldReminderTemplateName = "";
EmailTemplate oldReminderTemplate = originalCall
.getReminder_template();
if (oldReminderTemplate != null) {
oldReminderTemplateName = CommonUtil
.fromNullToEmpty(oldReminderTemplate.getName());
}
String newReminderTemplateName = "";
EmailTemplate newReminderTemplate = call.getReminder_template();
if (newReminderTemplate != null) {
newReminderTemplateName = CommonUtil
.fromNullToEmpty(newReminderTemplate.getName());
}
createChangeLog(changeLogs, entityName, recordID,
"entity.reminder_template.label", oldReminderTemplateName,
newReminderTemplateName, loginUser);
String oldNotes = CommonUtil.fromNullToEmpty(originalCall
.getNotes());
String newNotes = CommonUtil.fromNullToEmpty(call.getNotes());
createChangeLog(changeLogs, entityName, recordID,
"entity.notes.label", oldNotes, newNotes, loginUser);
String oldAssignedToName = "";
User oldAssignedTo = originalCall.getAssigned_to();
if (oldAssignedTo != null) {
oldAssignedToName = oldAssignedTo.getName();
}
String newAssignedToName = "";
User newAssignedTo = call.getAssigned_to();
if (newAssignedTo != null) {
newAssignedToName = newAssignedTo.getName();
}
createChangeLog(changeLogs, entityName, recordID,
"entity.assigned_to.label",
CommonUtil.fromNullToEmpty(oldAssignedToName),
CommonUtil.fromNullToEmpty(newAssignedToName), loginUser);