Map<String, String> row = new HashMap<String, String>();
for (int i = 0; i < line.size(); i++) {
row.put(header[i], line.get(i));
}
Call call = new Call();
try {
String id = row.get(getText("entity.id.label"));
if (!CommonUtil.isNullOrEmpty(id)) {
call.setId(Integer.parseInt(id));
UserUtil.permissionCheck("update_call");
} else {
UserUtil.permissionCheck("create_call");
}
call.setSubject(CommonUtil.fromNullToEmpty(row
.get(getText("entity.subject.label"))));
String directionID = row
.get(getText("call.direction_id.label"));
if (CommonUtil.isNullOrEmpty(directionID)) {
call.setDirection(null);
} else {
CallDirection callDirection = callDirectionService
.getEntityById(CallDirection.class,
Integer.parseInt(directionID));
call.setDirection(callDirection);
}
String statusID = row
.get(getText("entity.status_id.label"));
if (CommonUtil.isNullOrEmpty(statusID)) {
call.setStatus(null);
} else {
CallStatus status = callStatusService.getEntityById(
CallStatus.class, Integer.parseInt(statusID));
call.setStatus(status);
}
SimpleDateFormat dateFormat = new SimpleDateFormat(
Constant.DATE_TIME_FORMAT);
String startDateS = row
.get(getText("entity.start_date.label"));
if (startDateS != null) {
Date startDate = dateFormat.parse(startDateS);
call.setStart_date(startDate);
} else {
call.setStart_date(null);
}
String reminderWayEmail = row
.get(getText("entity.reminder_email.label"));
if (CommonUtil.isNullOrEmpty(reminderWayEmail)) {
call.setReminder_email(false);
} else {
call.setReminder_email(Boolean
.parseBoolean(reminderWayEmail));
}
String reminderOptionEmailID = row
.get(getText("entity.reminder_option_email_id.label"));
if (CommonUtil.isNullOrEmpty(reminderOptionEmailID)) {
call.setReminder_option_email(null);
} else {
ReminderOption reminderOption = reminderOptionService
.getEntityById(ReminderOption.class,
Integer.parseInt(reminderOptionEmailID));
call.setReminder_option_email(reminderOption);
}
call.setNotes(CommonUtil.fromNullToEmpty(row
.get(getText("entity.notes.label"))));
String assignedToID = row
.get(getText("entity.assigned_to_id.label"));
if (CommonUtil.isNullOrEmpty(assignedToID)) {
call.setAssigned_to(null);
} else {
User assignedTo = userService.getEntityById(User.class,
Integer.parseInt(assignedToID));
call.setAssigned_to(assignedTo);
}
baseService.makePersistent(call);
successfulNum++;
} catch (Exception e) {
failedNum++;
failedMsg.put(call.getSubject(), e.getMessage());
}
}
this.setFailedMsg(failedMsg);