Obsolescence: introduction of this new concept (wording could change later). The obsolescence of an object is computed after other attributes, by the mean of an OQL expression. The code has been refactored (again) so as to factorize between the computation of friendly names and the computation of obsolescence flags. The refactoring involved a significant AND RISKY change: external key friendly names (magic attributes) have been changed from AttributeFriendlyName to AttributeExternalField, which simplifies the SQL query build logic.

SVN:trunk[4732]
This commit is contained in:
Romain Quetiez
2017-05-11 11:58:42 +00:00
parent 6c6ad0a45b
commit 44b53e40a0
11 changed files with 415 additions and 187 deletions

View File

@@ -410,7 +410,7 @@ abstract class DBObject implements iDisplay
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sCode => $oDef)
{
if (($oDef->IsExternalField() || ($oDef instanceof AttributeFriendlyName)) && ($oDef->GetKeyAttCode() == $sAttCode))
if ($oDef->IsExternalField() && ($oDef->GetKeyAttCode() == $sAttCode))
{
$this->m_aCurrValues[$sCode] = $value->Get($oDef->GetExtAttCode());
$this->m_aLoadedAtt[$sCode] = true;
@@ -423,7 +423,7 @@ abstract class DBObject implements iDisplay
// Invalidate the corresponding fields so that they get reloaded in case they are needed (See Get())
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sCode => $oDef)
{
if (($oDef->IsExternalField() || ($oDef instanceof AttributeFriendlyName)) && ($oDef->GetKeyAttCode() == $sAttCode))
if ($oDef->IsExternalField() && ($oDef->GetKeyAttCode() == $sAttCode))
{
$this->m_aCurrValues[$sCode] = $oDef->GetDefaultValue($this);
unset($this->m_aLoadedAtt[$sCode]);
@@ -566,7 +566,7 @@ abstract class DBObject implements iDisplay
else
{
// Not loaded... is it related to an external key?
if ($oAttDef->IsExternalField() || ($oAttDef instanceof AttributeFriendlyName))
if ($oAttDef->IsExternalField())
{
// Let's get the object and compute all of the corresponding attributes
// (i.e not only the requested attribute)
@@ -588,7 +588,7 @@ abstract class DBObject implements iDisplay
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sCode => $oDef)
{
if (($oDef->IsExternalField() || ($oDef instanceof AttributeFriendlyName)) && ($oDef->GetKeyAttCode() == $sExtKeyAttCode))
if ($oDef->IsExternalField() && ($oDef->GetKeyAttCode() == $sExtKeyAttCode))
{
if ($oRemote)
{
@@ -3614,6 +3614,16 @@ abstract class DBObject implements iDisplay
return $bRet;
}
public function IsObsolete()
{
$bRet = false;
if (MetaModel::IsValidAttCode(get_class($this), 'obsolescence_flag') && $this->Get('obsolescence_flag'))
{
$bRet = true;
}
return $bRet;
}
/**
* @param $bArchive
* @throws Exception