if (originalCampaign != null) {
ActionContext context = ActionContext.getContext();
Map<String, Object> session = context.getSession();
String entityName = Campaign.class.getSimpleName();
Integer recordID = campaign.getId();
User loginUser = (User) session
.get(AuthenticationSuccessListener.LOGIN_USER);
changeLogs = new ArrayList<ChangeLog>();
String oldName = CommonUtil.fromNullToEmpty(originalCampaign
.getName());
String newName = CommonUtil.fromNullToEmpty(campaign.getName());
createChangeLog(changeLogs, entityName, recordID,
"entity.name.label", oldName, newName, loginUser);
String oldStatus = getOptionValue(originalCampaign.getStatus());
String newStatus = getOptionValue(campaign.getStatus());
createChangeLog(changeLogs, entityName, recordID,
"entity.status.label", oldStatus, newStatus, loginUser);
SimpleDateFormat dateFormat = new SimpleDateFormat(
Constant.DATE_EDIT_FORMAT);
String oldStartDateValue = "";
Date oldStartDate = originalCampaign.getStart_date();
if (oldStartDate != null) {
oldStartDateValue = dateFormat.format(oldStartDate);
}
String newStartDateValue = "";
Date newStartDate = campaign.getStart_date();
if (newStartDate != null) {
newStartDateValue = dateFormat.format(newStartDate);
}
createChangeLog(changeLogs, entityName, recordID,
"entity.start_date.label", oldStartDateValue,
newStartDateValue, loginUser);
String oldEndDateValue = "";
Date oldEndDate = originalCampaign.getEnd_date();
if (oldEndDate != null) {
oldEndDateValue = dateFormat.format(oldEndDate);
}
String newEndDateValue = "";
Date newEndDate = campaign.getEnd_date();
if (newEndDate != null) {
newEndDateValue = dateFormat.format(newEndDate);
}
createChangeLog(changeLogs, entityName, recordID,
"entity.end_date.label", oldEndDateValue, newEndDateValue,
loginUser);
String oldCampaignType = getOptionValue(originalCampaign.getType());
String newCampaignType = getOptionValue(campaign.getType());
createChangeLog(changeLogs, entityName, recordID,
"entity.type.label", oldCampaignType, newCampaignType,
loginUser);
String oldCurrencyName = "";
Currency oldCurrency = originalCampaign.getCurrency();
if (oldCurrency != null) {
oldCurrencyName = CommonUtil.fromNullToEmpty(oldCurrency
.getName());
}
String newCurrencyName = "";
Currency newCurrency = campaign.getCurrency();
if (newCurrency != null) {
newCurrencyName = CommonUtil.fromNullToEmpty(newCurrency
.getName());
}
createChangeLog(changeLogs, entityName, recordID,
"entity.currency.label", oldCurrencyName, newCurrencyName,
loginUser);
String oldImpressions = String.valueOf(originalCampaign
.getImpressions());
String newImpressions = String.valueOf(campaign.getImpressions());
createChangeLog(changeLogs, entityName, recordID,
"campaign.impressions.label", oldImpressions,
newImpressions, loginUser);
String oldBudget = String.valueOf(originalCampaign.getBudget());
String newBudget = String.valueOf(campaign.getBudget());
createChangeLog(changeLogs, entityName, recordID,
"campaign.budget.label", oldBudget, newBudget, loginUser);
String oldExpectedCost = String.valueOf(originalCampaign
.getExpected_cost());
String newExpectedCost = String
.valueOf(campaign.getExpected_cost());
createChangeLog(changeLogs, entityName, recordID,
"campaign.expected_cost.label", oldExpectedCost,
newExpectedCost, loginUser);
String oldActualCost = String.valueOf(originalCampaign
.getActual_cost());
String newActualCost = String.valueOf(campaign.getActual_cost());
createChangeLog(changeLogs, entityName, recordID,
"campaign.actual_cost.label", oldActualCost, newActualCost,
loginUser);
String oldExpectedRevenue = String.valueOf(originalCampaign
.getExpected_revenue());
String newExpectedRevenue = String.valueOf(campaign
.getExpected_revenue());
createChangeLog(changeLogs, entityName, recordID,
"campaign.expected_revenue.label", oldExpectedRevenue,
newExpectedRevenue, loginUser);
String oldExpectedRespone = String.valueOf(originalCampaign
.getExpected_respone());
String newExpectedRespone = String.valueOf(campaign
.getExpected_respone());
createChangeLog(changeLogs, entityName, recordID,
"campaign.expected_respone.label", oldExpectedRespone,
newExpectedRespone, loginUser);
String oldObjective = CommonUtil.fromNullToEmpty(originalCampaign
.getObjective());
String newObjective = CommonUtil.fromNullToEmpty(campaign
.getObjective());
createChangeLog(changeLogs, entityName, recordID,
"campaign.objective.label", oldObjective, newObjective,
loginUser);
String oldNotes = CommonUtil.fromNullToEmpty(originalCampaign
.getNotes());
String newNotes = CommonUtil.fromNullToEmpty(campaign.getNotes());
createChangeLog(changeLogs, entityName, recordID,
"entity.notes.label", oldNotes, newNotes, loginUser);
String oldAssignedToName = "";
User oldAssignedTo = originalCampaign.getAssigned_to();
if (oldAssignedTo != null) {
oldAssignedToName = oldAssignedTo.getName();
}
String newAssignedToName = "";
User newAssignedTo = campaign.getAssigned_to();
if (newAssignedTo != null) {
newAssignedToName = newAssignedTo.getName();
}
createChangeLog(changeLogs, entityName, recordID,
"entity.assigned_to.label",
CommonUtil.fromNullToEmpty(oldAssignedToName),
CommonUtil.fromNullToEmpty(newAssignedToName), loginUser);