BusinessProcess: avoid duplicates when stored

This commit is contained in:
Thomas Gelf 2015-03-03 12:51:03 +01:00
parent a7f5c6c61c
commit d243271462
4 changed files with 8 additions and 5 deletions

View file

@ -246,16 +246,18 @@ class BpNode extends Node
)); ));
} }
public function toLegacyConfigString() public function toLegacyConfigString(& $rendered = array())
{ {
$cfg = ''; $cfg = '';
$children = array(); $children = array();
foreach ($this->getChildren() as $name => $child) { foreach ($this->getChildren() as $name => $child) {
$children[] = (string) $child; $children[] = (string) $child;
if (array_key_exists($name, $rendered)) { continue; }
if ($child instanceof BpNode) { if ($child instanceof BpNode) {
$cfg .= $child->toLegacyConfigString() . "\n"; $cfg .= $child->toLegacyConfigString($rendered) . "\n";
} }
$rendered[$name] = true;
} }
$eq = '='; $eq = '=';
$op = $this->operator; $op = $this->operator;

View file

@ -408,8 +408,9 @@ class BusinessProcess
date('Y-m-d H:i:s') date('Y-m-d H:i:s')
); );
$rendered = array();
foreach ($this->getChildren() as $child) { foreach ($this->getChildren() as $child) {
$conf .= $child->toLegacyConfigString(); $conf .= $child->toLegacyConfigString($rendered);
} }
return $conf . "\n"; return $conf . "\n";
} }

View file

@ -27,7 +27,7 @@ class HostNode extends Node
)); ));
} else { } else {
return $view->qlink($this->getHostname(), 'monitoring/host/show', array( return $view->qlink($this->getHostname(), 'monitoring/host/show', array(
'host' => $this->getHostname, 'host' => $this->getHostname(),
'processName' => $this->bp->getName() 'processName' => $this->bp->getName()
)); ));
} }

View file

@ -340,7 +340,7 @@ abstract class Node
return ' '; return ' ';
} }
public function toLegacyConfigString() { return '';} public function toLegacyConfigString(& $rendered = array()) { return '';}
//abstract public function toLegacyConfigString(); //abstract public function toLegacyConfigString();
public function __toString() public function __toString()