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

Add documentation for Verification Service class

parent 70e1c28d
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,12 @@ import org.reflections.Reflections;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Service class for generating verifications of DMNs. This class scans for verifier, witch are
* annotated with {@link DmnVerifier}. The verifier can be executed by calling {@link
* DmnVerificationService#generate} or by filtering the {@link VerificationType} (and annotated with
* {@link Type}) or {@link ClassificationType} (and annotated with {@link Classification}).
*/
@ApplicationScoped
public class DmnVerificationService {
......@@ -56,6 +62,63 @@ public class DmnVerificationService {
super();
}
/**
* Create a {@link VerifierResultSet} by executing all verifiers, which are registered in the
* current deployment.
*
* @param dmnXml the XML of the DMN as String
* @return a {@link VerifierResultSet} containing all verifications of known verifiers.
*/
public VerifierResultSet generate(String dmnXml) {
return generateWithFilter(dmnXml, null, null);
}
/**
* Create a {@link VerifierResultSet} by executing the verifiers, which is registered in the
* 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 dmnXml the XML of the DMN as String
* @return a {@link VerifierResultSet} containing all verifications of the selected verifier.
*/
public VerifierResultSet generateFromType(String type, String dmnXml) {
return generateWithFilter(dmnXml, type, null);
}
/**
* Create a {@link VerifierResultSet} by executing the verifiers, which is registered in the
* current deployment and has the name of the {@code type} parameter.
*
* @param classification the type as String. Should be the name of a {@link ClassificationType}.
* @param dmnXml the XML of the DMN as String
* @return a {@link VerifierResultSet} containing all verifications of the selected verifier.
*/
public VerifierResultSet generateFromClassification(String classification, String dmnXml) {
return generateWithFilter(dmnXml, null, classification);
}
/**
* This function returns all currently registered {@link VerificationType}s as {@link
* Collections#unmodifiableList}.
*
* @return a list of {@link VerificationType}s
*/
public List<VerificationType> getVerificationTypes() {
initVerifier();
return Collections.unmodifiableList(verificationTypes);
}
/**
* This function returns all currently registered {@link ClassificationType}s as {@link
* Collections#unmodifiableList}.
*
* @return a list of {@link ClassificationType}s
*/
public List<ClassificationType> getVerificationClassificationTypes() {
initVerifier();
return Collections.unmodifiableList(verificationClassificationTypes);
}
private void initVerifier() {
if (executor == null || verifierClasses == null) {
LOGGER.info("Init verification.");
......@@ -70,8 +133,12 @@ public class DmnVerificationService {
try {
VerificationType verificationType =
(VerificationType) clVt.getMethod("getInstance").invoke(null, null);
LOGGER.info("Verifier found: " + verificationType.getName() + " (" + verificationType
.getClassification().getName() + ")");
LOGGER.info(
"Verifier found: "
+ verificationType.getName()
+ " ("
+ verificationType.getClassification().getName()
+ ")");
verificationTypes.add(verificationType);
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace();
......@@ -91,16 +158,16 @@ public class DmnVerificationService {
}
}
public VerifierResultSet generate(String dmnXml) {
return generateWithFilter(dmnXml, null, null);
}
public VerifierResultSet generateFromType(String type, String dmnXml) {
return generateWithFilter(dmnXml, type, null);
}
public VerifierResultSet generateFromClassification(String classification, String dmnXml) {
return generateWithFilter(dmnXml, null, classification);
private Map<Class<? extends AbstractDmnVerifierConfig>, AbstractDmnVerifierConfig> getConfigs(
String dmnXml) {
Map<Class<? extends AbstractDmnVerifierConfig>, AbstractDmnVerifierConfig> map =
new ConcurrentHashMap<>();
map.put(
DefaultConfiguration.class,
DefaultConfiguration.getBuilder()
.withDmnObjectContainer(dmnService.getDmnServiceFromXml(dmnXml))
.build());
return map;
}
private VerifierResultSet generateWithFilter(
......@@ -148,26 +215,4 @@ public class DmnVerificationService {
return resultBuilder.build();
}
private Map<Class<? extends AbstractDmnVerifierConfig>, AbstractDmnVerifierConfig> getConfigs(
String dmnXml) {
Map<Class<? extends AbstractDmnVerifierConfig>, AbstractDmnVerifierConfig> map =
new ConcurrentHashMap<>();
map.put(
DefaultConfiguration.class,
DefaultConfiguration.getBuilder()
.withDmnObjectContainer(dmnService.getDmnServiceFromXml(dmnXml))
.build());
return map;
}
public List<VerificationType> getVerificationTypes() {
initVerifier();
return Collections.unmodifiableList(verificationTypes);
}
public List<ClassificationType> getVerificationClassificationTypes() {
initVerifier();
return Collections.unmodifiableList(verificationClassificationTypes);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment