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

Merge branch 'develop' into 'documentation/verifier'

Develop

See merge request jonasblatt/ma-jonasblatt-dmn-verifier!92
parents d86ada7a 2e3c4262
No related branches found
No related tags found
No related merge requests found
...@@ -5,9 +5,10 @@ Root path: <code>/api</code> ...@@ -5,9 +5,10 @@ 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>
The <i>token</i> parameter is optional for some metric statistics.
<ul> <ul>
<li>POST</li> <li>POST</li>
<li><code>/api/dmn/verification/</code></li> <li><code>/api/dmn/verification?token={token}</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>
...@@ -23,16 +24,17 @@ Root path: <code>/api</code> ...@@ -23,16 +24,17 @@ Root path: <code>/api</code>
</ul> </ul>
<h4>Get all verifications for the given verification classification</h4> <h4>Get all verifications for the given verification classification</h4>
The <i>token</i> parameter is optional for some metric statistics.
<ul> <ul>
<li>POST</li> <li>POST</li>
<li><code>/api/dmn/verification/classifications/{classificationName}</code></li> <li><code>/api/dmn/verification/classifications/{classificationName}?token={token}</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 <b>active</b> verification types</h4>
<ul> <ul>
<li>GET</li> <li>GET</li>
<li> <li>
...@@ -43,17 +45,39 @@ Root path: <code>/api</code> ...@@ -43,17 +45,39 @@ Root path: <code>/api</code>
</ul> </ul>
<h4>Get all verifications for the given verification types a and b</h4> <h4>Get all verifications for the given verification types a and b</h4>
The <i>token</i> parameter is optional for some metric statistics.
<ul> <ul>
<li>POST</li> <li>POST</li>
<li><code>/api/dmn/verification/types?typeName={a}&typeName={b}</code></li> <li><code>/api/dmn/verification/types?typeName={a}&typeName={b}&token={token}</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 Config</h3>
<h4>Get all verification types and the boolean value of their active state</h4>
<ul>
<li>GET</li>
<li>
<code><a href="/api/dmn/verification/config"
target="_blank">/api/dmn/verification/config</a></code>
</li>
<li>Produces: application/json</li>
</ul>
<h4>Set the config to enable/disable a verification type</h4>
Set "true" or "false" for the active state of the verification. If "false", no verification will
be computed.
<ul>
<li>POST</li>
<li>
<code>/api/dmn/verification/config/{verificationName}/{active}</code>
</li>
</ul>
<h3>Metrics</h3> <h3>Metrics</h3>
<h4>Get some statistics about execution times</h4> <h4>Get some statistics about execution times</h4>
The token parameter is optional for some metric statistics. The default value is 'all'. The <i>token</i> parameter is optional for some metric statistics. The default value is 'all'.
<ul> <ul>
<li>GET</li> <li>GET</li>
<li> <li>
...@@ -63,7 +87,7 @@ The token parameter is optional for some metric statistics. The default value is ...@@ -63,7 +87,7 @@ The token parameter is optional for some metric statistics. The default value is
<li>Produces: application/json</li> <li>Produces: application/json</li>
</ul> </ul>
<h3>Actions</h3> <h3>Action Config</h3>
<h4>Get global the action config</h4> <h4>Get global the action config</h4>
Get "true" or "false" for the global action creation setting. If "false", no actions will be Get "true" or "false" for the global action creation setting. If "false", no actions will be
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<artifactId>dmn-verifier-parent</artifactId> <artifactId>dmn-verifier-parent</artifactId>
<groupId>de.unikoblenz.fgbks</groupId> <groupId>de.unikoblenz.fgbks</groupId>
<relativePath>../dmnverifierparent/pom.xml</relativePath> <relativePath>../dmnverifierparent/pom.xml</relativePath>
<version>0.9.8</version> <version>0.9.9</version>
</parent> </parent>
<properties> <properties>
......
...@@ -53,7 +53,7 @@ public class Verification { ...@@ -53,7 +53,7 @@ public class Verification {
} }
/** /**
* Method to get all registered verification types. * Method to get all active verification types.
* *
* @return a list of {@link VerificationType} as a JSON String. * @return a list of {@link VerificationType} as a JSON String.
*/ */
...@@ -142,6 +142,31 @@ public class Verification { ...@@ -142,6 +142,31 @@ public class Verification {
return Response.accepted(dmnVerificationMetricsService.getMetrics(token)).build(); return Response.accepted(dmnVerificationMetricsService.getMetrics(token)).build();
} }
/**
* Method to get all registered {@link VerificationType}s. These types are mapped with a boolean,
* which indicates, if the verifier is active or not.
*/
@GET
@Path("/config")
@Produces(MediaType.APPLICATION_JSON)
public Response configVerificationTypes() {
return Response.accepted(dmnVerificationService.getVerificationTypesConfig()).build();
}
/**
* Method to get all registered {@link VerificationType}s. These types are mapped with a boolean,
* which indicates, if the verifier is active or not.
*/
@POST
@Path("/config/{verificationName}/{active}")
@Produces(MediaType.APPLICATION_JSON)
public Response configVerificationTypes(
@PathParam("verificationName") String verificationTypeName,
@PathParam("active") boolean value) {
dmnVerificationService.setVerificationTypesConfig(verificationTypeName, value);
return Response.accepted().build();
}
/** /**
* Method to get a boolean, if the actions are active or inactive * Method to get a boolean, if the actions are active or inactive
* *
......
...@@ -10,7 +10,6 @@ import de.unikoblenz.fgbks.core.dmn.verification.result.VerifierResultSet.Builde ...@@ -10,7 +10,6 @@ import de.unikoblenz.fgbks.core.dmn.verification.result.VerifierResultSet.Builde
import de.unikoblenz.fgbks.core.dmn.verification.result.actions.FixActionService; import de.unikoblenz.fgbks.core.dmn.verification.result.actions.FixActionService;
import de.unikoblenz.fgbks.core.dmn.verification.verifier.AbstractVerifier; import de.unikoblenz.fgbks.core.dmn.verification.verifier.AbstractVerifier;
import de.unikoblenz.fgbks.core.dmn.verification.verifier.DmnVerifier; import de.unikoblenz.fgbks.core.dmn.verification.verifier.DmnVerifier;
import de.unikoblenz.fgbks.core.dmn.verification.verifier.Verifier;
import de.unikoblenz.fgbks.core.dmn.verification.verifier.classification.Classification; import de.unikoblenz.fgbks.core.dmn.verification.verifier.classification.Classification;
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.config.AbstractDmnVerifierConfig; import de.unikoblenz.fgbks.core.dmn.verification.verifier.config.AbstractDmnVerifierConfig;
...@@ -29,6 +28,7 @@ import java.util.concurrent.ExecutionException; ...@@ -29,6 +28,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.stream.Collectors;
import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
...@@ -59,14 +59,14 @@ public class DmnVerificationService { ...@@ -59,14 +59,14 @@ public class DmnVerificationService {
private ExecutorService executor; private ExecutorService executor;
private Set<Class<?>> verifierClasses; private Set<Class<?>> verifierClasses;
private List<VerificationType> verificationTypes; @Inject
protected DmnVerificationMetricsService dmnVerificationMetricsService;
private List<ClassificationType> verificationClassificationTypes; private List<ClassificationType> verificationClassificationTypes;
@Inject protected DmnService dmnService; @Inject protected DmnService dmnService;
@Inject @Inject
protected DmnVerificationMetricsService dmnVerificationMetricsService;
@Inject
protected FixActionService fixActionService; protected FixActionService fixActionService;
private Map<VerificationType, Boolean> verificationTypes;
protected DmnVerificationService() { protected DmnVerificationService() {
super(); super();
...@@ -112,13 +112,42 @@ public class DmnVerificationService { ...@@ -112,13 +112,42 @@ public class DmnVerificationService {
} }
/** /**
* This function returns all currently registered {@link VerificationType}s as {@link * This function returns all currently active {@link VerificationType}s as {@link
* Collections#unmodifiableList}. * Collections#unmodifiableList}.
* *
* @return a list of {@link VerificationType}s * @return a list of {@link VerificationType}s
*/ */
public List<VerificationType> getVerificationTypes() { public List<VerificationType> getVerificationTypes() {
return Collections.unmodifiableList(verificationTypes); return Collections.unmodifiableList(
verificationTypes.keySet().stream()
.filter(v -> verificationTypes.get(v))
.collect(Collectors.toList()));
}
/**
* This function returns a map of all currently registered {@link VerificationType}s. The boolean
* value indicates, if the verifier is active or not.
*
* @return a map of {@link VerificationType}s (Name as {@link String}) and {@link Boolean}
*/
public Map<String, Boolean> getVerificationTypesConfig() {
return verificationTypes.keySet().stream()
.collect(Collectors.toMap(v -> v.getName().getValue(), v -> verificationTypes.get(v)));
}
/**
* This function sets a config for a currently registered {@link VerificationType}s. The boolean
* value indicates, if the verifier is active or not.
*
* @param verificationName the name of a registered VerificationType as String
* @param value the boolean value, if the verifier is active or not
*/
public void setVerificationTypesConfig(String verificationName, boolean value) {
// try to find a verifier
verificationTypes.keySet().stream()
.filter(v -> v.getName().getValue().equals(verificationName))
.findFirst()
.ifPresent(v -> verificationTypes.put(v, value));
} }
/** /**
...@@ -143,8 +172,7 @@ public class DmnVerificationService { ...@@ -143,8 +172,7 @@ public class DmnVerificationService {
LOGGER.info("Init verifier."); LOGGER.info("Init verifier.");
Reflections reflections = new Reflections(packagePath); Reflections reflections = new Reflections(packagePath);
verifierClasses = reflections.getTypesAnnotatedWith(DmnVerifier.class); verifierClasses = reflections.getTypesAnnotatedWith(DmnVerifier.class);
verificationTypes = new ConcurrentHashMap<>();
verificationTypes = new ArrayList<>();
Set<Class<?>> clVts = reflections.getTypesAnnotatedWith(Type.class); Set<Class<?>> clVts = reflections.getTypesAnnotatedWith(Type.class);
for (Class<?> clVt : clVts) { for (Class<?> clVt : clVts) {
try { try {
...@@ -156,7 +184,7 @@ public class DmnVerificationService { ...@@ -156,7 +184,7 @@ public class DmnVerificationService {
+ " (" + " ("
+ verificationType.getClassification().getName() + verificationType.getClassification().getName()
+ ")"); + ")");
verificationTypes.add(verificationType); verificationTypes.put(verificationType, true);
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -211,9 +239,8 @@ public class DmnVerificationService { ...@@ -211,9 +239,8 @@ public class DmnVerificationService {
return resultBuilder.build(); return resultBuilder.build();
} }
LOGGER.info("Looking for verifiers. Id: " + verificationProcessId); LOGGER.info("Looking for verifiers. Id: " + verificationProcessId);
List<Future<VerifierResult>> results = new ArrayList<>(verifierClasses.size()); List<Future<VerifierResult>> results = new ArrayList<>(30);
List<VerificationType> activeVerifier = getVerificationTypes();
List<Verifier> executedVerifier = new ArrayList<>();
for (Class<?> verifierClass : verifierClasses) { for (Class<?> verifierClass : verifierClasses) {
AbstractVerifier av = null; AbstractVerifier av = null;
try { try {
...@@ -222,16 +249,15 @@ public class DmnVerificationService { ...@@ -222,16 +249,15 @@ public class DmnVerificationService {
LOGGER.error(e.getMessage()); LOGGER.error(e.getMessage());
} }
if (av != null if (av != null
&& activeVerifier.contains(av.getVerificationType())
&& (typeNames == null && (typeNames == null
|| typeNames.contains(av.getVerificationType().getName().getValue())) || typeNames.contains(av.getVerificationType().getName().getValue()))
&& (classificationName == null && (classificationName == null
|| av.getVerificationType() || av.getVerificationType()
.getClassification() .getClassification()
.getName() .getName()
.getValue() .getValue()
.equals(classificationName))) { .equals(classificationName))) {
// add verifier to list
executedVerifier.add(av);
// Create Configuration // Create Configuration
AbstractDmnVerifierConfig verifierConfig = AbstractDmnVerifierConfig verifierConfig =
configs.get(av.getClass().getAnnotation(DmnVerifier.class).verifierConfig()); configs.get(av.getClass().getAnnotation(DmnVerifier.class).verifierConfig());
......
...@@ -152,7 +152,7 @@ ...@@ -152,7 +152,7 @@
<h3>Verification types</h3> <h3>Verification types</h3>
<h4>Get a list of all verification types</h4> <h4>Get a list of all <b>active</b> verification types</h4>
<ul> <ul>
<li>GET</li> <li>GET</li>
<li> <li>
...@@ -171,6 +171,27 @@ ...@@ -171,6 +171,27 @@
<li>Produces: application/json</li> <li>Produces: application/json</li>
</ul> </ul>
<h3>Verification Config</h3>
<h4>Get all verification types and the boolean value of their active state</h4>
<ul>
<li>GET</li>
<li>
<code><a href="/api/dmn/verification/config"
target="_blank">/api/dmn/verification/config</a></code>
</li>
<li>Produces: application/json</li>
</ul>
<h4>Set the config to enable/disable a verification type</h4>
Set "true" or "false" for the active state of the verification. If "false", no verification will
be computed.
<ul>
<li>POST</li>
<li>
<code>/api/dmn/verification/config/{verificationName}/{active}</code>
</li>
</ul>
<h3>Metrics</h3> <h3>Metrics</h3>
<h4>Get some statistics about execution times</h4> <h4>Get some statistics about execution times</h4>
...@@ -184,7 +205,7 @@ ...@@ -184,7 +205,7 @@
<li>Produces: application/json</li> <li>Produces: application/json</li>
</ul> </ul>
<h3>Actions</h3> <h3>Action Config</h3>
<h4>Get global the action config</h4> <h4>Get global the action config</h4>
Get "true" or "false" for the global action creation setting. If "false", no actions will be Get "true" or "false" for the global action creation setting. If "false", no actions will be
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>dmn-verifier-parent</artifactId> <artifactId>dmn-verifier-parent</artifactId>
<groupId>de.unikoblenz.fgbks</groupId> <groupId>de.unikoblenz.fgbks</groupId>
<version>0.9.8</version> <version>0.9.9</version>
<relativePath>../dmnverifierparent/pom.xml</relativePath> <relativePath>../dmnverifierparent/pom.xml</relativePath>
</parent> </parent>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
margin: 5px; margin: 5px;
} }
#globalSettings { #globalActions {
margin-bottom: 15px; margin-bottom: 15px;
} }
...@@ -29,12 +29,14 @@ ...@@ -29,12 +29,14 @@
</head> </head>
<body> <body>
<div id="metricContainer"> <div id="metricContainer">
<h1>Actions - Configuration</h1> <h1>Configuration</h1>
<div id="configContent"> <div id="configContent">
<div id="globalSettings"></div> <h2>Verifications</h2>
<div id="verificationConfig"></div>
<h2>Actions</h2>
<div id="globalActions"></div>
<div id="allowedActions"></div> <div id="allowedActions"></div>
</div> </div>
</div> </div>
<!-- load jquery --> <!-- load jquery -->
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js" type="text/javascript"></script> <script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js" type="text/javascript"></script>
...@@ -49,29 +51,55 @@ ...@@ -49,29 +51,55 @@
const dmnApi = rootUrl + 'api/dmn/'; const dmnApi = rootUrl + 'api/dmn/';
function loadData() { function loadData() {
let $globalSettings = $('#globalSettings'); // load verification config
$globalSettings.empty(); let $verificationConfig = $('#verificationConfig');
$verificationConfig.empty();
$.ajax({ $.ajax({
timeout: 1000, timeout: 1000,
url: dmnApi + 'verification/actions/global', url: dmnApi + 'verification/config',
type: 'GET', type: 'GET',
error: function (err) { error: function (err) {
alert("No connection."); alert("No connection.");
}, },
success: function (verificationTypes) {
let $ul = $(`<ul>`);
$verificationConfig.append($ul);
for (const [name, value] of Object.entries(verificationTypes)) {
let $li = $(`<li>`);
let $checkbox = $(`<input type="checkbox" data-verificationtypename="${name}"
onchange="updateVerificationType(this)"/>`);
$checkbox[0].checked = value;
$li.append($checkbox);
$li.append($(`<label>${name}</label>`));
$ul.append($li);
}
}
});
// load global action config
let $globalActions = $('#globalActions');
$globalActions.empty();
$.ajax({
timeout: 1000,
url: dmnApi + 'verification/actions/global',
type: 'GET',
error: function (err) {
},
success: function (active) { success: function (active) {
$globalSettings.append("<label>Global active:</label>"); $globalActions.append("<label>Global active:</label>");
$globalSettings.append($globalCheckbox); $globalActions.append($globalCheckbox);
$globalCheckbox[0].checked = (active === 'true'); $globalCheckbox[0].checked = (active === 'true');
} }
}); });
// load actions config
let $allowedActions = $('#allowedActions'); let $allowedActions = $('#allowedActions');
$allowedActions.empty();
$.ajax({ $.ajax({
timeout: 1000, timeout: 1000,
url: dmnApi + 'verification/actions/allowedActions', url: dmnApi + 'verification/actions/allowedActions',
type: 'GET', type: 'GET',
error: function (err) { error: function (err) {
alert("No connection.");
}, },
success: function (allowedActions) { success: function (allowedActions) {
for (const [actionScope, typeBol] of Object.entries(allowedActions)) { for (const [actionScope, typeBol] of Object.entries(allowedActions)) {
...@@ -90,6 +118,23 @@ ...@@ -90,6 +118,23 @@
}); });
} }
function updateVerificationType(checkbox) {
console.log(checkbox.checked);
console.log(checkbox.dataset.actionscope);
console.log(checkbox.dataset.actiontype);
$.ajax({
timeout: 1000,
url: dmnApi + 'verification/config/' + checkbox.dataset.verificationtypename
+ "/" + checkbox.checked,
type: 'POST',
error: function (err) {
alert("No connection.");
},
success: function (active) {
}
});
}
function updateGlobal() { function updateGlobal() {
$.ajax({ $.ajax({
timeout: 1000, timeout: 1000,
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<properties> <properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<surefire-plugin.version>2.22.0</surefire-plugin.version> <surefire-plugin.version>2.22.0</surefire-plugin.version>
<quarkus.version>0.26.1</quarkus.version> <quarkus.version>0.27.0</quarkus.version>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<packaging>pom</packaging> <packaging>pom</packaging>
<version>0.9.8</version> <version>0.9.9</version>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
......
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