diff --git a/application/forms/DeleteNodeForm.php b/application/forms/DeleteNodeForm.php index b09cd68..259d834 100644 --- a/application/forms/DeleteNodeForm.php +++ b/application/forms/DeleteNodeForm.php @@ -135,7 +135,7 @@ class DeleteNodeForm extends QuickForm switch ($this->getValue('confirm')) { case 'yes': - $changes->deleteNode($this->node, $this->path); + $changes->deleteNode($this->node, $this->parentNode->getName()); break; case 'all': $changes->deleteNode($this->node); diff --git a/library/Businessprocess/BpConfig.php b/library/Businessprocess/BpConfig.php index 83f9346..884e1ca 100644 --- a/library/Businessprocess/BpConfig.php +++ b/library/Businessprocess/BpConfig.php @@ -416,6 +416,24 @@ class BpConfig return $node; } + public function calculateAllStates() + { + foreach ($this->getRootNodes() as $node) { + $node->getState(); + } + + return $this; + } + + public function clearAllStates() + { + foreach ($this->getBpNodes() as $node) { + $node->clearState(); + } + + return $this; + } + public function listInvolvedHostNames() { return array_keys($this->hosts); diff --git a/library/Businessprocess/Modification/NodeRemoveAction.php b/library/Businessprocess/Modification/NodeRemoveAction.php index 29e17a9..09a20d2 100644 --- a/library/Businessprocess/Modification/NodeRemoveAction.php +++ b/library/Businessprocess/Modification/NodeRemoveAction.php @@ -44,7 +44,7 @@ class NodeRemoveAction extends NodeAction if ($parent === null) { return $config->hasNode($this->getNodeName()); } else { - return $config->hasNode($this->getNodeName()) && $config->hasNode($this->getParentName()) ; + return $config->hasNode($this->getNodeName()) && $config->hasNode($this->getParentName()); } } @@ -53,14 +53,19 @@ class NodeRemoveAction extends NodeAction */ public function applyTo(BpConfig $config) { - $parent = $this->getParentName(); - if ($parent === null) { - $config->removeNode($this->getNodeName()); + $config->calculateAllStates(); + $name = $this->getNodeName(); + $parentName = $this->getParentName(); + if ($parentName === null) { + $config->removeNode($name); } else { - $node = $config->getNode($this->getNodeName()); - $node->removeParent($parent); + $node = $config->getNode($name); + $parent = $config->getBpNode($parentName); + $parent->getState(); + $parent->removeChild($name); + $node->removeParent($parentName); if (! $node->hasParents()) { - $config->removeNode($this->getNodeName()); + $config->removeNode($name); } } } diff --git a/library/Businessprocess/Modification/ProcessChanges.php b/library/Businessprocess/Modification/ProcessChanges.php index b4ffbde..0293442 100644 --- a/library/Businessprocess/Modification/ProcessChanges.php +++ b/library/Businessprocess/Modification/ProcessChanges.php @@ -96,15 +96,14 @@ class ProcessChanges /** * @param Node $node - * @param array $path - * + * @param string $parentName * @return $this */ - public function deleteNode(Node $node, array $path = null) + public function deleteNode(Node $node, $parentName = null) { $action = new NodeRemoveAction($node); - if ($path !== null) { - $action->setPath($path); + if ($parentName !== null) { + $action->setParentName($parentName); } return $this->push($action); diff --git a/library/Businessprocess/Node.php b/library/Businessprocess/Node.php index ba904af..bc751d3 100644 --- a/library/Businessprocess/Node.php +++ b/library/Businessprocess/Node.php @@ -307,6 +307,8 @@ abstract class Node return $parent->getName() !== $name; } ); + + return $this; } /**