String country = postalAddress.getRelatedOne("CountryGeo").getString("geoName");
address.setCountry(country);
address.setWork(true); // this can be better set by checking contactMechPurposeTypeId
contact.addAddress(address);
Communications communication = cmf.createCommunications();
contact.setCommunications(communication);
PhoneNumber number = cmf.createPhoneNumber();
GenericValue telecomNumber = PartyWorker.findPartyLatestTelecomNumber(partyId, delegator);
if (UtilValidate.isNotEmpty(telecomNumber)) {
number.setNumber(telecomNumber.getString("areaCode") + telecomNumber.getString("contactNumber"));
number.setWork(true); // this can be better set by checking contactMechPurposeTypeId
communication.addPhoneNumber(number);
}
EmailAddress email = cmf.createEmailAddress();
GenericValue emailAddress = PartyWorker.findPartyLatestContactMech(partyId, "EMAIL_ADDRESS", delegator);
if (UtilValidate.isNotEmpty(emailAddress.getString("infoString"))) {
email.setAddress(emailAddress.getString("infoString"));
communication.addEmailAddress(email);
}
ContactIOFactory ciof = Pim.getContactIOFactory();
ContactMarshaller marshaller = ciof.createContactMarshaller();
String saveToDirectory = UtilProperties.getPropertyValue("sfa.properties", "save.outgoing.directory", "");
if (UtilValidate.isEmpty(saveToDirectory)) {