Module: nagvis Branch: nagvis-1.4 Commit: e50153de5f7d056ca63e1f504beb311f4b61e32c URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=e50153de5f7d056ca63e1f504beb311f4b61e32c
Author: Lars Michelsen <[email protected]> Date: Sun Oct 11 19:30:48 2009 +0200 #128 Fixed wrong initial state for summary objects --- .../includes/classes/objects/NagVisMapObj.php | 75 +++++++++++-------- .../includes/classes/objects/NagVisObject.php | 6 ++- .../classes/objects/NagVisStatefulObject.php | 14 ++++ 3 files changed, 62 insertions(+), 33 deletions(-) diff --git a/nagvis/nagvis/includes/classes/objects/NagVisMapObj.php b/nagvis/nagvis/includes/classes/objects/NagVisMapObj.php index 2e41f18..61f0813 100644 --- a/nagvis/nagvis/includes/classes/objects/NagVisMapObj.php +++ b/nagvis/nagvis/includes/classes/objects/NagVisMapObj.php @@ -59,7 +59,7 @@ class NagVisMapObj extends NagVisStatefulObject { $this->iconset = 'std_medium'; $this->members = Array(); $this->linkedMaps = Array(); - $this->is_summary_object = FALSE; + $this->is_summary_object = false; $this->backend_id = $this->MAPCFG->getValue('global', 0, 'backend_id'); @@ -77,6 +77,42 @@ class NagVisMapObj extends NagVisStatefulObject { public function getMembers() { return $this->members; } + + /** + * PUBLIC getStateRelevantMembers() + * + * Returns an array of state relevant members + * textboxes, shapes and "summary objects" are + * excluded here + * + * @return Array Array with map objects + * @author Lars Michelsen <[email protected]> + */ + public function getStateRelevantMembers() { + $a = Array(); + + // Loop all members + foreach($this->members AS $OBJ) { + + // Skip unrelevant object types + if($OBJ->getType() == 'textbox' || $OBJ->getType() == 'shape') { + continue; + } + + /** + * When the current map object is a summary object skip the map + * child for preventing a loop + */ + if($OBJ->getType() == 'map' && $this->MAPCFG->getName() == $OBJ->MAPCFG->getName() && $this->is_summary_object == true) { + continue; + } + + // Add relevant objects to array + $a[] = $OBJ; + } + + return $a; + } /** * PUBLIC getNumMembers() @@ -162,7 +198,7 @@ class NagVisMapObj extends NagVisStatefulObject { * When the current map object is a summary object skip the map * child for preventing a loop */ - if($this->MAPCFG->getName() == $OBJ->MAPCFG->getName() && $this->is_summary_object) { + if($this->MAPCFG->getName() == $OBJ->MAPCFG->getName() && $this->is_summary_object == true) { continue; } @@ -173,7 +209,7 @@ class NagVisMapObj extends NagVisStatefulObject { * See the code above. */ if($this->MAPCFG->getName() == $OBJ->MAPCFG->getName()) { - $OBJ->is_summary_object = TRUE; + $OBJ->is_summary_object = true; } // Check for indirect loop when the current child is a map object @@ -196,17 +232,12 @@ class NagVisMapObj extends NagVisStatefulObject { */ public function fetchState() { // Get state of all member objects - foreach($this->getMembers() AS $OBJ) { - // Don't get state from textboxes and shapes - if($OBJ->getType() == 'textbox' || $OBJ->getType() == 'shape') { - continue; - } - + foreach($this->getStateRelevantMembers() AS $OBJ) { $OBJ->fetchState(); $OBJ->fetchIcon(); } - + // Also get summary state $this->fetchSummaryState(); @@ -275,17 +306,7 @@ class NagVisMapObj extends NagVisStatefulObject { if($this->hasObjects() && $this->hasStatefulObjects()) { $arrStates = Array('UNREACHABLE' => 0, 'CRITICAL' => 0,'DOWN' => 0,'WARNING' => 0,'UNKNOWN' => 0,'UP' => 0,'OK' => 0,'ERROR' => 0,'ACK' => 0,'PENDING' => 0); - foreach($this->getMembers() AS $OBJ) { - // Don't reconize summarize map objects - if($OBJ->getType() == 'map' && $OBJ->is_summary_object) { - continue; - } - - // Don't recognize textboxes and shapes - if($OBJ->getType() == 'textbox' || $OBJ->getType() == 'shape') { - continue; - } - + foreach($this->getStateRelevantMembers() AS $OBJ) { if(method_exists($OBJ,'getSummaryState')) { $sState = $OBJ->getSummaryState(); if(isset($arrStates[$sState])) { @@ -418,17 +439,7 @@ class NagVisMapObj extends NagVisStatefulObject { private function fetchSummaryState() { if($this->hasObjects() && $this->hasStatefulObjects()) { // Get summary state member objects - foreach($this->getMembers() AS $OBJ) { - // Don't reconize summarize map objects - if($OBJ->getType() == 'map' && $OBJ->is_summary_object) { - continue; - } - - // Don't recognize textboxes and shapes - if($OBJ->getType() == 'textbox' || $OBJ->getType() == 'shape') { - continue; - } - + foreach($this->getStateRelevantMembers() AS $OBJ) { if(method_exists($OBJ,'getSummaryState')) { $this->wrapChildState($OBJ); } diff --git a/nagvis/nagvis/includes/classes/objects/NagVisObject.php b/nagvis/nagvis/includes/classes/objects/NagVisObject.php index 5459c18..d3aafcb 100644 --- a/nagvis/nagvis/includes/classes/objects/NagVisObject.php +++ b/nagvis/nagvis/includes/classes/objects/NagVisObject.php @@ -327,7 +327,7 @@ class NagVisObject { public function getSortedObjectMembers($bStateInfo=FALSE) { $arr = Array(); - $aTmpMembers = $this->getMembers(); + $aTmpMembers = $this->getStateRelevantMembers(); // Sort the array of child objects by the sort option switch($this->hover_childs_sort) { @@ -498,6 +498,10 @@ class NagVisObject { if(method_exists($OBJ1, 'getSummaryState') && method_exists($OBJ2, 'getSummaryState')) { $state1 = $OBJ1->getSummaryState(); $state2 = $OBJ2->getSummaryState(); + + if($state1 == '' || $state2 == '') { + return 0; + } } else { return 0; } diff --git a/nagvis/nagvis/includes/classes/objects/NagVisStatefulObject.php b/nagvis/nagvis/includes/classes/objects/NagVisStatefulObject.php index d3735c3..5b87e4a 100644 --- a/nagvis/nagvis/includes/classes/objects/NagVisStatefulObject.php +++ b/nagvis/nagvis/includes/classes/objects/NagVisStatefulObject.php @@ -86,6 +86,20 @@ class NagVisStatefulObject extends NagVisObject { parent::__construct($CORE); } + + /** + * PUBLIC getStateRelevantMembers + * + * This is a wrapper function. When not implemented by the specific + * object it only calls the getMembers() function. It is useful to + * exclude uninteresting objects on maps. + * + * @return Array Array of child objects + * @author Lars Michelsen <[email protected]> + */ + public function getStateRelevantMembers() { + return $this->getMembers(); + } /** * PUBLIC getInDowntime() ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
