mirror of
https://github.com/Combodo/iTop.git
synced 2026-08-05 21:38:24 +02:00
* N°9144 - correct next button in audit page * N°9567 - WIP code style * N°9412 - Screen Analysis results wip + test endpoint * N°9412 - next button label * N°9412 - Mask CI pbs * N°9412 - Analysis results screen wip * N°9412 - Analysis results screen wip * N°9567 - fix extension map init of installation choices * N°9567 - fix test * N°9567 - link from ext mgt to setup WIP * N°9567 - add enc_type in UIForm to be able to change content type in twigs * N°9412 - wip * N°9567 - Extension Mgmt : Run setup * N°9567 - Extension Mgmt : Run setup * N°9567 - Extension Mgmt : Run setup (fix post-deletion button inputs) * N°9567 - Extension Mgmt : Run setup * N°9567 - Extension Mgmt : Run setup * N°9567 - Extension Mgmt : Run setup --------- Co-authored-by: Eric Espie <eric.espie@combodo.com>
72 lines
2.3 KiB
PHP
72 lines
2.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* @copyright Copyright (C) 2010-2026 Combodo SAS
|
|
* @license http://opensource.org/licenses/AGPL-3.0
|
|
*/
|
|
|
|
namespace Combodo\iTop\DataFeatureRemoval\Service;
|
|
|
|
use Combodo\iTop\DataFeatureRemoval\Entity\DataCleanupSummaryEntity;
|
|
use Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalLog;
|
|
use DBObject;
|
|
|
|
/**
|
|
* Manage operation summary instead of doing the actual update or delete
|
|
*
|
|
* The summary is an array [class => DeletionPlanSummaryEntity]
|
|
*/
|
|
class ObjectServiceSummary implements iObjectService
|
|
{
|
|
private array $aSummary = [];
|
|
|
|
public function Update(DBObject $oToUpdate, string $sAttCode, $value): void
|
|
{
|
|
$sClass = get_class($oToUpdate);
|
|
DataFeatureRemovalLog::Debug('Object to update', null, ['class' => $sClass, 'id' => $oToUpdate->GetKey(), 'code' => $sAttCode, 'value' => "$value"]);
|
|
if (! array_key_exists($sClass, $this->aSummary)) {
|
|
$this->aSummary[$sClass] = new DataCleanupSummaryEntity($sClass);
|
|
}
|
|
$oDeletionPlanSummaryEntity = $this->aSummary[$sClass];
|
|
$oDeletionPlanSummaryEntity->iUpdateCount++;
|
|
$oDeletionPlanSummaryEntity->iTotalUpdateCount++;
|
|
}
|
|
|
|
public function Delete(string $sClass, string $sId): void
|
|
{
|
|
DataFeatureRemovalLog::Debug('Object to delete', null, ['class' => $sClass, 'id' => $sId]);
|
|
if (!array_key_exists($sClass, $this->aSummary)) {
|
|
$this->aSummary[$sClass] = new DataCleanupSummaryEntity($sClass);
|
|
}
|
|
$oDeletionPlanSummaryEntity = $this->aSummary[$sClass];
|
|
$oDeletionPlanSummaryEntity->iDeleteCount++;
|
|
$oDeletionPlanSummaryEntity->iTotalDeleteCount++;
|
|
}
|
|
|
|
public function SetIssue(string $sClass): void
|
|
{
|
|
DataFeatureRemovalLog::Debug('Issue on object', null, ['class' => $sClass]);
|
|
if (!array_key_exists($sClass, $this->aSummary)) {
|
|
$this->aSummary[$sClass] = new DataCleanupSummaryEntity($sClass);
|
|
}
|
|
$oDeletionPlanSummaryEntity = $this->aSummary[$sClass];
|
|
$oDeletionPlanSummaryEntity->iIssueCount++;
|
|
}
|
|
|
|
public function GetSummary(): array
|
|
{
|
|
return $this->aSummary;
|
|
}
|
|
|
|
public function SetSummary(array $aSummary): void
|
|
{
|
|
foreach ($aSummary as $sClass => $oPreviousSummaryEntity) {
|
|
$oSummaryEntity = new DataCleanupSummaryEntity($sClass);
|
|
$oSummaryEntity->iTotalUpdateCount = $oPreviousSummaryEntity->iTotalUpdateCount;
|
|
$oSummaryEntity->iTotalDeleteCount = $oPreviousSummaryEntity->iTotalDeleteCount;
|
|
|
|
$this->aSummary[$sClass] = $oSummaryEntity;
|
|
}
|
|
}
|
|
}
|