/** Used in SQALE */ public PagedResult<RuleDto> find(Map<String, Object> params) { RuleQuery query = new RuleQuery(); query.setQueryText(Strings.emptyToNull((String) params.get("searchQuery"))); query.setKey(Strings.emptyToNull((String) params.get("key"))); query.setLanguages(RubyUtils.toStrings(params.get("languages"))); query.setRepositories(RubyUtils.toStrings(params.get("repositories"))); query.setSeverities(RubyUtils.toStrings(params.get("severities"))); query.setStatuses(RubyUtils.toEnums(params.get("statuses"), RuleStatus.class)); query.setTags(RubyUtils.toStrings(params.get("tags"))); query.setSortField(RuleIndexDefinition.FIELD_RULE_NAME); String profile = Strings.emptyToNull((String) params.get("profile")); if (profile != null) { query.setQProfileKey(profile); query.setActivation(true); } SearchOptions options = new SearchOptions(); Integer pageSize = RubyUtils.toInteger(params.get("pageSize")); int size = pageSize != null ? pageSize : 50; Integer page = RubyUtils.toInteger(params.get("p")); int pageIndex = page != null ? page : 1; options.setPage(pageIndex, size); SearchIdResult<RuleKey> result = service.search(query, options); List<RuleDto> ruleDtos = loadDtos(result.getIds()); return new PagedResult<>( ruleDtos, PagingResult.create(options.getLimit(), pageIndex, result.getTotal())); }
public static RuleService getRuleService(OMElement ruleServiceElement) { RuleService ruleService = new RuleService(ruleServiceElement); ruleService.setName( HelperUtil.getAttributeValue(ruleServiceElement, Constants.RULE_CONF_ATTR_NAME)); return ruleService; }