protected function executeCubeCountRequest(DataQueryControllerCubeRequest $request)
 {
     $callcontext = $this->prepareCallContext();
     $requestPreparer = new DataSourceCubeQueryRequestPreparer();
     $cubeCountRequest = $requestPreparer->prepareCubeCountRequest($request);
     $this->prepareCubeRequestMetaData($cubeCountRequest);
     $cubeResultFormatter = isset($request->resultFormatter) ? $request->resultFormatter : $this->getDefaultResultFormatter();
     $cubeResultFormatter->adjustCubeCountRequest($callcontext, $cubeCountRequest);
     LogHelper::log_debug($request);
     $cubeName = $cubeCountRequest->getCubeName();
     return $this->getDataSourceQueryHandlerByCubeName($cubeName)->countCubeRecords($callcontext, $cubeCountRequest, $cubeResultFormatter);
 }
    protected function executeCubeCountRequest(DataQueryControllerCubeRequest $request) {
        $environment_metamodel = data_controller_get_environment_metamodel();
        $metamodel = data_controller_get_metamodel();

        $callcontext = $this->prepareCallContext();

        $requestPreparer = new DataSourceCubeQueryRequestPreparer();
        $cubeCountRequest = $requestPreparer->prepareCountRequest($request);

        $this->prepareCubeRequestMetaData($cubeCountRequest);

        if (isset($request->resultFormatter)) {
            $request->resultFormatter->adjustCubeCountRequest($callcontext, $cubeCountRequest);
        }

        LogHelper::log_debug($cubeCountRequest);

        $dataset = $metamodel->getDataset($request->datasetName);
        $datasource = $environment_metamodel->getDataSource($dataset->datasourceName);

        $isCacheSupported = $this->isCacheSupported($datasource);
        $cache = $isCacheSupported ? new DataQueryControllerCacheProxy($cubeCountRequest) : NULL;

        list($data, $cacheHit) = isset($cache) ? $cache->getCachedResult() : array(NULL, FALSE);
        if (!$cacheHit) {
            $data = RequestChainFactory::getInstance()->initializeChain()->countCubeRecords(
                $this->lookupDataSourceHandler($datasource->type), $callcontext, $cubeCountRequest);
            if ($isCacheSupported) {
                $cache->cacheResult($data);
            }
        }

        return $data;
    }