use of org.kie.pmml.commons.model.HasNestedModels in project drools by kiegroup.
the class PMMLCompilerService method addPMMLRuleMapper.
static void addPMMLRuleMapper(final KiePMMLModel kiePMMLModel, final List<String> generatedRuleMappers, final String sourcePath) {
if (!(kiePMMLModel instanceof HasSourcesMap)) {
String errorMessage = String.format("Expecting HasSourcesMap instance, retrieved %s inside %s", kiePMMLModel.getClass().getName(), sourcePath);
throw new KiePMMLException(errorMessage);
}
if (kiePMMLModel instanceof HasRule) {
String pkgUUID = ((HasRule) kiePMMLModel).getPkgUUID();
String rulesFileName = kiePMMLModel.getKModulePackageName() + "." + RULES_FILE_NAME + pkgUUID;
String pmmlRuleMapper = kiePMMLModel.getKModulePackageName() + "." + KIE_PMML_RULE_MAPPER_CLASS_NAME;
String ruleMapperSource = PMMLRuleMapperFactory.getPMMLRuleMapperSource(rulesFileName);
((HasRule) kiePMMLModel).addSourceMap(pmmlRuleMapper, ruleMapperSource);
generatedRuleMappers.add(pmmlRuleMapper);
}
if (kiePMMLModel instanceof HasNestedModels) {
for (KiePMMLModel nestedModel : ((HasNestedModels) kiePMMLModel).getNestedModels()) {
addPMMLRuleMapper(nestedModel, generatedRuleMappers, sourcePath);
}
}
}
use of org.kie.pmml.commons.model.HasNestedModels 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());
}
}
}
Aggregations