use of org.kie.dmn.validation.dtanalysis.DMNDTAnalysisMessage in project drools by kiegroup.
the class DTAnalysis method gapsAsMessages.
private Collection gapsAsMessages() {
List<DMNDTAnalysisMessage> results = new ArrayList<>();
if (!ddtaTable.getColIDsStringWithoutEnum().isEmpty()) {
List<String> names = ddtaTable.getColIDsStringWithoutEnum().stream().map(id -> sourceDT.getInput().get(id - 1)).map(InputClause::getInputExpression).map(LiteralExpression::getText).collect(Collectors.toList());
results.add(new DMNDTAnalysisMessage(this, Severity.WARN, MsgUtil.createMessage(Msg.DTANALYSIS_GAP_SKIPPED_BECAUSE_FREE_STRING, names), Msg.DTANALYSIS_GAP_SKIPPED_BECAUSE_FREE_STRING.getType()));
return results;
}
for (Hyperrectangle gap : gaps) {
results.add(new DMNDTAnalysisMessage(this, Severity.WARN, MsgUtil.createMessage(Msg.DTANALYSIS_GAP, gap.asHumanFriendly(ddtaTable)), Msg.DTANALYSIS_GAP.getType()));
}
return results;
}
use of org.kie.dmn.validation.dtanalysis.DMNDTAnalysisMessage in project drools by kiegroup.
the class DTAnalysis method computeOutputInLOV.
public void computeOutputInLOV() {
for (int ruleIdx = 0; ruleIdx < ddtaTable.getRule().size(); ruleIdx++) {
DDTARule rule = ddtaTable.getRule().get(ruleIdx);
for (int outputIdx = 0; outputIdx < ddtaTable.getOutputs().size(); outputIdx++) {
Comparable<?> value = rule.getOutputEntry().get(outputIdx);
if (value instanceof DDTAOutputEntryExpression) {
// we can't say _statically_ if the output expression is in the output LoV; skipping
continue;
}
DDTAOutputClause outputClause = ddtaTable.getOutputs().get(outputIdx);
if (outputClause.isDiscreteDomain() && !outputClause.getDiscreteValues().contains(value)) {
passThruMessages.add(new DMNDTAnalysisMessage(this, Severity.ERROR, MsgUtil.createMessage(Msg.DTANALYSIS_ERROR_RULE_OUTPUT_OUTSIDE_LOV, ruleIdx + 1, value, outputIdx + 1, outputClause.getDiscreteValues()), Msg.DTANALYSIS_ERROR_RULE_OUTPUT_OUTSIDE_LOV.getType()));
}
}
}
}
use of org.kie.dmn.validation.dtanalysis.DMNDTAnalysisMessage in project drools by kiegroup.
the class DTAnalysis method subsumptionsAsMessages.
private Collection<? extends DMNMessage> subsumptionsAsMessages() {
List<DMNDTAnalysisMessage> results = new ArrayList<>();
for (Subsumption s : subsumptions) {
List<Integer> inNaturalOrder = Arrays.asList(s.rule, s.includedRule);
List<Integer> inReversedOrder = Arrays.asList(s.includedRule, s.rule);
boolean subsumptionIsA1NFdup = getDuplicateRulesTuples().stream().anyMatch(tuple -> tuple.equals(inNaturalOrder) || tuple.equals(inReversedOrder));
if (!subsumptionIsA1NFdup) {
results.add(new DMNDTAnalysisMessage(this, Severity.WARN, MsgUtil.createMessage(Msg.DTANALYSIS_SUBSUMPTION_RULE, s.rule, s.includedRule, s.rule, s.includedRule), Msg.DTANALYSIS_SUBSUMPTION_RULE.getType(), Collections.singletonList(s.rule)));
} else {
LOG.debug("skipping Subsumption message because it is actually redundant to the 1st NF duplicate rule ERROR: {}", s);
}
}
return results;
}
use of org.kie.dmn.validation.dtanalysis.DMNDTAnalysisMessage in project drools by kiegroup.
the class DTAnalysis method asDMNMessages.
public List<DMNMessage> asDMNMessages() {
List<DMNMessage> results = new ArrayList<>();
if (isError()) {
DMNMessage m = new DMNDTAnalysisMessage(this, Severity.WARN, MsgUtil.createMessage(Msg.DTANALYSIS_ERROR_ANALYSIS_SKIPPED, nameOrIDOfTable(), error.getMessage()), Msg.DTANALYSIS_ERROR_ANALYSIS_SKIPPED.getType());
results.add(m);
return results;
}
results.addAll(passThruMessages());
results.addAll(gapsAsMessages());
results.addAll(overlapsAsMessages());
results.addAll(maskedAndMisleadingRulesAsMessagesIfPriority());
results.addAll(subsumptionsAsMessages());
results.addAll(contractionsAsMessages());
results.addAll(check1stNFViolationAsMessages());
results.addAll(check2ndNFViolationAsMessages());
// keep last.
if (results.isEmpty()) {
DMNMessage m = new DMNDTAnalysisMessage(this, Severity.INFO, MsgUtil.createMessage(Msg.DTANALYSIS_EMPTY, nameOrIDOfTable()), Msg.DTANALYSIS_EMPTY.getType());
results.add(m);
return results;
}
return results;
}
use of org.kie.dmn.validation.dtanalysis.DMNDTAnalysisMessage in project drools by kiegroup.
the class DTAnalysis method overlapsAsMessages.
private Collection overlapsAsMessages() {
List<DMNDTAnalysisMessage> results = new ArrayList<>();
for (Overlap overlap : overlaps) {
switch(sourceDT.getHitPolicy()) {
case UNIQUE:
results.add(new DMNDTAnalysisMessage(this, Severity.ERROR, MsgUtil.createMessage(Msg.DTANALYSIS_OVERLAP_HITPOLICY_UNIQUE, overlap.asHumanFriendly(ddtaTable)), Msg.DTANALYSIS_OVERLAP_HITPOLICY_UNIQUE.getType(), overlap.getRules()));
break;
case ANY:
List<Comparable<?>> prevValue = ddtaTable.getRule().get(overlap.getRules().get(0) - 1).getOutputEntry();
for (int i = 1; i < overlap.getRules().size(); i++) {
// deliberately start index 1 for 2nd overlapping rule number.
int curIndex = overlap.getRules().get(i) - 1;
List<Comparable<?>> curValue = ddtaTable.getRule().get(curIndex).getOutputEntry();
if (!prevValue.equals(curValue)) {
results.add(new DMNDTAnalysisMessage(this, Severity.ERROR, MsgUtil.createMessage(Msg.DTANALYSIS_OVERLAP_HITPOLICY_ANY, overlap.asHumanFriendly(ddtaTable)), Msg.DTANALYSIS_OVERLAP_HITPOLICY_ANY.getType(), overlap.getRules()));
break;
} else {
prevValue = curValue;
}
}
break;
case PRIORITY:
case FIRST:
default:
LOG.debug("In case of any other HitPolicy no overalps is reported, DROOLS-5363: {}", overlap);
break;
}
}
return results;
}
Aggregations