From dbee38dfd110d8a01a31a6e04f72b9573c41fd2d Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Sun, 4 Jul 2010 07:46:45 +0000 Subject: [PATCH] ComputeValues optimized + fix in the algo computing the priority of an Incident SVN:trunk[543] --- core/dbobject.class.php | 15 ++++++++--- .../itop-tickets-1.0.0/model.itop-tickets.php | 26 +++++++------------ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/core/dbobject.class.php b/core/dbobject.class.php index 517248934..e665328ca 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -50,6 +50,10 @@ abstract class DBObject { $this->FromRow($aRow, $sClassAlias); $this->m_bFullyLoaded = $this->IsFullyLoaded(); + if ($this->m_bFullyLoaded) + { + $this->DoComputeValues(); + } return; } // Creation of brand new object @@ -74,6 +78,7 @@ abstract class DBObject $this->m_aLoadedAtt[$sAttCode] = true; } } + $this->DoComputeValues(); } // Read-only <=> Written once (archive) @@ -149,6 +154,7 @@ abstract class DBObject throw new CoreException("Failed to reload object of class '".get_class($this)."', id = ".$this->m_iKey); } $this->FromRow($aRow); + $this->DoComputeValues(); // Process linked set attributes // @@ -338,7 +344,6 @@ abstract class DBObject // #@# non-scalar attributes.... handle that differentely $this->Reload(); } - $this->ComputeFields(); return $this->m_aCurrValues[$sAttCode]; } @@ -351,7 +356,8 @@ abstract class DBObject return $this->m_aOrigValues[$sAttCode]; } - public function ComputeFields() + // Compute scalar attributes that depend on any other type of attribute + public function DoComputeValues() { if (is_callable(array($this, 'ComputeValues'))) { @@ -820,7 +826,7 @@ abstract class DBObject $sRootClass = MetaModel::GetRootClass($sClass); // Ensure the update of the values (we are accessing the data directly) - $this->ComputeFields(); + $this->DoComputeValues(); $this->OnInsert(); if ($this->m_iKey < 0) @@ -896,6 +902,9 @@ abstract class DBObject { throw new CoreException("DBUpdate: could not update a newly created object, please call DBInsert instead"); } + + $this->DoComputeValues(); + $aChanges = $this->ListChanges(); if (count($aChanges) == 0) { diff --git a/modules/itop-tickets-1.0.0/model.itop-tickets.php b/modules/itop-tickets-1.0.0/model.itop-tickets.php index a37be8376..a701062f0 100644 --- a/modules/itop-tickets-1.0.0/model.itop-tickets.php +++ b/modules/itop-tickets-1.0.0/model.itop-tickets.php @@ -376,30 +376,24 @@ class Incident extends Ticket $aPriorities = array( // single person 1 => array( - array( - 1 => 1, - 2 => 1, - 3 => 2, - ) + 1 => 1, + 2 => 1, + 3 => 2, ), // a group 2 => array( - array( - 1 => 1, - 2 => 2, - 3 => 3, - ) + 1 => 1, + 2 => 2, + 3 => 3, ), // a departement! 3 => array( - array( - 1 => 2, - 2 => 3, - 3 => 3, - ) + 1 => 2, + 2 => 3, + 3 => 3, ), ); - $iPriority = 1; //$aPriorities[$this->Get('impact')][$this->Get('urgency')]; + $iPriority = $aPriorities[$this->Get('impact')][$this->Get('urgency')]; $this->Set('priority', $iPriority); // Compute the SLA deadlines