Skip to content
Snippets Groups Projects
Commit 310ec04b authored by Jonas Blatt's avatar Jonas Blatt :ant:
Browse files

Merge branch 'fix/noInputColumns' into 'develop'

Fix errors in verifier, when there are no input columns

See merge request jonasblatt/ma-jonasblatt-dmn-verifier!73
parents 0f4ff52a 38ef5fef
No related branches found
No related tags found
No related merge requests found
......@@ -33,8 +33,10 @@ public class IdenticalRuleVerifier extends AbstractVerifier {
}
private void checkDecisionTable(VDmnDecisionTable dmnDecisionTable) {
checkForIdenticalRules(
dmnDecisionTable, dmnDecisionTable.getInputColumns(), 0, dmnDecisionTable.getRules());
if (dmnDecisionTable.getInputColumns().size() > 0) {
checkForIdenticalRules(
dmnDecisionTable, dmnDecisionTable.getInputColumns(), 0, dmnDecisionTable.getRules());
}
}
protected void checkForIdenticalRules(
......@@ -44,14 +46,11 @@ public class IdenticalRuleVerifier extends AbstractVerifier {
List<VDmnRule> currentRules) {
if (i == inputs.size()) {
currentRules.forEach(
rule ->
vreFactory.addElement(
VerificationResultEntryElement.create(rule)));
rule -> vreFactory.addElement(VerificationResultEntryElement.create(rule)));
vreFactory.addVerificationFix(SHOW_RULES);
vreFactory.addToEntry(
VerificationClassification.WARNING,
templateDecision(dmnDecisionTable.getDmnDecision())
+ "Rules %s have identical inputs.",
templateDecision(dmnDecisionTable.getDmnDecision()) + "Rules %s have identical inputs.",
getRulesRowsStrings(currentRules));
} else {
List<VDmnInputValue> curInVals = new ArrayList<>();
......
......@@ -50,34 +50,36 @@ public class MissingRuleVerifier extends AbstractVerifier {
private void findMissingRules(VDmnDecisionTable dmnDecisionTable) {
List<VDmnInputColumn> inputs = dmnDecisionTable.getInputColumns();
List<VDmnRuleChangeableImpl> missingRules =
checkForMissingRules(inputs, dmnDecisionTable.getRules());
// add errors for missing intervals
for (VDmnRule missingRule : missingRules) {
StringBuilder sb = new StringBuilder();
sb.append(templateDecision(dmnDecisionTable.getDmnDecision()));
sb.append("The following rule is not defined: { ");
sb.append(
missingRule.getDmnInputValues().stream()
.map(v -> v.getBoundary().getParsedText())
.map(s -> s.isEmpty() ? "-" : s)
.collect(Collectors.joining(" / ")));
sb.append(" }");
Action.Builder fixActionBuilder =
Action.getBuilder().withActionScope(ActionScope.RULE).withActionType(ActionType.CREATE);
for (VDmnInputValue v : missingRule.getDmnInputValues()) {
fixActionBuilder.addValue(
v.getDmnInputColumn().getInputId().getValue(), v.getBoundary().getParsedText());
if (inputs.size() > 0) {
List<VDmnRuleChangeableImpl> missingRules =
checkForMissingRules(inputs, dmnDecisionTable.getRules());
// add errors for missing intervals
for (VDmnRule missingRule : missingRules) {
StringBuilder sb = new StringBuilder();
sb.append(templateDecision(dmnDecisionTable.getDmnDecision()));
sb.append("The following rule is not defined: { ");
sb.append(
missingRule.getDmnInputValues().stream()
.map(v -> v.getBoundary().getParsedText())
.map(s -> s.isEmpty() ? "-" : s)
.collect(Collectors.joining(" / ")));
sb.append(" }");
Action.Builder fixActionBuilder =
Action.getBuilder().withActionScope(ActionScope.RULE).withActionType(ActionType.CREATE);
for (VDmnInputValue v : missingRule.getDmnInputValues()) {
fixActionBuilder.addValue(
v.getDmnInputColumn().getInputId().getValue(), v.getBoundary().getParsedText());
}
vreFactory
.addVerificationFix(VerificationFix.SHOW_DECISION)
.addVerificationFix(
VerificationFix.getBuilder()
.withFixName(FIX_NAME)
.addAction(fixActionBuilder.build())
.build())
.addElement(VerificationResultEntryElement.create(dmnDecisionTable))
.addToEntry(VerificationClassification.WARNING, sb.toString());
}
vreFactory
.addVerificationFix(VerificationFix.SHOW_DECISION)
.addVerificationFix(
VerificationFix.getBuilder()
.withFixName(FIX_NAME)
.addAction(fixActionBuilder.build())
.build())
.addElement(VerificationResultEntryElement.create(dmnDecisionTable))
.addToEntry(VerificationClassification.WARNING, sb.toString());
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment