Node, BusinessProcess: add and unify helpers

BusinessProcess will be reduced and is going to be a special root node
This commit is contained in:
Thomas Gelf 2014-11-30 11:28:58 +01:00
parent 0a1c14c01a
commit 31626b4728
2 changed files with 75 additions and 0 deletions

View file

@ -18,10 +18,39 @@ class BusinessProcess
protected $root_nodes = array(); protected $root_nodes = array();
protected $all_checks = array(); protected $all_checks = array();
protected $hosts = array(); protected $hosts = array();
protected $simulationMode = false;
protected $editMode = false;
public function __construct() 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() public function getObjectIds()
{ {
@ -113,11 +142,26 @@ class BusinessProcess
return $this; return $this;
} }
public function getChildren()
{
return $this->getRootNodes();
}
public function countChildren()
{
return count($this->root_nodes);
}
public function getRootNodes() public function getRootNodes()
{ {
return $this->root_nodes; return $this->root_nodes;
} }
public function getNodes()
{
return $this->nodes;
}
public function hasNode($name) public function hasNode($name)
{ {
return array_key_exists($name, $this->nodes); return array_key_exists($name, $this->nodes);

View file

@ -39,6 +39,11 @@ abstract class Node
return $this; return $this;
} }
public function hasBeenChanged()
{
return false;
}
public function isMissing() public function isMissing()
{ {
return $this->missing; return $this->missing;
@ -123,6 +128,11 @@ abstract class Node
return $this->duration; return $this->duration;
} }
public function isHandled()
{
return $this->isInDowntime() || $this->isAcknowledged();
}
public function isInDowntime() public function isInDowntime()
{ {
if ($this->downtime === null) { if ($this->downtime === null) {
@ -139,11 +149,32 @@ abstract class Node
return $this->ack; return $this->ack;
} }
public function isSimulationMode()
{
return $this->bp->isSimulationMode();
}
public function isEditMode()
{
return $this->bp->isEditMode();
}
public function hasChildren() public function hasChildren()
{ {
return false; return false;
} }
public function countChildren()
{
return 0;
}
public function getChildren()
{
return array();
}
public function __toString() public function __toString()
{ {
return $this->name; return $this->name;