diff --git a/process/setMissingAddressLocations_serverProcess/process.js b/process/setMissingAddressLocations_serverProcess/process.js index 38efd070554dc6d17d40bef2e82496faa433ad38..7cef5bfae4905e886a1464bbb29ef2cbdc4b7f1e 100644 --- a/process/setMissingAddressLocations_serverProcess/process.js +++ b/process/setMissingAddressLocations_serverProcess/process.js @@ -1,9 +1,12 @@ +import("system.logging"); +import("Util_lib"); import("system.db"); import("Sql_lib"); import("Address_lib"); import("Location_lib"); var locationSearch = new LocationFinder(); +var malformedAddressData = []; if (locationSearch.isEnabled()) { @@ -18,14 +21,31 @@ if (locationSearch.isEnabled()) addresses.forEach(function ([addressId, address, buildingno, zip, city, country, state]) { var addressData = new AddressObject(address, buildingno, zip, city, country, state); - var location = locationSearch.getGeoLocation(addressData); - if (location) + + try { - locationUpdates.push(["ADDRESS", ["LAT", "LON"], null, [location.lat, location.lon], - newWhere("ADDRESS.ADDRESSID", addressId).buildCondition()]); + var location = locationSearch.getGeoLocation(addressData); + if (location) + { + locationUpdates.push(["ADDRESS", ["LAT", "LON"], null, [location.lat, location.lon], + newWhere("ADDRESS.ADDRESSID", addressId).buildCondition()]); + } + } + catch (pException) + { + malformedAddressData.push(addressId); } }); if (locationUpdates.length > 0) db.updates(locationUpdates); }); + if (Utils.isNotNullOrEmptyString(malformedAddressData)) + { + errMsg = "updateAllAddressLocations_serverProcess: Something went wrong, during updating address locations, with the following uids: "; + malformedAddressData.forEach(function(pMalformedData) + { + errMsg += pMalformedData + "\n"; + }); + logging.log(errMsg); + } } \ No newline at end of file diff --git a/process/updateAllAddressLocations_serverProcess/process.js b/process/updateAllAddressLocations_serverProcess/process.js index 5341f47ddfb539cbd4af47400db6a154cb50ea2a..6239ba470a3f1cf50a35552c59bc374a1dadf86d 100644 --- a/process/updateAllAddressLocations_serverProcess/process.js +++ b/process/updateAllAddressLocations_serverProcess/process.js @@ -1,9 +1,12 @@ import("system.db"); +import("system.logging"); import("Sql_lib"); import("Address_lib"); import("Location_lib"); +import("Util_lib"); var locationSearch = new LocationFinder(); +var malformedAddressData = []; if (locationSearch.isEnabled()) { @@ -16,14 +19,31 @@ if (locationSearch.isEnabled()) addresses.forEach(function ([addressId, address, buildingno, zip, city, country, state]) { var addressData = new AddressObject(address, buildingno, zip, city, country, state); - var location = locationSearch.getGeoLocation(addressData); - if (location) + try { - locationUpdates.push(["ADDRESS", ["LAT", "LON"], null, [location.lat, location.lon], - newWhere("ADDRESS.ADDRESSID", addressId).buildCondition()]); + var location = locationSearch.getGeoLocation(addressData); + + if (location) + { + locationUpdates.push(["ADDRESS", ["LAT", "LON"], null, [location.lat, location.lon], + newWhere("ADDRESS.ADDRESSID", addressId).buildCondition()]); + } + } + catch (pException) + { + malformedAddressData.push(addressId); } }); if (locationUpdates.length > 0) db.updates(locationUpdates); }); + if (Utils.isNotNullOrEmptyString(malformedAddressData)) + { + errMsg = "updateAllAddressLocations_serverProcess: Something went wrong, during updating address locations, with the following uids: "; + malformedAddressData.forEach(function(pMalformedData) + { + errMsg += pMalformedData + "\n"; + }); + logging.log(errMsg); + } } \ No newline at end of file