Skip to content
Snippets Groups Projects
Commit 2fd3ccd0 authored by Daniel Tran's avatar Daniel Tran Committed by Sebastian Pongratz
Browse files

[Projekt: xRM-ContactManagement][TicketNr.: 1077287][updateAllAdressLocations...

[Projekt: xRM-ContactManagement][TicketNr.: 1077287][updateAllAdressLocations sollte bei invaliden Datensätzen weiterlaufen]
- Added logic, to prevent process from stopping when
    data is invalid and implemented logic to collect uids of
    invalid data sets and print it after process is finished.
parent 0da84f75
No related branches found
No related tags found
No related merge requests found
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment