if (originalCaseInstance != null) {
ActionContext context = ActionContext.getContext();
Map<String, Object> session = context.getSession();
String entityName = CaseInstance.class.getSimpleName();
Integer recordID = caseInstance.getId();
User loginUser = (User) session
.get(AuthenticationSuccessListener.LOGIN_USER);
changeLogs = new ArrayList<ChangeLog>();
String oldSubject = CommonUtil.fromNullToEmpty(originalCaseInstance
.getSubject());
String newSubject = CommonUtil.fromNullToEmpty(caseInstance
.getSubject());
createChangeLog(changeLogs, entityName, recordID,
"entity.subject.label", oldSubject, newSubject, loginUser);
String oldPriority = getOptionValue(originalCaseInstance
.getPriority());
String newPriority = getOptionValue(caseInstance.getPriority());
createChangeLog(changeLogs, entityName, recordID,
"entity.priority.label", oldPriority, newPriority,
loginUser);
String oldStatus = getOptionValue(originalCaseInstance.getStatus());
String newStatus = getOptionValue(caseInstance.getStatus());
createChangeLog(changeLogs, entityName, recordID,
"entity.status.label", oldStatus, newStatus, loginUser);
String oldAccountName = "";
Account oldAccount = originalCaseInstance.getAccount();
if (oldAccount != null) {
oldAccountName = CommonUtil.fromNullToEmpty(oldAccount
.getName());
}
String newAccountName = "";
Account newAccount = caseInstance.getAccount();
if (newAccount != null) {
newAccountName = CommonUtil.fromNullToEmpty(newAccount
.getName());
}
createChangeLog(changeLogs, entityName, recordID,
"entity.account.label", oldAccountName, newAccountName,
loginUser);
String oldType = getOptionValue(originalCaseInstance.getType());
String newType = getOptionValue(caseInstance.getType());
createChangeLog(changeLogs, entityName, recordID,
"case.type.label", oldType, newType, loginUser);
String oldOrigin = getOptionValue(originalCaseInstance.getOrigin());
String newOrigin = getOptionValue(caseInstance.getOrigin());
createChangeLog(changeLogs, entityName, recordID,
"case.origin.label", oldOrigin, newOrigin, loginUser);
String oldReason = getOptionValue(originalCaseInstance.getReason());
String newReason = getOptionValue(caseInstance.getReason());
createChangeLog(changeLogs, entityName, recordID,
"case.reason.label", oldReason, newReason, loginUser);
String oldResolution = CommonUtil
.fromNullToEmpty(originalCaseInstance.getResolution());
String newResolution = CommonUtil.fromNullToEmpty(caseInstance
.getResolution());
createChangeLog(changeLogs, entityName, recordID,
"case.resolution.label", oldResolution, newResolution,
loginUser);
String oldNotes = CommonUtil.fromNullToEmpty(originalCaseInstance
.getNotes());
String newNotes = CommonUtil.fromNullToEmpty(caseInstance
.getNotes());
createChangeLog(changeLogs, entityName, recordID,
"entity.notes.label", oldNotes, newNotes, loginUser);
String oldAssignedToName = "";
User oldAssignedTo = originalCaseInstance.getAssigned_to();
if (oldAssignedTo != null) {
oldAssignedToName = oldAssignedTo.getName();
}
String newAssignedToName = "";
User newAssignedTo = caseInstance.getAssigned_to();
if (newAssignedTo != null) {
newAssignedToName = newAssignedTo.getName();
}
createChangeLog(changeLogs, entityName, recordID,
"entity.assigned_to.label",
CommonUtil.fromNullToEmpty(oldAssignedToName),
CommonUtil.fromNullToEmpty(newAssignedToName), loginUser);