@Test public void getKiePMMLModelFromPluginWithKnowledgeBuilder() { KnowledgeBuilderImpl knowledgeBuilder = new KnowledgeBuilderImpl(); KiePMMLDroolsModel retrieved = droolsModelProvider.getKiePMMLModelFromPlugin(PACKAGE_NAME, pmml.getDataDictionary(), pmml.getTransformationDictionary(), scorecard, knowledgeBuilder); assertNotNull(retrieved); assertTrue(retrieved instanceof KiePMMLDroolsModelWithSources); KiePMMLDroolsModelWithSources retrievedSources = (KiePMMLDroolsModelWithSources) retrieved; assertEquals(SOURCE_MAP, retrievedSources.getSourcesMap()); assertEquals(PACKAGE_NAME, retrievedSources.getKModulePackageName()); assertEquals(scorecard.getModelName(), retrievedSources.getName()); PackageDescr packageDescr = knowledgeBuilder.getPackageDescrs("defaultpkg").get(0); commonVerifyPackageDescr(packageDescr, null, PACKAGE_NAME); }
@Override public E getKiePMMLModelFromPlugin(final String packageName, final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder) { logger.trace("getKiePMMLModelFromPlugin {} {} {}", dataDictionary, model, kBuilder); if (!(kBuilder instanceof KnowledgeBuilder)) { throw new KiePMMLException(String.format("Expecting KnowledgeBuilder, received %s", kBuilder.getClass().getName())); } try { final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>(); KiePMMLDroolsAST kiePMMLDroolsAST = getKiePMMLDroolsASTCommon(dataDictionary, transformationDictionary, model, fieldTypeMap); Map<String, String> sourcesMap = getKiePMMLDroolsModelSourcesMap(dataDictionary, transformationDictionary, model, fieldTypeMap, packageName); PackageDescr packageDescr = getPackageDescr(kiePMMLDroolsAST, packageName); String pkgUUID = getPkgUUID( ((KnowledgeBuilderImpl) kBuilder).getReleaseId(), packageName); packageDescr.setPreferredPkgUUID(pkgUUID); E toReturn = (E) new KiePMMLDroolsModelWithSources(model.getModelName(), packageName, sourcesMap, packageDescr); ((KnowledgeBuilderImpl) kBuilder).addPackage(packageDescr); return toReturn; } catch (Exception e) { throw new KiePMMLException(e); } }
DroolsModelProvider implements ModelImplementationProvider<T, E> { @Override public E getKiePMMLModelFromPlugin(final String packageName, final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder) { logger.trace("getKiePMMLModelFromPlugin {} {} {}", dataDictionary, model, kBuilder); if (!(kBuilder instanceof KnowledgeBuilder)) { throw new KiePMMLException(String.format("Expecting KnowledgeBuilder, received %s", kBuilder.getClass().getName())); } try { final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>(); KiePMMLDroolsAST kiePMMLDroolsAST = getKiePMMLDroolsASTCommon(dataDictionary, transformationDictionary, model, fieldTypeMap); Map<String, String> sourcesMap = getKiePMMLDroolsModelSourcesMap(dataDictionary, transformationDictionary, model, fieldTypeMap, packageName); PackageDescr packageDescr = getPackageDescr(kiePMMLDroolsAST, packageName); String pkgUUID = getPkgUUID( ((KnowledgeBuilderImpl) kBuilder).getReleaseId(), packageName); packageDescr.setPreferredPkgUUID(pkgUUID); E toReturn = (E) new KiePMMLDroolsModelWithSources(model.getModelName(), packageName, sourcesMap, packageDescr); ((KnowledgeBuilderImpl) kBuilder).addPackage(packageDescr); return toReturn; } catch (Exception e) { throw new KiePMMLException(e); } } }
DroolsModelProvider implements ModelImplementationProvider<T, E> { @Override public E getKiePMMLModelFromPlugin(final String packageName, final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder) { logger.trace("getKiePMMLModelFromPlugin {} {} {}", dataDictionary, model, kBuilder); if (!(kBuilder instanceof KnowledgeBuilder)) { throw new KiePMMLException(String.format("Expecting KnowledgeBuilder, received %s", kBuilder.getClass().getName())); } try { final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>(); KiePMMLDroolsAST kiePMMLDroolsAST = getKiePMMLDroolsASTCommon(dataDictionary, transformationDictionary, model, fieldTypeMap); Map<String, String> sourcesMap = getKiePMMLDroolsModelSourcesMap(dataDictionary, transformationDictionary, model, fieldTypeMap, packageName); PackageDescr packageDescr = getPackageDescr(kiePMMLDroolsAST, packageName); String pkgUUID = getPkgUUID( ((KnowledgeBuilderImpl) kBuilder).getReleaseId(), packageName); packageDescr.setPreferredPkgUUID(pkgUUID); E toReturn = (E) new KiePMMLDroolsModelWithSources(model.getModelName(), packageName, sourcesMap, packageDescr); ((KnowledgeBuilderImpl) kBuilder).addPackage(packageDescr); return toReturn; } catch (Exception e) { throw new KiePMMLException(e); } }  }
DroolsModelProvider implements ModelImplementationProvider<T, E> { @Override public E getKiePMMLModelFromPlugin(final String packageName, final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder) { logger.trace("getKiePMMLModelFromPlugin {} {} {}", dataDictionary, model, kBuilder); if (!(kBuilder instanceof KnowledgeBuilder)) { throw new KiePMMLException(String.format("Expecting KnowledgeBuilder, received %s", kBuilder.getClass().getName())); } try { final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>(); KiePMMLDroolsAST kiePMMLDroolsAST = getKiePMMLDroolsASTCommon(dataDictionary, transformationDictionary, model, fieldTypeMap); Map<String, String> sourcesMap = getKiePMMLDroolsModelSourcesMap(dataDictionary, transformationDictionary, model, fieldTypeMap, packageName); PackageDescr packageDescr = getPackageDescr(kiePMMLDroolsAST, packageName); String pkgUUID = getPkgUUID( ((KnowledgeBuilderImpl) kBuilder).getReleaseId(), packageName); packageDescr.setPreferredPkgUUID(pkgUUID); E toReturn = (E) new KiePMMLDroolsModelWithSources(model.getModelName(), packageName, sourcesMap, packageDescr); ((KnowledgeBuilderImpl) kBuilder).addPackage(packageDescr); return toReturn; } catch (Exception e) { throw new KiePMMLException(e); } }  @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 getKiePMMLModelFromPlugin(final String packageName, final DataDictionary dataDictionary, final TransformationDictionary transformationDictionary, final T model, final Object kBuilder) { logger.trace("getKiePMMLModelFromPlugin {} {} {}", dataDictionary, model, kBuilder); if (!(kBuilder instanceof KnowledgeBuilder)) { throw new KiePMMLException(String.format("Expecting KnowledgeBuilder, received %s", kBuilder.getClass().getName())); } try { final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>(); KiePMMLDroolsAST kiePMMLDroolsAST = getKiePMMLDroolsASTCommon(dataDictionary, transformationDictionary, model, fieldTypeMap); Map<String, String> sourcesMap = getKiePMMLDroolsModelSourcesMap(dataDictionary, transformationDictionary, model, fieldTypeMap, packageName); PackageDescr packageDescr = getPackageDescr(kiePMMLDroolsAST, packageName); String pkgUUID = getPkgUUID( ((KnowledgeBuilderImpl) kBuilder).getReleaseId(), packageName); packageDescr.setPreferredPkgUUID(pkgUUID); E toReturn = (E) new KiePMMLDroolsModelWithSources(model.getModelName(), packageName, sourcesMap, packageDescr); ((KnowledgeBuilderImpl) kBuilder).addPackage(packageDescr); return toReturn; } catch (Exception e) { throw new KiePMMLException(e); } }  @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);  }