writer.writeHeader(header);
if (!isTemplate) {
String[] ids = seleteIDs.split(",");
for (int i = 0; i < ids.length; i++) {
String id = ids[i];
Contact contact = baseService.getEntityById(Contact.class,
Integer.parseInt(id));
final HashMap<String, ? super Object> data1 = new HashMap<String, Object>();
data1.put(header[0], contact.getId());
Salutation salutation = contact.getSalutation();
if (salutation != null) {
data1.put(header[1], salutation.getId());
} else {
data1.put(header[1], "");
}
data1.put(header[2], CommonUtil.getOptionLabel(salutation));
data1.put(header[3],
CommonUtil.fromNullToEmpty(contact.getFirst_name()));
data1.put(header[4],
CommonUtil.fromNullToEmpty(contact.getLast_name()));
data1.put(header[5],
CommonUtil.fromNullToEmpty(contact.getEmail()));
data1.put(header[6], CommonUtil.fromNullToEmpty(contact
.getOffice_phone()));
data1.put(header[7],
CommonUtil.fromNullToEmpty(contact.getTitle()));
data1.put(header[8],
CommonUtil.fromNullToEmpty(contact.getMobile()));
data1.put(header[9],
CommonUtil.fromNullToEmpty(contact.getSkype_id()));
data1.put(header[10],
CommonUtil.fromNullToEmpty(contact.getDepartment()));
data1.put(header[11],
CommonUtil.fromNullToEmpty(contact.getFax()));
if (contact.getAccount() != null) {
data1.put(header[12], contact.getAccount().getId());
data1.put(header[13], contact.getAccount().getName());
} else {
data1.put(header[12], "");
data1.put(header[13], "");
}
data1.put(header[14],
CommonUtil.fromNullToEmpty(contact.getWebsite()));
data1.put(header[15], CommonUtil.fromNullToEmpty(contact
.getPrimary_street()));
data1.put(header[16], CommonUtil.fromNullToEmpty(contact
.getPrimary_city()));
data1.put(header[17], CommonUtil.fromNullToEmpty(contact
.getPrimary_state()));
data1.put(header[18], CommonUtil.fromNullToEmpty(contact
.getPrimary_postal_code()));
data1.put(header[19], CommonUtil.fromNullToEmpty(contact
.getPrimary_country()));
data1.put(header[20], CommonUtil.fromNullToEmpty(contact
.getOther_street()));
data1.put(header[21],
CommonUtil.fromNullToEmpty(contact.getOther_city()));
data1.put(header[22], CommonUtil.fromNullToEmpty(contact
.getOther_state()));
data1.put(header[23], CommonUtil.fromNullToEmpty(contact
.getOther_postal_code()));
data1.put(header[24], CommonUtil.fromNullToEmpty(contact
.getOther_country()));
data1.put(header[25],
CommonUtil.fromNullToEmpty(contact.getOrigo()));
data1.put(header[26], contact.getHeight());
data1.put(header[27], contact.getWeight());
data1.put(header[28], CommonUtil.fromNullToEmpty(contact
.getRelationship()));
data1.put(header[29],
CommonUtil.fromNullToEmpty(contact.getCharacter()));
data1.put(header[30],
CommonUtil.fromNullToEmpty(contact.getInterest()));
data1.put(header[31],
CommonUtil.fromNullToEmpty(contact.getTaboo()));
Religious religious = contact.getReligious();
if (religious != null) {
data1.put(header[32], religious.getId());
} else {
data1.put(header[32], "");
}
data1.put(header[33], CommonUtil.getOptionLabel(religious));
data1.put(header[34],
CommonUtil.fromNullToEmpty(contact.getHabit()));
data1.put(header[35],
CommonUtil.fromNullToEmpty(contact.getDiet()));
data1.put(header[36],
CommonUtil.fromNullToEmpty(contact.getNotes()));
if (contact.getReport_to() != null) {
data1.put(header[37], contact.getReport_to().getId());
data1.put(header[38], contact.getReport_to().getName());
} else {
data1.put(header[37], "");
data1.put(header[38], "");
}
data1.put(header[39], contact.isNot_call());
LeadSource leadSource = contact.getLeadSource();
if (leadSource != null) {
data1.put(header[40], leadSource.getId());
} else {
data1.put(header[40], "");
}
data1.put(header[41], CommonUtil.getOptionLabel(leadSource));
if (contact.getCampaign() != null) {
data1.put(header[42], contact.getCampaign().getId());
data1.put(header[43], contact.getCampaign().getName());
} else {
data1.put(header[42], "");
data1.put(header[43], "");
}
if (contact.getAssigned_to() != null) {
data1.put(header[44], contact.getAssigned_to().getId());
data1.put(header[45], contact.getAssigned_to()
.getName());
} else {
data1.put(header[44], "");
data1.put(header[45], "");
}