Search in sources :

Example 1 with DMNCompiler

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);
}
Also used : ResourceTypePackageRegistry(org.drools.core.definitions.ResourceTypePackageRegistry) PackageRegistry(org.drools.compiler.compiler.PackageRegistry) DMNPackageImpl(org.kie.dmn.core.impl.DMNPackageImpl) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) ArrayList(java.util.ArrayList) DMNCompiler(org.kie.dmn.api.core.DMNCompiler) ResourceTypePackage(org.kie.api.internal.io.ResourceTypePackage) DMNModel(org.kie.dmn.api.core.DMNModel)

Example 2 with DMNCompiler

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);
}
Also used : PackageRegistry(org.drools.compiler.compiler.PackageRegistry) DMNPackageImpl(org.kie.dmn.core.impl.DMNPackageImpl) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) ArrayList(java.util.ArrayList) DMNCompiler(org.kie.dmn.api.core.DMNCompiler) ResourceTypePackage(org.kie.api.internal.io.ResourceTypePackage) DMNModel(org.kie.dmn.api.core.DMNModel)

Example 3 with DMNCompiler

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();
}
Also used : DMNCompilerImpl(org.kie.dmn.core.compiler.DMNCompilerImpl) DMNCompiler(org.kie.dmn.api.core.DMNCompiler) DMNModel(org.kie.dmn.api.core.DMNModel)

Aggregations

DMNCompiler (org.kie.dmn.api.core.DMNCompiler)3 DMNModel (org.kie.dmn.api.core.DMNModel)3 ArrayList (java.util.ArrayList)2 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)2 PackageRegistry (org.drools.compiler.compiler.PackageRegistry)2 ResourceTypePackage (org.kie.api.internal.io.ResourceTypePackage)2 DMNPackageImpl (org.kie.dmn.core.impl.DMNPackageImpl)2 ResourceTypePackageRegistry (org.drools.core.definitions.ResourceTypePackageRegistry)1 DMNCompilerImpl (org.kie.dmn.core.compiler.DMNCompilerImpl)1