relationgraph.class.inc.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. <?php
  2. // Copyright (C) 2015 Combodo SARL
  3. //
  4. // This file is part of iTop.
  5. //
  6. // iTop is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU Affero General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // iTop is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU Affero General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Affero General Public License
  17. // along with iTop. If not, see <http://www.gnu.org/licenses/>
  18. /**
  19. * Data structures (i.e. PHP classes) to build and use relation graphs
  20. *
  21. * @copyright Copyright (C) 2015 Combodo SARL
  22. * @license http://opensource.org/licenses/AGPL-3.0
  23. *
  24. */
  25. require_once(APPROOT.'core/simplegraph.class.inc.php');
  26. /**
  27. * An object Node inside a RelationGraph
  28. */
  29. class RelationObjectNode extends GraphNode
  30. {
  31. public function __construct($oGraph, $oObject)
  32. {
  33. parent::__construct($oGraph, self::MakeId($oObject));
  34. $this->SetProperty('object', $oObject);
  35. $this->SetProperty('label', get_class($oObject).'::'.$oObject->GetKey().' ('.$oObject->Get('friendlyname').')');
  36. }
  37. /**
  38. * Make a normalized ID to ensure the uniqueness of such a node
  39. */
  40. public static function MakeId($oObject)
  41. {
  42. return get_class($oObject).'::'.$oObject->GetKey();
  43. }
  44. /**
  45. * Formatting for GraphViz
  46. */
  47. public function GetDotAttributes($bNoLabel = false)
  48. {
  49. $sDot = parent::GetDotAttributes();
  50. if ($this->GetProperty('developped', false))
  51. {
  52. $sDot .= ',fontcolor=black';
  53. }
  54. else
  55. {
  56. $sDot .= ',fontcolor=lightgrey';
  57. }
  58. if ($this->GetProperty('source', false) || $this->GetProperty('sink', false))
  59. {
  60. $sDot .= ',shape=rectangle';
  61. }
  62. if ($this->GetProperty('is_reached', false))
  63. {
  64. $sDot .= ',fillcolor="#ffdddd"';
  65. }
  66. else
  67. {
  68. $sDot .= ',fillcolor=white';
  69. }
  70. return $sDot;
  71. }
  72. /**
  73. * Recursively mark the objects nodes as reached, unless we get stopped by a redundancy node or a 'not allowed' node
  74. */
  75. public function ReachDown($sProperty, $value)
  76. {
  77. if (is_null($this->GetProperty($sProperty)) && ($this->GetProperty($sProperty.'_allowed') !== false))
  78. {
  79. $this->SetProperty($sProperty, $value);
  80. foreach ($this->GetOutgoingEdges() as $oOutgoingEdge)
  81. {
  82. // Recurse
  83. $oOutgoingEdge->GetSinkNode()->ReachDown($sProperty, $value);
  84. }
  85. }
  86. }
  87. }
  88. /**
  89. * An redundancy Node inside a RelationGraph
  90. */
  91. class RelationRedundancyNode extends GraphNode
  92. {
  93. public function __construct($oGraph, $sId, $iMinUp, $fThreshold)
  94. {
  95. parent::__construct($oGraph, $sId);
  96. $this->SetProperty('min_up', $iMinUp);
  97. $this->SetProperty('threshold', $fThreshold);
  98. }
  99. /**
  100. * Make a normalized ID to ensure the uniqueness of such a node
  101. */
  102. public static function MakeId($sRelCode, $sNeighbourId, $oSinkObject)
  103. {
  104. return 'redundancy-'.$sRelCode.'-'.$sNeighbourId.'-'.get_class($oSinkObject).'::'.$oSinkObject->GetKey();
  105. }
  106. /**
  107. * Formatting for GraphViz
  108. */
  109. public function GetDotAttributes($bNoLabel = false)
  110. {
  111. $sDisplayThreshold = sprintf('%.1f', $this->GetProperty('threshold'));
  112. $sDot = 'shape=doublecircle,fillcolor=indianred,fontcolor=papayawhip,label="'.$sDisplayThreshold.'"';
  113. return $sDot;
  114. }
  115. /**
  116. * Recursively mark the objects nodes as reached, unless we get stopped by a redundancy node
  117. */
  118. public function ReachDown($sProperty, $value)
  119. {
  120. $this->SetProperty($sProperty.'_count', $this->GetProperty($sProperty.'_count', 0) + 1);
  121. if ($this->GetProperty($sProperty.'_count') > $this->GetProperty('threshold'))
  122. {
  123. // Looping... though there should be only ONE SINGLE outgoing edge
  124. foreach ($this->GetOutgoingEdges() as $oOutgoingEdge)
  125. {
  126. // Recurse
  127. $oOutgoingEdge->GetSinkNode()->ReachDown($sProperty, $value);
  128. }
  129. }
  130. }
  131. }
  132. /**
  133. * Helper to name the edges in a unique way
  134. */
  135. class RelationEdge extends GraphEdge
  136. {
  137. public function __construct(SimpleGraph $oGraph, GraphNode $oSourceNode, GraphNode $oSinkNode)
  138. {
  139. $sId = $oSourceNode->GetId().'-to-'.$oSinkNode->GetId();
  140. parent::__construct($oGraph, $sId, $oSourceNode, $oSinkNode);
  141. }
  142. }
  143. /**
  144. * A graph representing the relations between objects
  145. * The graph is made of two types of nodes. Here is a list of the meaningful node properties
  146. * 1) RelationObjectNode
  147. * source: boolean, that node was added as a source node
  148. * sink: boolean, that node was added as a sink node
  149. * reached: boolean, that node has been marked as reached (impacted by the source nodes)
  150. * developped: boolean, that node has been visited to search for related objects
  151. * 1) RelationRedundancyNode
  152. * reached_count: int, the number of source nodes having reached=true
  153. * threshold: float, if reached_count > threshold, the sink nodes become reachable
  154. */
  155. class RelationGraph extends SimpleGraph
  156. {
  157. protected $aSourceNodes; // Index of source nodes (for a quicker access)
  158. protected $aSinkNodes; // Index of sink nodes (for a quicker access)
  159. protected $aRedundancySettings; // Cache of user settings
  160. protected $aContextSearches; // Context ("knowing that") stored as a hash array 'class' => DBObjectSearch
  161. public function __construct()
  162. {
  163. parent::__construct();
  164. $this->aSourceNodes = array();
  165. $this->aSinkNodes = array();
  166. $this->aRedundancySettings = array();
  167. $this->aContextSearches = array();
  168. }
  169. /**
  170. * Add an object that will be the starting point for building the relations downstream
  171. */
  172. public function AddSourceObject(DBObject $oObject)
  173. {
  174. $oSourceNode = new RelationObjectNode($this, $oObject);
  175. $oSourceNode->SetProperty('source', true);
  176. $this->aSourceNodes[$oSourceNode->GetId()] = $oSourceNode;
  177. }
  178. /**
  179. * Add an object that will be the starting point for building the relations uptream
  180. */
  181. public function AddSinkObject(DBObject$oObject)
  182. {
  183. $oSinkNode = new RelationObjectNode($this, $oObject);
  184. $oSinkNode->SetProperty('sink', true);
  185. $this->aSinkNodes[$oSinkNode->GetId()] = $oSinkNode;
  186. }
  187. /**
  188. * Add a 'context' OQL query, specifying extra objects to be marked as 'is_reached'
  189. * even though they are not part of the sources.
  190. * @param string $sOQL The OQL query defining the context objects
  191. */
  192. public function AddContextQuery($key, $sOQL)
  193. {
  194. if ($sOQL === '') return;
  195. $oSearch = DBObjectSearch::FromOQL($sOQL);
  196. $aAliases = $oSearch->GetSelectedClasses();
  197. if (count($aAliases) < 2 )
  198. {
  199. IssueLog::Error("Invalid context query '$sOQL'. A context query must contain at least two columns.");
  200. throw new Exception("Invalid context query '$sOQL'. A context query must contain at least two columns. Columns: ".implode(', ', $aAliases).'. ');
  201. }
  202. $aAliasNames = array_keys($aAliases);
  203. $sClassAlias = $oSearch->GetClassAlias();
  204. $oCondition = new BinaryExpression(new FieldExpression('id', $aAliasNames[0]), '=', new VariableExpression('id'));
  205. $oSearch->AddConditionExpression($oCondition);
  206. $sClass = $oSearch->GetClass();
  207. if (!array_key_exists($sClass, $this->aContextSearches))
  208. {
  209. $this->aContextSearches[$sClass] = array();
  210. }
  211. $this->aContextSearches[$sClass][] = array('key' => $key, 'search' => $oSearch);
  212. }
  213. /**
  214. * Determines if the given DBObject is part of a 'context'
  215. * @param DBObject $oObj
  216. * @return boolean
  217. */
  218. public function IsPartOfContext(DBObject $oObj, &$aRootCauses)
  219. {
  220. $bRet = false;
  221. $sFinalClass = get_class($oObj);
  222. $aParentClasses = MetaModel::EnumParentClasses($sFinalClass, ENUM_PARENT_CLASSES_ALL);
  223. foreach($aParentClasses as $sClass)
  224. {
  225. if (array_key_exists($sClass, $this->aContextSearches))
  226. {
  227. foreach($this->aContextSearches[$sClass] as $aContextQuery)
  228. {
  229. $aAliases = $aContextQuery['search']->GetSelectedClasses();
  230. $aAliasNames = array_keys($aAliases);
  231. $sRootCauseAlias = $aAliasNames[1]; // 1st column (=0) = object, second column = root cause
  232. $oSet = new DBObjectSet($aContextQuery['search'], array(), array('id' => $oObj->GetKey()));
  233. while($aRow = $oSet->FetchAssoc())
  234. {
  235. if (!is_null($aRow[$sRootCauseAlias]))
  236. {
  237. if (!array_key_exists($aContextQuery['key'], $aRootCauses))
  238. {
  239. $aRootCauses[$aContextQuery['key']] = array();
  240. }
  241. $aRootCauses[$aContextQuery['key']][] = $aRow[$sRootCauseAlias];
  242. $bRet = true;
  243. }
  244. }
  245. }
  246. }
  247. }
  248. return $bRet;
  249. }
  250. /**
  251. * Build the graph downstream, and mark the nodes that can be reached from the source node
  252. */
  253. public function ComputeRelatedObjectsDown($sRelCode, $iMaxDepth, $bEnableRedundancy, $aUnreachableObjects = array())
  254. {
  255. //echo "<h5>Sources only...</h5>\n".$this->DumpAsHtmlImage()."<br/>\n";
  256. // Build the graph out of the sources
  257. foreach ($this->aSourceNodes as $oSourceNode)
  258. {
  259. $this->AddRelatedObjects($sRelCode, true, $oSourceNode, $iMaxDepth, $bEnableRedundancy);
  260. //echo "<h5>After processing of {$oSourceNode->GetId()}</h5>\n".$this->DumpAsHtmlImage()."<br/>\n";
  261. }
  262. // Mark the unreachable nodes
  263. foreach ($aUnreachableObjects as $oObj)
  264. {
  265. $sNodeId = RelationObjectNode::MakeId($oObj);
  266. $oNode = $this->GetNode($sNodeId);
  267. if($oNode)
  268. {
  269. $oNode->SetProperty('is_reached_allowed', false);
  270. }
  271. }
  272. // Determine the reached nodes
  273. foreach ($this->aSourceNodes as $oSourceNode)
  274. {
  275. $oSourceNode->ReachDown('is_reached', true);
  276. //echo "<h5>After reaching from {$oSourceNode->GetId()}</h5>\n".$this->DumpAsHtmlImage()."<br/>\n";
  277. }
  278. // Mark also the "context" nodes as reached and record the "root causes" for each node
  279. $oIterator = new RelationTypeIterator($this, 'Node');
  280. foreach($oIterator as $oNode)
  281. {
  282. $oObj = $oNode->GetProperty('object');
  283. $aRootCauses = array();
  284. if (!is_null($oObj) && $this->IsPartOfContext($oObj, $aRootCauses))
  285. {
  286. $oNode->SetProperty('context_root_causes', $aRootCauses);
  287. $oNode->ReachDown('is_reached', true);
  288. }
  289. }
  290. }
  291. /**
  292. * Build the graph upstream
  293. */
  294. public function ComputeRelatedObjectsUp($sRelCode, $iMaxDepth, $bEnableRedundancy)
  295. {
  296. //echo "<h5>Sinks only...</h5>\n".$this->DumpAsHtmlImage()."<br/>\n";
  297. // Build the graph out of the sinks
  298. foreach ($this->aSinkNodes as $oSinkNode)
  299. {
  300. $this->AddRelatedObjects($sRelCode, false, $oSinkNode, $iMaxDepth, $bEnableRedundancy);
  301. //echo "<h5>After processing of {$oSinkNode->GetId()}</h5>\n".$this->DumpAsHtmlImage()."<br/>\n";
  302. }
  303. // Mark also the "context" nodes as reached and record the "root causes" for each node
  304. $oIterator = new RelationTypeIterator($this, 'Node');
  305. foreach($oIterator as $oNode)
  306. {
  307. $oObj = $oNode->GetProperty('object');
  308. $aRootCauses = array();
  309. if (!is_null($oObj) && $this->IsPartOfContext($oObj, $aRootCauses))
  310. {
  311. $oNode->SetProperty('context_root_causes', $aRootCauses);
  312. $oNode->ReachDown('is_reached', true);
  313. }
  314. }
  315. }
  316. /**
  317. * Recursively find related objects, and add them into the graph
  318. *
  319. * @param string $sRelCode The code of the relation to use for the computation
  320. * @param boolean $bDown The direction: downstream or upstream
  321. * @param array $oObjectNode The node from which to compute the neighbours
  322. * @param int $iMaxDepth
  323. * @param boolean $bEnableReduncancy
  324. *
  325. * @return void
  326. */
  327. protected function AddRelatedObjects($sRelCode, $bDown, $oObjectNode, $iMaxDepth, $bEnableRedundancy)
  328. {
  329. if ($iMaxDepth > 0)
  330. {
  331. if ($oObjectNode instanceof RelationRedundancyNode)
  332. {
  333. // Note: this happens when recursing on an existing part of the graph
  334. // Skip that redundancy node
  335. $aRelatedEdges = $bDown ? $oObjectNode->GetOutgoingEdges() : $oObjectNode->GetIncomingEdges();
  336. foreach ($aRelatedEdges as $oRelatedEdge)
  337. {
  338. $oRelatedNode = $bDown ? $oRelatedEdge->GetSinkNode() : $oRelatedEdge->GetSourceNode();
  339. // Recurse (same depth)
  340. $this->AddRelatedObjects($sRelCode, $bDown, $oRelatedNode, $iMaxDepth, $bEnableRedundancy);
  341. }
  342. }
  343. elseif ($oObjectNode->GetProperty('developped', false))
  344. {
  345. // No need to execute the queries again... just dig into the nodes down/up to iMaxDepth
  346. //
  347. $aRelatedEdges = $bDown ? $oObjectNode->GetOutgoingEdges() : $oObjectNode->GetIncomingEdges();
  348. foreach ($aRelatedEdges as $oRelatedEdge)
  349. {
  350. $oRelatedNode = $bDown ? $oRelatedEdge->GetSinkNode() : $oRelatedEdge->GetSourceNode();
  351. // Recurse (decrement the depth)
  352. $this->AddRelatedObjects($sRelCode, $bDown, $oRelatedNode, $iMaxDepth - 1, $bEnableRedundancy);
  353. }
  354. }
  355. else
  356. {
  357. $oObjectNode->SetProperty('developped', true);
  358. $oObject = $oObjectNode->GetProperty('object');
  359. $iPreviousTimeLimit = ini_get('max_execution_time');
  360. $iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop');
  361. foreach (MetaModel::EnumRelationQueries(get_class($oObject), $sRelCode, $bDown) as $sDummy => $aQueryInfo)
  362. {
  363. $sQuery = $bDown ? $aQueryInfo['sQueryDown'] : $aQueryInfo['sQueryUp'];
  364. try
  365. {
  366. $oFlt = DBObjectSearch::FromOQL($sQuery);
  367. $oObjSet = new DBObjectSet($oFlt, array(), $oObject->ToArgsForQuery());
  368. $oRelatedObj = $oObjSet->Fetch();
  369. }
  370. catch (Exception $e)
  371. {
  372. $sDirection = $bDown ? 'downstream' : 'upstream';
  373. throw new Exception("Wrong query ($sDirection) for the relation $sRelCode/{$aQueryInfo['sDefinedInClass']}/{$aQueryInfo['sNeighbour']}: ".$e->getMessage());
  374. }
  375. if ($oRelatedObj)
  376. {
  377. do
  378. {
  379. set_time_limit($iLoopTimeLimit);
  380. $sObjectRef = RelationObjectNode::MakeId($oRelatedObj);
  381. $oRelatedNode = $this->GetNode($sObjectRef);
  382. if (is_null($oRelatedNode))
  383. {
  384. $oRelatedNode = new RelationObjectNode($this, $oRelatedObj);
  385. }
  386. $oSourceNode = $bDown ? $oObjectNode : $oRelatedNode;
  387. $oSinkNode = $bDown ? $oRelatedNode : $oObjectNode;
  388. if ($bEnableRedundancy)
  389. {
  390. $oRedundancyNode = $this->ComputeRedundancy($sRelCode, $aQueryInfo, $oSourceNode, $oSinkNode);
  391. }
  392. else
  393. {
  394. $oRedundancyNode = null;
  395. }
  396. if (!$oRedundancyNode)
  397. {
  398. // Direct link (otherwise handled by ComputeRedundancy)
  399. $oEdge = new RelationEdge($this, $oSourceNode, $oSinkNode);
  400. }
  401. // Recurse
  402. $this->AddRelatedObjects($sRelCode, $bDown, $oRelatedNode, $iMaxDepth - 1, $bEnableRedundancy);
  403. }
  404. while ($oRelatedObj = $oObjSet->Fetch());
  405. }
  406. }
  407. set_time_limit($iPreviousTimeLimit);
  408. }
  409. }
  410. }
  411. /**
  412. * Determine if there is a redundancy (or use the existing one) and add the corresponding nodes/edges
  413. */
  414. protected function ComputeRedundancy($sRelCode, $aQueryInfo, $oFromNode, $oToNode)
  415. {
  416. $oRedundancyNode = null;
  417. $oObject = $oToNode->GetProperty('object');
  418. if ($this->IsRedundancyEnabled($sRelCode, $aQueryInfo, $oToNode))
  419. {
  420. $sId = RelationRedundancyNode::MakeId($sRelCode, $aQueryInfo['sNeighbour'], $oToNode->GetProperty('object'));
  421. $oRedundancyNode = $this->GetNode($sId);
  422. if (is_null($oRedundancyNode))
  423. {
  424. // Get the upper neighbours
  425. $sQuery = $aQueryInfo['sQueryUp'];
  426. try
  427. {
  428. $oFlt = DBObjectSearch::FromOQL($sQuery);
  429. $oObjSet = new DBObjectSet($oFlt, array(), $oObject->ToArgsForQuery());
  430. $iCount = $oObjSet->Count();
  431. }
  432. catch (Exception $e)
  433. {
  434. throw new Exception("Wrong query (upstream) for the relation $sRelCode/{$aQueryInfo['sDefinedInClass']}/{$aQueryInfo['sNeighbour']}: ".$e->getMessage());
  435. }
  436. $iMinUp = $this->GetRedundancyMinUp($sRelCode, $aQueryInfo, $oToNode, $iCount);
  437. $fThreshold = max(0, $iCount - $iMinUp);
  438. $oRedundancyNode = new RelationRedundancyNode($this, $sId, $iMinUp, $fThreshold);
  439. new RelationEdge($this, $oRedundancyNode, $oToNode);
  440. while ($oUpperObj = $oObjSet->Fetch())
  441. {
  442. $sObjectRef = RelationObjectNode::MakeId($oUpperObj);
  443. $oUpperNode = $this->GetNode($sObjectRef);
  444. if (is_null($oUpperNode))
  445. {
  446. $oUpperNode = new RelationObjectNode($this, $oUpperObj);
  447. }
  448. new RelationEdge($this, $oUpperNode, $oRedundancyNode);
  449. }
  450. }
  451. }
  452. return $oRedundancyNode;
  453. }
  454. /**
  455. * Helper to determine the redundancy setting on a given relation
  456. */
  457. protected function IsRedundancyEnabled($sRelCode, $aQueryInfo, $oToNode)
  458. {
  459. $bRet = false;
  460. $oToObject = $oToNode->GetProperty('object');
  461. $oRedundancyAttDef = $this->FindRedundancyAttribute($sRelCode, $aQueryInfo, get_class($oToObject));
  462. if ($oRedundancyAttDef)
  463. {
  464. $sValue = $oToObject->Get($oRedundancyAttDef->GetCode());
  465. $bRet = $oRedundancyAttDef->IsEnabled($sValue);
  466. }
  467. return $bRet;
  468. }
  469. /**
  470. * Helper to determine the redundancy threshold, given the count of objects upstream
  471. */
  472. protected function GetRedundancyMinUp($sRelCode, $aQueryInfo, $oToNode, $iUpstreamObjects)
  473. {
  474. $iMinUp = 0;
  475. $oToObject = $oToNode->GetProperty('object');
  476. $oRedundancyAttDef = $this->FindRedundancyAttribute($sRelCode, $aQueryInfo, get_class($oToObject));
  477. if ($oRedundancyAttDef)
  478. {
  479. $sValue = $oToObject->Get($oRedundancyAttDef->GetCode());
  480. if ($oRedundancyAttDef->GetMinUpType($sValue) == 'count')
  481. {
  482. $iMinUp = $oRedundancyAttDef->GetMinUpValue($sValue);
  483. }
  484. else
  485. {
  486. $iMinUp = $iUpstreamObjects * $oRedundancyAttDef->GetMinUpValue($sValue) / 100;
  487. }
  488. }
  489. return $iMinUp;
  490. }
  491. /**
  492. * Helper to search for the redundancy attribute
  493. */
  494. protected function FindRedundancyAttribute($sRelCode, $aQueryInfo, $sClass)
  495. {
  496. $oRet = null;
  497. foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
  498. {
  499. if ($oAttDef instanceof AttributeRedundancySettings)
  500. {
  501. if ($oAttDef->Get('relation_code') == $sRelCode)
  502. {
  503. if ($oAttDef->Get('neighbour_id') == $aQueryInfo['sNeighbour'])
  504. {
  505. $oRet = $oAttDef;
  506. break;
  507. }
  508. }
  509. }
  510. }
  511. return $oRet;
  512. }
  513. /**
  514. * Get the objects referenced by the graph as a hash array: 'class' => array of objects
  515. * @return Ambigous <multitype:multitype: , unknown>
  516. */
  517. public function GetObjectsByClass()
  518. {
  519. $aResults = array();
  520. $oIterator = new RelationTypeIterator($this, 'Node');
  521. foreach($oIterator as $oNode)
  522. {
  523. $oObj = $oNode->GetProperty('object'); // Some nodes (Redundancy Nodes and Group) do not contain an object
  524. if ($oObj)
  525. {
  526. $sObjClass = get_class($oObj);
  527. if (!array_key_exists($sObjClass, $aResults))
  528. {
  529. $aResults[$sObjClass] = array();
  530. }
  531. $aResults[$sObjClass][] = $oObj;
  532. }
  533. }
  534. return $aResults;
  535. }
  536. }