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

Merge branch 'feat/dmnapp' into 'develop'

Feat/dmnapp

See merge request jonasblatt/ma-jonasblatt-dmn-verifier!13
parents 193dc56b b9a7d29a
No related branches found
No related tags found
No related merge requests found
Showing
with 208 additions and 67 deletions
...@@ -7,11 +7,12 @@ This project contains all source files of the implementation, created for the ma ...@@ -7,11 +7,12 @@ This project contains all source files of the implementation, created for the ma
- [Frontend Project](../dmnverifierfrontend) - [Frontend Project](../dmnverifierfrontend)
## Backend ## Backend
[Api Documentation](docApi.md) - [Running Backend Instance](http://dmn.fg-bks.uni-koblenz.de:8080)
- [Api Documentation](docApi.md)
Based on ### Important dependencies
- [Quarkus](https://quarkus.io/) - [Quarkus](https://quarkus.io/)
- [Camunda DMN](https://github.com/camunda/camunda-dmn-model/) - [Camunda DMN](https://github.com/camunda/camunda-dmn-model/)
## Verifier ### Verifier
- [Overview verifier](verifier.md) - [Overview verifier](verifier.md)
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
Root path: <code>/api</code> Root path: <code>/api</code>
<h3>Verifications</h3> <h3>Verifications</h3>
<h4>Get all verifications from all verifiers with the given dmn table</h4> <h4>Get all verifications from all verifiers with the given dmn table</h4>
<ul> <ul>
<li>POST</li> <li>POST</li>
...@@ -12,39 +13,45 @@ Root path: <code>/api</code> ...@@ -12,39 +13,45 @@ Root path: <code>/api</code>
</ul> </ul>
<h3>Verification classifications</h3> <h3>Verification classifications</h3>
<h4>Get a list of all verification classifications</h4> <h4>Get a list of all verification classifications</h4>
<ul> <ul>
<li>GET</li> <li>GET</li>
<li><code><a href="/api/dmn/verification/classification" target="_blank">/api/dmn/verification/classification</a></code> <li><code><a href="/api/dmn/verification/classifications" target="_blank">/api/dmn/verification/classifications</a></code>
</li> </li>
<li>Produces: application/json</li> <li>Produces: application/json</li>
</ul> </ul>
<h4>Get all verifications for the given verification classification</h4> <h4>Get all verifications for the given verification classification</h4>
<ul> <ul>
<li>POST</li> <li>POST</li>
<li><code>/api/dmn/verification/classification/{classificationName}</code></li> <li><code>/api/dmn/verification/classifications/{classificationName}</code></li>
<li>Consumes: text/xml - the dmn table as xml string</li> <li>Consumes: text/xml - the dmn table as xml string</li>
<li>Produces: application/json</li> <li>Produces: application/json</li>
</ul> </ul>
<h3>Verification types</h3> <h3>Verification types</h3>
<h4>Get a list of all verification types</h4> <h4>Get a list of all verification types</h4>
<ul> <ul>
<li>GET</li> <li>GET</li>
<li> <li>
<code><a href="/api/dmn/verification/type" <code><a href="/api/dmn/verification/types"
target="_blank">/api/dmn/verification/type</a></code> target="_blank">/api/dmn/verification/types</a></code>
</li> </li>
<li>Produces: application/json</li> <li>Produces: application/json</li>
</ul> </ul>
<h4>Get all verifications for the given verification type</h4>
<h4>Get all verifications for the given verification types a and b</h4>
<ul> <ul>
<li>POST</li> <li>POST</li>
<li><code>/api/dmn/verification/classification/{classificationName}</code></li> <li><code>/api/dmn/verification/types?typeName={a}&typeName={b}</code></li>
<li>Consumes: text/xml - the dmn table as xml string</li> <li>Consumes: text/xml - the dmn table as xml string</li>
<li>Produces: application/json</li> <li>Produces: application/json</li>
</ul> </ul>
<h3>Metrics</h3> <h3>Metrics</h3>
<h4>Get some statistics about execution times</h4> <h4>Get some statistics about execution times</h4>
<ul> <ul>
<li>GET</li> <li>GET</li>
......
...@@ -7,6 +7,7 @@ import de.unikoblenz.fgbks.core.dmn.verification.metrics.DmnVerificationMetricsS ...@@ -7,6 +7,7 @@ import de.unikoblenz.fgbks.core.dmn.verification.metrics.DmnVerificationMetricsS
import de.unikoblenz.fgbks.core.dmn.verification.result.VerifierResultSet; import de.unikoblenz.fgbks.core.dmn.verification.result.VerifierResultSet;
import de.unikoblenz.fgbks.core.dmn.verification.verifier.classification.ClassificationType; import de.unikoblenz.fgbks.core.dmn.verification.verifier.classification.ClassificationType;
import de.unikoblenz.fgbks.core.dmn.verification.verifier.types.VerificationType; import de.unikoblenz.fgbks.core.dmn.verification.verifier.types.VerificationType;
import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
...@@ -14,6 +15,7 @@ import javax.ws.rs.POST; ...@@ -14,6 +15,7 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
...@@ -47,26 +49,27 @@ public class Verification { ...@@ -47,26 +49,27 @@ public class Verification {
* @return a list of {@link VerificationType} as a JSON String. * @return a list of {@link VerificationType} as a JSON String.
*/ */
@GET @GET
@Path("/type") @Path("/types")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public Response verifyType() { public Response verifyType() {
return Response.accepted(dmnVerificationService.getVerificationTypes()).build(); return Response.accepted(dmnVerificationService.getVerificationTypes()).build();
} }
/** /**
* Method to generate all verifications for a dmn with the given name of a {@link * Method to generate all verifications for a dmn with the given names of {@link
* VerificationType}. * VerificationType}. The types are listed in the query param "typeName". Multiple typeNames can
* be requested.
* *
* @param typeName the name of a {@link VerificationType} * @param typeNames the "typeName"(s) of a {@link VerificationType}
* @param payload the dmn as XML format as * @param payload the dmn as XML format as
* @return a JSON String, which represents a {@link VerifierResultSet} * @return a JSON String, which represents a {@link VerifierResultSet}
*/ */
@POST @POST
@Path("/type/{typeName}") @Path("/types")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.TEXT_XML) @Consumes(MediaType.TEXT_XML)
public Response verifyType(@PathParam("typeName") String typeName, String payload) { public Response verifyTypes(@QueryParam("typeName") List<String> typeNames, String payload) {
return checkResult(dmnVerificationService.generateFromType(typeName, payload)); return checkResult(dmnVerificationService.generateFromTypes(typeNames, payload));
} }
/** /**
...@@ -75,7 +78,7 @@ public class Verification { ...@@ -75,7 +78,7 @@ public class Verification {
* @return a list of {@link ClassificationType} as a JSON String. * @return a list of {@link ClassificationType} as a JSON String.
*/ */
@GET @GET
@Path("/classification") @Path("/classifications")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public Response verifyClassification() { public Response verifyClassification() {
return Response.accepted(dmnVerificationService.getVerificationClassificationTypes()).build(); return Response.accepted(dmnVerificationService.getVerificationClassificationTypes()).build();
...@@ -90,7 +93,7 @@ public class Verification { ...@@ -90,7 +93,7 @@ public class Verification {
* @return a JSON String, which represents a {@link VerifierResultSet} * @return a JSON String, which represents a {@link VerifierResultSet}
*/ */
@POST @POST
@Path("/classification/{classificationName}") @Path("/classifications/{classificationName}")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.TEXT_XML) @Consumes(MediaType.TEXT_XML)
public Response verifyClassification( public Response verifyClassification(
......
...@@ -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);
}
} }
package de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils; package de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils;
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;
...@@ -11,6 +13,7 @@ import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnRule; ...@@ -11,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;
...@@ -20,6 +23,7 @@ import org.apache.commons.lang3.Validate; ...@@ -20,6 +23,7 @@ import org.apache.commons.lang3.Validate;
*/ */
public class VDmnFunctions { public class VDmnFunctions {
private VDmnFunctions() {}
/** /**
* Generate a list of {@link VDmnColumn}, which are in the {@link VDmnDefinition} and has the * Generate a list of {@link VDmnColumn}, which are in the {@link VDmnDefinition} and has the
* defined type ({@link VTypeRef}). * defined type ({@link VTypeRef}).
...@@ -213,4 +217,66 @@ public class VDmnFunctions { ...@@ -213,4 +217,66 @@ public class VDmnFunctions {
} }
return clusters; return clusters;
} }
/**
* Get the name of a column as string. If a label is present, the string of the label is returned.
* If the label is not present, the name is returned. If the name is not present, "[no name]" is
* returned.
*
* @param column the {@link VDmnColumn}
* @return a string, representing the "name" of the column
*/
public static String getColumnStringName(VDmnColumn column) {
Validate.notNull(column);
return column.getLabel().isPresent()
? column.getLabel().get().toString()
: column.getName().orElse(Name.NO_NAME).toString();
}
/**
* Get a string with all row numbers of the given list of {@link VDmnRule}. The rows are sorted.
*
* @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}
* @return a string "Decision %s, Column %s: '
*/
public static String templateDecisionColumn(VDmnColumn column) {
return String.format(
"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());
}
} }
...@@ -84,12 +84,12 @@ public class DmnVerificationService { ...@@ -84,12 +84,12 @@ public class DmnVerificationService {
* Create a {@link VerifierResultSet} by executing the verifiers, which is registered in the * Create a {@link VerifierResultSet} by executing the verifiers, which is registered in the
* current deployment and has the name of the {@code type} parameter. * current deployment and has the name of the {@code type} parameter.
* *
* @param type the type as String. Should be the name of a {@link VerificationType}. * @param types the type as string list. Should be the name of a {@link VerificationType}.
* @param dmnXml the XML of the DMN as String * @param dmnXml the XML of the DMN as String
* @return a {@link VerifierResultSet} containing all verifications of the selected verifier. * @return a {@link VerifierResultSet} containing all verifications of the selected verifier.
*/ */
public VerifierResultSet generateFromType(String type, String dmnXml) { public VerifierResultSet generateFromTypes(List<String> types, String dmnXml) {
return generateWithFilter(dmnXml, type, null); return generateWithFilter(dmnXml, types, null);
} }
/** /**
...@@ -188,7 +188,7 @@ public class DmnVerificationService { ...@@ -188,7 +188,7 @@ public class DmnVerificationService {
} }
private VerifierResultSet generateWithFilter( private VerifierResultSet generateWithFilter(
String dmnXml, String typeName, String classificationName) { String dmnXml, List<String> typeNames, String classificationName) {
long verificationProcessId = UniqueIdGenerator.getNextId(); long verificationProcessId = UniqueIdGenerator.getNextId();
LOGGER.info("Start verification process. Id: " + verificationProcessId); LOGGER.info("Start verification process. Id: " + verificationProcessId);
LOGGER.info("Parsing dmn. Id: " + verificationProcessId); LOGGER.info("Parsing dmn. Id: " + verificationProcessId);
...@@ -214,7 +214,8 @@ public class DmnVerificationService { ...@@ -214,7 +214,8 @@ public class DmnVerificationService {
LOGGER.error(e.getMessage()); LOGGER.error(e.getMessage());
} }
if (av != null if (av != null
&& (typeName == null || av.getVerificationType().getName().getValue().equals(typeName)) && (typeNames == null
|| typeNames.contains(av.getVerificationType().getName().getValue()))
&& (classificationName == null && (classificationName == null
|| av.getVerificationType() || av.getVerificationType()
.getClassification() .getClassification()
......
...@@ -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.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;
...@@ -80,7 +81,8 @@ public class PredefinedExistingValueVerifier extends AbstractVerifier { ...@@ -80,7 +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.", templateDecisionColumn(stringValue.getDmnColumn())
+ "String value \"%s\" was not found in the list of predefined values.",
missingStringValue); missingStringValue);
} }
} }
...@@ -58,8 +58,8 @@ public class PredefinedMissingValueVerifier extends AbstractVerifier { ...@@ -58,8 +58,8 @@ public class PredefinedMissingValueVerifier extends AbstractVerifier {
} }
// get all missing strings // get all missing strings
Set<String> missingStrings = new HashSet<>(); Set<String> missingStrings = new HashSet<>();
for (String s : stringValuesInColumn) { for (String s : predefinedValues) {
if (!predefinedValues.contains(s)) { if (!stringValuesInColumn.contains(s)) {
missingStrings.add(s); missingStrings.add(s);
} }
} }
...@@ -86,8 +86,9 @@ public class PredefinedMissingValueVerifier extends AbstractVerifier { ...@@ -86,8 +86,9 @@ 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(VDmnFunctions.templateDecisionColumn(stringColumn));
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 present in the predefined values of the column: "); sb.append(" not used: ");
sb.append( sb.append(
missingStringValues.stream().map(v -> '"' + v + '"').collect(Collectors.joining(","))); missingStringValues.stream().map(v -> '"' + v + '"').collect(Collectors.joining(",")));
vreFactory.addToEntry(VerificationClassification.WARNING, sb.toString()); vreFactory.addToEntry(VerificationClassification.WARNING, 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