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;
|
||||
|
||||
use Icinga\Data\BaseQuery;
|
||||
use Icinga\Data\SimpleQuery;
|
||||
|
||||
class Query extends BaseQuery
|
||||
class Query extends SimpleQuery
|
||||
{
|
||||
/**
|
||||
* Remember the last count
|
||||
|
|
|
@ -33,7 +33,7 @@ use PDO;
|
|||
use Zend_Config;
|
||||
use Zend_Db;
|
||||
use Icinga\Application\Benchmark;
|
||||
use Icinga\Data\BaseQuery;
|
||||
use Icinga\Data\SimpleQuery;
|
||||
use Icinga\Data\Selectable;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
|
||||
|
@ -207,11 +207,11 @@ class Connection implements Selectable
|
|||
/**
|
||||
* Retrieve an array containing all rows of the result set
|
||||
*
|
||||
* @param BaseQuery $query
|
||||
* @param SimpleQuery $query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchAll(BaseQuery $query)
|
||||
public function fetchAll(SimpleQuery $query)
|
||||
{
|
||||
Benchmark::measure('DB is fetching All');
|
||||
$result = $this->dbAdapter->fetchAll($query->getSelectQuery());
|
||||
|
@ -222,11 +222,11 @@ class Connection implements Selectable
|
|||
/**
|
||||
* Fetch the first row of the result set
|
||||
*
|
||||
* @param BaseQuery $query
|
||||
* @param SimpleQuery $query
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function fetchRow(BaseQuery $query)
|
||||
public function fetchRow(SimpleQuery $query)
|
||||
{
|
||||
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
|
||||
*
|
||||
* @param BaseQuery $query
|
||||
* @param SimpleQuery $query
|
||||
* @param int $columnIndex Index of the column to fetch
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchColumn(BaseQuery $query, $columnIndex = 0)
|
||||
public function fetchColumn(SimpleQuery $query, $columnIndex = 0)
|
||||
{
|
||||
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
|
||||
*
|
||||
* @param BaseQuery $query
|
||||
* @param SimpleQuery $query
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetchOne(BaseQuery $query)
|
||||
public function fetchOne(SimpleQuery $query)
|
||||
{
|
||||
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.
|
||||
*
|
||||
* @param BaseQuery $query
|
||||
* @param SimpleQuery $query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchPairs(BaseQuery $query)
|
||||
public function fetchPairs(SimpleQuery $query)
|
||||
{
|
||||
return $this->dbAdapter->fetchPairs($query->getSelectQuery());
|
||||
}
|
||||
|
|
|
@ -30,13 +30,13 @@
|
|||
namespace Icinga\Data\Db;
|
||||
|
||||
use Zend_Db_Select;
|
||||
use Icinga\Data\BaseQuery;
|
||||
use Icinga\Data\SimpleQuery;
|
||||
use Icinga\Application\Benchmark;
|
||||
|
||||
/**
|
||||
* Database query class
|
||||
*/
|
||||
class Query extends BaseQuery
|
||||
class Query extends SimpleQuery
|
||||
{
|
||||
/**
|
||||
* @var Zend_Db_Adapter_Abstract
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
namespace Icinga\Data\Db;
|
||||
|
||||
use Icinga\Data\BaseQuery;
|
||||
use Icinga\Data\SimpleQuery;
|
||||
use Icinga\Filter\Query\Tree;
|
||||
use Icinga\Filter\Query\Node;
|
||||
|
||||
|
@ -41,7 +41,7 @@ class TreeToSqlParser
|
|||
/**
|
||||
* The query class to use as the base for converting
|
||||
*
|
||||
* @var BaseQuery
|
||||
* @var SimpleQuery
|
||||
*/
|
||||
private $query;
|
||||
|
||||
|
@ -54,9 +54,9 @@ class TreeToSqlParser
|
|||
/**
|
||||
* 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;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace Icinga\Data;
|
||||
|
||||
use \Zend_Paginator;
|
||||
use Icinga\Data\BaseQuery;
|
||||
use Icinga\Data\SimpleQuery;
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Web\Paginator\Adapter\QueryAdapter;
|
||||
|
||||
|
@ -14,21 +14,21 @@ class PivotTable
|
|||
/**
|
||||
* The query to fetch as pivot table
|
||||
*
|
||||
* @var BaseQuery
|
||||
* @var SimpleQuery
|
||||
*/
|
||||
protected $baseQuery;
|
||||
|
||||
/**
|
||||
* The query to fetch the x axis labels
|
||||
*
|
||||
* @var BaseQuery
|
||||
* @var SimpleQuery
|
||||
*/
|
||||
protected $xAxisQuery;
|
||||
|
||||
/**
|
||||
* The query to fetch the y axis labels
|
||||
*
|
||||
* @var BaseQuery
|
||||
* @var SimpleQuery
|
||||
*/
|
||||
protected $yAxisQuery;
|
||||
|
||||
|
@ -49,11 +49,11 @@ class PivotTable
|
|||
/**
|
||||
* 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 $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->xAxisColumn = $xAxisColumn;
|
||||
|
@ -86,8 +86,8 @@ class PivotTable
|
|||
protected function adjustSorting()
|
||||
{
|
||||
$currentOrderColumns = $this->baseQuery->getOrderColumns();
|
||||
$xAxisOrderColumns = array(array($this->baseQuery->getMappedField($this->xAxisColumn), BaseQuery::SORT_ASC));
|
||||
$yAxisOrderColumns = array(array($this->baseQuery->getMappedField($this->yAxisColumn), BaseQuery::SORT_ASC));
|
||||
$xAxisOrderColumns = array(array($this->baseQuery->getMappedField($this->xAxisColumn), SimpleQuery::SORT_ASC));
|
||||
$yAxisOrderColumns = array(array($this->baseQuery->getMappedField($this->yAxisColumn), SimpleQuery::SORT_ASC));
|
||||
|
||||
foreach ($currentOrderColumns as $orderInfo) {
|
||||
if ($orderInfo[0] === $xAxisOrderColumns[0][0]) {
|
||||
|
|
|
@ -6,7 +6,7 @@ use Zend_Controller_Front;
|
|||
use Zend_Paginator;
|
||||
use Icinga\Web\Paginator\Adapter\QueryAdapter;
|
||||
|
||||
abstract class BaseQuery implements QueryInterface, Queryable
|
||||
abstract class SimpleQuery implements QueryInterface, Queryable
|
||||
{
|
||||
/**
|
||||
* Query data source
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Icinga\Protocol\File;
|
||||
|
||||
use Icinga\Data\BaseQuery;
|
||||
use Icinga\Data\SimpleQuery;
|
||||
|
||||
/**
|
||||
* Class Query
|
||||
|
@ -13,7 +13,7 @@ use Icinga\Data\BaseQuery;
|
|||
*
|
||||
* @package Icinga\Protocol\File
|
||||
*/
|
||||
class Query extends BaseQuery
|
||||
class Query extends SimpleQuery
|
||||
{
|
||||
/**
|
||||
* Sort direction
|
||||
|
|
|
@ -31,14 +31,14 @@ namespace Icinga\Protocol\Statusdat;
|
|||
|
||||
use Exception;
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
use Icinga\Data\BaseQuery;
|
||||
use Icinga\Data\SimpleQuery;
|
||||
use Icinga\Protocol\Statusdat\View\MonitoringObjectList;
|
||||
use Icinga\Protocol\Statusdat\Query\IQueryPart;
|
||||
|
||||
/**
|
||||
* Base implementation for Statusdat queries.
|
||||
*/
|
||||
class Query extends BaseQuery
|
||||
class Query extends SimpleQuery
|
||||
{
|
||||
/**
|
||||
* 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\Widget\Tabextension\OutputFormat;
|
||||
use \Icinga\Module\Monitoring\Backend;
|
||||
use \Icinga\Data\BaseQuery;
|
||||
use \Icinga\Data\SimpleQuery;
|
||||
use \Icinga\Web\Widget\Chart\InlinePie;
|
||||
use \Icinga\Module\Monitoring\Form\Command\MultiCommandFlagForm;
|
||||
use \Icinga\Module\Monitoring\DataView\HostStatus as HostStatusView;
|
||||
|
@ -183,16 +183,16 @@ class Monitoring_MultiController extends ActionController
|
|||
/**
|
||||
* 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
|
||||
* array-structure.
|
||||
* @param $hostColumn string The name of the host-column in the BaseQuery, defaults to 'host_name'
|
||||
* @param $serviceColumn string The name of the service-column in the BaseQuery, defaults to 'service-description'
|
||||
* @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 SimpleQuery, defaults to 'service-description'
|
||||
*
|
||||
* @return BaseQuery The given BaseQuery
|
||||
* @return SimpleQuery The given SimpleQuery
|
||||
*/
|
||||
private function applyQueryFilter(
|
||||
BaseQuery $backendQuery,
|
||||
SimpleQuery $backendQuery,
|
||||
array $filter,
|
||||
$hostColumn = 'host_name',
|
||||
$serviceColumn = 'service_description'
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
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(
|
||||
'host_name',
|
||||
|
|
|
@ -36,7 +36,7 @@ use Icinga\Filter\Query\Node;
|
|||
use Icinga\Filter\Query\Tree;
|
||||
use Icinga\Protocol\Statusdat;
|
||||
use Icinga\Exception;
|
||||
use Icinga\Data\BaseQuery;
|
||||
use Icinga\Data\SimpleQuery;
|
||||
use Icinga\Protocol\Statusdat\Query as Query;
|
||||
use Icinga\Protocol\Statusdat\View\AccessorStrategy;
|
||||
use Icinga\Filter\Filterable;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\DataView;
|
||||
|
||||
use Icinga\Data\BaseQuery;
|
||||
use Icinga\Data\SimpleQuery;
|
||||
use Icinga\Data\Browsable;
|
||||
use Icinga\Data\PivotTable;
|
||||
use Icinga\Data\Sortable;
|
||||
|
@ -45,17 +45,17 @@ abstract class DataView implements Browsable, Filterable, Sortable
|
|||
/**
|
||||
* The query used to populate the view
|
||||
*
|
||||
* @var BaseQuery
|
||||
* @var SimpleQuery
|
||||
*/
|
||||
private $query;
|
||||
|
||||
/**
|
||||
* Create a new view
|
||||
*
|
||||
* @param BaseQuery $query Which backend to query
|
||||
* @param SimpleQuery $query Which backend to query
|
||||
* @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->columns($columns === null ? $this->getColumns() : $columns);
|
||||
|
|
|
@ -13,7 +13,7 @@ class CsvTest extends BaseTestCase
|
|||
public function testWhetherValidCsvIsRendered()
|
||||
{
|
||||
$queryMock = Mockery::mock(
|
||||
'Icinga\Data\BaseQuery',
|
||||
'Icinga\Data\SimpleQuery',
|
||||
array(
|
||||
'fetchAll' => array(
|
||||
array('col1' => 'val1', 'col2' => 'val2', 'col3' => 'val3', 'col4' => 'val4'),
|
||||
|
|
Loading…
Reference in New Issue