Search in sources :

Example 1 with KiePMMLScorecardModel

use of org.kie.pmml.models.drools.scorecard.model.KiePMMLScorecardModel in project drools by kiegroup.

the class ScorecardModelImplementationProviderTest method getKiePMMLModel.

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

Example 2 with KiePMMLScorecardModel

use of org.kie.pmml.models.drools.scorecard.model.KiePMMLScorecardModel in project drools by kiegroup.

the class KiePMMLScorecardModelFactory method getKiePMMLScorecardModel.

public static KiePMMLScorecardModel getKiePMMLScorecardModel(final DroolsCompilationDTO<Scorecard> compilationDTO) throws IllegalAccessException, InstantiationException {
    logger.trace("getKiePMMLScorecardModel {} {}", compilationDTO.getPackageName(), compilationDTO.getModel());
    Map<String, String> sourcesMap = getKiePMMLScorecardModelSourcesMap(compilationDTO);
    try {
        Class<?> kiePMMLScorecardModelClass = compilationDTO.compileAndLoadClass(sourcesMap);
        return (KiePMMLScorecardModel) kiePMMLScorecardModelClass.newInstance();
    } catch (Exception e) {
        throw new KiePMMLException(e);
    }
}
Also used : KiePMMLScorecardModel(org.kie.pmml.models.drools.scorecard.model.KiePMMLScorecardModel) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException)

Example 3 with KiePMMLScorecardModel

use of org.kie.pmml.models.drools.scorecard.model.KiePMMLScorecardModel in project drools by kiegroup.

the class KiePMMLScorecardModelFactoryTest method getKiePMMLScorecardModel.

@Test
public void getKiePMMLScorecardModel() throws Exception {
    final DataDictionary dataDictionary = pmml.getDataDictionary();
    final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = getFieldTypeMap(dataDictionary, pmml.getTransformationDictionary(), scorecardModel.getLocalTransformations());
    KnowledgeBuilderImpl knowledgeBuilder = new KnowledgeBuilderImpl();
    final CommonCompilationDTO<Scorecard> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, scorecardModel, new HasKnowledgeBuilderMock(knowledgeBuilder));
    final DroolsCompilationDTO<Scorecard> droolsCompilationDTO = DroolsCompilationDTO.fromCompilationDTO(compilationDTO, fieldTypeMap);
    KiePMMLScorecardModel retrieved = KiePMMLScorecardModelFactory.getKiePMMLScorecardModel(droolsCompilationDTO);
    assertNotNull(retrieved);
    assertEquals(scorecardModel.getModelName(), retrieved.getName());
    assertEquals(TARGET_FIELD, retrieved.getTargetField());
}
Also used : KiePMMLScorecardModel(org.kie.pmml.models.drools.scorecard.model.KiePMMLScorecardModel) HasKnowledgeBuilderMock(org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) DataDictionary(org.dmg.pmml.DataDictionary) CommonTestingUtils.getFieldsFromDataDictionary(org.kie.pmml.compiler.api.CommonTestingUtils.getFieldsFromDataDictionary) Scorecard(org.dmg.pmml.scorecard.Scorecard) KiePMMLOriginalTypeGeneratedType(org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType) Test(org.junit.Test)

Aggregations

KiePMMLScorecardModel (org.kie.pmml.models.drools.scorecard.model.KiePMMLScorecardModel)3 Scorecard (org.dmg.pmml.scorecard.Scorecard)2 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)2 Test (org.junit.Test)2 HasKnowledgeBuilderMock (org.kie.pmml.models.drools.commons.implementations.HasKnowledgeBuilderMock)2 DataDictionary (org.dmg.pmml.DataDictionary)1 PMML (org.dmg.pmml.PMML)1 KiePMMLException (org.kie.pmml.api.exceptions.KiePMMLException)1 CommonTestingUtils.getFieldsFromDataDictionary (org.kie.pmml.compiler.api.CommonTestingUtils.getFieldsFromDataDictionary)1 KiePMMLOriginalTypeGeneratedType (org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType)1