Data\BaseQuery: rename to Data\SimpleQuery
BaseQuery should no longer be abstract but be usable as is as soon as we stripped ResultSet-specific tasks. As "Base" suggests something that must be extended, the name no longer fits. So this is SimpleQuery right now.
This commit is contained in:
parent
ab32a91a6e
commit
820b6b7a8d
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
namespace Icinga\Data\DataArray;
|
namespace Icinga\Data\DataArray;
|
||||||
|
|
||||||
use Icinga\Data\BaseQuery;
|
use Icinga\Data\SimpleQuery;
|
||||||
|
|
||||||
class Query extends BaseQuery
|
class Query extends SimpleQuery
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Remember the last count
|
* Remember the last count
|
||||||
|
|
|
@ -33,7 +33,7 @@ use PDO;
|
||||||
use Zend_Config;
|
use Zend_Config;
|
||||||
use Zend_Db;
|
use Zend_Db;
|
||||||
use Icinga\Application\Benchmark;
|
use Icinga\Application\Benchmark;
|
||||||
use Icinga\Data\BaseQuery;
|
use Icinga\Data\SimpleQuery;
|
||||||
use Icinga\Data\Selectable;
|
use Icinga\Data\Selectable;
|
||||||
use Icinga\Exception\ConfigurationError;
|
use Icinga\Exception\ConfigurationError;
|
||||||
|
|
||||||
|
@ -207,11 +207,11 @@ class Connection implements Selectable
|
||||||
/**
|
/**
|
||||||
* Retrieve an array containing all rows of the result set
|
* Retrieve an array containing all rows of the result set
|
||||||
*
|
*
|
||||||
* @param BaseQuery $query
|
* @param SimpleQuery $query
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fetchAll(BaseQuery $query)
|
public function fetchAll(SimpleQuery $query)
|
||||||
{
|
{
|
||||||
Benchmark::measure('DB is fetching All');
|
Benchmark::measure('DB is fetching All');
|
||||||
$result = $this->dbAdapter->fetchAll($query->getSelectQuery());
|
$result = $this->dbAdapter->fetchAll($query->getSelectQuery());
|
||||||
|
@ -222,11 +222,11 @@ class Connection implements Selectable
|
||||||
/**
|
/**
|
||||||
* Fetch the first row of the result set
|
* Fetch the first row of the result set
|
||||||
*
|
*
|
||||||
* @param BaseQuery $query
|
* @param SimpleQuery $query
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function fetchRow(BaseQuery $query)
|
public function fetchRow(SimpleQuery $query)
|
||||||
{
|
{
|
||||||
return $this->dbAdapter->fetchRow($query->getSelectQuery());
|
return $this->dbAdapter->fetchRow($query->getSelectQuery());
|
||||||
}
|
}
|
||||||
|
@ -234,12 +234,12 @@ class Connection implements Selectable
|
||||||
/**
|
/**
|
||||||
* Fetch a column of all rows of the result set as an array
|
* Fetch a column of all rows of the result set as an array
|
||||||
*
|
*
|
||||||
* @param BaseQuery $query
|
* @param SimpleQuery $query
|
||||||
* @param int $columnIndex Index of the column to fetch
|
* @param int $columnIndex Index of the column to fetch
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fetchColumn(BaseQuery $query, $columnIndex = 0)
|
public function fetchColumn(SimpleQuery $query, $columnIndex = 0)
|
||||||
{
|
{
|
||||||
return $this->dbAdapter->fetchCol($query->getSelectQuery());
|
return $this->dbAdapter->fetchCol($query->getSelectQuery());
|
||||||
}
|
}
|
||||||
|
@ -247,11 +247,11 @@ class Connection implements Selectable
|
||||||
/**
|
/**
|
||||||
* Fetch the first column of the first row of the result set
|
* Fetch the first column of the first row of the result set
|
||||||
*
|
*
|
||||||
* @param BaseQuery $query
|
* @param SimpleQuery $query
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function fetchOne(BaseQuery $query)
|
public function fetchOne(SimpleQuery $query)
|
||||||
{
|
{
|
||||||
return $this->dbAdapter->fetchOne($query->getSelectQuery());
|
return $this->dbAdapter->fetchOne($query->getSelectQuery());
|
||||||
}
|
}
|
||||||
|
@ -261,11 +261,11 @@ class Connection implements Selectable
|
||||||
*
|
*
|
||||||
* The first column is the key, the second column is the value.
|
* The first column is the key, the second column is the value.
|
||||||
*
|
*
|
||||||
* @param BaseQuery $query
|
* @param SimpleQuery $query
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function fetchPairs(BaseQuery $query)
|
public function fetchPairs(SimpleQuery $query)
|
||||||
{
|
{
|
||||||
return $this->dbAdapter->fetchPairs($query->getSelectQuery());
|
return $this->dbAdapter->fetchPairs($query->getSelectQuery());
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,13 @@
|
||||||
namespace Icinga\Data\Db;
|
namespace Icinga\Data\Db;
|
||||||
|
|
||||||
use Zend_Db_Select;
|
use Zend_Db_Select;
|
||||||
use Icinga\Data\BaseQuery;
|
use Icinga\Data\SimpleQuery;
|
||||||
use Icinga\Application\Benchmark;
|
use Icinga\Application\Benchmark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database query class
|
* Database query class
|
||||||
*/
|
*/
|
||||||
class Query extends BaseQuery
|
class Query extends SimpleQuery
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Zend_Db_Adapter_Abstract
|
* @var Zend_Db_Adapter_Abstract
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
namespace Icinga\Data\Db;
|
namespace Icinga\Data\Db;
|
||||||
|
|
||||||
use Icinga\Data\BaseQuery;
|
use Icinga\Data\SimpleQuery;
|
||||||
use Icinga\Filter\Query\Tree;
|
use Icinga\Filter\Query\Tree;
|
||||||
use Icinga\Filter\Query\Node;
|
use Icinga\Filter\Query\Node;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class TreeToSqlParser
|
||||||
/**
|
/**
|
||||||
* The query class to use as the base for converting
|
* The query class to use as the base for converting
|
||||||
*
|
*
|
||||||
* @var BaseQuery
|
* @var SimpleQuery
|
||||||
*/
|
*/
|
||||||
private $query;
|
private $query;
|
||||||
|
|
||||||
|
@ -54,9 +54,9 @@ class TreeToSqlParser
|
||||||
/**
|
/**
|
||||||
* Create a new converter from this query
|
* Create a new converter from this query
|
||||||
*
|
*
|
||||||
* @param BaseQuery $query The query to use for conversion
|
* @param SimpleQuery $query The query to use for conversion
|
||||||
*/
|
*/
|
||||||
public function __construct(BaseQuery $query)
|
public function __construct(SimpleQuery $query)
|
||||||
{
|
{
|
||||||
$this->query = $query;
|
$this->query = $query;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
namespace Icinga\Data;
|
namespace Icinga\Data;
|
||||||
|
|
||||||
use \Zend_Paginator;
|
use \Zend_Paginator;
|
||||||
use Icinga\Data\BaseQuery;
|
use Icinga\Data\SimpleQuery;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Web\Paginator\Adapter\QueryAdapter;
|
use Icinga\Web\Paginator\Adapter\QueryAdapter;
|
||||||
|
|
||||||
|
@ -14,21 +14,21 @@ class PivotTable
|
||||||
/**
|
/**
|
||||||
* The query to fetch as pivot table
|
* The query to fetch as pivot table
|
||||||
*
|
*
|
||||||
* @var BaseQuery
|
* @var SimpleQuery
|
||||||
*/
|
*/
|
||||||
protected $baseQuery;
|
protected $baseQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The query to fetch the x axis labels
|
* The query to fetch the x axis labels
|
||||||
*
|
*
|
||||||
* @var BaseQuery
|
* @var SimpleQuery
|
||||||
*/
|
*/
|
||||||
protected $xAxisQuery;
|
protected $xAxisQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The query to fetch the y axis labels
|
* The query to fetch the y axis labels
|
||||||
*
|
*
|
||||||
* @var BaseQuery
|
* @var SimpleQuery
|
||||||
*/
|
*/
|
||||||
protected $yAxisQuery;
|
protected $yAxisQuery;
|
||||||
|
|
||||||
|
@ -49,11 +49,11 @@ class PivotTable
|
||||||
/**
|
/**
|
||||||
* Create a new pivot table
|
* Create a new pivot table
|
||||||
*
|
*
|
||||||
* @param BaseQuery $query The query to fetch as pivot table
|
* @param SimpleQuery $query The query to fetch as pivot table
|
||||||
* @param string $xAxisColumn The column that contains the labels for the x axis
|
* @param string $xAxisColumn The column that contains the labels for the x axis
|
||||||
* @param string $yAxisColumn The column that contains the labels for the y axis
|
* @param string $yAxisColumn The column that contains the labels for the y axis
|
||||||
*/
|
*/
|
||||||
public function __construct(BaseQuery $query, $xAxisColumn, $yAxisColumn)
|
public function __construct(SimpleQuery $query, $xAxisColumn, $yAxisColumn)
|
||||||
{
|
{
|
||||||
$this->baseQuery = $query;
|
$this->baseQuery = $query;
|
||||||
$this->xAxisColumn = $xAxisColumn;
|
$this->xAxisColumn = $xAxisColumn;
|
||||||
|
@ -86,8 +86,8 @@ class PivotTable
|
||||||
protected function adjustSorting()
|
protected function adjustSorting()
|
||||||
{
|
{
|
||||||
$currentOrderColumns = $this->baseQuery->getOrderColumns();
|
$currentOrderColumns = $this->baseQuery->getOrderColumns();
|
||||||
$xAxisOrderColumns = array(array($this->baseQuery->getMappedField($this->xAxisColumn), BaseQuery::SORT_ASC));
|
$xAxisOrderColumns = array(array($this->baseQuery->getMappedField($this->xAxisColumn), SimpleQuery::SORT_ASC));
|
||||||
$yAxisOrderColumns = array(array($this->baseQuery->getMappedField($this->yAxisColumn), BaseQuery::SORT_ASC));
|
$yAxisOrderColumns = array(array($this->baseQuery->getMappedField($this->yAxisColumn), SimpleQuery::SORT_ASC));
|
||||||
|
|
||||||
foreach ($currentOrderColumns as $orderInfo) {
|
foreach ($currentOrderColumns as $orderInfo) {
|
||||||
if ($orderInfo[0] === $xAxisOrderColumns[0][0]) {
|
if ($orderInfo[0] === $xAxisOrderColumns[0][0]) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ use Zend_Controller_Front;
|
||||||
use Zend_Paginator;
|
use Zend_Paginator;
|
||||||
use Icinga\Web\Paginator\Adapter\QueryAdapter;
|
use Icinga\Web\Paginator\Adapter\QueryAdapter;
|
||||||
|
|
||||||
abstract class BaseQuery implements QueryInterface, Queryable
|
abstract class SimpleQuery implements QueryInterface, Queryable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Query data source
|
* Query data source
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace Icinga\Protocol\File;
|
namespace Icinga\Protocol\File;
|
||||||
|
|
||||||
use Icinga\Data\BaseQuery;
|
use Icinga\Data\SimpleQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Query
|
* Class Query
|
||||||
|
@ -13,7 +13,7 @@ use Icinga\Data\BaseQuery;
|
||||||
*
|
*
|
||||||
* @package Icinga\Protocol\File
|
* @package Icinga\Protocol\File
|
||||||
*/
|
*/
|
||||||
class Query extends BaseQuery
|
class Query extends SimpleQuery
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Sort direction
|
* Sort direction
|
||||||
|
|
|
@ -31,14 +31,14 @@ namespace Icinga\Protocol\Statusdat;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Data\BaseQuery;
|
use Icinga\Data\SimpleQuery;
|
||||||
use Icinga\Protocol\Statusdat\View\MonitoringObjectList;
|
use Icinga\Protocol\Statusdat\View\MonitoringObjectList;
|
||||||
use Icinga\Protocol\Statusdat\Query\IQueryPart;
|
use Icinga\Protocol\Statusdat\Query\IQueryPart;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base implementation for Statusdat queries.
|
* Base implementation for Statusdat queries.
|
||||||
*/
|
*/
|
||||||
class Query extends BaseQuery
|
class Query extends SimpleQuery
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* An array denoting valid targets by mapping the query target to
|
* An array denoting valid targets by mapping the query target to
|
||||||
|
|
|
@ -31,7 +31,7 @@ use \Icinga\Web\Form;
|
||||||
use \Icinga\Web\Controller\ActionController;
|
use \Icinga\Web\Controller\ActionController;
|
||||||
use \Icinga\Web\Widget\Tabextension\OutputFormat;
|
use \Icinga\Web\Widget\Tabextension\OutputFormat;
|
||||||
use \Icinga\Module\Monitoring\Backend;
|
use \Icinga\Module\Monitoring\Backend;
|
||||||
use \Icinga\Data\BaseQuery;
|
use \Icinga\Data\SimpleQuery;
|
||||||
use \Icinga\Web\Widget\Chart\InlinePie;
|
use \Icinga\Web\Widget\Chart\InlinePie;
|
||||||
use \Icinga\Module\Monitoring\Form\Command\MultiCommandFlagForm;
|
use \Icinga\Module\Monitoring\Form\Command\MultiCommandFlagForm;
|
||||||
use \Icinga\Module\Monitoring\DataView\HostStatus as HostStatusView;
|
use \Icinga\Module\Monitoring\DataView\HostStatus as HostStatusView;
|
||||||
|
@ -183,16 +183,16 @@ class Monitoring_MultiController extends ActionController
|
||||||
/**
|
/**
|
||||||
* Apply the query-filter received
|
* Apply the query-filter received
|
||||||
*
|
*
|
||||||
* @param $backendQuery BaseQuery The query to apply the filter to
|
* @param $backendQuery SimpleQuery The query to apply the filter to
|
||||||
* @param $filter array Containing the queries of the current request, converted into an
|
* @param $filter array Containing the queries of the current request, converted into an
|
||||||
* array-structure.
|
* array-structure.
|
||||||
* @param $hostColumn string The name of the host-column in the BaseQuery, defaults to 'host_name'
|
* @param $hostColumn string The name of the host-column in the SimpleQuery, defaults to 'host_name'
|
||||||
* @param $serviceColumn string The name of the service-column in the BaseQuery, defaults to 'service-description'
|
* @param $serviceColumn string The name of the service-column in the SimpleQuery, defaults to 'service-description'
|
||||||
*
|
*
|
||||||
* @return BaseQuery The given BaseQuery
|
* @return SimpleQuery The given SimpleQuery
|
||||||
*/
|
*/
|
||||||
private function applyQueryFilter(
|
private function applyQueryFilter(
|
||||||
BaseQuery $backendQuery,
|
SimpleQuery $backendQuery,
|
||||||
array $filter,
|
array $filter,
|
||||||
$hostColumn = 'host_name',
|
$hostColumn = 'host_name',
|
||||||
$serviceColumn = 'service_description'
|
$serviceColumn = 'service_description'
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
namespace \Icinga\Module\Monitoring\Backend\Livestatus\Query;
|
namespace \Icinga\Module\Monitoring\Backend\Livestatus\Query;
|
||||||
|
|
||||||
use Icinga\Data\BaseQuery;
|
use Icinga\Data\SimpleQuery;
|
||||||
|
|
||||||
class StatusQuery extends BaseQuery implements Filterable
|
class StatusQuery extends SimpleQuery implements Filterable
|
||||||
{
|
{
|
||||||
protected $available_columns = array(
|
protected $available_columns = array(
|
||||||
'host_name',
|
'host_name',
|
||||||
|
|
|
@ -36,7 +36,7 @@ use Icinga\Filter\Query\Node;
|
||||||
use Icinga\Filter\Query\Tree;
|
use Icinga\Filter\Query\Tree;
|
||||||
use Icinga\Protocol\Statusdat;
|
use Icinga\Protocol\Statusdat;
|
||||||
use Icinga\Exception;
|
use Icinga\Exception;
|
||||||
use Icinga\Data\BaseQuery;
|
use Icinga\Data\SimpleQuery;
|
||||||
use Icinga\Protocol\Statusdat\Query as Query;
|
use Icinga\Protocol\Statusdat\Query as Query;
|
||||||
use Icinga\Protocol\Statusdat\View\AccessorStrategy;
|
use Icinga\Protocol\Statusdat\View\AccessorStrategy;
|
||||||
use Icinga\Filter\Filterable;
|
use Icinga\Filter\Filterable;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Monitoring\DataView;
|
namespace Icinga\Module\Monitoring\DataView;
|
||||||
|
|
||||||
use Icinga\Data\BaseQuery;
|
use Icinga\Data\SimpleQuery;
|
||||||
use Icinga\Data\Browsable;
|
use Icinga\Data\Browsable;
|
||||||
use Icinga\Data\PivotTable;
|
use Icinga\Data\PivotTable;
|
||||||
use Icinga\Data\Sortable;
|
use Icinga\Data\Sortable;
|
||||||
|
@ -45,17 +45,17 @@ abstract class DataView implements Browsable, Filterable, Sortable
|
||||||
/**
|
/**
|
||||||
* The query used to populate the view
|
* The query used to populate the view
|
||||||
*
|
*
|
||||||
* @var BaseQuery
|
* @var SimpleQuery
|
||||||
*/
|
*/
|
||||||
private $query;
|
private $query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new view
|
* Create a new view
|
||||||
*
|
*
|
||||||
* @param BaseQuery $query Which backend to query
|
* @param SimpleQuery $query Which backend to query
|
||||||
* @param array $columns Select columns
|
* @param array $columns Select columns
|
||||||
*/
|
*/
|
||||||
public function __construct(BaseQuery $query, array $columns = null)
|
public function __construct(SimpleQuery $query, array $columns = null)
|
||||||
{
|
{
|
||||||
$this->query = $query;
|
$this->query = $query;
|
||||||
$this->query->columns($columns === null ? $this->getColumns() : $columns);
|
$this->query->columns($columns === null ? $this->getColumns() : $columns);
|
||||||
|
|
|
@ -13,7 +13,7 @@ class CsvTest extends BaseTestCase
|
||||||
public function testWhetherValidCsvIsRendered()
|
public function testWhetherValidCsvIsRendered()
|
||||||
{
|
{
|
||||||
$queryMock = Mockery::mock(
|
$queryMock = Mockery::mock(
|
||||||
'Icinga\Data\BaseQuery',
|
'Icinga\Data\SimpleQuery',
|
||||||
array(
|
array(
|
||||||
'fetchAll' => array(
|
'fetchAll' => array(
|
||||||
array('col1' => 'val1', 'col2' => 'val2', 'col3' => 'val3', 'col4' => 'val4'),
|
array('col1' => 'val1', 'col2' => 'val2', 'col3' => 'val3', 'col4' => 'val4'),
|
||||||
|
|
Loading…
Reference in New Issue