From 31626b47283821b26b9c29ed49f8befc19afeacb Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 30 Nov 2014 11:28:58 +0100 Subject: [PATCH] Node, BusinessProcess: add and unify helpers BusinessProcess will be reduced and is going to be a special root node --- library/Bpapp/BusinessProcess.php | 44 +++++++++++++++++++++++++++++++ library/Bpapp/Node.php | 31 ++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/library/Bpapp/BusinessProcess.php b/library/Bpapp/BusinessProcess.php index 461c157..7988f13 100644 --- a/library/Bpapp/BusinessProcess.php +++ b/library/Bpapp/BusinessProcess.php @@ -18,10 +18,39 @@ class BusinessProcess protected $root_nodes = array(); protected $all_checks = array(); protected $hosts = array(); + protected $simulationMode = false; + protected $editMode = false; public function __construct() { } + + public function hasBeenChanged() + { + return false; + } + + public function setSimulationMode($mode = true) + { + $this->simulationMode = (bool) $mode; + return $this; + } + + public function isSimulationMode() + { + return $this->simulationMode; + } + + public function setEditMode($mode = true) + { + $this->editMode = (bool) $mode; + return $this; + } + + public function isEditMode() + { + return $this->editMode; + } /* public function getObjectIds() { @@ -113,11 +142,26 @@ class BusinessProcess return $this; } + public function getChildren() + { + return $this->getRootNodes(); + } + + public function countChildren() + { + return count($this->root_nodes); + } + public function getRootNodes() { return $this->root_nodes; } + public function getNodes() + { + return $this->nodes; + } + public function hasNode($name) { return array_key_exists($name, $this->nodes); diff --git a/library/Bpapp/Node.php b/library/Bpapp/Node.php index cde423f..ea4498c 100644 --- a/library/Bpapp/Node.php +++ b/library/Bpapp/Node.php @@ -39,6 +39,11 @@ abstract class Node return $this; } + public function hasBeenChanged() + { + return false; + } + public function isMissing() { return $this->missing; @@ -123,6 +128,11 @@ abstract class Node return $this->duration; } + public function isHandled() + { + return $this->isInDowntime() || $this->isAcknowledged(); + } + public function isInDowntime() { if ($this->downtime === null) { @@ -139,11 +149,32 @@ abstract class Node return $this->ack; } + + public function isSimulationMode() + { + return $this->bp->isSimulationMode(); + } + + public function isEditMode() + { + return $this->bp->isEditMode(); + } + public function hasChildren() { return false; } + public function countChildren() + { + return 0; + } + + public function getChildren() + { + return array(); + } + public function __toString() { return $this->name;