Search in sources :

Example 11 with KiePMMLDroolsAST

use of org.kie.pmml.models.drools.ast.KiePMMLDroolsAST in project drools by kiegroup.

the class DroolsModelProviderTest method getPackageDescr.

@Test
public void getPackageDescr() {
    KiePMMLDroolsAST kiePMMLDroolsAST = new KiePMMLDroolsAST(Collections.emptyList(), Collections.emptyList());
    PackageDescr retrieved = droolsModelProvider.getPackageDescr(kiePMMLDroolsAST, PACKAGE_NAME);
    commonVerifyPackageDescr(retrieved, PACKAGE_NAME);
}
Also used : KiePMMLDroolsAST(org.kie.pmml.models.drools.ast.KiePMMLDroolsAST) PackageDescr(org.drools.drl.ast.descr.PackageDescr) CompositePackageDescr(org.drools.compiler.lang.descr.CompositePackageDescr) Test(org.junit.Test)

Example 12 with KiePMMLDroolsAST

use of org.kie.pmml.models.drools.ast.KiePMMLDroolsAST in project drools by kiegroup.

the class DroolsModelProviderTest method getKiePMMLDroolsASTCommon.

@Test
public void getKiePMMLDroolsASTCommon() {
    final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>();
    final List<Field<?>> fields = getFieldsFromDataDictionaryAndTransformationDictionaryAndLocalTransformations(pmml.getDataDictionary(), pmml.getTransformationDictionary(), scorecard.getLocalTransformations());
    KiePMMLDroolsAST retrieved = droolsModelProvider.getKiePMMLDroolsASTCommon(fields, scorecard, fieldTypeMap);
    commonVerifyKiePMMLDroolsAST(retrieved, fieldTypeMap);
    commonVerifyFieldTypeMap(fieldTypeMap, pmml.getDataDictionary().getDataFields(), pmml.getTransformationDictionary().getDerivedFields(), scorecard.getLocalTransformations().getDerivedFields());
}
Also used : Field(org.dmg.pmml.Field) DerivedField(org.dmg.pmml.DerivedField) DataField(org.dmg.pmml.DataField) KiePMMLDroolsAST(org.kie.pmml.models.drools.ast.KiePMMLDroolsAST) HashMap(java.util.HashMap) KiePMMLOriginalTypeGeneratedType(org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType) Test(org.junit.Test)

Example 13 with KiePMMLDroolsAST

use of org.kie.pmml.models.drools.ast.KiePMMLDroolsAST in project drools by kiegroup.

the class KiePMMLTreeModelASTFactory method getKiePMMLDroolsAST.

/**
 * Returns the <code>KiePMMLDroolsAST</code> built out of the given parameters.
 * It also <b>populate</b> the <b>fieldNameTypeNameMap</b> with mapping between original field' name and <b>original type/generated type</b> tupla
 *
 * @param dataDictionary
 * @param model
 * @param fieldTypeMap
 * @param types
 * @return
 */
public static KiePMMLDroolsAST getKiePMMLDroolsAST(final List<Field<?>> fields, final TreeModel model, final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap, final List<KiePMMLDroolsType> types) {
    logger.trace("getKiePMMLDroolsAST {} {}", fields, model);
    DATA_TYPE targetType = getTargetFieldType(fields, model);
    List<OutputField> outputFields = model.getOutput() != null ? model.getOutput().getOutputFields() : Collections.emptyList();
    List<KiePMMLDroolsRule> rules = KiePMMLTreeModelNodeASTFactory.factory(fieldTypeMap, outputFields, model.getNoTrueChildStrategy(), targetType).declareRulesFromRootNode(model.getNode(), "");
    return new KiePMMLDroolsAST(types, rules);
}
Also used : KiePMMLDroolsAST(org.kie.pmml.models.drools.ast.KiePMMLDroolsAST) OutputField(org.dmg.pmml.OutputField) KiePMMLDroolsRule(org.kie.pmml.models.drools.ast.KiePMMLDroolsRule) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE)

Example 14 with KiePMMLDroolsAST

use of org.kie.pmml.models.drools.ast.KiePMMLDroolsAST in project drools by kiegroup.

the class KiePMMLTreeModelASTFactoryTest method getKiePMMLDroolsGolfingAST.

@Test
public void getKiePMMLDroolsGolfingAST() {
    final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = getFieldTypeMap(golfingPmml.getDataDictionary(), golfingPmml.getTransformationDictionary(), golfingModel.getLocalTransformations());
    List<KiePMMLDroolsType> types = Collections.emptyList();
    KiePMMLDroolsAST retrieved = KiePMMLTreeModelASTFactory.getKiePMMLDroolsAST(getFieldsFromDataDictionary(golfingPmml.getDataDictionary()), golfingModel, fieldTypeMap, types);
    assertNotNull(retrieved);
    assertEquals(types, retrieved.getTypes());
    assertFalse(retrieved.getRules().isEmpty());
}
Also used : KiePMMLDroolsAST(org.kie.pmml.models.drools.ast.KiePMMLDroolsAST) KiePMMLDroolsType(org.kie.pmml.models.drools.ast.KiePMMLDroolsType) KiePMMLOriginalTypeGeneratedType(org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType) Test(org.junit.Test)

Example 15 with KiePMMLDroolsAST

use of org.kie.pmml.models.drools.ast.KiePMMLDroolsAST in project drools by kiegroup.

the class KiePMMLTreeModelASTFactoryTest method getKiePMMLDroolsIrisAST.

@Test
public void getKiePMMLDroolsIrisAST() {
    final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = getFieldTypeMap(irisPmml.getDataDictionary(), irisPmml.getTransformationDictionary(), irisModel.getLocalTransformations());
    List<KiePMMLDroolsType> types = Collections.emptyList();
    KiePMMLDroolsAST retrieved = KiePMMLTreeModelASTFactory.getKiePMMLDroolsAST(getFieldsFromDataDictionary(irisPmml.getDataDictionary()), irisModel, fieldTypeMap, types);
    assertNotNull(retrieved);
    assertEquals(types, retrieved.getTypes());
    assertFalse(retrieved.getRules().isEmpty());
}
Also used : KiePMMLDroolsAST(org.kie.pmml.models.drools.ast.KiePMMLDroolsAST) KiePMMLDroolsType(org.kie.pmml.models.drools.ast.KiePMMLDroolsType) KiePMMLOriginalTypeGeneratedType(org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType) Test(org.junit.Test)

Aggregations

KiePMMLDroolsAST (org.kie.pmml.models.drools.ast.KiePMMLDroolsAST)15 KiePMMLOriginalTypeGeneratedType (org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType)11 Test (org.junit.Test)9 PackageDescr (org.drools.drl.ast.descr.PackageDescr)6 KiePMMLDroolsType (org.kie.pmml.models.drools.ast.KiePMMLDroolsType)6 HashMap (java.util.HashMap)5 CompositePackageDescr (org.drools.compiler.lang.descr.CompositePackageDescr)5 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)4 DATA_TYPE (org.kie.pmml.api.enums.DATA_TYPE)4 KiePMMLException (org.kie.pmml.api.exceptions.KiePMMLException)4 HasKnowledgeBuilder (org.kie.pmml.kie.dependencies.HasKnowledgeBuilder)4 IOException (java.io.IOException)3 KiePMMLDroolsRule (org.kie.pmml.models.drools.ast.KiePMMLDroolsRule)3 KiePMMLDroolsModelWithSources (org.kie.pmml.models.drools.commons.model.KiePMMLDroolsModelWithSources)3 ArrayList (java.util.ArrayList)2 DataDictionary (org.dmg.pmml.DataDictionary)2 DataField (org.dmg.pmml.DataField)2 Field (org.dmg.pmml.Field)2 OutputField (org.dmg.pmml.OutputField)2 EXPECTING_HAS_KNOWLEDGEBUILDER_TEMPLATE (org.kie.pmml.commons.Constants.EXPECTING_HAS_KNOWLEDGEBUILDER_TEMPLATE)2