mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-02-11 06:53:05 -05:00
BpNode: move state-related logic to base Node
This commit is contained in:
parent
01929bbfae
commit
a97073334c
2 changed files with 36 additions and 34 deletions
|
|
@ -19,20 +19,6 @@ class BpNode extends Node
|
|||
protected $counters;
|
||||
protected $missing = null;
|
||||
|
||||
protected static $sortStateToStateMap = array(
|
||||
4 => 2,
|
||||
3 => 3,
|
||||
2 => 1,
|
||||
1 => 99,
|
||||
0 => 0
|
||||
);
|
||||
|
||||
protected static $stateToSortStateMap = array(
|
||||
99 => 1,
|
||||
3 => 3,
|
||||
2 => 4,
|
||||
1 => 2,
|
||||
0 => 0,
|
||||
);
|
||||
|
||||
public function __construct(
|
||||
|
|
@ -207,26 +193,6 @@ class BpNode extends Node
|
|||
$this->state = $this->sortStateTostate($sort_state);
|
||||
}
|
||||
|
||||
protected function stateToSortState($state)
|
||||
{
|
||||
if (array_key_exists(self::$stateToSortStateMap, $state)) {
|
||||
return self::$stateToSortStateMap[$state];
|
||||
}
|
||||
|
||||
throw new ProgrammingError('Got invalid state %s', $sort_state);
|
||||
}
|
||||
|
||||
protected function sortStateTostate($sortState)
|
||||
{
|
||||
$sortState = $sortState >> self::SHIFT_FLAGS;
|
||||
|
||||
if (array_key_exists(self::$sortStateToState, $sortState)) {
|
||||
return self::$sortStateToSortState[$sortState];
|
||||
}
|
||||
|
||||
throw new ProgrammingError('Got invalid sorting state %s', $sort_state);
|
||||
}
|
||||
|
||||
public function countChildren()
|
||||
{
|
||||
return count($this->getChildren());
|
||||
|
|
|
|||
|
|
@ -23,6 +23,22 @@ abstract class Node
|
|||
const ICINGA_UNREACHABLE = 2;
|
||||
const ICINGA_PENDING = 99;
|
||||
|
||||
protected static $sortStateToStateMap = array(
|
||||
4 => 2,
|
||||
3 => 3,
|
||||
2 => 1,
|
||||
1 => 99,
|
||||
0 => 0
|
||||
);
|
||||
|
||||
protected static $stateToSortStateMap = array(
|
||||
99 => 1,
|
||||
3 => 3,
|
||||
2 => 4,
|
||||
1 => 2,
|
||||
0 => 0,
|
||||
);
|
||||
|
||||
/**
|
||||
* Main business process object
|
||||
*
|
||||
|
|
@ -273,6 +289,26 @@ abstract class Node
|
|||
return count($this->parents) > 0;
|
||||
}
|
||||
|
||||
protected function stateToSortState($state)
|
||||
{
|
||||
if (array_key_exists($state, self::$stateToSortStateMap)) {
|
||||
return self::$stateToSortStateMap[$state];
|
||||
}
|
||||
|
||||
throw new ProgrammingError('Got invalid state %s', $sort_state);
|
||||
}
|
||||
|
||||
protected function sortStateTostate($sortState)
|
||||
{
|
||||
$sortState = $sortState >> self::SHIFT_FLAGS;
|
||||
|
||||
if (array_key_exists($sortState, self::$sortStateToStateMap)) {
|
||||
return self::$sortStateToStateMap[$sortState];
|
||||
}
|
||||
|
||||
throw new ProgrammingError('Got invalid sorting state %s', $sort_state);
|
||||
}
|
||||
|
||||
protected function renderHtmlForChildren($view)
|
||||
{
|
||||
$html = '';
|
||||
|
|
|
|||
Loading…
Reference in a new issue