if (CVUtility.updateFieldPermitted(entityRights, "id2")) {
this.setExternalID((String)dynaForm.get("id2"));
}
AddressVO primaryAddress = this.getPrimaryAddress();
if (CVUtility.updateFieldPermitted(entityRights, "address")) {
primaryAddress.setStreet1((String)dynaForm.get("street1"));
primaryAddress.setStreet2((String)dynaForm.get("street2"));
primaryAddress.setCity((String)dynaForm.get("city"));
primaryAddress.setStateName((String)dynaForm.get("state"));
primaryAddress.setZip((String)dynaForm.get("zip"));
primaryAddress.setCountryName((String)dynaForm.get("country"));
String webSiteForm = (dynaForm.get("website") == null || dynaForm.get("website") == null) ? "" : (String)dynaForm.get("website");
String webSite = "";
if (webSiteForm.matches("^https?://.+")) {
webSite = webSiteForm;
} else if (webSiteForm.trim().length() > 0) {
webSite = "http://" + webSiteForm;
}
primaryAddress.setWebsite(webSite);
Integer addressId = dynaForm.get("addressId") == null ? new Integer(-1) : (Integer)dynaForm.get("addressId");
primaryAddress.setAddressID(addressId.intValue());
primaryAddress.setIsPrimary("YES");
if (!primaryAddress.isEmpty()) {
this.setPrimaryAddress(primaryAddress);
}
}
if (CVUtility.updateFieldPermitted(entityRights, "source")) {
Integer sourceIdInteger = (Integer)dynaForm.get("sourceId");
int sourceId = sourceIdInteger == null ? 0 : sourceIdInteger.intValue();
this.setSource(sourceId);
this.setSourceName((String)dynaForm.get("sourceName"));
}
if (CVUtility.updateFieldPermitted(entityRights, "acctmanager")) {
this.setAccManager(((Integer)dynaForm.get("accountManagerId")).intValue());
this.setAcctMgrName((String)dynaForm.get("accountManagerName"));
}
if (CVUtility.updateFieldPermitted(entityRights, "acctteam")) {
this.setAccTeam(((Integer)dynaForm.get("accountTeamId")).intValue());
this.setAcctTeamName((String)dynaForm.get("accountTeamName"));
}
String pcFName = dynaForm.get("pcFirstName") == null ? "" : (String)dynaForm.get("pcFirstName");
String pcMName = dynaForm.get("pcMiddleInitial") == null ? "" : (String)dynaForm.get("pcMiddleInitial");
String pcLName = dynaForm.get("pcLastName") == null ? "" : (String)dynaForm.get("pcLastName");
String pcTitle = dynaForm.get("pcTitle") == null ? "" : (String)dynaForm.get("pcTitle");
IndividualVO individualVO = null;
int individualId = dynaForm.get("pcIndividualId") == null ? 0 : ((Integer)dynaForm.get("pcIndividualId")).intValue();
if (individualId != 0) {
individualVO = contactFacadeRemote.getIndividual(individualId);
// In certain cases (when the individual was imported via marketing list)
// The individual and the Entity share the same (exact) Address Therefore
// If that is the case, I must make sure the IndividualVO address is updated also
// otherwise the crapiness of the Entity and Individual EJB interaction. will
// cause a condition, which always reverts the common address to the old one
// if it were changed.
// The real solution is probably to delete this code, and make a method on the
// Individual EJB that simply updates the potentially changed fields on the Individual.
AddressVO individualPrimaryAddress = individualVO.getPrimaryAddress();
if (individualPrimaryAddress.getAddressID() == primaryAddress.getAddressID()) {
individualVO.setPrimaryAddress(primaryAddress);
}
// We must clear the mocs on this Individual otherwise we will create new mocs
// associated with the Individual