@Test public void getKiePMMLModelWithKnowledgeBuilder() { KnowledgeBuilderImpl knowledgeBuilder = new KnowledgeBuilderImpl(); KiePMMLDroolsModel retrieved = droolsModelProvider.getKiePMMLModel(pmml.getDataDictionary(), pmml.getTransformationDictionary(), scorecard, knowledgeBuilder); assertNotNull(retrieved); assertTrue(retrieved instanceof KiePMMLDroolsModelTest); KiePMMLDroolsModelTest retrievedTest = (KiePMMLDroolsModelTest) retrieved; assertEquals(pmml.getDataDictionary(), retrievedTest.dataDictionary); assertEquals(pmml.getTransformationDictionary(), retrievedTest.transformationDictionary); assertEquals(scorecard, retrievedTest.model); String expectedPackageName = getSanitizedPackageName(PACKAGE_NAME); assertEquals(expectedPackageName, retrievedTest.getKModulePackageName()); assertEquals(PACKAGE_NAME, retrievedTest.getName()); PackageDescr packageDescr = knowledgeBuilder.getPackageDescrs("defaultpkg").get(0); commonVerifyPackageDescr(packageDescr, null, expectedPackageName); }
@Override public E getKiePMMLModel(final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder) { logger.trace("getKiePMMLModel {} {} {}", dataDictionary, transformationDictionary, model); if (!(kBuilder instanceof KnowledgeBuilder)) { throw new KiePMMLException(String.format("Expecting KnowledgeBuilder, received %s", kBuilder.getClass().getName())); } final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>(); KiePMMLDroolsAST kiePMMLDroolsAST = getKiePMMLDroolsASTCommon(dataDictionary, transformationDictionary, model, fieldTypeMap); E toReturn = getKiePMMLDroolsModel(dataDictionary, transformationDictionary, model, fieldTypeMap); PackageDescr packageDescr = getPackageDescr(kiePMMLDroolsAST, toReturn.getKModulePackageName()); ((KnowledgeBuilderImpl) kBuilder).addPackage(packageDescr); return toReturn; }
DroolsModelProvider implements ModelImplementationProvider<T, E> { @Override public E getKiePMMLModel(final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder) { logger.trace("getKiePMMLModel {} {} {}", dataDictionary, transformationDictionary, model); if (!(kBuilder instanceof KnowledgeBuilder)) { throw new KiePMMLException(String.format("Expecting KnowledgeBuilder, received %s", kBuilder.getClass().getName())); } final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>(); KiePMMLDroolsAST kiePMMLDroolsAST = getKiePMMLDroolsASTCommon(dataDictionary, transformationDictionary, model, fieldTypeMap); E toReturn = getKiePMMLDroolsModel(dataDictionary, transformationDictionary, model, fieldTypeMap); PackageDescr packageDescr = getPackageDescr(kiePMMLDroolsAST, toReturn.getKModulePackageName()); ((KnowledgeBuilderImpl) kBuilder).addPackage(packageDescr); return toReturn; } }
DroolsModelProvider implements ModelImplementationProvider<T, E> { @Override public E getKiePMMLModel(final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder) { logger.trace("getKiePMMLModel {} {} {}", dataDictionary, transformationDictionary, model); if (!(kBuilder instanceof KnowledgeBuilder)) { throw new KiePMMLException(String.format("Expecting KnowledgeBuilder, received %s", kBuilder.getClass().getName())); } final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>(); KiePMMLDroolsAST kiePMMLDroolsAST = getKiePMMLDroolsASTCommon(dataDictionary, transformationDictionary, model, fieldTypeMap); E toReturn = getKiePMMLDroolsModel(dataDictionary, transformationDictionary, model, fieldTypeMap); PackageDescr packageDescr = getPackageDescr(kiePMMLDroolsAST, toReturn.getKModulePackageName()); ((KnowledgeBuilderImpl) kBuilder).addPackage(packageDescr); return toReturn; }  }
DroolsModelProvider implements ModelImplementationProvider<T, E> { @Override public E getKiePMMLModel(final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder) { logger.trace("getKiePMMLModel {} {} {}", dataDictionary, transformationDictionary, model); if (!(kBuilder instanceof KnowledgeBuilder)) { throw new KiePMMLException(String.format("Expecting KnowledgeBuilder, received %s", kBuilder.getClass().getName())); } final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>(); KiePMMLDroolsAST kiePMMLDroolsAST = getKiePMMLDroolsASTCommon(dataDictionary, transformationDictionary, model, fieldTypeMap); E toReturn = getKiePMMLDroolsModel(dataDictionary, transformationDictionary, model, fieldTypeMap); PackageDescr packageDescr = getPackageDescr(kiePMMLDroolsAST, toReturn.getKModulePackageName()); ((KnowledgeBuilderImpl) kBuilder).addPackage(packageDescr); return toReturn; }  @Override E getKiePMMLModel(final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder); @Override E getKiePMMLModelFromPlugin(final String packageName, final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder); PackageDescr getPackageDescr(final KiePMMLDroolsAST kiePMMLDroolsAST, final String packageName); abstract E getKiePMMLDroolsModel(final DataDictionary dataDictionary,
                                            final TransformationDictionary transformationDictionary,
                                            final T model,
                                            final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap); abstract KiePMMLDroolsAST getKiePMMLDroolsAST(final DataDictionary dataDictionary,
                                                         final T model,
                                                         final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap,
                                                         final List<KiePMMLDroolsType> types); abstract Map<String, String> getKiePMMLDroolsModelSourcesMap(final DataDictionary dataDictionary,
                                                                        final TransformationDictionary transformationDictionary,
                                                                        final T model,
                                                                        final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap,
                                                                        final String packageName); }
DroolsModelProvider implements ModelImplementationProvider<T, E> { @Override public E getKiePMMLModel(final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder) { logger.trace("getKiePMMLModel {} {} {}", dataDictionary, transformationDictionary, model); if (!(kBuilder instanceof KnowledgeBuilder)) { throw new KiePMMLException(String.format("Expecting KnowledgeBuilder, received %s", kBuilder.getClass().getName())); } final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>(); KiePMMLDroolsAST kiePMMLDroolsAST = getKiePMMLDroolsASTCommon(dataDictionary, transformationDictionary, model, fieldTypeMap); E toReturn = getKiePMMLDroolsModel(dataDictionary, transformationDictionary, model, fieldTypeMap); PackageDescr packageDescr = getPackageDescr(kiePMMLDroolsAST, toReturn.getKModulePackageName()); ((KnowledgeBuilderImpl) kBuilder).addPackage(packageDescr); return toReturn; }  @Override E getKiePMMLModel(final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder); @Override E getKiePMMLModelFromPlugin(final String packageName, final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder); PackageDescr getPackageDescr(final KiePMMLDroolsAST kiePMMLDroolsAST, final String packageName); abstract E getKiePMMLDroolsModel(final DataDictionary dataDictionary,
                                            final TransformationDictionary transformationDictionary,
                                            final T model,
                                            final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap); abstract KiePMMLDroolsAST getKiePMMLDroolsAST(final DataDictionary dataDictionary,
                                                         final T model,
                                                         final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap,
                                                         final List<KiePMMLDroolsType> types); abstract Map<String, String> getKiePMMLDroolsModelSourcesMap(final DataDictionary dataDictionary,
                                                                        final TransformationDictionary transformationDictionary,
                                                                        final T model,
                                                                        final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap,
                                                                        final String packageName);  }