N°3171 - Friendly name and obsolescence flag not refreshed (#151)

- Compute any type of expression on server side
- Recompute friendly name and obsolescence flag on server side (DBOBject)
- Bonus : compute dependency for external keys
This commit is contained in:
Romain Quetiez
2020-07-10 17:26:37 +02:00
committed by GitHub
parent b1fa429234
commit acf0548c4c
9 changed files with 1435 additions and 51 deletions

View File

@@ -6653,6 +6653,23 @@ class AttributeExternalKey extends AttributeDBFieldVoid
return (int)$proposedValue;
}
public function GetPrerequisiteAttributes($sClass = null)
{
$aAttributes = parent::GetPrerequisiteAttributes($sClass);
$oExpression = DBSearch::FromOQL($this->GetValuesDef()->GetFilterExpression())->GetCriteria();
foreach ($oExpression->GetParameters('this') as $sAttCode)
{
// Skip the id as it cannot change anyway
if ($sAttCode =='id') continue;
if (!in_array($sAttCode, $aAttributes))
{
$aAttributes[] = $sAttCode;
}
}
return $aAttributes;
}
public function GetMaximumComboLength()
{
return $this->GetOptional('max_combo_length', MetaModel::GetConfig()->Get('max_combo_length'));
@@ -11561,7 +11578,17 @@ class AttributeFriendlyName extends AttributeDefinition
public function GetPrerequisiteAttributes($sClass = null)
{
return $this->GetOptional("depends_on", array());
// Code duplicated with AttributeObsolescenceFlag
$aAttributes = $this->GetOptional("depends_on", array());
$oExpression = $this->GetOQLExpression();
foreach ($oExpression->ListRequiredFields() as $sClass => $sAttCode)
{
if (!in_array($sAttCode, $aAttributes))
{
$aAttributes[] = $sAttCode;
}
}
return $aAttributes;
}
public static function IsScalar()
@@ -12793,7 +12820,17 @@ class AttributeObsolescenceFlag extends AttributeBoolean
public function GetPrerequisiteAttributes($sClass = null)
{
return $this->GetOptional("depends_on", array());
// Code duplicated with AttributeFriendlyName
$aAttributes = $this->GetOptional("depends_on", array());
$oExpression = $this->GetOQLExpression();
foreach ($oExpression->ListRequiredFields() as $sClass => $sAttCode)
{
if (!in_array($sAttCode, $aAttributes))
{
$aAttributes[] = $sAttCode;
}
}
return $aAttributes;
}
public function IsDirectField()