String currentMainPhone = new String("");
String currentPagerPhone = new String("");
String currentMobilePhone = new String("");
String currentEmail = new String("");
MethodOfContactVO currentWorkVO = null;
MethodOfContactVO currentHomeVO = null;
MethodOfContactVO currentFaxVO = null;
MethodOfContactVO currentOtherVO = null;
MethodOfContactVO currentMainVO = null;
MethodOfContactVO currentPagerVO = null;
MethodOfContactVO currentMobileVO = null;
MethodOfContactVO currentEmailVO = null;
Vector currentMOCs = individualCurrent.getMOC();
if (currentMOCs != null) {
Enumeration e = currentMOCs.elements();
while (e.hasMoreElements()) {
MethodOfContactVO mocVO = (MethodOfContactVO)e.nextElement();
String syncAs = mocVO.getSyncAs();
if (syncAs != null && (! syncAs.equals(""))) {
if (syncAs.equals("Work")) {
currentWorkPhone = mocVO.getContent();
currentWorkVO = mocVO;
}else if (syncAs.equals("Home")){
currentHomePhone = mocVO.getContent();
currentHomeVO = mocVO;
}else if (syncAs.equals("Fax")){
currentFaxPhone = mocVO.getContent();
currentFaxVO = mocVO;
}else if (syncAs.equals("Other")){
currentOtherPhone = mocVO.getContent();
currentOtherVO = mocVO;
}else if (syncAs.equals("Main")){
currentMainPhone = mocVO.getContent();
currentMainVO = mocVO;
}else if (syncAs.equals("Pager")){
currentPagerPhone = mocVO.getContent();
currentPagerVO = mocVO;
}else if (syncAs.equals("Mobile")){
currentMobilePhone = mocVO.getContent();
currentMobileVO = mocVO;
} // end if (syncAs.equals("Work"))
}else if (mocVO.getMocType() == 1 && mocVO.getIsPrimary().equals("YES")){
currentEmail = mocVO.getContent();
currentEmailVO = mocVO;
} // end if (syncAs != null && (! syncAs.equals("")))
} // end while (e.hasMoreElements())
} // end if (currentMOCS != null)
Vector newMOCs = new Vector();
// now, check to see what SyncAs values we were passed,
// if a given value is not null, then check to see if
// there is an existing value for that field in the db:
// (check "currentXxxVO" where "Xxx" equals one of the
// syncAs types [Work, Home, Fax, etc]). If currentXxxVO
// is null, create a new MethodOfContactVO object, and set
// the appropriate values, then add that object to the
// individualVO using setMOC(). Else, update the "content"
// field and updated field on the currentXxxVO, and pass
// that object to individualVO.setMOC();
String workPhone = (String)contactForm.get("workPhone");
if (workPhone != null && (! workPhone.equals(""))) {
if (currentWorkVO == null) {
MethodOfContactVO workPhoneVO = new MethodOfContactVO();
workPhoneVO.setContent(workPhone);
workPhoneVO.setSyncAs("Work");
workPhoneVO.setMocType(Constants.MOC_WORK);
newMOCs.add(workPhoneVO);
}else{
currentWorkVO.setContent(workPhone);
currentWorkVO.updated(true);
currentWorkVO.added(false);
currentWorkVO.delete(false);
newMOCs.add(currentWorkVO);
}
}
String homePhone = (String)contactForm.get("homePhone");
if (homePhone != null && (! homePhone.equals(""))) {
if (currentHomeVO == null) {
MethodOfContactVO homePhoneVO = new MethodOfContactVO();
homePhoneVO.setContent(homePhone);
homePhoneVO.setSyncAs("Home");
homePhoneVO.setMocType(Constants.MOC_HOME);
newMOCs.add(homePhoneVO);
}else{
currentHomeVO.setContent(homePhone);
currentHomeVO.updated(true);
currentHomeVO.added(false);
currentHomeVO.delete(false);
newMOCs.add(currentHomeVO);
}
}
String faxPhone = (String)contactForm.get("faxPhone");
if (faxPhone != null && (! faxPhone.equals(""))) {
if (currentFaxVO == null) {
MethodOfContactVO faxPhoneVO = new MethodOfContactVO();
faxPhoneVO.setContent(faxPhone);
faxPhoneVO.setSyncAs("fax");
faxPhoneVO.setMocType(Constants.MOC_FAX);
newMOCs.add(faxPhoneVO);
}else{
currentFaxVO.setContent(faxPhone);
currentFaxVO.updated(true);
currentFaxVO.added(false);
currentFaxVO.delete(false);
newMOCs.add(currentFaxVO);
}
}
String otherPhone = (String)contactForm.get("otherPhone");
if (otherPhone != null && (! otherPhone.equals(""))) {
if (currentOtherVO == null) {
MethodOfContactVO otherPhoneVO = new MethodOfContactVO();
otherPhoneVO.setContent(otherPhone);
otherPhoneVO.setSyncAs("other");
otherPhoneVO.setMocType(Constants.MOC_OTHER);
newMOCs.add(otherPhoneVO);
}else{
currentOtherVO.setContent(otherPhone);
currentOtherVO.updated(true);
currentOtherVO.added(false);
currentOtherVO.delete(false);
newMOCs.add(currentOtherVO);
}
}
String mainPhone = (String)contactForm.get("mainPhone");
if (mainPhone != null && (! mainPhone.equals(""))) {
if (currentMainVO == null) {
MethodOfContactVO mainPhoneVO = new MethodOfContactVO();
mainPhoneVO.setContent(mainPhone);
mainPhoneVO.setSyncAs("main");
mainPhoneVO.setMocType(Constants.MOC_MAIN);
newMOCs.add(mainPhoneVO);
}else{
currentMainVO.setContent(mainPhone);
currentMainVO.updated(true);
currentMainVO.added(false);
currentMainVO.delete(false);
newMOCs.add(currentMainVO);
}
}
String pagerPhone = (String)contactForm.get("pagerPhone");
if (pagerPhone != null && (! pagerPhone.equals(""))) {
if (currentPagerVO == null) {
MethodOfContactVO pagerPhoneVO = new MethodOfContactVO();
pagerPhoneVO.setContent(pagerPhone);
pagerPhoneVO.setSyncAs("pager");
pagerPhoneVO.setMocType(Constants.MOC_PAGER);
newMOCs.add(pagerPhoneVO);
}else{
currentPagerVO.setContent(pagerPhone);
currentPagerVO.updated(true);
currentPagerVO.added(false);
currentPagerVO.delete(false);
newMOCs.add(currentPagerVO);
}
}
String mobilePhone = (String)contactForm.get("mobilePhone");
if (mobilePhone != null && (! mobilePhone.equals(""))) {
if (currentMobileVO == null) {
MethodOfContactVO mobilePhoneVO = new MethodOfContactVO();
mobilePhoneVO.setContent(mobilePhone);
mobilePhoneVO.setSyncAs("mobile");
mobilePhoneVO.setMocType(Constants.MOC_MOBILE);
newMOCs.add(mobilePhoneVO);
}else{
currentMobileVO.setContent(mobilePhone);
currentMobileVO.updated(true);
currentMobileVO.added(false);
currentMobileVO.delete(false);
newMOCs.add(currentMobileVO);
}
}
String email = (String)contactForm.get("email");
if (email != null && (! email.equals(""))) {
if (currentEmailVO == null) {
MethodOfContactVO emailVO = new MethodOfContactVO();
emailVO.setContent(email);
emailVO.setMocType(Constants.MOC_EMAIL); // 1 == "email"
emailVO.setIsPrimary("YES"); // always set as the primary email address
newMOCs.add(emailVO);
}else{
currentEmailVO.setContent(email);
currentEmailVO.updated(true);
currentEmailVO.added(false);