Sync: use row filters
This commit is contained in:
parent
2164c1e2b9
commit
7f2e9ddc52
|
@ -142,6 +142,9 @@ class Sync
|
|||
json_encode($row)
|
||||
);
|
||||
}
|
||||
if (! $rule->matches($row)) {
|
||||
continue;
|
||||
}
|
||||
$imported[$sourceId][$row->$key] = $row;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Icinga\Module\Director\Objects;
|
||||
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Module\Director\Data\Db\DbObject;
|
||||
|
||||
class SyncRule extends DbObject
|
||||
|
@ -21,6 +22,8 @@ class SyncRule extends DbObject
|
|||
'filter_expression' => null,
|
||||
);
|
||||
|
||||
private $filter;
|
||||
|
||||
public function listInvolvedSourceIds()
|
||||
{
|
||||
if (! $this->hasBeenLoadedFromDb()) {
|
||||
|
@ -55,6 +58,24 @@ class SyncRule extends DbObject
|
|||
);
|
||||
}
|
||||
|
||||
public function matches($row)
|
||||
{
|
||||
if ($this->filter_expression === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->filter()->matches($row);
|
||||
}
|
||||
|
||||
protected function filter()
|
||||
{
|
||||
if ($this->filter === null) {
|
||||
$this->filter = Filter::fromQueryString($this->filter_expression);
|
||||
}
|
||||
|
||||
return $this->filter;
|
||||
}
|
||||
|
||||
public function fetchSyncProperties()
|
||||
{
|
||||
$db = $this->getDb();
|
||||
|
|
Loading…
Reference in New Issue