IdoQuery: Introduce method `whereEx()`
This commit is contained in:
parent
84f4ced3d8
commit
3edb5c3c94
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
use Zend_Db_Expr;
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
@ -144,4 +145,14 @@ class CommentQuery extends IdoQuery
|
|||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
foreach ($this->subQueries as $sub) {
|
||||
$sub->whereEx($ex);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
use Zend_Db_Expr;
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
@ -165,4 +166,14 @@ class CommentdeletionhistoryQuery extends IdoQuery
|
|||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
foreach ($this->subQueries as $sub) {
|
||||
$sub->whereEx($ex);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
use Zend_Db_Expr;
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
@ -165,4 +166,14 @@ class CommenthistoryQuery extends IdoQuery
|
|||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
foreach ($this->subQueries as $sub) {
|
||||
$sub->whereEx($ex);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
||||
|
@ -106,6 +107,16 @@ class ContactQuery extends IdoQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
foreach ($this->subQueries as $sub) {
|
||||
$sub->whereEx($ex);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function transformToUnion()
|
||||
{
|
||||
$this->contactQuery = $this->db->select();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Application\Config;
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
|
||||
class CustomvarQuery extends IdoQuery
|
||||
{
|
||||
|
@ -40,6 +41,20 @@ class CustomvarQuery extends IdoQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$types = ['host' => 1, 'service' => 2, 'contact' => 10];
|
||||
if ($ex->getColumn() === 'object_type') {
|
||||
$ex = clone $ex;
|
||||
$ex->setColumn('object_type_id');
|
||||
$ex->setExpression($types[$ex->getExpression()]);
|
||||
}
|
||||
|
||||
parent::whereEx($ex);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function joinBaseTables()
|
||||
{
|
||||
if (version_compare($this->getIdoVersion(), '1.12.0', '<')) {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
use Zend_Db_Expr;
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
@ -149,4 +150,14 @@ class DowntimeQuery extends IdoQuery
|
|||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
foreach ($this->subQueries as $sub) {
|
||||
$sub->whereEx($ex);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
use Zend_Db_Expr;
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
@ -165,4 +166,14 @@ class DowntimeendhistoryQuery extends IdoQuery
|
|||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
foreach ($this->subQueries as $sub) {
|
||||
$sub->whereEx($ex);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
use Zend_Db_Expr;
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
@ -165,4 +166,14 @@ class DowntimestarthistoryQuery extends IdoQuery
|
|||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
foreach ($this->subQueries as $sub) {
|
||||
$sub->whereEx($ex);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
||||
|
@ -120,4 +121,14 @@ class EventhistoryQuery extends IdoQuery
|
|||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
foreach ($this->subQueries as $sub) {
|
||||
$sub->whereEx($ex);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
use Zend_Db_Expr;
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
@ -165,4 +166,14 @@ class FlappingstarthistoryQuery extends IdoQuery
|
|||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
foreach ($this->subQueries as $sub) {
|
||||
$sub->whereEx($ex);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
|
||||
/**
|
||||
* Query for host group summaries
|
||||
|
@ -80,4 +81,11 @@ class HoststatussummaryQuery extends IdoQuery
|
|||
$this->subSelect->where($condition, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->subSelect->whereEx($ex);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -783,6 +783,30 @@ abstract class IdoQuery extends DbQuery
|
|||
return parent::where($col, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a filter expression, with as less validation as possible
|
||||
*
|
||||
* @param FilterExpression $ex
|
||||
*
|
||||
* @internal If you use this outside the monitoring module, it's your fault if something breaks
|
||||
* @return $this
|
||||
*/
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
$col = $this->getMappedField($ex->getColumn());
|
||||
if ($col === null) {
|
||||
throw new IcingaException(
|
||||
'No such field: %s',
|
||||
$ex->getColumn()
|
||||
);
|
||||
}
|
||||
|
||||
parent::addFilter((clone $ex)->setColumn($col));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if an field contains an explicit timestamp
|
||||
*
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
use Zend_Db_Expr;
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
@ -130,4 +131,14 @@ class NotificationQuery extends IdoQuery
|
|||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
foreach ($this->subQueries as $sub) {
|
||||
$sub->whereEx($ex);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
use Zend_Db_Expr;
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
@ -128,4 +129,14 @@ class NotificationhistoryQuery extends IdoQuery
|
|||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
foreach ($this->subQueries as $sub) {
|
||||
$sub->whereEx($ex);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
|
||||
/**
|
||||
* Query for service status summary
|
||||
|
@ -93,4 +94,11 @@ class ServicestatussummaryQuery extends IdoQuery
|
|||
$this->subSelect->where($condition, $value);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->subSelect->whereEx($ex);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
use Zend_Db_Expr;
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
@ -165,4 +166,14 @@ class StatehistoryQuery extends IdoQuery
|
|||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
foreach ($this->subQueries as $sub) {
|
||||
$sub->whereEx($ex);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Data\Filter\FilterExpression;
|
||||
use Zend_Db_Expr;
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
|
@ -229,4 +230,14 @@ We have to find a better solution here.
|
|||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->requireColumn($ex->getColumn());
|
||||
foreach ($this->subQueries as $sub) {
|
||||
$sub->whereEx($ex);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,6 +94,20 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a filter expression, with as less validation as possible
|
||||
*
|
||||
* @param FilterExpression $ex
|
||||
*
|
||||
* @internal If you use this outside the monitoring module, it's your fault if something breaks
|
||||
* @return $this
|
||||
*/
|
||||
public function whereEx(FilterExpression $ex)
|
||||
{
|
||||
$this->query->whereEx($ex);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function dump()
|
||||
{
|
||||
if (! $this->isSorted) {
|
||||
|
|
Loading…
Reference in New Issue