if (originalDocument != null) {
ActionContext context = ActionContext.getContext();
Map<String, Object> session = context.getSession();
String entityName = Document.class.getSimpleName();
Integer recordID = document.getId();
User loginUser = (User) session
.get(AuthenticationSuccessListener.LOGIN_USER);
changeLogs = new ArrayList<ChangeLog>();
String oldName = CommonUtil.fromNullToEmpty(originalDocument
.getName());
String newName = CommonUtil.fromNullToEmpty(document.getName());
createChangeLog(changeLogs, entityName, recordID,
"entity.name.label", oldName, newName, loginUser);
String oldFileName = CommonUtil.fromNullToEmpty(originalDocument
.getFileName());
String newFileName = CommonUtil.fromNullToEmpty(document
.getFileName());
createChangeLog(changeLogs, entityName, recordID,
"document.file.label", oldFileName, newFileName, loginUser);
String oldRevision = String.valueOf(originalDocument.getRevision());
String newRevision = String.valueOf(document.getRevision());
createChangeLog(changeLogs, entityName, recordID,
"document.revision.label", oldRevision, newRevision,
loginUser);
SimpleDateFormat dateFormat = new SimpleDateFormat(
Constant.DATE_EDIT_FORMAT);
String oldPublishDateValue = "";
Date oldPublishDate = originalDocument.getPublish_date();
if (oldPublishDate != null) {
oldPublishDateValue = dateFormat.format(oldPublishDate);
}
String newPublishDateValue = "";
Date newPublishDate = document.getPublish_date();
if (newPublishDate != null) {
newPublishDateValue = dateFormat.format(newPublishDate);
}
createChangeLog(changeLogs, entityName, recordID,
"document.publish_date.label", oldPublishDateValue,
newPublishDateValue, loginUser);
String oldExpirationDateValue = "";
Date oldExpirationDate = originalDocument.getExpiration_date();
if (oldExpirationDate != null) {
oldExpirationDateValue = dateFormat.format(oldExpirationDate);
}
String newExpirationDateValue = "";
Date newExpirationDate = document.getExpiration_date();
if (newExpirationDate != null) {
newExpirationDateValue = dateFormat.format(newExpirationDate);
}
createChangeLog(changeLogs, entityName, recordID,
"document.expiration_date.label", oldExpirationDateValue,
newExpirationDateValue, loginUser);
String oldCategory = getOptionValue(originalDocument.getCategory());
String newCategory = getOptionValue(document.getCategory());
createChangeLog(changeLogs, entityName, recordID,
"document.category.label", oldCategory, newCategory,
loginUser);
String oldSubCategory = getOptionValue(originalDocument
.getSub_category());
String newSubCategory = getOptionValue(document.getSub_category());
createChangeLog(changeLogs, entityName, recordID,
"document.sub_category.label", oldSubCategory,
newSubCategory, loginUser);
String oldRelatedDocumentName = "";
Document oldRelatedDocument = originalDocument
.getRelated_document();
if (oldRelatedDocument != null) {
oldRelatedDocumentName = CommonUtil
.fromNullToEmpty(oldRelatedDocument.getName());
}
String newRelatedDocumentName = "";
Document newRelatedDocument = document.getRelated_document();
if (newRelatedDocument != null) {
newRelatedDocumentName = CommonUtil
.fromNullToEmpty(newRelatedDocument.getName());
}
createChangeLog(changeLogs, entityName, recordID,
"document.related_document.label", oldRelatedDocumentName,
newRelatedDocumentName, loginUser);
String oldNotes = CommonUtil.fromNullToEmpty(originalDocument
.getNotes());
String newNotes = CommonUtil.fromNullToEmpty(document.getNotes());
createChangeLog(changeLogs, entityName, recordID,
"entity.notes.label", oldNotes, newNotes, loginUser);
String oldAssignedToName = "";
User oldAssignedTo = originalDocument.getAssigned_to();
if (oldAssignedTo != null) {
oldAssignedToName = oldAssignedTo.getName();
}
String newAssignedToName = "";
User newAssignedTo = document.getAssigned_to();
if (newAssignedTo != null) {
newAssignedToName = newAssignedTo.getName();
}
createChangeLog(changeLogs, entityName, recordID,
"entity.assigned_to.label",
CommonUtil.fromNullToEmpty(oldAssignedToName),
CommonUtil.fromNullToEmpty(newAssignedToName), loginUser);