use of org.kie.pmml.commons.Constants.EXPECTING_HAS_KNOWLEDGEBUILDER_TEMPLATE in project drools by kiegroup.
the class DroolsModelProvider method getKiePMMLModel.
@Override
public E getKiePMMLModel(final CompilationDTO<T> compilationDTO) {
logger.trace("getKiePMMLModel {} {} {}", compilationDTO.getPackageName(), compilationDTO.getFields(), compilationDTO.getModel());
if (!(compilationDTO.getHasClassloader() instanceof HasKnowledgeBuilder)) {
throw new KiePMMLException(String.format(EXPECTING_HAS_KNOWLEDGEBUILDER_TEMPLATE, compilationDTO.getHasClassloader().getClass().getName()));
}
HasKnowledgeBuilder hasKnowledgeBuilder = (HasKnowledgeBuilder) compilationDTO.getHasClassloader();
KnowledgeBuilderImpl knowledgeBuilder = (KnowledgeBuilderImpl) hasKnowledgeBuilder.getKnowledgeBuilder();
final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>();
KiePMMLDroolsAST kiePMMLDroolsAST = getKiePMMLDroolsASTCommon(compilationDTO.getFields(), compilationDTO.getModel(), fieldTypeMap);
final DroolsCompilationDTO<T> droolsCompilationDTO = DroolsCompilationDTO.fromCompilationDTO(compilationDTO, fieldTypeMap);
E toReturn = getKiePMMLDroolsModel(droolsCompilationDTO);
PackageDescr packageDescr = getPackageDescr(kiePMMLDroolsAST, toReturn.getKModulePackageName());
// Needed to compile Rules from PackageDescr
CompositePackageDescr compositePackageDescr = new CompositePackageDescr(null, packageDescr);
knowledgeBuilder.buildPackages(Collections.singletonList(compositePackageDescr));
return toReturn;
}
Aggregations