use of org.drools.core.definitions.ResourceTypePackageRegistry in project drools by kiegroup.
the class KnowledgePackageImpl method addProcess.
/**
* Add a rule flow to this package.
*/
public void addProcess(Process process) {
ResourceTypePackageRegistry rtps = getResourceTypePackages();
ProcessPackage rtp = ProcessPackage.getOrCreate(rtps);
rtp.add(process);
}
use of org.drools.core.definitions.ResourceTypePackageRegistry in project drools by kiegroup.
the class WeaverTest method testBayesPackageWeaving.
@Test
public void testBayesPackageWeaving() throws Exception {
KnowledgeBuilderImpl kbuilder = new KnowledgeBuilderImpl();
kbuilder.add(ResourceFactory.newClassPathResource("Garden.xmlbif", AssemblerTest.class), ResourceType.BAYES);
InternalKnowledgeBase kbase = getKnowledgeBase();
kbase.addPackages(kbuilder.getKnowledgePackages());
InternalKnowledgePackage kpkg = (InternalKnowledgePackage) kbase.getKiePackage("org.drools.beliefs.bayes.integration");
ResourceTypePackageRegistry map = kpkg.getResourceTypePackages();
BayesPackage existing = (BayesPackage) map.get(ResourceType.BAYES);
JunctionTree jtree = existing.getJunctionTree("Garden");
assertNotNull(jtree);
}
use of org.drools.core.definitions.ResourceTypePackageRegistry in project drools by kiegroup.
the class DMNRuntimeKBWrappingIKB method getModel.
@Override
public DMNModel getModel(String namespace, String modelName) {
Objects.requireNonNull(namespace, () -> MsgUtil.createMessage(Msg.PARAM_CANNOT_BE_NULL, "namespace"));
Objects.requireNonNull(modelName, () -> MsgUtil.createMessage(Msg.PARAM_CANNOT_BE_NULL, "modelName"));
InternalKnowledgePackage kpkg = (InternalKnowledgePackage) knowledgeBase.getKiePackage(namespace);
if (kpkg == null) {
return null;
}
ResourceTypePackageRegistry map = kpkg.getResourceTypePackages();
DMNPackage dmnpkg = (DMNPackage) map.get(ResourceType.DMN);
return dmnpkg != null ? dmnpkg.getModel(modelName) : null;
}
use of org.drools.core.definitions.ResourceTypePackageRegistry in project drools by kiegroup.
the class DMNWeaverService method merge.
@Override
public void merge(KiePackage kiePkg, DMNPackage dmnpkg) {
ResourceTypePackageRegistry registry = ((InternalKnowledgePackage) kiePkg).getResourceTypePackages();
DMNPackageImpl existing = registry.computeIfAbsent(ResourceType.DMN, rt -> new DMNPackageImpl(dmnpkg.getNamespace()));
for (Map.Entry<String, DMNModel> entry : dmnpkg.getAllModels().entrySet()) {
existing.addModel(entry.getKey(), entry.getValue());
}
existing.addProfiles(((DMNPackageImpl) dmnpkg).getProfiles());
}
Aggregations