Search in sources :

Example 96 with InternalKnowledgePackage

use of org.drools.core.definitions.InternalKnowledgePackage in project drools by kiegroup.

the class DMNRuntimeImpl method getModel.

@Override
public DMNModel getModel(String namespace, String modelName) {
    InternalKnowledgePackage kpkg = (InternalKnowledgePackage) runtime.getKieBase().getKiePackage(namespace);
    if (kpkg == null) {
        return null;
    }
    Map<ResourceType, ResourceTypePackage> map = kpkg.getResourceTypePackages();
    DMNPackage dmnpkg = (DMNPackage) map.get(ResourceType.DMN);
    return dmnpkg != null ? dmnpkg.getModel(modelName) : null;
}
Also used : DMNPackage(org.kie.dmn.api.core.DMNPackage) ResourceType(org.kie.api.io.ResourceType) ResourceTypePackage(org.kie.api.internal.io.ResourceTypePackage) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Example 97 with InternalKnowledgePackage

use of org.drools.core.definitions.InternalKnowledgePackage in project drools by kiegroup.

the class DMNRuntimeImpl method getModels.

@Override
public List<DMNModel> getModels() {
    List<DMNModel> models = new ArrayList<>();
    runtime.getKieBase().getKiePackages().forEach(kpkg -> {
        DMNPackage dmnPkg = (DMNPackage) ((InternalKnowledgePackage) kpkg).getResourceTypePackages().get(ResourceType.DMN);
        if (dmnPkg != null) {
            dmnPkg.getAllModels().values().forEach(model -> models.add(model));
        }
    });
    return models;
}
Also used : DMNPackage(org.kie.dmn.api.core.DMNPackage) ArrayList(java.util.ArrayList) DMNModel(org.kie.dmn.api.core.DMNModel) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage)

Aggregations

InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)97 Test (org.junit.Test)32 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)28 KnowledgePackageImpl (org.drools.core.definitions.impl.KnowledgePackageImpl)26 RuleDescr (org.drools.compiler.lang.descr.RuleDescr)24 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)21 PackageDescr (org.drools.compiler.lang.descr.PackageDescr)20 PackageRegistry (org.drools.compiler.compiler.PackageRegistry)16 DialectCompiletimeRegistry (org.drools.compiler.compiler.DialectCompiletimeRegistry)14 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)13 TypeDeclaration (org.drools.core.rule.TypeDeclaration)13 HashMap (java.util.HashMap)12 Pattern (org.drools.core.rule.Pattern)12 RuleBuildContext (org.drools.compiler.rule.builder.RuleBuildContext)11 CompositeObjectSinkAdapterTest (org.drools.core.reteoo.CompositeObjectSinkAdapterTest)11 MVELDialectRuntimeData (org.drools.core.rule.MVELDialectRuntimeData)11 ClassObjectType (org.drools.core.base.ClassObjectType)10 ArrayList (java.util.ArrayList)9 KnowledgeBuilderConfigurationImpl (org.drools.compiler.builder.impl.KnowledgeBuilderConfigurationImpl)9 ResourceTypePackage (org.kie.api.internal.io.ResourceTypePackage)8