public RuleSet parse(List<? extends RuleSource> sources) throws RuleException { RuleSetBuilder ruleSetBuilder = RuleSetBuilder.newInstance(); for (RuleSource source : sources) { for (RuleParserPlugin ruleParserPlugin : ruleParserPlugins) { if (ruleParserPlugin.accepts(source)) { ruleParserPlugin.parse(source, ruleSetBuilder); } } } return ruleSetBuilder.getRuleSet(); } }
protected RuleSet getAvailableRules() throws CliExecutionException { List<RuleSource> sources = new ArrayList<>(); if (rulesUrl != null) { sources.add(new UrlRuleSource(rulesUrl)); } else { File selectedDirectory = new File(ruleDirectory); // read rules from rules directory sources.addAll(readRulesDirectory(selectedDirectory)); List<RuleSource> ruleSources; try { ruleSources = pluginRepository.getRulePluginRepository().getRuleSources(); } catch (PluginRepositoryException e) { throw new CliExecutionException("Cannot get rule plugin repository.", e); } sources.addAll(ruleSources); } RuleSetBuilder ruleSetBuilder = RuleSetBuilder.newInstance(); try { ruleSetReader.read(sources, ruleSetBuilder); } catch (RuleException e) { throw new CliExecutionException("Cannot read rules.", e); } return ruleSetBuilder.getRuleSet(); }
protected AbstractJQARestService(Store store) throws PluginRepositoryException, RuleException { this.store = store; PluginConfigurationReader pluginConfigurationReader = new PluginConfigurationReaderImpl(); RulePluginRepository rulePluginRepository = new RulePluginRepositoryImpl(pluginConfigurationReader); List<RuleSource> ruleSources = rulePluginRepository.getRuleSources(); RuleSetReader ruleSetReader = new CompoundRuleSetReader(); RuleSetBuilder ruleSetBuilder = RuleSetBuilder.newInstance(); ruleSetReader.read(ruleSources, ruleSetBuilder); availableRules = ruleSetBuilder.getRuleSet(); }