Search in sources :

Example 1 with ConceptDescriptor

use of com.buschmais.jqassistant.core.analysis.api.model.ConceptDescriptor in project jqa-core-framework by buschmais.

the class AnalyzerRuleVisitor method visitConcept.

@Override
public boolean visitConcept(Concept concept, Severity effectiveSeverity) throws RuleException {
    ConceptDescriptor conceptDescriptor = analyzerContext.getStore().find(ConceptDescriptor.class, concept.getId());
    Result.Status status;
    if (conceptDescriptor == null || configuration.isExecuteAppliedConcepts()) {
        analyzerContext.getLogger().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 = analyzerContext.getStore().create(ConceptDescriptor.class);
            conceptDescriptor.setId(concept.getId());
            conceptDescriptor.setStatus(status);
        }
        reportPlugin.endConcept();
    } else {
        status = conceptDescriptor.getStatus();
    }
    return Result.Status.SUCCESS.equals(status);
}
Also used : Concept(com.buschmais.jqassistant.core.rule.api.model.Concept) ConceptDescriptor(com.buschmais.jqassistant.core.analysis.api.model.ConceptDescriptor) Result(com.buschmais.jqassistant.core.report.api.model.Result)

Example 2 with ConceptDescriptor

use of com.buschmais.jqassistant.core.analysis.api.model.ConceptDescriptor 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)

Aggregations

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