fixed unmarking rimo_deleted in rimo import
This commit is contained in:
@@ -27,6 +27,8 @@ $mainlog = \mfLoghandler::singleton();
|
|||||||
$log = new \mfLog_File();
|
$log = new \mfLog_File();
|
||||||
$log->init(BASEDIR . "/var/log/rimo-import.log");
|
$log->init(BASEDIR . "/var/log/rimo-import.log");
|
||||||
|
|
||||||
|
$disable_delete = false;
|
||||||
|
|
||||||
$usage = "Usage: " . $argv[0] . " [argument|rimocluster]\n\nAvailable arguments:\n\t--list-rimo-clusters\tLists Clusters returned by Rimo API, then exits\n\t--help\t\t\tLists available arguments\n\nRuns import when no argument is given. If rimocluster is given, only imports this cluster.\n\n";
|
$usage = "Usage: " . $argv[0] . " [argument|rimocluster]\n\nAvailable arguments:\n\t--list-rimo-clusters\tLists Clusters returned by Rimo API, then exits\n\t--help\t\t\tLists available arguments\n\nRuns import when no argument is given. If rimocluster is given, only imports this cluster.\n\n";
|
||||||
$command = false;
|
$command = false;
|
||||||
$request_cluster = false;
|
$request_cluster = false;
|
||||||
@@ -278,6 +280,11 @@ foreach ($clusters as $cluster_data) {
|
|||||||
$hausnummer_count++;
|
$hausnummer_count++;
|
||||||
|
|
||||||
$rimo_building_id = $building->id;
|
$rimo_building_id = $building->id;
|
||||||
|
|
||||||
|
//$disable_delete = true;
|
||||||
|
//if($rimo_building_id != "SDIBuilding_898208091393_1647266063") continue;
|
||||||
|
//echo $rimo_building_id."\n";
|
||||||
|
|
||||||
$rimo_building_list[] = $rimo_building_id;
|
$rimo_building_list[] = $rimo_building_id;
|
||||||
|
|
||||||
$hausnummer = $AddressHelper->findUpdateAddressFromRimoBuilding($building);
|
$hausnummer = $AddressHelper->findUpdateAddressFromRimoBuilding($building);
|
||||||
@@ -349,6 +356,7 @@ foreach ($clusters as $cluster_data) {
|
|||||||
if($hausnummer_changed) {
|
if($hausnummer_changed) {
|
||||||
$hausnummer->save();
|
$hausnummer->save();
|
||||||
$hausnummer->resetSaveNesting();
|
$hausnummer->resetSaveNesting();
|
||||||
|
$hausnummer_changed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -449,6 +457,7 @@ foreach ($clusters as $cluster_data) {
|
|||||||
if($unit->rimo_deleted) {
|
if($unit->rimo_deleted) {
|
||||||
$unit->rimo_deleted = 0;
|
$unit->rimo_deleted = 0;
|
||||||
$unit_changed = true;
|
$unit_changed = true;
|
||||||
|
//echo "{$unit->id} unit undelete\n";
|
||||||
//$unit->save(["no_updates" => 1]);
|
//$unit->save(["no_updates" => 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,6 +566,12 @@ foreach ($clusters as $cluster_data) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($unit_changed) {
|
||||||
|
$unit->save();
|
||||||
|
$unit->resetSaveNesting();
|
||||||
|
$unit_changed = false;
|
||||||
|
}
|
||||||
|
|
||||||
// get ports from service
|
// get ports from service
|
||||||
$params = $baseParams;
|
$params = $baseParams;
|
||||||
$params["homeId"] = $home_rimo_id;
|
$params["homeId"] = $home_rimo_id;
|
||||||
@@ -637,6 +652,7 @@ foreach ($clusters as $cluster_data) {
|
|||||||
if($unit_changed) {
|
if($unit_changed) {
|
||||||
$unit->save();
|
$unit->save();
|
||||||
$unit->resetSaveNesting();
|
$unit->resetSaveNesting();
|
||||||
|
$unit_changed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -733,6 +749,7 @@ foreach ($clusters as $cluster_data) {
|
|||||||
if($hausnummer_changed) {
|
if($hausnummer_changed) {
|
||||||
$hausnummer->save();
|
$hausnummer->save();
|
||||||
$hausnummer->resetSaveNesting();
|
$hausnummer->resetSaveNesting();
|
||||||
|
$hausnummer_changed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -748,6 +765,8 @@ foreach ($clusters as $cluster_data) {
|
|||||||
$addressErrors[] = $delete_string;
|
$addressErrors[] = $delete_string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($disable_delete) continue;
|
||||||
|
|
||||||
if(!\ADBWohneinheitModel::count(["hausnummer_id" => $hausnummer->id])) {
|
if(!\ADBWohneinheitModel::count(["hausnummer_id" => $hausnummer->id])) {
|
||||||
// keine homes mehr übrig, lösche Hausnummer
|
// keine homes mehr übrig, lösche Hausnummer
|
||||||
echo "[DD] Deleting Hausnummer ".$hausnummer->id.", da keine Wohneinheit mehr (extref ".$hausnummer->extref.", rimo_id: ".$hausnummer->rimo_id.")\n";
|
echo "[DD] Deleting Hausnummer ".$hausnummer->id.", da keine Wohneinheit mehr (extref ".$hausnummer->extref.", rimo_id: ".$hausnummer->rimo_id.")\n";
|
||||||
@@ -1022,6 +1041,9 @@ function getServiceDnValues($dn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
function deleteHomesIfEligible(Array $rimo_home_list, Object $hausnummer) {
|
function deleteHomesIfEligible(Array $rimo_home_list, Object $hausnummer) {
|
||||||
|
global $disable_delete;
|
||||||
|
if($disable_delete) return [];
|
||||||
|
|
||||||
$return_strings = [];
|
$return_strings = [];
|
||||||
foreach (\ADBWohneinheitModel::search(["hausnummer_id" => $hausnummer->id]) as $adb_unit) {
|
foreach (\ADBWohneinheitModel::search(["hausnummer_id" => $hausnummer->id]) as $adb_unit) {
|
||||||
//$adb_unit->rimo_deleted = 1;
|
//$adb_unit->rimo_deleted = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user