mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
Prevent timeouts during the computation of the impact analysis + keep the columns (and ordering) in the lists of objects when creating a PDF of the impact analysis.
SVN:trunk[3707]
This commit is contained in:
@@ -702,10 +702,13 @@ class DisplayableGraph extends SimpleGraph
|
||||
{
|
||||
$oNewGraph = new DisplayableGraph();
|
||||
$oNewGraph->bDirectionDown = $bDirectionDown;
|
||||
$iPreviousTimeLimit = ini_get('max_execution_time');
|
||||
$iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop');
|
||||
|
||||
$oNodesIter = new RelationTypeIterator($oGraph, 'Node');
|
||||
foreach($oNodesIter as $oNode)
|
||||
{
|
||||
set_time_limit($iLoopTimeLimit);
|
||||
switch(get_class($oNode))
|
||||
{
|
||||
case 'RelationObjectNode':
|
||||
@@ -753,6 +756,7 @@ class DisplayableGraph extends SimpleGraph
|
||||
$oEdgesIter = new RelationTypeIterator($oGraph, 'Edge');
|
||||
foreach($oEdgesIter as $oEdge)
|
||||
{
|
||||
set_time_limit($iLoopTimeLimit);
|
||||
$oSourceNode = $oNewGraph->GetNode($oEdge->GetSourceNode()->GetId());
|
||||
$oSinkNode = $oNewGraph->GetNode($oEdge->GetSinkNode()->GetId());
|
||||
$oNewEdge = new DisplayableEdge($oNewGraph, $oEdge->GetId(), $oSourceNode, $oSinkNode);
|
||||
@@ -763,6 +767,7 @@ class DisplayableGraph extends SimpleGraph
|
||||
$aEdgeKeys = array();
|
||||
foreach($oEdgesIter as $oEdge)
|
||||
{
|
||||
set_time_limit($iLoopTimeLimit);
|
||||
$sSourceId = $oEdge->GetSourceNode()->GetId();
|
||||
$sSinkId = $oEdge->GetSinkNode()->GetId();
|
||||
if ($sSourceId == $sSinkId)
|
||||
@@ -788,6 +793,7 @@ class DisplayableGraph extends SimpleGraph
|
||||
$oNodesIter = new RelationTypeIterator($oNewGraph, 'Node');
|
||||
foreach($oNodesIter as $oNode)
|
||||
{
|
||||
set_time_limit($iLoopTimeLimit);
|
||||
if ($oNode->GetProperty('source'))
|
||||
{
|
||||
$oNode->GroupSimilarNeighbours($oNewGraph, $iGroupingThreshold, true, true);
|
||||
@@ -798,6 +804,7 @@ class DisplayableGraph extends SimpleGraph
|
||||
$iGroupIdx = 0;
|
||||
foreach($oIterator as $oNode)
|
||||
{
|
||||
set_time_limit($iLoopTimeLimit);
|
||||
if ($oNode instanceof DisplayableGroupNode)
|
||||
{
|
||||
$aGroups[] = $oNode->GetObjects();
|
||||
@@ -811,6 +818,7 @@ class DisplayableGraph extends SimpleGraph
|
||||
$aEdgeKeys = array();
|
||||
foreach($oEdgesIter as $oEdge)
|
||||
{
|
||||
set_time_limit($iLoopTimeLimit);
|
||||
$sSourceId = $oEdge->GetSourceNode()->GetId();
|
||||
$sSinkId = $oEdge->GetSinkNode()->GetId();
|
||||
if ($sSourceId == $sSinkId)
|
||||
@@ -832,7 +840,8 @@ class DisplayableGraph extends SimpleGraph
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set_time_limit($iPreviousTimeLimit);
|
||||
|
||||
return $oNewGraph;
|
||||
}
|
||||
|
||||
|
||||
@@ -385,6 +385,8 @@ class RelationGraph extends SimpleGraph
|
||||
$oObjectNode->SetProperty('developped', true);
|
||||
|
||||
$oObject = $oObjectNode->GetProperty('object');
|
||||
$iPreviousTimeLimit = ini_get('max_execution_time');
|
||||
$iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop');
|
||||
foreach (MetaModel::EnumRelationQueries(get_class($oObject), $sRelCode, $bDown) as $sDummy => $aQueryInfo)
|
||||
{
|
||||
$sQuery = $bDown ? $aQueryInfo['sQueryDown'] : $aQueryInfo['sQueryUp'];
|
||||
@@ -403,6 +405,8 @@ class RelationGraph extends SimpleGraph
|
||||
{
|
||||
do
|
||||
{
|
||||
set_time_limit($iLoopTimeLimit);
|
||||
|
||||
$sObjectRef = RelationObjectNode::MakeId($oRelatedObj);
|
||||
$oRelatedNode = $this->GetNode($sObjectRef);
|
||||
if (is_null($oRelatedNode))
|
||||
@@ -426,11 +430,11 @@ class RelationGraph extends SimpleGraph
|
||||
}
|
||||
// Recurse
|
||||
$this->AddRelatedObjects($sRelCode, $bDown, $oRelatedNode, $iMaxDepth - 1, $bEnableRedundancy);
|
||||
|
||||
}
|
||||
while ($oRelatedObj = $oObjSet->Fetch());
|
||||
}
|
||||
}
|
||||
set_time_limit($iPreviousTimeLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
pages/UI.php
17
pages/UI.php
@@ -220,11 +220,16 @@ function DisplayMultipleSelectionForm($oP, $oFilter, $sNextOperation, $oChecker,
|
||||
$oP->add_ready_script("$('#1 table.listResults').trigger('check_all');");
|
||||
}
|
||||
|
||||
function DisplayNavigatorListTab($oP, $aResults, $sRelation, $oObj)
|
||||
function DisplayNavigatorListTab($oP, $aResults, $sRelation, $sDirection, $oObj)
|
||||
{
|
||||
$oP->SetCurrentTab(Dict::S('UI:RelationshipList'));
|
||||
$oP->add("<div id=\"impacted_objects\" style=\"width:100%;background-color:#fff;padding:10px;\">");
|
||||
$oP->add("<h1>".MetaModel::GetRelationDescription($sRelation).' '.$oObj->GetName()."</h1>\n");
|
||||
$sOldRelation = $sRelation;
|
||||
if (($sRelation == 'impacts') && ($sDirection == 'up'))
|
||||
{
|
||||
$sOldRelation = 'depends on';
|
||||
}
|
||||
$oP->add("<h1>".MetaModel::GetRelationDescription($sOldRelation).' '.$oObj->GetName()."</h1>\n");
|
||||
$iBlock = 1; // Zero is not a valid blockid
|
||||
foreach($aResults as $sListClass => $aObjects)
|
||||
{
|
||||
@@ -233,7 +238,7 @@ function DisplayNavigatorListTab($oP, $aResults, $sRelation, $oObj)
|
||||
$oP->add("<h2>".MetaModel::GetClassIcon($sListClass)." <span class=\"hilite\">".Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', count($aObjects), Metamodel::GetName($sListClass))."</h2>\n");
|
||||
$oP->add("</div>\n");
|
||||
$oBlock = DisplayBlock::FromObjectSet($oSet, 'list');
|
||||
$oBlock->Display($oP, $iBlock++);
|
||||
$oBlock->Display($oP, $iBlock++, array('table_id' => get_class($oObj).'_'.$sRelation.'_'.$sDirection.'_'.$sListClass));
|
||||
$oP->P(' '); // Some space ?
|
||||
}
|
||||
$oP->add("</div>");
|
||||
@@ -244,7 +249,7 @@ function DisplayNavigatorGroupTab($oP, $aGroups, $sRelation, $oObj)
|
||||
if (count($aGroups) > 0)
|
||||
{
|
||||
$oP->SetCurrentTab(Dict::S('UI:RelationGroups'));
|
||||
$oP->add("<div id=\"impacted_groupss\" style=\"width:100%;background-color:#fff;padding:10px;\">");
|
||||
$oP->add("<div id=\"impacted_groups\" style=\"width:100%;background-color:#fff;padding:10px;\">");
|
||||
$iBlock = 1; // Zero is not a valid blockid
|
||||
foreach($aGroups as $idx => $aObjects)
|
||||
{
|
||||
@@ -1518,7 +1523,7 @@ EOF
|
||||
// Display the tabs
|
||||
if ($sFirstTab == 'list')
|
||||
{
|
||||
DisplayNavigatorListTab($oP, $aResults, $sRelation, $oObj);
|
||||
DisplayNavigatorListTab($oP, $aResults, $sRelation, $sDirection, $oObj);
|
||||
$oP->SetCurrentTab(Dict::S('UI:RelationshipGraph'));
|
||||
$oDisplayGraph->Display($oP, $aResults, $sRelation, $oAppContext, array(), $sClassForAttachment, $iIdForAttachment, $sContextKey, array('this' => $oObj));
|
||||
DisplayNavigatorGroupTab($oP, $aGroups, $sRelation, $oObj);
|
||||
@@ -1527,7 +1532,7 @@ EOF
|
||||
{
|
||||
$oP->SetCurrentTab(Dict::S('UI:RelationshipGraph'));
|
||||
$oDisplayGraph->Display($oP, $aResults, $sRelation, $oAppContext, array(), $sClassForAttachment, $iIdForAttachment, $sContextKey, array('this' => $oObj));
|
||||
DisplayNavigatorListTab($oP, $aResults, $sRelation, $oObj);
|
||||
DisplayNavigatorListTab($oP, $aResults, $sRelation, $sDirection, $oObj);
|
||||
DisplayNavigatorGroupTab($oP, $aGroups, $sRelation, $oObj);
|
||||
}
|
||||
|
||||
|
||||
@@ -1771,6 +1771,11 @@ EOF
|
||||
$aSourceObjects[] = $oObj;
|
||||
}
|
||||
}
|
||||
$sSourceClass = '*';
|
||||
if (count($aSourceObjects) == 1)
|
||||
{
|
||||
$sSourceClass = get_class($aSourceObjects[0]);
|
||||
}
|
||||
|
||||
// Get the list of excluded objects
|
||||
$aExcluded = utils::ReadParam('excluded', array(), false, 'raw_data');
|
||||
@@ -1856,13 +1861,13 @@ EOF
|
||||
$iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop');
|
||||
foreach($aResults as $sListClass => $aObjects)
|
||||
{
|
||||
set_time_limit($iLoopTimeLimit);
|
||||
set_time_limit($iLoopTimeLimit*count($aObjects));
|
||||
$oSet = CMDBObjectSet::FromArray($sListClass, $aObjects);
|
||||
$sHtml = "<div class=\"page_header\">\n";
|
||||
$sHtml .= "<table class=\"section\"><tr><td>".MetaModel::GetClassIcon($sListClass, true, 'width: 24px; height: 24px;')." ".Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', $oSet->Count(), Metamodel::GetName($sListClass))."</td></tr></table>\n";
|
||||
$sHtml .= "</div>\n";
|
||||
$oPage->add($sHtml);
|
||||
cmdbAbstractObject::DisplaySet($oPage, $oSet);
|
||||
cmdbAbstractObject::DisplaySet($oPage, $oSet, array('table_id' => $sSourceClass.'_'.$sRelation.'_'.$sDirection.'_'.$sListClass));
|
||||
$oPage->p(''); // Some space
|
||||
}
|
||||
|
||||
@@ -1873,7 +1878,7 @@ EOF
|
||||
$oPage->add('<div class="page_header"><h1>'.Dict::S('UI:RelationGroups').'</h1></div>');
|
||||
foreach($aGroups as $idx => $aObjects)
|
||||
{
|
||||
set_time_limit($iLoopTimeLimit);
|
||||
set_time_limit($iLoopTimeLimit*count($aObjects));
|
||||
$sListClass = get_class(current($aObjects));
|
||||
$oSet = CMDBObjectSet::FromArray($sListClass, $aObjects);
|
||||
$sHtml = "<div class=\"page_header\">\n";
|
||||
|
||||
Reference in New Issue
Block a user