Adds filters specified through HTTP GET as filter query parameters to
the Solr query.

@param array $resultParameters
@param array $allFacets
@param bool $keepAllFacetsOnSelection
@return array
519802
protected function addFacetQueryFilters($resultParameters, $allFacets, $keepAllFacetsOnSelection)
    {
        $facetFilters = [];

        if (!is_array($resultParameters['filter'])) {
            return $facetFilters;
        }

        $filtersByFacetName = $this->getFiltersByFacetName($resultParameters, $allFacets);

        foreach ($filtersByFacetName as $facetName => $filterValues) {
            $facetConfiguration = $allFacets[$facetName . '.'];
            $tag = $this->getFilterTag($facetConfiguration, $keepAllFacetsOnSelection);
            $filterParts = $this->getFilterParts($facetConfiguration, $facetName, $filterValues);
            $operator = ($facetConfiguration['operator'] === 'OR') ? ' OR ' : ' AND ';
            $facetFilters[] = $tag . '(' . implode($operator, $filterParts) . ')';
        }

        return $facetFilters;
    }
239676
protected function getFilterParts($facetConfiguration, $facetName, $filterValues)
    {
        $filterParts = [];

        $type = isset($facetConfiguration['type']) ? $facetConfiguration['type'] : 'options';
        $filterEncoder = $this->facetRegistry->getPackage($type)->getUrlDecoder();

        if (is_null($filterEncoder)) {
            throw new \InvalidArgumentException('No encoder configured for facet ' . htmlspecialchars($facetName));
        }

        foreach ($filterValues as $filterValue) {
            $filterOptions = $facetConfiguration[$facetConfiguration['type'] . '.'];
            if (empty($filterOptions)) {
                $filterOptions = [];
            }

            $filterValue = $filterEncoder->decode($filterValue, $filterOptions);
            $filterParts[] = $facetConfiguration['field'] . ':' . $filterValue;
        }

        return $filterParts;
    }
524883
protected function getActiveFacetValuesFromRequest(SearchResultSet $resultSet, $facetName)
    {
        $activeFacetValues = [];
        $values = $resultSet->getUsedSearchRequest()->getActiveFacetValuesByName($facetName);

        foreach (is_array($values) ? $values : [] as $valueFromRequest) {
            // Attach the 'depth' param again to the value
            if (strpos($valueFromRequest, '-') === false) {
                $valueFromRequest = HierarchyTool::substituteSlashes($valueFromRequest);
                $valueFromRequest = trim($valueFromRequest, '/');
                $valueFromRequest = (count(explode('/', $valueFromRequest)) - 1) . '-' . $valueFromRequest . '/';
                $valueFromRequest = HierarchyTool::unSubstituteSlashes($valueFromRequest);
            }
            $activeFacetValues[] = $valueFromRequest;
        }
        return $activeFacetValues;
    }
557676
public JSONObject searchInFacetValues(String facetName, String facetQuery, Query params) throws AlgoliaException {
    return this.searchInFacetValues(facetName, facetQuery, params, RequestOptions.empty);
  }
718285
public void search(
        Map<String, List<String>> fieldFacets,
        Map<String, List<String>> rangeFacets,
        String additionalQuery) {

        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly((String)m_resultSorter.getValue())) {
            m_currentConfigParser.setSortOption((String)m_resultSorter.getValue());
        }

        CmsSolrQuery query = m_currentConfigParser.getInitialQuery();
        CmsSearchController controller = new CmsSearchController(new CmsSearchConfiguration(m_currentConfigParser));
        controller.getPagination().getState().setCurrentPage(1);
        if (fieldFacets != null) {
            Map<String, I_CmsSearchControllerFacetField> fieldFacetControllers = controller.getFieldFacets().getFieldFacetController();
            for (Map.Entry<String, List<String>> facetEntry : fieldFacets.entrySet()) {
                I_CmsSearchStateFacet state = fieldFacetControllers.get(facetEntry.getKey()).getState();
                state.clearChecked();
                for (String check : facetEntry.getValue()) {
                    state.addChecked(check);
                }
            }
        }
        if (rangeFacets != null) {
            Map<String, I_CmsSearchControllerFacetRange> rangeFacetControllers = controller.getRangeFacets().getRangeFacetController();
            for (Map.Entry<String, List<String>> facetEntry : rangeFacets.entrySet()) {
                I_CmsSearchStateFacet state = rangeFacetControllers.get(facetEntry.getKey()).getState();
                state.clearChecked();
                for (String check : facetEntry.getValue()) {
                    state.addChecked(check);
                }
            }
        }
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(additionalQuery)) {
            controller.getCommon().getState().setQuery(additionalQuery);
        } else {
            resetTextSearch();
        }

        controller.addQueryParts(query, A_CmsUI.getCmsObject());
        executeSearch(controller, query);
    }
1236794
public function apply(ResultInterface $result, array $configuration, $filterDepth)
    {
        if (false === $this->listAllowsUseOfPostSearchFilter($configuration, $filterDepth)) {
            return $result;
        }

        $result->addFilterQueryString($this->getFilterQueryString());

        return $result;
    }
487489
final public function getQuery(array $parameters = [])
    {
        $parameters = $this->getOptionsResolver()->resolve($parameters);
        $query = $this->buildQuery();

        $sortDefinitions = $parameters['sort'];
        if (!is_array($sortDefinitions)) {
            $sortDefinitions = [$sortDefinitions];
        }

        $query->query = $this->getQueryCriterion($parameters);
        $query->filter = $this->resolveFilterCriteria($parameters);
        $query->facetBuilders = $this->getFacetBuilders($parameters);
        $query->sortClauses = $this->getSortClauses($sortDefinitions);
        $query->limit = $parameters['limit'];
        $query->offset = $parameters['offset'];

        return $query;
    }
921619
public List getFacesExtensionsFilterMappings()
    {
        if (_facesExtensionsFilterMappings != null)
        {
            return _facesExtensionsFilterMappings;
        }

        List tempExtensionsFilterMappings = new ArrayList();
        for (Iterator it = _filters.entrySet().iterator(); it.hasNext(); )
        {
            Map.Entry entry = (Map.Entry)it.next();
            String filterName = (String)entry.getKey();
            String filterClassName = (String)entry.getValue();
            
            if (!"org.apache.myfaces.component.html.util.ExtensionsFilter".equals(filterClassName) &&
                !"org.apache.myfaces.webapp.filter.ExtensionsFilter".equals(filterClassName))
            {
                // not an extensions filter
                continue;
            }
            
            Class filterClass = org.apache.myfaces.shared.util.ClassUtils.simpleClassForName(filterClassName);
            List urlPatterns = (List)_filterMappings.get(filterName);
            if( urlPatterns != null )
            {
                for (Iterator it2 = urlPatterns.iterator(); it2.hasNext(); )
                {
                    String urlpattern = (String)it2.next();
                    tempExtensionsFilterMappings.add(new org.apache.myfaces.shared.webapp.webxml.FilterMapping(
                        filterName, filterClass, urlpattern));
                    if (log.isLoggable(Level.FINEST))
                    {
                        log.finest("adding mapping for filter + " + filterName + " urlpattern = " + urlpattern);
                    }
                }
            }
        }
        
        //Expose to all threads
        _facesExtensionsFilterMappings = tempExtensionsFilterMappings;
        
        return _facesExtensionsFilterMappings;
    }
555442
public static function all( $sort = array() , $fields = array())
    {
        $criteria = array();
        self::processCriteriaWithType($criteria);
        return self::find($criteria, self::mapFields($sort), self::mapFields($fields));
    }
832775
@Override
  public FacetResult[] getFacetResults() {
    if (facets == null || facets.isEmpty()) {
      return new FacetResult[0];
    }
    Collection<FacetResult> facetResults = facets.values();
    return facetResults.toArray(new FacetResult[facetResults.size()]);
  }
385364
protected function applySorting(array $facetParameters)
    {
        $sortingExpression = new SortingExpression();
        $globalSortingExpression = $sortingExpression->getForFacet($this->sorting);

        if (!empty($globalSortingExpression)) {
            $facetParameters['facet.sort'] = $globalSortingExpression;
        }

        return $facetParameters;
    }
1118841
private Component prepareDateFacets(CmsSolrResultList solrResultList, CmsSearchResultWrapper resultWrapper) {

        RangeFacet<?, ?> dateFacets = resultWrapper.getRangeFacet().get(CmsListManager.FIELD_DATE_FACET_NAME);
        I_CmsSearchControllerFacetRange facetController = resultWrapper.getController().getRangeFacets().getRangeFacetController().get(
            CmsListManager.FIELD_DATE_FACET_NAME);
        if ((dateFacets != null) && (dateFacets.getCounts().size() > 0)) {
            GridLayout dateLayout = new GridLayout();
            dateLayout.setWidth("100%");
            dateLayout.setColumns(6);
            String currentYear = null;
            int row = -2;
            for (final RangeFacet.Count value : dateFacets.getCounts()) {
                String[] dateParts = value.getValue().split("-");
                if (!dateParts[0].equals(currentYear)) {
                    row += 2;
                    dateLayout.setRows(row + 2);
                    currentYear = dateParts[0];
                    Label year = new Label(currentYear);
                    year.addStyleName(OpenCmsTheme.PADDING_HORIZONTAL);
                    dateLayout.addComponent(year, 0, row, 5, row);
                    row++;
                }
                int month = Integer.parseInt(dateParts[1]) - 1;

                Button date = new Button(CmsListManager.MONTHS[month] + " (" + value.getCount() + ")");
                date.addStyleName(ValoTheme.BUTTON_TINY);
                date.addStyleName(ValoTheme.BUTTON_BORDERLESS);
                Boolean selected = facetController.getState().getIsChecked().get(value.getValue());
                if ((selected != null) && selected.booleanValue()) {
                    date.addStyleName(SELECTED_STYLE);
                }
                date.addClickListener(new ClickListener() {

                    private static final long serialVersionUID = 1L;

                    public void buttonClick(ClickEvent event) {

                        if (isSelected(event.getComponent())) {
                            resetFacetsAndSearch();
                        } else {
                            selectRangeFacet(CmsListManager.FIELD_DATE_FACET_NAME, value.getValue());
                        }
                    }
                });
                int targetColumn;
                int targetRow;
                if (month < 6) {
                    targetColumn = month;
                    targetRow = row;
                } else {
                    targetColumn = month - 6;
                    targetRow = row + 1;
                    dateLayout.setRows(row + 2);
                }
                dateLayout.addComponent(date, targetColumn, targetRow);
            }
            Panel datePanel = new Panel(CmsVaadinUtils.getMessageText(Messages.GUI_LISTMANAGER_FACET_DATE_0));
            datePanel.setContent(dateLayout);
            return datePanel;
        } else {
            return null;
        }
    }
575735
public static <FACETEDTYPE extends Faceted<FACETTYPE>, FACETTYPE extends Facet<FACETEDTYPE>> Set<Class<FACETTYPE>> getAllOptionalFacets(
            final Class<FACETTYPE> inspectedType)
   {
      Set<Class<FACETTYPE>> seen = new LinkedHashSet<Class<FACETTYPE>>();
      return getAllRelatedFacets(seen, inspectedType, FacetConstraintType.OPTIONAL);
   }
1341719
public static function all($filters = [], $options = null, $fields = null)
    {
        return static::query()->select($fields)->where($filters)->options($options)->fetch();
    }
568061
public function getReferringSites($parameters = [], $parseResult = true)
    {
        $this->setParams([
            'metrics'    => 'ga:pageviews,ga:sessionDuration,ga:exits',
            'dimensions' => 'ga:source',
            'filters'    => 'ga:medium==referral',
            'sort'       => '-ga:pageviews',
        ]);

        return $this->execute($parameters, $parseResult);
    }
755908
public function retrieveAll(array $filters = array(), $limit = null, $offset = null)
    {
        $result = clone $this->entityCollection;
        if (!empty($filters)) {
            $result = $result->search($filters);
        }
        if ($offset) {
            $result = $result->cslice($offset, $limit);
        }
        if ($limit && !$offset) {
            $result = $result->chunk($limit);
        }

        return $result;
    }
841815
protected function getRoute(
        ResultInterface $result,
        /*# string */ $routeKey,
        array $matches
    )/*# : bool */ {
        $request = $result->getRequest();
        $method  = $request->getHttpMethod();

        // matched but method not allowed
        if (!isset($this->routes[$routeKey][$method])) {
            $result->setStatus(Status::METHOD_NOT_ALLOWED);
            return false;
        }

        // get the route
        $route = $this->routes[$routeKey][$method];

        // apply others filters
        if (!$this->filtering($route, $request)) {
            $status = Status::PRECONDITION_FAILED;
            $result->setStatus($status)
                   ->setHandler($route->getHandler($status));
            return false;
        }

        // remember the route
        $result->setRoute($route);

        // set result's parameters
        $result->setParameter(array_replace($route->getDefault(), $matches));

        // set status & handler
        $status = Status::OK;
        $result->setStatus($status)
               ->setHandler($route->getHandler(Status::OK));

        return true;
    }