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

Prettify verifier messages

parent 6065b7df
No related branches found
No related tags found
No related merge requests found
Showing
with 206 additions and 64 deletions
...@@ -7,6 +7,7 @@ import de.unikoblenz.fgbks.base.value.AbstractStringValueObject; ...@@ -7,6 +7,7 @@ import de.unikoblenz.fgbks.base.value.AbstractStringValueObject;
*/ */
public class Name extends AbstractStringValueObject { public class Name extends AbstractStringValueObject {
public static final Name NO_NAME = new Name("[no name]");
/** Create a new copy of the given name object. */ /** Create a new copy of the given name object. */
public Name(Name initialValue) { public Name(Name initialValue) {
this(initialValue.getValue()); this(initialValue.getValue());
......
...@@ -2,6 +2,7 @@ package de.unikoblenz.fgbks.core.dmn.domain.vdmn.impl; ...@@ -2,6 +2,7 @@ package de.unikoblenz.fgbks.core.dmn.domain.vdmn.impl;
import de.unikoblenz.fgbks.core.dmn.domain.ids.AbstractId; import de.unikoblenz.fgbks.core.dmn.domain.ids.AbstractId;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnElement; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnElement;
import java.util.Objects;
/** /**
* Implementation of {@link VDmnElement} * Implementation of {@link VDmnElement}
...@@ -14,4 +15,21 @@ public abstract class AbstractVDmnElement implements VDmnElement { ...@@ -14,4 +15,21 @@ public abstract class AbstractVDmnElement implements VDmnElement {
public AbstractId getId() { public AbstractId getId() {
return id; return id;
} }
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AbstractVDmnElement that = (AbstractVDmnElement) o;
return id.equals(that.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
} }
...@@ -3,6 +3,7 @@ package de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils; ...@@ -3,6 +3,7 @@ package de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils;
import de.unikoblenz.fgbks.base.domain.Name; import de.unikoblenz.fgbks.base.domain.Name;
import de.unikoblenz.fgbks.core.dmn.domain.ids.RuleId; import de.unikoblenz.fgbks.core.dmn.domain.ids.RuleId;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnColumn; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnColumn;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecisionTable; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecisionTable;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDefinition; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDefinition;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnInputColumn; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnInputColumn;
...@@ -12,6 +13,7 @@ import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnRule; ...@@ -12,6 +13,7 @@ import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnRule;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnValue; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnValue;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VTypeRef; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VTypeRef;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
...@@ -228,19 +230,53 @@ public class VDmnFunctions { ...@@ -228,19 +230,53 @@ public class VDmnFunctions {
Validate.notNull(column); Validate.notNull(column);
return column.getLabel().isPresent() return column.getLabel().isPresent()
? column.getLabel().get().toString() ? column.getLabel().get().toString()
: column.getName().orElse(new Name("[no name]")).toString(); : column.getName().orElse(Name.NO_NAME).toString();
} }
/** /**
* Get the name of a column as string. If a label is present, the string of the label is returned. * Get a string with all row numbers of the given list of {@link VDmnRule}. The rows are sorted.
* If the label is not present, the name is returned. If the name is not present, "[no name]" is *
* returned. * @param rules the collection of {@link VDmnRule}
* @return the string of (sorted) rows
*/
public static String getRulesRowsStrings(Collection<VDmnRule> rules) {
return Validate.notNull(rules).stream()
.map(r -> r.getRowNumber().toString())
.sorted()
.collect(Collectors.joining(", "));
}
/**
* Get the String for a decision (for message text)
*
* @param decision the {@link VDmnDecision}
* @return a string "Decision %s: '
*/
public static String templateDecision(VDmnDecision decision) {
return String.format("Decision \"%s\": ", decision.getName().orElse(Name.NO_NAME));
}
/**
* Get the String for a decision and a column (for message text)
* *
* @param column the {@link VDmnColumn} * @param column the {@link VDmnColumn}
* @return a string, representing the "name" of the column + "name" * @return a string "Decision %s, Column %s: '
*/ */
public static String getColumnStringNameWithDoubleQuotes(VDmnColumn column) { public static String templateDecisionColumn(VDmnColumn column) {
Validate.notNull(column); return String.format(
return "\"" + getColumnStringName(column) + "\""; "Decision \"%s\", Column \"%s\": ",
column.getDmnDecision().getName().orElse(Name.NO_NAME), getColumnStringName(column));
}
/**
* Get the String for a decision and a rule (for message text)
*
* @param rule the {@link VDmnRule}
* @return a string "Decision %s, Rule %s: '
*/
public static String templateDecisionRule(VDmnRule rule) {
return String.format(
"Decision \"%s\", Rule \"%s\": ",
rule.getDmnDecision().getName().orElse(Name.NO_NAME), rule.getRowNumber());
} }
} }
...@@ -7,6 +7,7 @@ import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision; ...@@ -7,6 +7,7 @@ import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecisionTable; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecisionTable;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnInputData; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnInputData;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnNode; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnNode;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnRule;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnValue; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnValue;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -113,6 +114,22 @@ public class VerificationResultEntryElement extends AbstractResultObject { ...@@ -113,6 +114,22 @@ public class VerificationResultEntryElement extends AbstractResultObject {
.withIdentifier(vDmnNode.getId()); .withIdentifier(vDmnNode.getId());
} }
/**
* Create a new {@link VerificationResultEntryElement} with the initial identifier from a {@link
* VDmnRule}. Call {@link VerificationResultEntryElement#withIdentifier(AbstractId)} to add
* further identifier.
*
* @param rule the {@link VDmnRule}
* @return the new {@link VerificationResultEntryElement}
*/
public static VerificationResultEntryElement create(VDmnRule rule) {
return new VerificationResultEntryElement()
.withIdentifier(rule.getDmnDefinition().getDefinitionId())
.withIdentifier(rule.getDmnDecision().getDecisionId())
.withIdentifier(rule.getDmnDecisionTable().getDecisionTableId())
.withIdentifier(rule.getId());
}
/** /**
* Get all required ids ({@link AbstractId}) of the {@link VerificationResultEntryElement}. * Get all required ids ({@link AbstractId}) of the {@link VerificationResultEntryElement}.
* *
......
...@@ -2,6 +2,7 @@ package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl; ...@@ -2,6 +2,7 @@ package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl;
import static de.unikoblenz.fgbks.base.utils.boundary.impl.DateBoundary.dateGroupName; import static de.unikoblenz.fgbks.base.utils.boundary.impl.DateBoundary.dateGroupName;
import static de.unikoblenz.fgbks.base.utils.boundary.impl.DateBoundary.datePattern; import static de.unikoblenz.fgbks.base.utils.boundary.impl.DateBoundary.datePattern;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.templateDecisionRule;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_INPUT_ENTRIES; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_INPUT_ENTRIES;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_OUTPUT_ENTRIES; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_OUTPUT_ENTRIES;
...@@ -62,7 +63,8 @@ public class DateVerifier extends AbstractVerifier { ...@@ -62,7 +63,8 @@ public class DateVerifier extends AbstractVerifier {
vreFactory.addElement(VerificationResultEntryElement.create(dateValue)); vreFactory.addElement(VerificationResultEntryElement.create(dateValue));
vreFactory.addToEntry( vreFactory.addToEntry(
VerificationClassification.FATAL_ERROR, VerificationClassification.FATAL_ERROR,
"Date value '%s' does not match 'date and time(\"yyyy-mm-ddTHH:MM:SS\").'", templateDecisionRule(dateValue.getDmnRule())
+ "Date value '%s' does not match 'date and time(\"yyyy-mm-ddTHH:MM:SS\").'",
dateStringValue); dateStringValue);
} else { } else {
// 2. check correct date // 2. check correct date
...@@ -74,7 +76,10 @@ public class DateVerifier extends AbstractVerifier { ...@@ -74,7 +76,10 @@ public class DateVerifier extends AbstractVerifier {
vreFactory.addVerificationFix( vreFactory.addVerificationFix(
dateValue.isInputValue() ? SHOW_INPUT_ENTRIES : SHOW_OUTPUT_ENTRIES); dateValue.isInputValue() ? SHOW_INPUT_ENTRIES : SHOW_OUTPUT_ENTRIES);
vreFactory.addToEntry( vreFactory.addToEntry(
VerificationClassification.FATAL_ERROR, "Date value '%s' is no valid date.", dateTime); VerificationClassification.FATAL_ERROR,
templateDecisionRule(dateValue.getDmnRule())
+ "Date value '%s' has no valid date format.",
dateTime);
} }
} }
} }
......
package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl; package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.templateDecisionRule;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_OUTPUT_ENTRIES; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_OUTPUT_ENTRIES;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnOutputColumn; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnOutputColumn;
...@@ -32,7 +33,9 @@ public class EmptyOutputVerifier extends AbstractVerifier { ...@@ -32,7 +33,9 @@ public class EmptyOutputVerifier extends AbstractVerifier {
if (outputValue.getText().getValue().isEmpty()) { if (outputValue.getText().getValue().isEmpty()) {
vreFactory.addElement(VerificationResultEntryElement.create(outputValue)); vreFactory.addElement(VerificationResultEntryElement.create(outputValue));
vreFactory.addVerificationFix(SHOW_OUTPUT_ENTRIES); vreFactory.addVerificationFix(SHOW_OUTPUT_ENTRIES);
vreFactory.addToEntry(VerificationClassification.WARNING, "Output value is empty.'"); vreFactory.addToEntry(
VerificationClassification.WARNING,
templateDecisionRule(outputValue.getDmnRule()) + "Output value is empty.'");
} }
} }
} }
package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl; package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.templateDecisionColumn;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_INPUT_ENTRIES; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_INPUT_ENTRIES;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_OUTPUT_ENTRIES; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_OUTPUT_ENTRIES;
...@@ -74,9 +75,12 @@ public class EquivalentVerifier extends AbstractVerifier { ...@@ -74,9 +75,12 @@ public class EquivalentVerifier extends AbstractVerifier {
v1.isInputValue() ? SHOW_INPUT_ENTRIES : SHOW_OUTPUT_ENTRIES); v1.isInputValue() ? SHOW_INPUT_ENTRIES : SHOW_OUTPUT_ENTRIES);
vreFactory.addToEntry( vreFactory.addToEntry(
VerificationClassification.WARNING, VerificationClassification.WARNING,
"String values %s and %s might be equivalent.", templateDecisionColumn(v1.getDmnColumn())
+ "String values \"%s\" (Row %s) and \"%s\" (Row %s) might be equivalent.",
stringVals.get(i), stringVals.get(i),
stringValsInner.get(u)); v1.getDmnRule().getRowNumber().toString(),
stringValsInner.get(u),
v2.getDmnRule().getRowNumber().toString());
} }
} }
} }
......
package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl; package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl;
import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.IS_EQUAL; import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.IS_EQUAL;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.getRulesRowsStrings;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.templateDecision;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_RULES; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_RULES;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision;
...@@ -44,10 +46,13 @@ public class IdenticalVerifier extends AbstractVerifier { ...@@ -44,10 +46,13 @@ public class IdenticalVerifier extends AbstractVerifier {
currentRules.forEach( currentRules.forEach(
rule -> rule ->
vreFactory.addElement( vreFactory.addElement(
VerificationResultEntryElement.create(dmnDecisionTable) VerificationResultEntryElement.create(rule)));
.withIdentifier(rule.getRuleId())));
vreFactory.addVerificationFix(SHOW_RULES); vreFactory.addVerificationFix(SHOW_RULES);
vreFactory.addToEntry(VerificationClassification.WARNING, "identical"); vreFactory.addToEntry(
VerificationClassification.WARNING,
templateDecision(dmnDecisionTable.getDmnDecision())
+ "Rules %s have identical input.",
getRulesRowsStrings(currentRules));
} else { } else {
List<VDmnInputValue> curInVals = new ArrayList<>(); List<VDmnInputValue> curInVals = new ArrayList<>();
List<VDmnInputValue> sortInVals = List<VDmnInputValue> sortInVals =
......
package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl; package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.templateDecisionRule;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_INPUT_ENTRIES; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_INPUT_ENTRIES;
import de.unikoblenz.fgbks.base.utils.boundary.impl.InvalidBoundary; import de.unikoblenz.fgbks.base.utils.boundary.impl.InvalidBoundary;
...@@ -33,7 +34,9 @@ public class InputValueSyntaxVerifier extends AbstractVerifier { ...@@ -33,7 +34,9 @@ public class InputValueSyntaxVerifier extends AbstractVerifier {
.addVerificationFix(SHOW_INPUT_ENTRIES) .addVerificationFix(SHOW_INPUT_ENTRIES)
.addToEntry( .addToEntry(
VerificationClassification.FATAL_ERROR, VerificationClassification.FATAL_ERROR,
"Input value is not valid: " + inputValue.getText()); templateDecisionRule(inputValue.getDmnRule())
+ "Input value is not valid: "
+ inputValue.getText());
System.out.println(inputValue.getText() + " IS INVALID SYNTAX"); System.out.println(inputValue.getText() + " IS INVALID SYNTAX");
} }
} }
......
...@@ -22,8 +22,6 @@ import java.util.stream.Collectors; ...@@ -22,8 +22,6 @@ import java.util.stream.Collectors;
@DmnVerifier(verifierType = MissingInputColumnVerification.class) @DmnVerifier(verifierType = MissingInputColumnVerification.class)
public class MissingInputColumnVerifier extends AbstractVerifier { public class MissingInputColumnVerifier extends AbstractVerifier {
private Name defaultName = new Name("[no name]");
@Override @Override
protected void doVerification() { protected void doVerification() {
// 1. check for input data nodes // 1. check for input data nodes
...@@ -70,9 +68,12 @@ public class MissingInputColumnVerifier extends AbstractVerifier { ...@@ -70,9 +68,12 @@ public class MissingInputColumnVerifier extends AbstractVerifier {
.build()) .build())
.addToEntry( .addToEntry(
VerificationClassification.WARNING, VerificationClassification.WARNING,
"Node \"%s\" has no corresponding input column in decision \"%s\"", inputDataNode.isInputData()
inputDataNode.getName().orElse(defaultName), ? "Input data"
decision.getName().orElse(defaultName)); : "Decision"
+ " node \"%s\" has no corresponding input column in decision \"%s\"",
inputDataNode.getName().orElse(Name.NO_NAME),
decision.getName().orElse(Name.NO_NAME));
} }
} }
} }
package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl; package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.getColumnStringName;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.templateDecision;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_INPUT_COLUMNS; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_INPUT_COLUMNS;
import de.unikoblenz.fgbks.base.domain.Name; import de.unikoblenz.fgbks.base.domain.Name;
...@@ -54,18 +56,13 @@ public class MissingInputDataVerifier extends AbstractVerifier { ...@@ -54,18 +56,13 @@ public class MissingInputDataVerifier extends AbstractVerifier {
} }
} }
// no input data found yet -> add column to results // no input data found yet -> add column to results
String label = "";
if (inputColumn.getLabel().isPresent()) {
label = inputColumn.getLabel().get().getValue();
} else if (inputColumn.getName().isPresent()) {
label = inputColumn.getName().get().getValue();
} else {
label = "no name";
}
vreFactory vreFactory
.addElement(VerificationResultEntryElement.create(inputColumn)) .addElement(VerificationResultEntryElement.create(inputColumn))
.addVerificationFix(SHOW_INPUT_COLUMNS) .addVerificationFix(SHOW_INPUT_COLUMNS)
.addToEntry( .addToEntry(
VerificationClassification.WARNING, "Input column \"%s\" has no input data.", label); VerificationClassification.WARNING,
templateDecision(inputColumn.getDmnDecision())
+ "Input column \"%s\" has no input data node.",
getColumnStringName(inputColumn));
} }
} }
package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl; package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.templateDecision;
import de.unikoblenz.fgbks.base.utils.boundary.Boundary; import de.unikoblenz.fgbks.base.utils.boundary.Boundary;
import de.unikoblenz.fgbks.base.utils.boundary.bicreater.BoundaryBiCreaterType; import de.unikoblenz.fgbks.base.utils.boundary.bicreater.BoundaryBiCreaterType;
import de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType; import de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType;
...@@ -45,14 +47,14 @@ public class MissingRuleVerifier extends AbstractVerifier { ...@@ -45,14 +47,14 @@ public class MissingRuleVerifier extends AbstractVerifier {
checkForMissingRules(inputs, dmnDecisionTable.getRules()); checkForMissingRules(inputs, dmnDecisionTable.getRules());
// add errors for missing intervals // add errors for missing intervals
for (VDmnRule missingRule : missingRules) { for (VDmnRule missingRule : missingRules) {
StringBuilder sb = new StringBuilder("In table "); StringBuilder sb = new StringBuilder();
sb.append(dmnDecisionTable.getDecisionTableId()); // TODO: add real name sb.append(templateDecision(dmnDecisionTable.getDmnDecision()));
sb.append(", the following rule is not defined: ("); sb.append("The following rule is not defined: {");
sb.append( sb.append(
missingRule.getDmnInputValues().stream() missingRule.getDmnInputValues().stream()
.map(v -> v.getBoundary().getParsedText()) .map(v -> v.getBoundary().getParsedText())
.collect(Collectors.joining("), ("))); .collect(Collectors.joining("), (")));
sb.append(")"); sb.append("}");
vreFactory.addElement(VerificationResultEntryElement.create(dmnDecisionTable)); vreFactory.addElement(VerificationResultEntryElement.create(dmnDecisionTable));
vreFactory.addToEntry(VerificationClassification.WARNING, sb.toString()); vreFactory.addToEntry(VerificationClassification.WARNING, sb.toString());
......
...@@ -3,6 +3,7 @@ package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl; ...@@ -3,6 +3,7 @@ package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl;
import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.IS_NOT_IN_CONTACT; import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.IS_NOT_IN_CONTACT;
import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.IS_OVERLAPPING; import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.IS_OVERLAPPING;
import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.SUBSUMES; import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.SUBSUMES;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.getRulesRowsStrings;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_RULES; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_RULES;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision;
...@@ -45,7 +46,7 @@ public class OverlappingVerifier extends AbstractVerifier { ...@@ -45,7 +46,7 @@ public class OverlappingVerifier extends AbstractVerifier {
private void checkOverlapping( private void checkOverlapping(
List<VDmnInputColumn> inColumns, List<VDmnInputColumn> inColumns,
int i, int i,
List<VDmnRule> currentRuleIds, List<VDmnRule> currentRules,
boolean hasOverlap, boolean hasOverlap,
List<VDmnRule> subsumptionRules) { List<VDmnRule> subsumptionRules) {
// no more columns to check // no more columns to check
...@@ -53,19 +54,20 @@ public class OverlappingVerifier extends AbstractVerifier { ...@@ -53,19 +54,20 @@ public class OverlappingVerifier extends AbstractVerifier {
// do nothing, if there was no real overlap found prev.. // do nothing, if there was no real overlap found prev..
if (hasOverlap) { if (hasOverlap) {
// add to rules to result // add to rules to result
currentRuleIds.forEach( currentRules.forEach(
rule -> rule -> vreFactory.addElement(VerificationResultEntryElement.create(rule)));
vreFactory.addElement(
VerificationResultEntryElement.create(inColumns.get(0).getDmnDecisionTable())
.withIdentifier(rule.getRuleId())));
vreFactory.addVerificationFix(SHOW_RULES); vreFactory.addVerificationFix(SHOW_RULES);
vreFactory.addToEntry(VerificationClassification.WARNING, "overlapping"); vreFactory.addToEntry(
VerificationClassification.WARNING,
VDmnFunctions.templateDecision(inColumns.get(0).getDmnDecision())
+ "The rules %s are overlapping.",
getRulesRowsStrings(currentRules));
} }
} else { } else {
// check current column // check current column
List<VDmnInputValue> currentBounds = new ArrayList<>(); List<VDmnInputValue> currentBounds = new ArrayList<>();
List<VDmnInputValue> sortedBounds = List<VDmnInputValue> sortedBounds =
VDmnFunctions.getColumnValuesInRules(inColumns.get(i), currentRuleIds); VDmnFunctions.getColumnValuesInRules(inColumns.get(i), currentRules);
sortedBounds.sort(Comparator.comparing(VDmnInputValue::getBoundary)); sortedBounds.sort(Comparator.comparing(VDmnInputValue::getBoundary));
int z = 0; int z = 0;
boolean foundPOverlap = false; boolean foundPOverlap = false;
......
...@@ -2,6 +2,8 @@ package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl; ...@@ -2,6 +2,8 @@ package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl;
import static de.unikoblenz.fgbks.base.utils.boundary.bicreater.BoundaryBiCreaterType.COMBINE; import static de.unikoblenz.fgbks.base.utils.boundary.bicreater.BoundaryBiCreaterType.COMBINE;
import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.IS_EQUAL; import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.IS_EQUAL;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.getRulesRowsStrings;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.templateDecision;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_RULES; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_RULES;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision;
...@@ -40,12 +42,12 @@ public class PartialReductionVerifier extends AbstractVerifier { ...@@ -40,12 +42,12 @@ public class PartialReductionVerifier extends AbstractVerifier {
if (i == inColumns.size()) { if (i == inColumns.size()) {
if (hasCombination) { if (hasCombination) {
clusterRules.forEach( clusterRules.forEach(
rule -> rule -> vreFactory.addElement(VerificationResultEntryElement.create(rule)));
vreFactory.addElement(
VerificationResultEntryElement.create(inColumns.get(0).getDmnDecisionTable())
.withIdentifier(rule.getRuleId())));
vreFactory.addVerificationFix(SHOW_RULES); vreFactory.addVerificationFix(SHOW_RULES);
vreFactory.addToEntry(VerificationClassification.INFO, "PartialReduction"); vreFactory.addToEntry(
VerificationClassification.INFO,
templateDecision(inColumns.get(0).getDmnDecision()) + "Rules %s can be combined.",
getRulesRowsStrings(clusterRules));
} }
} else { } else {
List<VDmnInputValue> rules = List<VDmnInputValue> rules =
......
package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl; package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.getColumnStringNameWithDoubleQuotes; import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.templateDecisionColumn;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_INPUT_ENTRIES; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_INPUT_ENTRIES;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_OUTPUT_ENTRIES; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_OUTPUT_ENTRIES;
...@@ -81,8 +81,8 @@ public class PredefinedExistingValueVerifier extends AbstractVerifier { ...@@ -81,8 +81,8 @@ public class PredefinedExistingValueVerifier extends AbstractVerifier {
stringValue.isInputValue() ? SHOW_INPUT_ENTRIES : SHOW_OUTPUT_ENTRIES); stringValue.isInputValue() ? SHOW_INPUT_ENTRIES : SHOW_OUTPUT_ENTRIES);
vreFactory.addToEntry( vreFactory.addToEntry(
VerificationClassification.WARNING, VerificationClassification.WARNING,
"String value \"%s\" was not found in the list of predefined values of column %s.", templateDecisionColumn(stringValue.getDmnColumn())
missingStringValue, + "String value \"%s\" was not found in the list of predefined values.",
getColumnStringNameWithDoubleQuotes(stringValue.getDmnColumn())); missingStringValue);
} }
} }
package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl; package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.getColumnStringNameWithDoubleQuotes;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_INPUT_COLUMNS; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_INPUT_COLUMNS;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_OUTPUT_COLUMNS; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_OUTPUT_COLUMNS;
...@@ -87,9 +86,7 @@ public class PredefinedMissingValueVerifier extends AbstractVerifier { ...@@ -87,9 +86,7 @@ public class PredefinedMissingValueVerifier extends AbstractVerifier {
vreFactory.addVerificationFix( vreFactory.addVerificationFix(
stringColumn.isInputColumn() ? SHOW_INPUT_COLUMNS : SHOW_OUTPUT_COLUMNS); stringColumn.isInputColumn() ? SHOW_INPUT_COLUMNS : SHOW_OUTPUT_COLUMNS);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("In column "); sb.append(VDmnFunctions.templateDecisionColumn(stringColumn));
sb.append(getColumnStringNameWithDoubleQuotes(stringColumn));
sb.append(". ");
sb.append(missingStringValues.size() > 1 ? "These string values are" : "This string value is"); sb.append(missingStringValues.size() > 1 ? "These string values are" : "This string value is");
sb.append(" not used: "); sb.append(" not used: ");
sb.append( sb.append(
......
...@@ -2,6 +2,8 @@ package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl; ...@@ -2,6 +2,8 @@ package de.unikoblenz.fgbks.core.dmn.verification.verifier.impl;
import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.IS_EQUAL; import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.IS_EQUAL;
import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.SUBSUMES; import static de.unikoblenz.fgbks.base.utils.boundary.checker.BoundaryCheckType.SUBSUMES;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.getRulesRowsStrings;
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.templateDecision;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_RULES; import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_RULES;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision;
...@@ -43,25 +45,29 @@ public class SubsumptionVerifier extends AbstractVerifier { ...@@ -43,25 +45,29 @@ public class SubsumptionVerifier extends AbstractVerifier {
private void checkSubsumptions( private void checkSubsumptions(
List<VDmnInputColumn> inColumns, List<VDmnInputColumn> inColumns,
int i, int i,
List<VDmnRule> currentRuleIds, List<VDmnRule> currentRules,
boolean hasSubsumption, boolean hasSubsumption,
List<VDmnRule> currentRootSubsumptionElements) { List<VDmnRule> currentRootSubsumptionElements) {
if (i == inColumns.size()) { if (i == inColumns.size()) {
if (hasSubsumption && currentRuleIds.size() > currentRootSubsumptionElements.size()) { if (hasSubsumption && currentRules.size() > currentRootSubsumptionElements.size()) {
// add to rules to result // add to rules to result
// TODO boolean differentConclusions = VDmnFunctions.differentConclusions(currentRules);
currentRuleIds.forEach( currentRules.forEach(
rule -> rule ->
vreFactory.addElement( vreFactory.addElement(
VerificationResultEntryElement.create(inColumns.get(0).getDmnDecisionTable()) VerificationResultEntryElement.create(inColumns.get(0).getDmnDecisionTable())
.withIdentifier(rule.getRuleId()))); .withIdentifier(rule.getRuleId())));
vreFactory.addVerificationFix(SHOW_RULES); vreFactory.addVerificationFix(SHOW_RULES);
vreFactory.addToEntry(VerificationClassification.WARNING, "subsumption"); vreFactory.addToEntry(
VerificationClassification.WARNING,
templateDecision(inColumns.get(0).getDmnDecision())
+ getMessageText(
currentRules, currentRootSubsumptionElements, differentConclusions));
} }
} else { } else {
// get all input values from the current column, and filter with the prev. iteration // get all input values from the current column, and filter with the prev. iteration
List<VDmnInputValue> selectedBounds = List<VDmnInputValue> selectedBounds =
VDmnFunctions.getColumnValuesInRules(inColumns.get(i), currentRuleIds); VDmnFunctions.getColumnValuesInRules(inColumns.get(i), currentRules);
List<List<VDmnInputValue>> clusters = new ArrayList<>(); // clusters of subsumptions List<List<VDmnInputValue>> clusters = new ArrayList<>(); // clusters of subsumptions
List<Boolean> subsumptions = List<Boolean> subsumptions =
...@@ -69,7 +75,7 @@ public class SubsumptionVerifier extends AbstractVerifier { ...@@ -69,7 +75,7 @@ public class SubsumptionVerifier extends AbstractVerifier {
List<List<VDmnInputValue>> subsumptionValue = List<List<VDmnInputValue>> subsumptionValue =
new ArrayList<>(); // save the subsumption value of the current cluster new ArrayList<>(); // save the subsumption value of the current cluster
// if previously a rule was found, which has a subsumption, than it must be also the element, // if previously a rule was found, which has a subsumption, than it must be also the element,
// which subsume the other elements. // which subsumes the other elements.
// First, build clusters, which contain a subsumption set // First, build clusters, which contain a subsumption set
if (!currentRootSubsumptionElements.isEmpty()) { if (!currentRootSubsumptionElements.isEmpty()) {
// get the value from the subsumption rule // get the value from the subsumption rule
...@@ -85,7 +91,7 @@ public class SubsumptionVerifier extends AbstractVerifier { ...@@ -85,7 +91,7 @@ public class SubsumptionVerifier extends AbstractVerifier {
c1.add(cb2); c1.add(cb2);
} else if (nValue.getBoundary().checkWith(IS_EQUAL, cb2.getBoundary())) { } else if (nValue.getBoundary().checkWith(IS_EQUAL, cb2.getBoundary())) {
c1.add(cb2); c1.add(cb2);
if (currentRootSubsumptionElements.contains(cb2)) { if (currentRootSubsumptionElements.contains(cb2.getDmnRule())) {
subsumptionVals.add(cb2); subsumptionVals.add(cb2);
} }
} }
...@@ -166,4 +172,47 @@ public class SubsumptionVerifier extends AbstractVerifier { ...@@ -166,4 +172,47 @@ public class SubsumptionVerifier extends AbstractVerifier {
} }
} }
} }
private String getMessageText(
List<VDmnRule> currentRules,
List<VDmnRule> currentRootSubsumptionElements,
boolean differentConclusions) {
StringBuilder sb = new StringBuilder();
sb.append(templateDecision(currentRules.get(0).getDmnDecision()));
sb.append("Rule");
if (currentRootSubsumptionElements.size() > 1) {
sb.append("s");
}
sb.append(" ");
sb.append(getRulesRowsStrings(currentRootSubsumptionElements));
if (currentRootSubsumptionElements.size() > 1) {
sb.append("subsume"); // Plural
} else {
sb.append(" subsumes");
}
// subsumed rules:
List<VDmnRule> subsumedRules =
currentRules.stream()
.filter(
r ->
!currentRootSubsumptionElements.stream()
.map(VDmnRule::getRuleId)
.collect(Collectors.toList())
.contains(r.getRuleId()))
.collect(Collectors.toList());
sb.append(" rule");
if (subsumedRules.size() > 1) {
sb.append("s");
}
sb.append(" ");
sb.append(getRulesRowsStrings(subsumedRules));
sb.append(".");
if (differentConclusions) {
sb.append(" The outputs have different conclusions!");
} else {
sb.append(" The output is the same.");
}
return sb.toString();
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment