private void applyConcepts(RuleSet ruleSet, String conceptPattern, Severity parentSeverity, Severity requestedSeverity) throws RuleException { List<Concept> matchingConcepts = ruleSet.getConceptBucket().match(conceptPattern); if (matchingConcepts.isEmpty()) { LOGGER.warn("Could not find concepts matching to '{}'.", matchingConcepts); } else { for (Concept matchingConcept : matchingConcepts) { applyConcept(ruleSet, matchingConcept, getEffectiveSeverity(matchingConcept, parentSeverity, requestedSeverity)); } } }
private boolean applyRequiredConcepts(RuleSet ruleSet, ExecutableRule<?> rule) throws RuleException { boolean requiredConceptsApplied = true; for (Map.Entry<String, Boolean> entry : rule.getRequiresConcepts().entrySet()) { List<Concept> requiredConcepts = ruleSet.getConceptBucket().match(entry.getKey()); for (Concept requiredConcept : requiredConcepts) { boolean conceptResult = applyConcept(ruleSet, requiredConcept, requiredConcept.getSeverity()); Boolean optional = entry.getValue(); if (optional == null) { optional = configuration.isRequiredConceptsAreOptionalByDefault(); } requiredConceptsApplied = requiredConceptsApplied && (conceptResult || optional); } } return requiredConceptsApplied; }
@Override public void write(RuleSet ruleSet, Writer writer) throws com.buschmais.jqassistant.core.analysis.api.rule.RuleException { CollectRulesVisitor visitor = new CollectRulesVisitor(); RuleSelection ruleSelection = RuleSelection.builder().groupIds(ruleSet.getGroupsBucket().getIds()) .constraintIds(ruleSet.getConstraintBucket().getIds()).conceptIds(ruleSet.getConceptBucket().getIds()).build(); new RuleSetExecutor(visitor, configuration).execute(ruleSet, ruleSelection); JqassistantRules rules = new JqassistantRules(); writeGroups(visitor.getGroups(), rules); writeConcepts(visitor.getConcepts().keySet(), rules); writeConstraints(visitor.getConstraints().keySet(), rules); marshal(writer, rules); }
/** * Logs the given rule set on level info. * * @param ruleSet * The rule set. */ public void printRuleSet(RuleSet ruleSet) throws RuleException { RuleSelection ruleSelection = RuleSelection.builder() .conceptIds(ruleSet.getConceptBucket().getIds()) .constraintIds(ruleSet.getConstraintBucket().getIds()) .groupIds(ruleSet.getGroupsBucket().getIds()).build(); printRuleSet(ruleSet, ruleSelection); }
for (Concept concept : ruleSet.getConceptBucket().getAll()) { JSONObject conceptObject = new JSONObject(); conceptObject.put(JSON_OBJECT_KEY_ID, concept.getId());