use of org.kie.pmml.evaluator.assembler.container.PMMLPackageImpl in project drools by kiegroup.
the class PMMLRuntimeFactoryInternalTest method getKnowledgePackageWithPMMLResourceType.
private InternalKnowledgePackage getKnowledgePackageWithPMMLResourceType(KiePMMLModel kiePMMLModel) {
PMMLPackage pmmlPkg = new PMMLPackageImpl();
pmmlPkg.addAll(Collections.singleton(kiePMMLModel));
InternalKnowledgePackage pmmlKnowledgePackage = CoreComponentFactory.get().createKnowledgePackage(kiePMMLModel.getKModulePackageName());
pmmlKnowledgePackage.getResourceTypePackages().put(ResourceType.PMML, pmmlPkg);
return pmmlKnowledgePackage;
}
use of org.kie.pmml.evaluator.assembler.container.PMMLPackageImpl in project drools by kiegroup.
the class PMMLRuntimeFactoryInternalTest method createKieBaseFromKnowledgeBuilder.
@Test
public void createKieBaseFromKnowledgeBuilder() {
KnowledgeBuilderImpl knowledgeBuilder = new KnowledgeBuilderImpl();
knowledgeBuilder.addPackage(CoreComponentFactory.get().createKnowledgePackage("namespace_1"));
knowledgeBuilder.addPackage(CoreComponentFactory.get().createKnowledgePackage("namespace_2"));
PMMLPackage pmmlPkg = new PMMLPackageImpl();
pmmlPkg.addAll(Collections.singleton(new KiePMMLTestingModel("FAKE", Collections.emptyList())));
InternalKnowledgePackage pmmlKnowledgePackage = CoreComponentFactory.get().createKnowledgePackage("pmmled_package");
pmmlKnowledgePackage.getResourceTypePackages().put(ResourceType.PMML, pmmlPkg);
KieBase retrieved = PMMLRuntimeFactoryInternal.createKieBase(knowledgeBuilder);
assertNotNull(retrieved);
assertFalse(retrieved.getKiePackages().isEmpty());
assertEquals(knowledgeBuilder.getKnowledgePackages().size(), retrieved.getKiePackages().size());
knowledgeBuilder.getKnowledgePackages().forEach(kBuilderPackage -> {
assertNotNull(retrieved.getKiePackage(kBuilderPackage.getName()));
ResourceTypePackage knowledgeBuilderResourceTypePackage = ((InternalKnowledgePackage) kBuilderPackage).getResourceTypePackages().get(ResourceType.PMML);
if (((InternalKnowledgePackage) kBuilderPackage).getResourceTypePackages().get(ResourceType.PMML) != null) {
InternalKnowledgePackage retrievedKiePackage = (InternalKnowledgePackage) retrieved.getKiePackage(kBuilderPackage.getName());
ResourceTypePackage retrievedResourceTypePackage = retrievedKiePackage.getResourceTypePackages().get(ResourceType.PMML);
assertNotNull(retrievedKiePackage.getResourceTypePackages().get(ResourceType.PMML));
assertEquals(knowledgeBuilderResourceTypePackage, retrievedResourceTypePackage);
}
});
}
use of org.kie.pmml.evaluator.assembler.container.PMMLPackageImpl in project drools by kiegroup.
the class PMMLAssemblerService method addModels.
protected void addModels(KnowledgeBuilderImpl kbuilderImpl, List<KiePMMLModel> toAdd) {
for (KiePMMLModel kiePMMLModel : toAdd) {
PackageDescr pkgDescr = new PackageDescr(kiePMMLModel.getKModulePackageName());
PackageRegistry pkgReg = kbuilderImpl.getOrCreatePackageRegistry(pkgDescr);
InternalKnowledgePackage kpkgs = pkgReg.getPackage();
ResourceTypePackageRegistry rpkg = kpkgs.getResourceTypePackages();
PMMLPackage pmmlPkg = rpkg.computeIfAbsent(ResourceType.PMML, rtp -> new PMMLPackageImpl());
pmmlPkg.addAll(Collections.singletonList(kiePMMLModel));
if (kiePMMLModel instanceof HasNestedModels) {
addModels(kbuilderImpl, ((HasNestedModels) kiePMMLModel).getNestedModels());
}
}
}
use of org.kie.pmml.evaluator.assembler.container.PMMLPackageImpl in project drools by kiegroup.
the class PMMLWeaverService method merge.
@Override
public void merge(KiePackage kiePkg, PMMLPackage dmnpkg) {
ResourceTypePackageRegistry registry = ((InternalKnowledgePackage) kiePkg).getResourceTypePackages();
PMMLPackageImpl existing = registry.computeIfAbsent(ResourceType.PMML, rt -> new PMMLPackageImpl());
existing.addAll(dmnpkg.getAllModels().values());
}
Aggregations