diff --git a/application/forms/AddNodeForm.php b/application/forms/AddNodeForm.php index 4413421..e79bf36 100644 --- a/application/forms/AddNodeForm.php +++ b/application/forms/AddNodeForm.php @@ -383,11 +383,12 @@ class AddNodeForm extends QuickForm case 'new-process': $properties = $this->getValues(); unset($properties['name']); + $properties['parentName'] = $this->parent->getName(); $changes->createNode($this->getValue('name'), $properties); break; } - // Trigger session desctruction to make sure it get's stored. + // Trigger session destruction to make sure it get's stored. // TODO: figure out why this is necessary, might be an unclean shutdown on redirect unset($changes); diff --git a/library/Businessprocess/BpNode.php b/library/Businessprocess/BpNode.php index efa8999..cef6298 100644 --- a/library/Businessprocess/BpNode.php +++ b/library/Businessprocess/BpNode.php @@ -104,7 +104,7 @@ class BpNode extends Node $this->getChildren(); } - $name = (string) $node; + $name = $node->getName(); if (array_key_exists($name, $this->children)) { throw new ConfigurationError( 'Node "%s" has been defined more than once', diff --git a/library/Businessprocess/Modification/NodeAddChildrenAction.php b/library/Businessprocess/Modification/NodeAddChildrenAction.php index 8ccd08c..dfd2ac2 100644 --- a/library/Businessprocess/Modification/NodeAddChildrenAction.php +++ b/library/Businessprocess/Modification/NodeAddChildrenAction.php @@ -36,14 +36,23 @@ class NodeAddChildrenAction extends NodeAction // be a different action return $this; } - $node = $bp->getNode($this->getNodeName()); - $existing = $node->getChildNames(); + + $node = $config->getBpNode($this->getNodeName()); + foreach ($this->children as $name) { - if (! in_array($name, $existing)) { - $existing[] = $name; + if (! $config->hasNode($name)) { + if (strpos($name, ';') !== false) { + list($host, $service) = preg_split('/;/', $name, 2); + + if ($service === 'Hoststatus') { + $config->createHost($host); + } else { + $config->createService($host, $service); + } + } } + $node->addChild($config->getNode($name)); } - $node->setChildNames($existing); return $this; } diff --git a/library/Businessprocess/Modification/NodeCreateAction.php b/library/Businessprocess/Modification/NodeCreateAction.php index c3bac80..69dc77c 100644 --- a/library/Businessprocess/Modification/NodeCreateAction.php +++ b/library/Businessprocess/Modification/NodeCreateAction.php @@ -91,17 +91,18 @@ class NodeCreateAction extends NodeAction } else { $properties['child_names'] = array(); } - $node = new BpNode($bp, (object) $properties); + $node = new BpNode($config, (object) $properties); foreach ($this->getProperties() as $key => $val) { + if ($key === 'parentName') { + $config->getBpNode($val)->addChild($node); + continue; + } $func = 'set' . ucfirst($key); $node->$func($val); } - $bp->addNode($name, $node); - if ($this->hasParent()) { - $node->addParent($bp->getNode($this->getParentName())); - } + $config->addNode($name, $node); return $node; }