Map<String, String> row = new HashMap<String, String>();
for (int i = 0; i < line.size(); i++) {
row.put(header[i], line.get(i));
}
Contact contact = new Contact();
try {
String id = row.get(getText("entity.id.label"));
if (!CommonUtil.isNullOrEmpty(id)) {
contact.setId(Integer.parseInt(id));
UserUtil.permissionCheck("update_contact");
} else {
UserUtil.permissionCheck("create_contact");
}
String salutationID = row
.get(getText("entity.salutation_id.label"));
if (CommonUtil.isNullOrEmpty(salutationID)) {
contact.setSalutation(null);
} else {
Salutation salutation = salutationService
.getEntityById(Salutation.class,
Integer.parseInt(salutationID));
contact.setSalutation(salutation);
}
contact.setFirst_name(CommonUtil.fromNullToEmpty(row
.get(getText("entity.first_name.label"))));
contact.setLast_name(CommonUtil.fromNullToEmpty(row
.get(getText("entity.last_name.label"))));
contact.setEmail(CommonUtil.fromNullToEmpty(row
.get(getText("entity.email.label"))));
contact.setOffice_phone(CommonUtil.fromNullToEmpty(row
.get(getText("entity.office_phone.label"))));
contact.setTitle(CommonUtil.fromNullToEmpty(row
.get(getText("entity.title.label"))));
contact.setMobile(CommonUtil.fromNullToEmpty(row
.get(getText("entity.mobile.label"))));
contact.setSkype_id(CommonUtil.fromNullToEmpty(row
.get(getText("contact.skype_id.label"))));
contact.setDepartment(CommonUtil.fromNullToEmpty(row
.get(getText("entity.department.label"))));
contact.setFax(CommonUtil.fromNullToEmpty(row
.get(getText("entity.fax.label"))));
String accountID = row
.get(getText("entity.account_id.label"));
if (CommonUtil.isNullOrEmpty(accountID)) {
contact.setAccount(null);
} else {
Account account = accountService.getEntityById(
Account.class, Integer.parseInt(accountID));
contact.setAccount(account);
}
contact.setWebsite(CommonUtil.fromNullToEmpty(row
.get(getText("entity.website.label"))));
contact.setPrimary_street(CommonUtil.fromNullToEmpty(row
.get(getText("entity.primary_street.label"))));
contact.setPrimary_city(CommonUtil.fromNullToEmpty(row
.get(getText("entity.primary_city.label"))));
contact.setPrimary_state(CommonUtil.fromNullToEmpty(row
.get(getText("entity.primary_state.label"))));
contact.setPrimary_postal_code(CommonUtil.fromNullToEmpty(row
.get(getText("entity.primary_postal_code.label"))));
contact.setPrimary_country(CommonUtil.fromNullToEmpty(row
.get(getText("entity.primary_country.label"))));
contact.setOther_street(CommonUtil.fromNullToEmpty(row
.get(getText("entity.other_street.label"))));
contact.setOther_city(CommonUtil.fromNullToEmpty(row
.get(getText("entity.other_city.label"))));
contact.setOther_state(CommonUtil.fromNullToEmpty(row
.get(getText("entity.other_state.label"))));
contact.setOther_postal_code(CommonUtil.fromNullToEmpty(row
.get(getText("entity.other_postal_code.label"))));
contact.setOther_country(CommonUtil.fromNullToEmpty(row
.get(getText("entity.other_country.label"))));
contact.setOrigo(CommonUtil.fromNullToEmpty(row
.get(getText("entity.origo.label"))));
String height = row.get(getText("entity.height.label"));
if (CommonUtil.isNullOrEmpty(height)) {
contact.setHeight(0);
} else {
contact.setHeight(Double.parseDouble(height));
}
String weight = row.get(getText("entity.weight.label"));
if (CommonUtil.isNullOrEmpty(weight)) {
contact.setWeight(0);
} else {
contact.setWeight(Double.parseDouble(weight));
}
contact.setRelationship(CommonUtil.fromNullToEmpty(row
.get(getText("entity.relationship.label"))));
contact.setCharacter(CommonUtil.fromNullToEmpty(row
.get(getText("entity.character.label"))));
contact.setInterest(CommonUtil.fromNullToEmpty(row
.get(getText("entity.interest.label"))));
contact.setTaboo(CommonUtil.fromNullToEmpty(row
.get(getText("entity.taboo.label"))));
String religiousID = row
.get(getText("entity.religious_id.label"));
if (CommonUtil.isNullOrEmpty(religiousID)) {
contact.setReligious(null);
} else {
Religious religious = religiousService.getEntityById(
Religious.class, Integer.parseInt(religiousID));
contact.setReligious(religious);
}
contact.setHabit(CommonUtil.fromNullToEmpty(row
.get(getText("entity.habit.label"))));
contact.setDiet(CommonUtil.fromNullToEmpty(row
.get(getText("entity.diet.label"))));
contact.setNotes(CommonUtil.fromNullToEmpty(row
.get(getText("entity.notes.label"))));
String reportToID = row
.get(getText("contact.report_to_id.label"));
if (CommonUtil.isNullOrEmpty(reportToID)) {
contact.setReport_to(null);
} else {
Contact reportTo = baseService.getEntityById(
Contact.class, Integer.parseInt(reportToID));
contact.setReport_to(reportTo);
}
String doNotCall = row
.get(getText("entity.not_call.label"));