Generate result objects for processing.
@param array $settings Query settings.
@param array $query_list List of queries.
@return An array of result objects.
556432
private function generateResults($settings, $query_list) {
        if(count($query_list) == 0) {
            return [];
        }

        $query_stack = array_reverse($query_list);
        $results = [];

        // Extract global settings. These are applied to all results.
        $global_settings = [];
        foreach($settings as $k=>$v) {
            if(!in_array($k, ['fields', 'map', 'flatten', 'sort', 'count'])) {
                $global_settings[$k] = $v;
            }
        }

        // Construct result objects from our list of querys and
        // link them together.
        do {
            $curr = new Result();
            $curr->setConnProvider($this->conn_provider);
            $curr->setListProvider($this->list_provider);
            $curr->setSettings($global_settings);

            // A source has been set.
            $source = false;
            // We've consumed at least one agg.
            $agg = false;
            // We've consumed a metrics agg.
            $metrics = false;
            // We've consumed all the commands we can.
            $end = false;
            while(count($query_stack) && !$end) {
                $len = count($query_stack);
                switch($query_stack[$len - 1][0]) {
                    // Transactions are terminal commands.
                    case Token::C_TRANS:
                        // It doesn't make sense for a transaction to be followed by anything.
                        if(count($query_stack) > 1) {
                            throw new Exception('Unexpected command');
                        }
                        $curr->setPostQuery(array_pop($query_stack));
                        $end = true;
                        break;
                    // Consume a source command and enable the source bit.
                    case Token::C_SEARCH:
                    case Token::C_JOIN:
                        if(!$source) {
                            $curr->setQuery(array_pop($query_stack));
                            $source = true;
                        } else {
                            $end = true;
                        }
                        break;

                    // Consume an agg if we've already a source.
                    case Token::C_AGG:
                        if(!$source) {
                            throw new Exception('No source');
                        }
                        $q = array_pop($query_stack);
                        // Metrics aggs can't have children.
                        switch($q[1]) {
                            case Token::A_MIN:
                            case Token::A_MAX:
                            case Token::A_AVG:
                            case Token::A_SUM:
                                if($metrics) {
                                    throw new Exception('Unexpected agg');
                                }
                                $metrics = true;
                        }
                        $curr->addAgg($q);
                        $agg = true;
                        break;

                    default:
                        throw new Exception('Unknown command type');
                }
            }

            // Register providers and add to the list.
            $results[] = $curr;
        } while(count($query_stack));

        $results[count($results) - 1]->setSettings($settings);

        return $results;
    }
88087
public function getResults()
    {
        if (null === $this->results) {
            $queryKey = method_exists($this->getQuery(), 'getQueryKey') ? $this->getQuery()->getQueryKey() : null;
            if ($queryKey) {
                $newQueryKey = sprintf('%s offset %s limit %s', $queryKey, $this->getQuery()->getOffset(), $this->getQuery()->getLimit());
                $this->getQuery()->setQueryKey($newQueryKey);
            }
            
            $this->results = $this->getQuery()
                ->find($this->con)
            ;
        }

        return $this->results;
    }
107939
protected function getPageFromQueryParams(array $query_params)
    {
        $page = 1;

        if (isset($query_params['page'])) {
            $page = (integer) $query_params['page'];
        }

        return $page < 1 ? 1 : $page;
    }
1021542
public function getList()
    {
        //ACCESS CHECK
        if (!$this->isAllowed(
            ResourceName::RESOURCE_SITES,
            'admin'
        )
        ) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);

            return $this->getResponse();
        }

        /** @var \Doctrine\ORM\EntityManagerInterface $entityManager */
        $entityManager = $this->getEntityManager();

        /** @var \Rcm\Repository\Site $siteRepo */
        $siteRepo = $entityManager->getRepository(\Rcm\Entity\Site::class);
        $createQueryBuilder = $siteRepo->createQueryBuilder('site')
            ->select('site')
            ->leftJoin('site.domain', 'domain')
            ->leftJoin('site.country', 'country')
            ->leftJoin('site.language', 'language');
        // @todo This is broken in doctrine 1.* with MySQL 5.7
        //->orderBy('domain.domain', 'ASC');

        $query = $createQueryBuilder->getQuery();

        $searchQuery = $this->params()->fromQuery('q');

        if ($searchQuery) {
            $createQueryBuilder->where(
                $createQueryBuilder->expr()->like(
                    'domain.domain',
                    ':searchQuery'
                )
            );
            $query = $createQueryBuilder->getQuery();
            $query->setParameter('searchQuery', $searchQuery . '%');
        }

        $adaptor = new DoctrinePaginator(
            new ORMPaginator($query)
        );
        $paginator = new Paginator($adaptor);
        $paginator->setDefaultItemCountPerPage(10);

        $page = (int)$this->params()->fromQuery('page');

        if ($page) {
            $paginator->setCurrentPageNumber($page);
        }

        $pageSize = (int)$this->params()->fromQuery('page_size');
        if ($pageSize) {
            $paginator->setItemCountPerPage($pageSize);
        }

        $sitesObjects = $paginator->getCurrentItems();

        $sites = [];

        /** @var \Rcm\Entity\Site $site */
        foreach ($sitesObjects as $site) {
            $sites[] = $site->toArray();
        }

        $list['items'] = $sites;
        $list['itemCount'] = $paginator->getTotalItemCount();
        $list['pageCount'] = $paginator->count();
        $list['currentPage'] = $paginator->getCurrentPageNumber();

        return new ApiJsonModel($list, 0, 'Success');
    }
840326
public function read ($list_name, $limit = NULL, $query = NULL, $view = NULL, $sort = NULL, $options = NULL) {
		// Check limit is set
		if ($limit < 1 || is_null($limit)) {
			$limit = $this->MAX_ROWS;
		}

		// Create Query XML is query is being used
		$xml_options = '';
		$xml_query   = '';
		$fields_xml = '';

		// Setup Options
		if ($query instanceof Service\QueryObjectService) {
			$xml_query = $query->getCAML();
			$xml_options = $query->getOptionCAML();
		} else {

			if (!is_null($query)) {
				$xml_query .= $this->whereXML($query); // Build Query
			}
			if (!is_null($sort)) {
				$xml_query .= $this->sortXML($sort);// add sort
			}

			// Add view or fields
			if (!is_null($view)){
				// array, fields have been specified
				if(is_array($view)){
					$xml_options .= $this->viewFieldsXML($view);
				}else{
					$xml_options .= '<viewName>' . $view . '</viewName>';
				}
			}
		}

		// If query is required
		if (!empty($xml_query)) {
			$xml_options .= '<query><Query>' . $xml_query . '</Query></query>';
		}

		/*
		 * Setup basic XML for querying a SharePoint list.
		 * If rowLimit is not provided SharePoint will default to a limit of 100 items.
		 */
		$CAML = '
			<GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
				<listName>' . $list_name . '</listName>
				<rowLimit>' . $limit . '</rowLimit>
				' . $xml_options . '
				<queryOptions xmlns:SOAPSDK9="http://schemas.microsoft.com/sharepoint/soap/" >
					<QueryOptions>
						' . $options . '
					</QueryOptions>
				</queryOptions>
			</GetListItems>';

		// Ready XML
		$xmlvar = new \SoapVar($CAML, XSD_ANYXML);
		$result = NULL;

		// Attempt to query SharePoint
		try {
			$result = $this->xmlHandler($this->soapClient->GetListItems($xmlvar)->GetListItemsResult->any);
		} catch (\SoapFault $fault) {
			$this->onError($fault);
		}

		// Return a XML as nice clean Array
		return $result;
	}
125396
private function getMappedSettings(array $settings, $fromIndex, $toIndex)
    {
        $mappedSettings = ['sourceOrder' => [], 'sources' => []];

        if (isset($settings['sourceOrder'])) {
            foreach ($settings['sourceOrder'] as $row) {
                if ('key' == $row[0]) {
                    $row[1] = $this->getSource('', $row[1], $fromIndex, $toIndex);
                }
                $mappedSettings['sourceOrder'][] = $row;
            }
        }

        if (isset($settings['sources'])) {
            foreach ($settings['sources'] as $source => $sourceSettings) {
                $mappedSource = $this->getSource('', $source, $fromIndex, $toIndex);
                $mappedSettings['sources'][$mappedSource] = [
                  'tableAttributes' => $this->getSources('', $sourceSettings['tableAttributes'], $fromIndex, $toIndex),
                ];
            }
        }

        return $mappedSettings;
    }
1213728
public function listStates($optParams = array()) {
      $params = array();
      $params = array_merge($params, $optParams);
      $data = $this->__call('list', array($params));
      if ($this->useObjects()) {
        return new Google_ListResponse($data);
      } else {
        return $data;
      }
    }
835354
protected function buildPageSettings($settings)
    {
        if (empty($settings)) {
            return $settings;
        }

        $output = [];
        foreach ($settings as $setting) {
            $output[$setting->setting_key] = $setting->setting_value;
        }

        return $output;
    }
1017300
protected List<Group> executePaginatedQuery(GroupQuery query, Integer firstResult, Integer maxResults) {
    if (firstResult == null) {
      firstResult = 0;
    }
    if (maxResults == null) {
      maxResults = Integer.MAX_VALUE;
    }
    return query.listPage(firstResult, maxResults);
  }
444781
static public function fetchList( $params, $limits = null, $sorts = null, $mainTranslation = false, $locale = false )
    {
        $customConds = self::fetchCustomCondsSQL( $params, $mainTranslation, $locale );

        if ( is_array( $params ) )
        {
            $newParams = array();
            foreach ( $params as $key => $value )
            {
                if ( $key != 'keyword' )
                    $newParams[$key] = $value;
                else
                    $newParams['eztags_keyword.keyword'] = $value;
            }

            $params = $newParams;
        }

        if ( is_array( $sorts ) )
        {
            $newSorts = array();
            foreach ( $sorts as $key => $value )
            {
                if ( $key != 'keyword' )
                    $newSorts[$key] = $value;
                else
                    $newSorts['eztags_keyword.keyword'] = $value;
            }

            $sorts = $newSorts;
        }
        else if ( $sorts == null )
        {
            $sorts = array( 'eztags_keyword.keyword' => 'asc' );
        }

        $tagsList = parent::fetchObjectList( self::definition(), array(), $params,
                                                         $sorts, $limits, true, false,
                                                         array( 'DISTINCT eztags.*',
                                                                array( 'operation' => 'eztags_keyword.keyword',
                                                                       'name'      => 'keyword' ),
                                                                array( 'operation' => 'eztags_keyword.locale',
                                                                       'name'      => 'locale' ) ),
                                                         array( 'eztags_keyword' ), $customConds );
        return $tagsList;
    }
827800
protected function listQueryParams(array $list)
    {
        $result = [];
        $params = $this->getRequest()->getQueryParams();
        
        foreach ($list as $key => $value) {
            if (is_int($key)) {
                $key = $value;
                $value = null;
            }
            
            $result[] = isset($params[$key]) ? $params[$key] : $value;
        }
        
        return $result;
    }
168835
public static FutureRowCount applyPageList(MultivaluedMap<String, String> queryParams, Query query) {

        FutureRowCount futureRowCount = fetchRowCount(queryParams, query);

        applyPageConfig(queryParams, query);

        return futureRowCount;
    }
468201
public function buildResultSet(Response $response, Query $query): ResultSet
    {
        $resultSet = $this->builder->buildResultSet($response, $query);

        $this->processor->process($resultSet);

        return $resultSet;
    }
333022
def results(self, query_name):
        

        url = "{0}/{1}/result".format(self.saved_query_url, query_name)
        response = self._get_json(HTTPMethods.GET, url, self._get_read_key())

        return response
981126
private function getSearchResult(array $filters, $limit, $page, $pageSize, $locale, $webspaceKey)
    {
        $repository = $this->searchManager->getRepository($this->articleDocumentClass);
        $search = $this->createSearch($repository->createSearch(), $filters, $locale);
        if (!$search) {
            return new \ArrayIterator([]);
        }

        $this->addPagination($search, $pageSize, $page, $limit);

        if (array_key_exists('sortBy', $filters) && is_array($filters['sortBy'])) {
            $sortMethod = array_key_exists('sortMethod', $filters) ? $filters['sortMethod'] : 'asc';
            $this->appendSortBy($filters['sortBy'], $sortMethod, $search);
        }

        if ($webspaceKey) {
            $webspaceQuery = new BoolQuery();

            // check for mainWebspace
            $webspaceQuery->add(new TermQuery('main_webspace', $webspaceKey), BoolQuery::SHOULD);

            // check for additionalWebspaces
            $webspaceQuery->add(new TermQuery('additional_webspaces', $webspaceKey), BoolQuery::SHOULD);

            $search->addQuery($webspaceQuery);
        }

        return $repository->findDocuments($search);
    }
911589
public function generateSqlQueries(array $diff_res)
    {
        $queries = $this->generateQueries($diff_res);
        $sql = '';
        foreach ($queries as $query) {
            $sql .= $this->getSqlQuery($query) . ";\n";
        }
        return $sql;
    }
1318790
public function getAll(array $queryParams = [])
    {
        $response = $this->api->settings()->getAll($queryParams);

        return new SettingsResponse($response);
    }