Skip to content

Commit

Permalink
Fix DMN Validation when build fails
Browse files Browse the repository at this point in the history
  • Loading branch information
yesamer committed Jul 15, 2024
1 parent 54b973d commit 3778faa
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ public Collection<DomainViolation> validate(final Diagram diagram,

final Reader[] aDMNXMLReaders = new Reader[]{};

final ClassLoader classLoader = getClassLoader(diagram);

final DMNValidator dmnValidator = getDmnValidator(classLoader);
final DMNValidator dmnValidator = getDmnValidator(diagram);

final List<DMNMessage> messages = dmnValidator
.validateUsing(DMNValidator.Validation.VALIDATE_MODEL,
Expand All @@ -148,17 +146,23 @@ public Collection<DomainViolation> validate(final Diagram diagram,
}
}

DMNValidator getDmnValidator(final ClassLoader classLoader) {
return DMNValidatorFactory.newValidator(classLoader, Collections.emptyList());
DMNValidator getDmnValidator(Diagram diagram) {
final ClassLoader classLoader = getClassLoader(diagram);

return classLoader != null ?
DMNValidatorFactory.newValidator(classLoader, Collections.emptyList()) :
DMNValidatorFactory.newValidator();
}

ClassLoader getClassLoader(final Diagram diagram) {
final Path path = diagram.getMetadata().getPath();
final WorkspaceProject project = workspaceProjectService.resolveProject(path);
final Module module = project.getMainModule();
final BuildHelper.BuildResult result = buildHelper.build(module);
final ClassLoader classLoader = ((InternalKieModule) result.getBuilder().getKieModuleIgnoringErrors()).getModuleClassLoader();
return classLoader;
if (result.getBuilder() != null) {
return ((InternalKieModule) result.getBuilder().getKieModuleIgnoringErrors()).getModuleClassLoader();
}
return null;
}

DMNValidator.ValidatorBuilder.ValidatorImportReaderResolver getValidatorImportReaderResolver(final Metadata metadata) {
Expand Down

0 comments on commit 3778faa

Please sign in to comment.