diff --git a/application/forms/ProcessForm.php b/application/forms/ProcessForm.php index a238de9..ddad40b 100644 --- a/application/forms/ProcessForm.php +++ b/application/forms/ProcessForm.php @@ -2,25 +2,30 @@ namespace Icinga\Module\Businessprocess\Forms; -use Icinga\Web\Notification; -use Icinga\Web\Request; -use Icinga\Module\Businessprocess\Node; use Icinga\Module\Businessprocess\BpNode; -use Icinga\Module\Businessprocess\Form; -use Icinga\Module\Businessprocess\ProcessChanges; +use Icinga\Module\Businessprocess\BusinessProcess; +use Icinga\Module\Businessprocess\Modification\ProcessChanges; +use Icinga\Module\Businessprocess\Web\Form\QuickForm; +use Icinga\Module\Monitoring\Backend\MonitoringBackend; +use Icinga\Web\Notification; +use Icinga\Web\Session\SessionNamespace; -class ProcessForm extends Form +class ProcessForm extends QuickForm { + /** @var MonitoringBackend */ protected $backend; - protected $process; + /** @var BusinessProcess */ + protected $bp; + /** @var BpNode */ protected $node; protected $objectList = array(); protected $processList = array(); + /** @var SessionNamespace */ protected $session; public function setup() @@ -37,7 +42,7 @@ class ProcessForm extends Form 'label' => $this->translate('Title'), 'description' => $this->translate( 'Usually this title will be shown for this node. Equals name' - . ' if not given' + . ' if not given' ), )); diff --git a/library/Businessprocess/BusinessProcess.php b/library/Businessprocess/BusinessProcess.php index 83764f0..6e89b57 100644 --- a/library/Businessprocess/BusinessProcess.php +++ b/library/Businessprocess/BusinessProcess.php @@ -3,6 +3,8 @@ namespace Icinga\Module\Businessprocess; use Icinga\Application\Benchmark; +use Icinga\Exception\ProgrammingError; +use Icinga\Module\Businessprocess\Modification\ProcessChanges; use Icinga\Module\Monitoring\Backend\MonitoringBackend; use Icinga\Data\Filter\Filter; use Exception; @@ -360,7 +362,7 @@ class BusinessProcess $hostStatus = $backend->select()->from('hostStatus', array( 'hostname' => 'host_name', - 'last_state_change' => $hostStateChangeColumn, + 'last_state_change' => $hostStateChangeColumn, 'in_downtime' => 'host_in_downtime', 'ack' => 'host_acknowledged', 'state' => $hostStateColumn @@ -369,7 +371,7 @@ class BusinessProcess $serviceStatus = $backend->select()->from('serviceStatus', array( 'hostname' => 'host_name', 'service' => 'service_description', - 'last_state_change' => $serviceStateChangeColumn, + 'last_state_change' => $serviceStateChangeColumn, 'in_downtime' => 'service_in_downtime', 'ack' => 'service_acknowledged', 'state' => $serviceStateColumn @@ -381,7 +383,7 @@ class BusinessProcess foreach ($hostStatus as $row) { $this->handleDbRow($row); - } + } ksort($this->root_nodes); Benchmark::measure('Got states for business process ' . $this->getName()); @@ -398,7 +400,10 @@ class BusinessProcess $key .= ';Hoststatus'; } // We fetch more states than we need, so skip unknown ones - if (! $this->hasNode($key)) return; + if (! $this->hasNode($key)) { + return; + } + $node = $this->getNode($key); if ($row->state !== null) { @@ -527,6 +532,11 @@ class BusinessProcess return $this; } + public function removeNode($name) + { + throw new ProgrammingError('Not implemented yet'); + } + public function listBpNodes() { $nodes = array(); diff --git a/library/Businessprocess/Controller.php b/library/Businessprocess/Controller.php index 070adbb..fa4499f 100644 --- a/library/Businessprocess/Controller.php +++ b/library/Businessprocess/Controller.php @@ -3,13 +3,12 @@ namespace Icinga\Module\Businessprocess; use Icinga\Application\Icinga; -use Icinga\Module\Businessprocess\BusinessProcess; +use Icinga\Module\Businessprocess\Modification\ProcessChanges; use Icinga\Module\Businessprocess\Storage\LegacyStorage; use Icinga\Module\Businessprocess\Web\Component\ActionBar; -use Icinga\Module\Monitoring\Backend; +use Icinga\Module\Businessprocess\Web\Form\FormLoader; use Icinga\Web\Controller as ModuleController; use Icinga\Web\Notification; -use Icinga\Module\Businessprocess\Web\Form\FormLoader; use Icinga\Web\Widget; class Controller extends ModuleController diff --git a/library/Businessprocess/NodeAction.php b/library/Businessprocess/Modification/NodeAction.php similarity index 90% rename from library/Businessprocess/NodeAction.php rename to library/Businessprocess/Modification/NodeAction.php index 3266574..98329bd 100644 --- a/library/Businessprocess/NodeAction.php +++ b/library/Businessprocess/Modification/NodeAction.php @@ -1,7 +1,9 @@ actionName, $object->nodeName); diff --git a/library/Businessprocess/NodeCreateAction.php b/library/Businessprocess/Modification/NodeCreateAction.php similarity index 91% rename from library/Businessprocess/NodeCreateAction.php rename to library/Businessprocess/Modification/NodeCreateAction.php index c95321e..b47dacb 100644 --- a/library/Businessprocess/NodeCreateAction.php +++ b/library/Businessprocess/Modification/NodeCreateAction.php @@ -1,7 +1,10 @@ get($key)) { foreach ($actions as $string) { - $changes->push(NodeAction::unserialize($string)); + $changes->push(NodeAction::unSerialize($string)); } } $changes->session = $session; @@ -64,7 +66,7 @@ class ProcessChanges /** * @param Node|string $nodeName - * @param array $properties + * @param object $properties * @param Node $parent * * @return $this @@ -86,7 +88,7 @@ class ProcessChanges */ public function deleteNode(Node $node) { - return $this->push(new NodeDeleteAction($node)); + return $this->push(new NodeRemoveAction($node)); } /**