CVUtility.addHistoryRecord(historyInfo, ds);
// Create the address.
AddressVO addVO = individualDetail.getPrimaryAddress();
ContactHelperLocalHome home = (ContactHelperLocalHome)ic.lookup("local/ContactHelper");
ContactHelperLocal remote = home.create();
remote.setDataSource(ds);
// if there is no address filled in, automatically fill in the address
// from the associated entity.
if ((addVO.getCity() == null || addVO.getCity().equals("")) &&
(addVO.getCountryName() == null || addVO.getCountryName().equals("")) &&
(addVO.getStateName() == null || addVO.getStateName().equals("")) &&
(addVO.getStreet1() == null || addVO.getStreet1().equals("")) &&
(addVO.getStreet2() == null || addVO.getStreet2().equals("")) &&
(addVO.getZip() == null || addVO.getZip().equals("")))
{
// This of course creates a copy of the address from the entity, therefore
// it is possible to be changed independently of Entities, however it will
// not be in sync with changes to the entities.
addVO = remote.getPrimaryAddressForContact(userID, individualDetail.getEntityID(), 1);
addVO.setIsPrimary("YES");
}
// We are passing the Extra boolean value to the method. if the boolean
// value is false then we wil not update the individual table
remote.addAddress(addVO, individualID, individualDetail.getContactType(), userID, false);
// Getting MethodOfContactVO List from Individual Object
Collection mocList = individualDetail.getMOC();
Iterator it = mocList.iterator();
int counter = 0;
MethodOfContactVO mocVO = null;
while (it.hasNext()) {
mocVO = (MethodOfContactVO)it.next();
// Count all the Mobile and Phone type MOCs that were manually added.
// If there were none, try to inheirit copies of them from the parent
// entity.
if (mocVO.getIsPrimary().equals("YES")) {
counter++;
}
// We are passing the Extra boolean value to the method. if the boolean
// value is false then we wil not update the individual table
remote.addMOC(mocVO, individualID, 2, userID, false); // Hardcoded for
// Individual
// ContactType
}
// if counter < 1 then there were no phone or mobile numbers entered for
// this individual. So we should try and suck down copies of the Entities.
if (counter < 1) {
Collection col = remote.getAllMOCForContact(userID, individualDetail.getEntityID(), 1);
if (col != null) {
Iterator mocIter = col.iterator();
while (mocIter.hasNext()) {
mocVO = (MethodOfContactVO)mocIter.next();
// we ussed to only copy "Main" and "Fax" types, but per Alan's
// request this has been changed. Please see bug #88. I have
// changed this to copy ALL MOC's.
if (mocVO.getIsPrimary().equals("YES")) {
remote.addMOC(mocVO, individualID, 2, userID, false); // false means don't update the modified timestamp of individual record
}
}
}
}