2548 - API : remove \DBObject::GetRelationQueries overrides in default datamodel

This commit is contained in:
acognet
2020-07-01 16:27:54 +02:00
parent 46d91322c1
commit 98870b06e3
6 changed files with 27 additions and 501 deletions

View File

@@ -4336,22 +4336,7 @@ abstract class DBObject implements iDisplay
}
/**
* implement relations
*
* Return an empty set for the parent of all
*
* this way of implementing the relations suffers limitations (not handling the redundancy)
* and you should consider defining those things in XML
*
* @internal
* @deprecated
*/
public static function GetRelationQueries($sRelCode)
{
return array();
}
/**
* Reserved: do not overload
*

View File

@@ -2047,7 +2047,6 @@ abstract class MetaModel
*/
protected static function ComputeRelationQueries($sRelCode)
{
$bHasLegacy = false;
$aQueries = array();
foreach(self::GetClasses() as $sClass)
{
@@ -2133,158 +2132,8 @@ abstract class MetaModel
}
}
}
// Read legacy definitions
// The up/down queries have to be reconcilied, which can only be done later when all the classes have been browsed
//
// The keys used to store a query (up or down) into the array are built differently between the modern and legacy made data:
// Modern way: aQueries[sClass]['up'|'down'][sArrowId], where sArrowId is made of the source class + neighbour id (XML def)
// Legacy way: aQueries[sClass]['up'|'down'][sRemoteClass]
// The modern way does allow for several arrows between two classes
// The legacy way aims at simplifying the transformation (reconciliation between up and down)
if ($sRelCode == 'impacts')
{
$sRevertCode = 'depends on';
$aLegacy = call_user_func_array(array($sClass, 'GetRelationQueries'), array($sRelCode));
foreach($aLegacy as $sId => $aLegacyEntry)
{
$bHasLegacy = true;
$oFilter = DBObjectSearch::FromOQL($aLegacyEntry['sQuery']);
$sRemoteClass = $oFilter->GetClass();
// Determine wether the query is inherited from a parent or not
$bInherited = false;
foreach(self::EnumParentClasses($sClass) as $sParent)
{
if (!isset($aQueries[$sParent]['down'][$sRemoteClass]))
{
continue;
}
if ($aLegacyEntry['sQuery'] == $aQueries[$sParent]['down'][$sRemoteClass]['sQueryDown'])
{
$bInherited = true;
$aQueries[$sClass]['down'][$sRemoteClass] = $aQueries[$sParent]['down'][$sRemoteClass];
break;
}
}
if (!$bInherited)
{
$aQueries[$sClass]['down'][$sRemoteClass] = array(
'_legacy_' => true,
'sDefinedInClass' => $sClass,
'sFromClass' => $sClass,
'sToClass' => $sRemoteClass,
'sDirection' => 'down',
'sQueryDown' => $aLegacyEntry['sQuery'],
'sQueryUp' => null,
'sNeighbour' => $sRemoteClass // Normalize the neighbour id
);
}
}
$aLegacy = call_user_func_array(array($sClass, 'GetRelationQueries'), array($sRevertCode));
foreach($aLegacy as $sId => $aLegacyEntry)
{
$bHasLegacy = true;
$oFilter = DBObjectSearch::FromOQL($aLegacyEntry['sQuery']);
$sRemoteClass = $oFilter->GetClass();
// Determine wether the query is inherited from a parent or not
$bInherited = false;
foreach(self::EnumParentClasses($sClass) as $sParent)
{
if (!isset($aQueries[$sParent]['up'][$sRemoteClass]))
{
continue;
}
if ($aLegacyEntry['sQuery'] == $aQueries[$sParent]['up'][$sRemoteClass]['sQueryUp'])
{
$bInherited = true;
$aQueries[$sClass]['up'][$sRemoteClass] = $aQueries[$sParent]['up'][$sRemoteClass];
break;
}
}
if (!$bInherited)
{
$aQueries[$sClass]['up'][$sRemoteClass] = array(
'_legacy_' => true,
'sDefinedInClass' => $sRemoteClass,
'sFromClass' => $sRemoteClass,
'sToClass' => $sClass,
'sDirection' => 'both',
'sQueryDown' => null,
'sQueryUp' => $aLegacyEntry['sQuery'],
'sNeighbour' => $sClass// Normalize the neighbour id
);
}
}
}
//else
//{
// Cannot take the legacy system into account... simply ignore it
//}
} // foreach class
// Perform the up/down reconciliation for the legacy definitions
if ($bHasLegacy)
{
foreach(self::GetClasses() as $sClass)
{
// Foreach "up" legacy query, update its "down" counterpart
if (isset($aQueries[$sClass]['up']))
{
foreach($aQueries[$sClass]['up'] as $sNeighbourId => $aNeighbourData)
{
if (!array_key_exists('_legacy_', $aNeighbourData))
{
continue;
}
if (!$aNeighbourData['_legacy_'])
{
continue;
} // Skip modern definitions
$sLocalClass = $aNeighbourData['sToClass'];
foreach(self::EnumChildClasses($aNeighbourData['sFromClass'], ENUM_CHILD_CLASSES_ALL) as $sRemoteClass)
{
if (isset($aQueries[$sRemoteClass]['down'][$sLocalClass]))
{
$aQueries[$sRemoteClass]['down'][$sLocalClass]['sQueryUp'] = $aNeighbourData['sQueryUp'];
$aQueries[$sRemoteClass]['down'][$sLocalClass]['sDirection'] = 'both';
}
// Be silent in order to transparently support legacy data models where the counterpart query does not always exist
//else
//{
// throw new Exception("Legacy definition of the relation '$sRelCode/$sRevertCode', defined on $sLocalClass (relation: $sRevertCode, inherited to $sClass), missing the counterpart query on class $sRemoteClass ($sRelCode)");
//}
}
}
}
// Foreach "down" legacy query, update its "up" counterpart (if any)
foreach($aQueries[$sClass]['down'] as $sNeighbourId => $aNeighbourData)
{
if (!$aNeighbourData['_legacy_'])
{
continue;
} // Skip modern definitions
$sLocalClass = $aNeighbourData['sFromClass'];
foreach(self::EnumChildClasses($aNeighbourData['sToClass'], ENUM_CHILD_CLASSES_ALL) as $sRemoteClass)
{
if (isset($aQueries[$sRemoteClass]['up'][$sLocalClass]))
{
$aQueries[$sRemoteClass]['up'][$sLocalClass]['sQueryDown'] = $aNeighbourData['sQueryDown'];
}
}
}
}
}
return $aQueries;
}
@@ -3318,18 +3167,6 @@ abstract class MetaModel
// In fact it is an ABSTRACT function, but this is not compatible with the fact that it is STATIC (error in E_STRICT interpretation)
}
/**
* To be overloaded by biz model declarations
*
* @param string $sRelCode
*
* @return array
*/
public static function GetRelationQueries($sRelCode)
{
// In fact it is an ABSTRACT function, but this is not compatible with the fact that it is STATIC (error in E_STRICT interpretation)
return array();
}
/**
* @param array $aParams

View File

@@ -1684,16 +1684,6 @@
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
<method id="DisplayBareRelations">
<static>false</static>
<access>public</access>
@@ -2170,18 +2160,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
</class>
<class id="DatacenterDevice" _delta="define">
<parent>ConnectableCI</parent>
@@ -2732,18 +2711,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<relations>
<relation id="impacts">
<neighbours>
@@ -3060,18 +3028,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
</class>
<class id="ApplicationSolution" _delta="define">
<parent>FunctionalCI</parent>
@@ -3210,18 +3167,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<relations>
<relation id="impacts">
<neighbours>
@@ -3341,18 +3287,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
</class>
<class id="SoftwareInstance" _delta="define">
<parent>FunctionalCI</parent>
@@ -3533,18 +3468,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
</class>
<class id="Middleware" _delta="define">
<parent>SoftwareInstance</parent>
@@ -3669,18 +3593,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<relations>
<relation id="impacts">
<neighbours>
@@ -3814,18 +3727,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<relations>
<relation id="impacts">
<neighbours>
@@ -3959,18 +3861,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<relations>
<relation id="impacts">
<neighbours>
@@ -4329,18 +4220,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
</class>
<class id="DatabaseSchema" _delta="define">
<parent>FunctionalCI</parent>
@@ -4462,18 +4342,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
</class>
<class id="WebApplication" _delta="define">
<parent>FunctionalCI</parent>
@@ -4604,18 +4473,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
</class>
<class id="Software" _delta="define">
<parent>cmdbAbstractObject</parent>

View File

@@ -232,18 +232,7 @@
<count_max>0</count_max>
</field>
</fields>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<presentation>
<details>
<items>
@@ -411,18 +400,7 @@
</reconciliation>
</properties>
<fields/>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<presentation>
<details>
<items>
@@ -911,18 +889,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
</class>
</classes>
<menus>

View File

@@ -240,18 +240,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<relations>
<relation id="impacts">
<neighbours>
@@ -498,18 +487,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<relations>
<relation id="impacts">
<neighbours>
@@ -756,18 +734,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<relations>
<relation id="impacts">
<neighbours>
@@ -1014,18 +981,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<relations>
<relation id="impacts">
<neighbours>
@@ -1127,18 +1083,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
</class>
<class id="NASFileSystem" _delta="define">
<parent>cmdbAbstractObject</parent>
@@ -1245,18 +1190,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
</class>
<class id="FiberChannelInterface" _delta="define">
<parent>NetworkInterface</parent>
@@ -1511,18 +1445,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<relations>
<relation id="impacts">
<neighbours>

View File

@@ -235,18 +235,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<relations>
<relation id="impacts">
<neighbours>
@@ -394,18 +383,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
<relations>
<relation id="impacts">
<neighbours>
@@ -540,18 +518,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
</class>
<class id="VirtualMachine" _delta="define">
<parent>VirtualDevice</parent>
@@ -783,18 +750,7 @@
</items>
</list>
</presentation>
<methods>
<method id="GetRelationQueries">
<comment>/**
* Placeholder for backward compatibility (iTop &lt;= 2.1.0)
* in case an extension attempts to redefine this function...
*/</comment>
<static>true</static>
<access>public</access>
<type>Overload-DBObject</type>
<code><![CDATA[ public static function GetRelationQueries($sRelCode){return parent::GetRelationQueries($sRelCode);} ]]></code>
</method>
</methods>
<methods/>
</class>
<class id="LogicalInterface" _delta="define">
<parent>IPInterface</parent>