use of org.kie.dmn.api.core.DMNCompiler in project drools by kiegroup.
the class DMNAssemblerService method addResourceAfterRules.
@Override
public void addResourceAfterRules(Object kbuilder, Resource resource, ResourceType type, ResourceConfiguration configuration) throws Exception {
logger.warn("invoked legacy addResourceAfterRules (no control on the order of the assembler compilation): {}", resource.getSourcePath());
KnowledgeBuilderImpl kbuilderImpl = (KnowledgeBuilderImpl) kbuilder;
DMNCompiler dmnCompiler = kbuilderImpl.getCachedOrCreate(DMN_COMPILER_CACHE_KEY, () -> getCompiler(kbuilderImpl));
Collection<DMNModel> dmnModels = new ArrayList<>();
for (PackageRegistry pr : kbuilderImpl.getPackageRegistry().values()) {
ResourceTypePackage resourceTypePackage = pr.getPackage().getResourceTypePackages().get(ResourceType.DMN);
if (resourceTypePackage != null) {
DMNPackageImpl dmnpkg = (DMNPackageImpl) resourceTypePackage;
dmnModels.addAll(dmnpkg.getAllModels().values());
}
}
compileResourceToModel(kbuilderImpl, dmnCompiler, resource, null, dmnModels);
}
use of org.kie.dmn.api.core.DMNCompiler in project drools by kiegroup.
the class DMNAssemblerService method addResource.
@Override
public void addResource(Object kbuilder, Resource resource, ResourceType type, ResourceConfiguration configuration) throws Exception {
logger.warn("invoked legacy addResource (no control on the order of the assembler compilation): " + resource.getSourcePath());
KnowledgeBuilderImpl kbuilderImpl = (KnowledgeBuilderImpl) kbuilder;
DMNCompiler dmnCompiler = kbuilderImpl.getCachedOrCreate(DMN_COMPILER_CACHE_KEY, () -> getCompiler(kbuilderImpl));
Collection<DMNModel> dmnModels = new ArrayList<>();
for (PackageRegistry pr : kbuilderImpl.getPackageRegistry().values()) {
ResourceTypePackage resourceTypePackage = pr.getPackage().getResourceTypePackages().get(ResourceType.DMN);
if (resourceTypePackage != null) {
DMNPackageImpl dmnpkg = (DMNPackageImpl) resourceTypePackage;
dmnModels.addAll(dmnpkg.getAllModels().values());
}
}
compileResourceToModel(kbuilderImpl, dmnCompiler, resource, dmnModels);
}
use of org.kie.dmn.api.core.DMNCompiler in project drools by kiegroup.
the class DMNValidatorImpl method validateCompilation.
private List<DMNMessage> validateCompilation(Definitions dmnModel, DMNMessageManager results) {
if (dmnModel != null) {
DMNCompiler compiler = new DMNCompilerImpl(dmnCompilerConfig);
DMNModel model = compiler.compile(dmnModel);
if (model != null) {
return model.getMessages();
} else {
MsgUtil.reportMessage(LOG, DMNMessage.Severity.ERROR, dmnModel, results, null, null, Msg.FAILED_VALIDATOR);
}
}
return Collections.emptyList();
}
Aggregations