// have to determine if we need to insert, delete or update any
logger.info("Starting Address update process...");
java.util.List newAddresses = newData.getAddress();
java.util.List oldAddresses = baselinePerson.getAddress();
for (int i=0; i<newAddresses.size(); i++) {
Address newAddress = (Address)newAddresses.get(i);
String newAddressKey = newAddress.getCombinedKeyValue();
boolean foundMatch = false;
for (int j=0; j<oldAddresses.size(); j++) {
Address oldAddress = (Address)oldAddresses.get(j);
String oldAddressKey = oldAddress.getCombinedKeyValue();
if (oldAddressKey.equalsIgnoreCase(newAddressKey)) {
// found a match, might have to update...
foundMatch = true;
if (newAddress.equals(oldAddress) == false) {
// need to update individual address
logger.info("updating existing address object.");
updateAddress(conn, msgCategory, msgObject, msgRelease, instId, newAddress);
}
}
}
if (foundMatch == false) {
// need to create address
logger.info("creating new address object.");
createAddress(conn, msgCategory, msgObject, msgRelease, instId, newAddress);
}
}
// now we need to check the oldAddresses and delete any that don't
// exist in the newAddress list
for (int i=0; i<oldAddresses.size(); i++) {
Address oldAddress = (Address)oldAddresses.get(i);
String oldAddressKey = oldAddress.getCombinedKeyValue();
boolean foundMatch = false;
for (int j=0; j<newAddresses.size(); j++) {
Address newAddress = (Address)newAddresses.get(j);
String newAddressKey = newAddress.getCombinedKeyValue();
if (oldAddressKey.equalsIgnoreCase(newAddressKey)) {
// found a match, don't delete
foundMatch = true;
}
}