Search in sources :

Example 1 with KiePMMLTreeModel

use of org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel in project drools by kiegroup.

the class TreeModelImplementationProviderTest method getKiePMMLModel.

@Test
public void getKiePMMLModel() throws Exception {
    final PMML pmml = getPMML(SOURCE_1);
    KnowledgeBuilderImpl knowledgeBuilder = new KnowledgeBuilderImpl();
    final CommonCompilationDTO<TreeModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, (TreeModel) pmml.getModels().get(0), new HasKnowledgeBuilderMock(knowledgeBuilder));
    final KiePMMLTreeModel retrieved = PROVIDER.getKiePMMLModel(compilationDTO);
    assertNotNull(retrieved);
    commonVerifyIsDeepCloneable(retrieved);
}
Also used : TreeModel(org.dmg.pmml.tree.TreeModel) KiePMMLTreeModel(org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel) HasKnowledgeBuilderMock(org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock) KiePMMLTreeModel(org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) PMML(org.dmg.pmml.PMML) Test(org.junit.Test)

Example 2 with KiePMMLTreeModel

use of org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel in project drools by kiegroup.

the class KiePMMLTreeModelFactory method getKiePMMLTreeModel.

public static KiePMMLTreeModel getKiePMMLTreeModel(final DroolsCompilationDTO<TreeModel> compilationDTO) throws IllegalAccessException, InstantiationException {
    logger.trace("getKiePMMLTreeModel {} {}", compilationDTO.getPackageName(), compilationDTO.getModel());
    Map<String, String> sourcesMap = getKiePMMLTreeModelSourcesMap(compilationDTO);
    try {
        Class<?> kiePMMLTreeModelClass = compilationDTO.compileAndLoadClass(sourcesMap);
        return (KiePMMLTreeModel) kiePMMLTreeModelClass.newInstance();
    } catch (Exception e) {
        throw new KiePMMLException(e);
    }
}
Also used : KiePMMLTreeModel(org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) KiePMMLInternalException(org.kie.pmml.api.exceptions.KiePMMLInternalException) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException)

Example 3 with KiePMMLTreeModel

use of org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel in project drools by kiegroup.

the class KiePMMLTreeModelFactoryTest method getKiePMMLTreeModel.

@Test
public void getKiePMMLTreeModel() throws InstantiationException, IllegalAccessException {
    final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = getFieldTypeMap(pmml.getDataDictionary(), pmml.getTransformationDictionary(), treeModel.getLocalTransformations());
    KnowledgeBuilderImpl knowledgeBuilder = new KnowledgeBuilderImpl();
    final CommonCompilationDTO<TreeModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, treeModel, new HasKnowledgeBuilderMock(knowledgeBuilder));
    final DroolsCompilationDTO<TreeModel> droolsCompilationDTO = DroolsCompilationDTO.fromCompilationDTO(compilationDTO, fieldTypeMap);
    KiePMMLTreeModel retrieved = KiePMMLTreeModelFactory.getKiePMMLTreeModel(droolsCompilationDTO);
    assertNotNull(retrieved);
    assertEquals(treeModel.getModelName(), retrieved.getName());
    assertEquals(TARGET_FIELD, retrieved.getTargetField());
}
Also used : KiePMMLTreeModel(org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel) TreeModel(org.dmg.pmml.tree.TreeModel) HasKnowledgeBuilderMock(org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock) KiePMMLTreeModel(org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) KiePMMLOriginalTypeGeneratedType(org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType) Test(org.junit.Test)

Aggregations

KiePMMLTreeModel (org.kie.pmml.models.drools.tree.model.KiePMMLTreeModel)3 TreeModel (org.dmg.pmml.tree.TreeModel)2 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)2 Test (org.junit.Test)2 HasKnowledgeBuilderMock (org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock)2 PMML (org.dmg.pmml.PMML)1 KiePMMLException (org.kie.pmml.api.exceptions.KiePMMLException)1 KiePMMLInternalException (org.kie.pmml.api.exceptions.KiePMMLInternalException)1 KiePMMLOriginalTypeGeneratedType (org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType)1