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

Add default show verifications fixes to existing verifier

parent 2dce147a
No related branches found
No related tags found
No related merge requests found
Showing
with 35 additions and 6 deletions
...@@ -83,7 +83,7 @@ public class VerificationResultEntry extends AbstractResultObject { ...@@ -83,7 +83,7 @@ public class VerificationResultEntry extends AbstractResultObject {
return this; return this;
} }
public Builder addAction(VerificationFix verificationFix) { public Builder addVerificationFix(VerificationFix verificationFix) {
value.verificationFixes.add(Validate.notNull(verificationFix)); value.verificationFixes.add(Validate.notNull(verificationFix));
return this; return this;
} }
......
...@@ -3,6 +3,7 @@ package de.unikoblenz.fgbks.core.dmn.verification.result; ...@@ -3,6 +3,7 @@ package de.unikoblenz.fgbks.core.dmn.verification.result;
import de.unikoblenz.fgbks.base.domain.Message; import de.unikoblenz.fgbks.base.domain.Message;
import de.unikoblenz.fgbks.core.dmn.verification.result.VerificationResultEntry.VerificationClassification; import de.unikoblenz.fgbks.core.dmn.verification.result.VerificationResultEntry.VerificationClassification;
import de.unikoblenz.fgbks.core.dmn.verification.result.VerifierResult.Builder; import de.unikoblenz.fgbks.core.dmn.verification.result.VerifierResult.Builder;
import de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
public class VerificationResultEntryFactory { public class VerificationResultEntryFactory {
...@@ -26,6 +27,11 @@ public class VerificationResultEntryFactory { ...@@ -26,6 +27,11 @@ public class VerificationResultEntryFactory {
return verificationResultEntryBuilder; return verificationResultEntryBuilder;
} }
public VerificationResultEntryFactory addVerificationFix(VerificationFix verificationFix) {
getCurrentOrCreate().addVerificationFix(verificationFix);
return this;
}
public VerificationResultEntryFactory addElement( public VerificationResultEntryFactory addElement(
VerificationResultEntryElement verificationResultEntryElement) { VerificationResultEntryElement verificationResultEntryElement) {
getCurrentOrCreate().addVerificationResultEntryElement(verificationResultEntryElement); getCurrentOrCreate().addVerificationResultEntryElement(verificationResultEntryElement);
......
...@@ -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.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.verification.result.actions.VerificationFix.SHOW_INPUT_ENTRIES;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_OUTPUT_ENTRIES;
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.VDmnValue; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnValue;
...@@ -69,6 +71,8 @@ public class DateVerifier extends AbstractVerifier { ...@@ -69,6 +71,8 @@ public class DateVerifier extends AbstractVerifier {
LocalDateTime.parse(dateTime); LocalDateTime.parse(dateTime);
} catch (DateTimeParseException e) { } catch (DateTimeParseException e) {
vreFactory.addElement(VerificationResultEntryElement.create(dateValue)); vreFactory.addElement(VerificationResultEntryElement.create(dateValue));
vreFactory.addVerificationFix(
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, "Date value '%s' is no valid date.", 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.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;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnOutputValue; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnOutputValue;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions;
...@@ -32,6 +34,7 @@ public class EmptyOutputVerifier extends AbstractVerifier { ...@@ -32,6 +34,7 @@ public class EmptyOutputVerifier extends AbstractVerifier {
private void checkEmptyOutputValue(VDmnOutputValue outputValue) { private void checkEmptyOutputValue(VDmnOutputValue outputValue) {
if (outputValue.getText().isEmpty()) { if (outputValue.getText().isEmpty()) {
vreFactory.addElement(VerificationResultEntryElement.create(outputValue)); vreFactory.addElement(VerificationResultEntryElement.create(outputValue));
vreFactory.addVerificationFix(SHOW_OUTPUT_ENTRIES);
vreFactory.addToEntry(VerificationClassification.WARNING, "Output value is empty.'"); vreFactory.addToEntry(VerificationClassification.WARNING, "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.verification.result.actions.VerificationFix.SHOW_INPUT_ENTRIES;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_OUTPUT_ENTRIES;
import de.unikoblenz.fgbks.base.utils.boundary.impl.StringBoundary; import de.unikoblenz.fgbks.base.utils.boundary.impl.StringBoundary;
import de.unikoblenz.fgbks.base.wordnet.WordnetService; import de.unikoblenz.fgbks.base.wordnet.WordnetService;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnColumn; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnColumn;
...@@ -70,6 +73,8 @@ public class EquivalentVerifier extends AbstractVerifier { ...@@ -70,6 +73,8 @@ public class EquivalentVerifier extends AbstractVerifier {
if (wordnetService.areNounsSynonyms(stringVals.get(i), stringValsInner.get(u))) { if (wordnetService.areNounsSynonyms(stringVals.get(i), stringValsInner.get(u))) {
vreFactory.addElement(VerificationResultEntryElement.create(v1)); vreFactory.addElement(VerificationResultEntryElement.create(v1));
vreFactory.addElement(VerificationResultEntryElement.create(v2)); vreFactory.addElement(VerificationResultEntryElement.create(v2));
vreFactory.addVerificationFix(
v1.isInputValue() ? SHOW_INPUT_ENTRIES : SHOW_OUTPUT_ENTRIES);
vreFactory.addToEntry( vreFactory.addToEntry(
VerificationClassification.WARNING, VerificationClassification.WARNING,
"String values %s and %s might be equivalent.", "String values %s and %s might be equivalent.",
......
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.verification.result.actions.VerificationFix.SHOW_RULES;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision; 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;
...@@ -48,6 +49,7 @@ public class IdenticalVerifier extends AbstractVerifier { ...@@ -48,6 +49,7 @@ public class IdenticalVerifier extends AbstractVerifier {
vreFactory.addElement( vreFactory.addElement(
VerificationResultEntryElement.create(dmnDecisionTable) VerificationResultEntryElement.create(dmnDecisionTable)
.withIdentifier(rule.getRuleId()))); .withIdentifier(rule.getRuleId())));
vreFactory.addVerificationFix(SHOW_RULES);
vreFactory.addToEntry(VerificationClassification.WARNING, "identical"); vreFactory.addToEntry(VerificationClassification.WARNING, "identical");
} else { } else {
List<VDmnInputValue> curInVals = new ArrayList<>(); List<VDmnInputValue> curInVals = new ArrayList<>();
......
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.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;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnInputValue; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnInputValue;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VTypeRef; import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VTypeRef;
...@@ -29,10 +31,12 @@ public class InputValueSyntaxVerifier extends AbstractVerifier { ...@@ -29,10 +31,12 @@ public class InputValueSyntaxVerifier extends AbstractVerifier {
// no Date, because of extra DateVerifier // no Date, because of extra DateVerifier
if (inputValue.getDmnColumn().getTypeRef() != VTypeRef.DATE if (inputValue.getDmnColumn().getTypeRef() != VTypeRef.DATE
&& inputValue.getBoundary() instanceof InvalidBoundary) { && inputValue.getBoundary() instanceof InvalidBoundary) {
vreFactory.addElement(VerificationResultEntryElement.create(inputValue)); vreFactory
vreFactory.addToEntry( .addElement(VerificationResultEntryElement.create(inputValue))
VerificationClassification.FATAL_ERROR, .addVerificationFix(SHOW_INPUT_ENTRIES)
"Input value is not valid: " + inputValue.getText()); .addToEntry(
VerificationClassification.FATAL_ERROR,
"Input value is not valid: " + inputValue.getText());
System.out.println(inputValue.getText() + " IS INVALID SYNTAX"); System.out.println(inputValue.getText() + " IS INVALID SYNTAX");
} }
} }
......
...@@ -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.verification.result.actions.VerificationFix.SHOW_RULES;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision; 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;
...@@ -55,12 +56,12 @@ public class OverlappingVerifier extends AbstractVerifier { ...@@ -55,12 +56,12 @@ 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
// TODO
currentRuleIds.forEach( currentRuleIds.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.addToEntry(VerificationClassification.WARNING, "overlapping"); vreFactory.addToEntry(VerificationClassification.WARNING, "overlapping");
} }
} else { } else {
......
...@@ -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.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.verification.result.actions.VerificationFix.SHOW_RULES;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision; 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;
...@@ -47,6 +48,7 @@ public class PartialReductionVerifier extends AbstractVerifier { ...@@ -47,6 +48,7 @@ public class PartialReductionVerifier extends AbstractVerifier {
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.addToEntry(VerificationClassification.WARNING, "PartialReduction"); vreFactory.addToEntry(VerificationClassification.WARNING, "PartialReduction");
} }
} else { } else {
......
...@@ -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.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.verification.result.actions.VerificationFix.SHOW_RULES;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision; 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;
...@@ -57,6 +58,7 @@ public class SubsumptionVerifier extends AbstractVerifier { ...@@ -57,6 +58,7 @@ public class SubsumptionVerifier extends AbstractVerifier {
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.addToEntry(VerificationClassification.WARNING, "subsumption"); vreFactory.addToEntry(VerificationClassification.WARNING, "subsumption");
} }
} else { } else {
......
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