Node: remove implementation-specific logic

This commit is contained in:
Thomas Gelf 2015-10-05 12:34:47 +02:00
parent a97073334c
commit 64bab3f8da
5 changed files with 17 additions and 14 deletions

View file

@ -21,6 +21,8 @@ class BpNode extends Node
);
protected $className = 'process';
public function __construct(
BusinessProcess $bp,
$object

View file

@ -8,6 +8,8 @@ class HostNode extends Node
{
protected $hostname;
protected $className = 'host';
public function __construct(BusinessProcess $bp, $object)
{
$this->name = $object->hostname . ';Hoststatus';

View file

@ -14,6 +14,8 @@ class ImportedNode extends Node
protected $importedNode;
protected $className = 'subtree';
public function __construct(BusinessProcess $bp, $object)
{
$this->name = $object->name;

View file

@ -93,6 +93,8 @@ abstract class Node
protected $missing = false;
protected $className = 'unknown';
protected static $state_names = array(
'OK',
'WARNING',
@ -327,32 +329,25 @@ abstract class Node
{
return md5($prefix . (string) $this);
}
protected function getObjectClassName()
{
return $this->className;
}
public function renderHtml($view, $prefix = '')
{
$id = $this->getId($prefix);
$state = strtolower($this->getStateName());
if ($this->isMissing()) $state = 'missing';
$handled = $this->isAcknowledged() || $this->isInDowntime();
if ($this instanceof BpNode) {
$typeClass = 'process';
} elseif ($this instanceof HostNode) {
$typeClass = 'host';
} elseif ($this instanceof ServiceNode) {
$typeClass = 'service';
} elseif ($this instanceof ImportedNode) {
$typeClass = 'subtree';
} else {
// WTF?
var_dump($this); exit;
}
$html = sprintf(
'<table class="bp %s%s%s%s" id="%s"><tbody><tr>',
$state === 'ok' ? 'ok' : 'problem ' . $state,
$handled ? ' handled' : '',
($this->hasChildren() ? ' operator ' : ' node '),
$typeClass,
$this->getObjectClassName(),
$id
);

View file

@ -10,6 +10,8 @@ class ServiceNode extends Node
protected $service;
protected $className = 'service';
public function __construct(BusinessProcess $bp, $object)
{
$this->name = $object->hostname . ';' . $object->service;