if (originalTask != null) {
ActionContext context = ActionContext.getContext();
Map<String, Object> session = context.getSession();
String entityName = Task.class.getSimpleName();
Integer recordID = task.getId();
User loginUser = (User) session
.get(AuthenticationSuccessListener.LOGIN_USER);
changeLogs = new ArrayList<ChangeLog>();
String oldSubject = CommonUtil.fromNullToEmpty(originalTask
.getSubject());
String newSubject = CommonUtil.fromNullToEmpty(task.getSubject());
createChangeLog(changeLogs, entityName, recordID,
"entity.subject.label", oldSubject, newSubject, loginUser);
String oldStatus = getOptionValue(originalTask.getStatus());
String newStatus = getOptionValue(task.getStatus());
createChangeLog(changeLogs, entityName, recordID,
"entity.status.label", oldStatus, newStatus, loginUser);
SimpleDateFormat dateFormat = new SimpleDateFormat(
Constant.DATE_EDIT_FORMAT);
String oldStartDateValue = "";
Date oldStartDate = originalTask.getStart_date();
if (oldStartDate != null) {
oldStartDateValue = dateFormat.format(oldStartDate);
}
String newStartDateValue = "";
Date newStartDate = task.getStart_date();
if (newStartDate != null) {
newStartDateValue = dateFormat.format(newStartDate);
}
createChangeLog(changeLogs, entityName, recordID,
"entity.start_date.label", oldStartDateValue,
newStartDateValue, loginUser);
String oldDueDateValue = "";
Date oldDueDate = originalTask.getDue_date();
if (oldDueDate != null) {
oldDueDateValue = dateFormat.format(oldDueDate);
}
String newDueDateValue = "";
Date newDueDate = task.getDue_date();
if (newDueDate != null) {
newDueDateValue = dateFormat.format(newDueDate);
}
createChangeLog(changeLogs, entityName, recordID,
"task.due_date.label", oldDueDateValue, newDueDateValue,
loginUser);
String oldRelatedObject = CommonUtil.fromNullToEmpty(originalTask
.getRelated_object());
String newRelatedObject = CommonUtil.fromNullToEmpty(task
.getRelated_object());
createChangeLog(changeLogs, entityName, recordID,
"entity.related_object.label", oldRelatedObject,
newRelatedObject, loginUser);
String oldRelatedRecord = String.valueOf(originalTask
.getRelated_record());
String newRelatedRecord = String.valueOf(task.getRelated_record());
createChangeLog(changeLogs, entityName, recordID,
"entity.related_record.label", oldRelatedRecord,
newRelatedRecord, loginUser);
String oldContactName = "";
Contact oldContact = originalTask.getContact();
if (oldContact != null) {
oldContactName = CommonUtil.fromNullToEmpty(oldContact
.getName());
}
String newContactName = "";
Contact newContact = task.getContact();
if (newContact != null) {
newContactName = CommonUtil.fromNullToEmpty(newContact
.getName());
}
createChangeLog(changeLogs, entityName, recordID,
"entity.contact.label", oldContactName, newContactName,
loginUser);
String oldTaskPriority = getOptionValue(originalTask.getPriority());
String newTaskPriority = getOptionValue(task.getPriority());
createChangeLog(changeLogs, entityName, recordID,
"entity.priority.label", oldTaskPriority, newTaskPriority,
loginUser);
String oldDescription = CommonUtil.fromNullToEmpty(originalTask
.getDescription());
String newDescription = CommonUtil.fromNullToEmpty(task
.getDescription());
createChangeLog(changeLogs, entityName, recordID,
"entity.description.label", oldDescription, newDescription,
loginUser);
String oldNotes = CommonUtil.fromNullToEmpty(originalTask
.getNotes());
String newNotes = CommonUtil.fromNullToEmpty(task.getNotes());
createChangeLog(changeLogs, entityName, recordID,
"entity.notes.label", oldNotes, newNotes, loginUser);
String oldAssignedToName = "";
User oldAssignedTo = originalTask.getAssigned_to();
if (oldAssignedTo != null) {
oldAssignedToName = oldAssignedTo.getName();
}
String newAssignedToName = "";
User newAssignedTo = task.getAssigned_to();
if (newAssignedTo != null) {
newAssignedToName = newAssignedTo.getName();
}
createChangeLog(changeLogs, entityName, recordID,
"entity.assigned_to.label",
CommonUtil.fromNullToEmpty(oldAssignedToName),
CommonUtil.fromNullToEmpty(newAssignedToName), loginUser);