// have to determine if we need to insert, delete or update any
logger.info("Starting Phone update process...");
java.util.List newPhones = newData.getPhone();
java.util.List oldPhones = baselinePerson.getPhone();
for (int i=0; i<newPhones.size(); i++) {
Phone newPhone = (Phone)newPhones.get(i);
String newPhoneKey = newPhone.getCombinedKeyValue();
boolean foundMatch = false;
for (int j=0; j<oldPhones.size(); j++) {
Phone oldPhone = (Phone)oldPhones.get(j);
String oldPhoneKey = oldPhone.getCombinedKeyValue();
if (oldPhoneKey.equalsIgnoreCase(newPhoneKey)) {
// found a match, might have to update...
foundMatch = true;
if (newPhone.equals(oldPhone) == false) {
// need to update individual phone
logger.info("updating existing phone object.");
updatePhone(conn, msgCategory, msgObject, msgRelease, instId, newPhone);
}
}
}
if (foundMatch == false) {
// need to create phone
logger.info("creating new address object.");
createPhone(conn, msgCategory, msgObject, msgRelease, instId, newPhone);
}
}
// now we need to check the oldPhones and delete any that don't
// exist in the newAddress list
for (int i=0; i<oldPhones.size(); i++) {
Phone oldPhone = (Phone)oldPhones.get(i);
String oldPhoneKey = oldPhone.getCombinedKeyValue();
boolean foundMatch = false;
for (int j=0; j<newPhones.size(); j++) {
Phone newPhone = (Phone)newPhones.get(j);
String newPhoneKey = newPhone.getCombinedKeyValue();
if (oldPhoneKey.equalsIgnoreCase(newPhoneKey)) {
// found a match, don't delete
foundMatch = true;
}
}