Search in sources :

Example 1 with XOException

use of com.buschmais.xo.api.XOException in project jqa-core-framework by buschmais.

the class AnalyzerVisitor method visitConcept.

@Override
public boolean visitConcept(Concept concept, Severity effectiveSeverity) throws RuleExecutorException {
    try {
        store.beginTransaction();
        ConceptDescriptor conceptDescriptor = store.find(ConceptDescriptor.class, concept.getId());
        Result.Status status;
        if (conceptDescriptor == null || configuration.isExecuteAppliedConcepts()) {
            logger.info("Applying concept '" + concept.getId() + "' with severity: '" + concept.getSeverity().getInfo(effectiveSeverity) + "'.");
            reportPlugin.beginConcept(concept);
            Result<Concept> result = execute(concept, effectiveSeverity);
            reportPlugin.setResult(result);
            status = result.getStatus();
            if (conceptDescriptor == null) {
                conceptDescriptor = store.create(ConceptDescriptor.class);
                conceptDescriptor.setId(concept.getId());
                conceptDescriptor.setStatus(result.getStatus());
            }
            reportPlugin.endConcept();
        } else {
            status = conceptDescriptor.getStatus();
        }
        store.commitTransaction();
        return Result.Status.SUCCESS.equals(status);
    } catch (XOException e) {
        store.rollbackTransaction();
        throw new RuleExecutorException("Cannot apply concept " + concept.getId(), e);
    }
}
Also used : XOException(com.buschmais.xo.api.XOException) RuleExecutorException(com.buschmais.jqassistant.core.rule.api.executor.RuleExecutorException) ConceptDescriptor(com.buschmais.jqassistant.core.analysis.api.model.ConceptDescriptor) Result(com.buschmais.jqassistant.core.analysis.api.Result)

Example 2 with XOException

use of com.buschmais.xo.api.XOException in project jqa-core-framework by buschmais.

the class AnalyzerVisitor method visitConstraint.

@Override
public void visitConstraint(Constraint constraint, Severity effectiveSeverity) throws RuleExecutorException {
    logger.info("Validating constraint '" + constraint.getId() + "' with severity: '" + constraint.getSeverity().getInfo(effectiveSeverity) + "'.");
    try {
        store.beginTransaction();
        reportPlugin.beginConstraint(constraint);
        reportPlugin.setResult(execute(constraint, effectiveSeverity));
        reportPlugin.endConstraint();
        store.commitTransaction();
    } catch (XOException e) {
        store.rollbackTransaction();
        throw new RuleExecutorException("Cannot validate constraint " + constraint.getId(), e);
    }
}
Also used : XOException(com.buschmais.xo.api.XOException) RuleExecutorException(com.buschmais.jqassistant.core.rule.api.executor.RuleExecutorException)

Aggregations

RuleExecutorException (com.buschmais.jqassistant.core.rule.api.executor.RuleExecutorException)2 XOException (com.buschmais.xo.api.XOException)2 Result (com.buschmais.jqassistant.core.analysis.api.Result)1 ConceptDescriptor (com.buschmais.jqassistant.core.analysis.api.model.ConceptDescriptor)1