docs: public RuleQuery createRuleQuery(DbSession dbSession, Request request) {
      RuleQuery query = new RuleQuery();
      query.setQueryText(request.param(WebService.Param.TEXT_QUERY));
      query.setSeverities(request.paramAsStrings(PARAM_SEVERITIES));
      query.setRepositories(request.paramAsStrings(PARAM_REPOSITORIES));
      Date availableSince = request.paramAsDate(PARAM_AVAILABLE_SINCE);
      query.setAvailableSince(availableSince != null ? availableSince.getTime() : null);
      query.setStatuses(toEnums(request.paramAsStrings(PARAM_STATUSES), RuleStatus.class));
  
      // Order is important : 1. Load profile, 2. Load organization either from parameter or from profile, 3. Load compare to profile
      setProfile(dbSession, query, request);
      setOrganization(dbSession, query, request);
      setCompareToProfile(dbSession, query, request);
      QProfileDto profile = query.getQProfile();
      query.setLanguages(profile == null ? request.paramAsStrings(PARAM_LANGUAGES) : ImmutableList.of(profile.getLanguage()));
      if (wsSupport.areActiveRulesVisible(query.getOrganization())) {
        query.setActivation(request.paramAsBoolean(PARAM_ACTIVATION));
      }
      query.setTags(request.paramAsStrings(PARAM_TAGS));
      query.setInheritance(request.paramAsStrings(PARAM_INHERITANCE));
      query.setActiveSeverities(request.paramAsStrings(PARAM_ACTIVE_SEVERITIES));
      query.setIsTemplate(request.paramAsBoolean(PARAM_IS_TEMPLATE));
      query.setTemplateKey(request.param(PARAM_TEMPLATE_KEY));
      query.setTypes(toEnums(request.paramAsStrings(PARAM_TYPES), RuleType.class));
      query.setKey(request.param(PARAM_RULE_KEY));
  
      String sortParam = request.param(WebService.Param.SORT);
      if (sortParam != null) {
        query.setSortField(sortParam);
        query.setAscendingSort(request.mandatoryParamAsBoolean(WebService.Param.ASCENDING));
      }
      return query;
    }