Search in sources :

Example 1 with CollectRulesVisitor

use of com.buschmais.jqassistant.core.rule.api.executor.CollectRulesVisitor in project jqa-core-framework by buschmais.

the class RuleHelper method getAllRules.

/**
     * Determines all rules.
     * 
     * @param ruleSet
     *            The rule set.
     * @return The visitor with all valid and missing rules.
     * @throws RuleExecutorException
     *             If the rules cannot be evaluated.
     */
private CollectRulesVisitor getAllRules(RuleSet ruleSet, RuleSelection ruleSelection) throws RuleExecutorException {
    CollectRulesVisitor visitor = new CollectRulesVisitor();
    RuleExecutor executor = new RuleExecutor(visitor, new RuleExecutorConfiguration());
    executor.execute(ruleSet, ruleSelection);
    return visitor;
}
Also used : RuleExecutor(com.buschmais.jqassistant.core.rule.api.executor.RuleExecutor) CollectRulesVisitor(com.buschmais.jqassistant.core.rule.api.executor.CollectRulesVisitor) RuleExecutorConfiguration(com.buschmais.jqassistant.core.rule.api.executor.RuleExecutorConfiguration)

Example 2 with CollectRulesVisitor

use of com.buschmais.jqassistant.core.rule.api.executor.CollectRulesVisitor in project jqa-core-framework by buschmais.

the class RuleHelper method printRuleSet.

/**
     *
     * @param ruleSet
     * @param ruleSelection
     * @throws RuleExecutorException
     */
public void printRuleSet(RuleSet ruleSet, RuleSelection ruleSelection) throws RuleExecutorException {
    CollectRulesVisitor visitor = getAllRules(ruleSet, ruleSelection);
    printValidRules(visitor);
    printMissingRules(visitor);
}
Also used : CollectRulesVisitor(com.buschmais.jqassistant.core.rule.api.executor.CollectRulesVisitor)

Example 3 with CollectRulesVisitor

use of com.buschmais.jqassistant.core.rule.api.executor.CollectRulesVisitor in project jqa-core-framework by buschmais.

the class RuleSetWriterImpl method write.

@Override
public void write(RuleSet ruleSet, Writer writer) throws RuleException {
    CollectRulesVisitor visitor = new CollectRulesVisitor();
    RuleSelection ruleSelection = RuleSelection.Builder.newInstance().addGroupIds(ruleSet.getGroupsBucket().getIds()).addConstraintIds(ruleSet.getConstraintBucket().getIds()).addConceptIds(ruleSet.getConceptBucket().getIds()).get();
    try {
        new RuleExecutor(visitor, configuration).execute(ruleSet, ruleSelection);
    } catch (RuleExecutorException e) {
        throw new RuleException("Cannot create rule set", e);
    }
    JqassistantRules rules = new JqassistantRules();
    writeGroups(visitor.getGroups(), rules);
    writeConcepts(visitor.getConcepts().keySet(), rules);
    writeConstraints(visitor.getConstraints().keySet(), rules);
    marshal(writer, rules);
}
Also used : RuleExecutorException(com.buschmais.jqassistant.core.rule.api.executor.RuleExecutorException) RuleExecutor(com.buschmais.jqassistant.core.rule.api.executor.RuleExecutor) CollectRulesVisitor(com.buschmais.jqassistant.core.rule.api.executor.CollectRulesVisitor)

Aggregations

CollectRulesVisitor (com.buschmais.jqassistant.core.rule.api.executor.CollectRulesVisitor)3 RuleExecutor (com.buschmais.jqassistant.core.rule.api.executor.RuleExecutor)2 RuleExecutorConfiguration (com.buschmais.jqassistant.core.rule.api.executor.RuleExecutorConfiguration)1 RuleExecutorException (com.buschmais.jqassistant.core.rule.api.executor.RuleExecutorException)1