use of org.kie.pmml.models.drools.ast.KiePMMLDroolsType in project drools by kiegroup.
the class KiePMMLTreeModelASTFactoryTest method getKiePMMLDroolsSimpleSetAST.
@Test
public void getKiePMMLDroolsSimpleSetAST() {
final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = getFieldTypeMap(simpleSetPmml.getDataDictionary(), simpleSetPmml.getTransformationDictionary(), simpleSetModel.getLocalTransformations());
List<KiePMMLDroolsType> types = Collections.emptyList();
KiePMMLDroolsAST retrieved = KiePMMLTreeModelASTFactory.getKiePMMLDroolsAST(getFieldsFromDataDictionary(simpleSetPmml.getDataDictionary()), simpleSetModel, fieldTypeMap, types);
assertNotNull(retrieved);
assertEquals(types, retrieved.getTypes());
assertFalse(retrieved.getRules().isEmpty());
}
use of org.kie.pmml.models.drools.ast.KiePMMLDroolsType in project drools by kiegroup.
the class KiePMMLDerivedFieldASTFactory method declareType.
/**
* Create a <code>KiePMMLDroolsType</code> out of original <code>DerivedField</code>,
* and <b>populate</b> the <b>fieldNameTypeNameMap</b> with mapping between original field' name and <b>original type/generated type</b> tupla
* @param derivedField
*/
public KiePMMLDroolsType declareType(DerivedField derivedField) {
String generatedType = getSanitizedClassName(derivedField.getName().getValue().toUpperCase());
String fieldName = derivedField.getName().getValue();
String fieldType = derivedField.getDataType().value();
fieldTypeMap.put(fieldName, new KiePMMLOriginalTypeGeneratedType(fieldType, generatedType));
return new KiePMMLDroolsType(generatedType, DATA_TYPE.byName(fieldType).getMappedClass().getSimpleName());
}
use of org.kie.pmml.models.drools.ast.KiePMMLDroolsType in project drools by kiegroup.
the class KiePMMLDataDictionaryASTFactoryTest method declareType.
@Test
public void declareType() {
DataField dataField = getTypeDataField();
final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>();
KiePMMLDroolsType retrieved = KiePMMLDataDictionaryASTFactory.factory(fieldTypeMap).declareType(dataField);
assertNotNull(retrieved);
commonVerifyTypeDeclarationDescr(dataField, fieldTypeMap, retrieved);
}
use of org.kie.pmml.models.drools.ast.KiePMMLDroolsType in project drools by kiegroup.
the class KiePMMLDescrTypesFactoryTest method declareType.
@Test
public void declareType() {
KiePMMLDroolsType type = KiePMMLDescrTestUtils.getDroolsType();
KiePMMLDescrTypesFactory.factory(builder).declareType(type);
assertEquals(1, builder.getDescr().getTypeDeclarations().size());
commonVerifyTypeDeclarationDescr(type, builder.getDescr().getTypeDeclarations().get(0));
}
use of org.kie.pmml.models.drools.ast.KiePMMLDroolsType in project drools by kiegroup.
the class KiePMMLDescrFactoryTest method getBaseDescr.
@Test
public void getBaseDescr() {
List<KiePMMLDroolsType> types = new ArrayList<>();
types.add(KiePMMLDescrTestUtils.getDroolsType());
types.add(KiePMMLDescrTestUtils.getDottedDroolsType());
List<KiePMMLFieldOperatorValue> orConstraints = Arrays.asList(new KiePMMLFieldOperatorValue(PATTERN_TYPE, BOOLEAN_OPERATOR.OR, Collections.singletonList(new KiePMMLOperatorValue(OPERATOR.LESS_THAN, 35)), null), new KiePMMLFieldOperatorValue(PATTERN_TYPE, BOOLEAN_OPERATOR.AND, Collections.singletonList(new KiePMMLOperatorValue(OPERATOR.GREATER_THAN, 85)), null));
KiePMMLDroolsRule rule = KiePMMLDroolsRule.builder(RULE_NAME, STATUS_TO_SET, Collections.emptyList()).withOrConstraints(orConstraints).build();
List<KiePMMLDroolsRule> rules = new ArrayList<>();
rules.add(rule);
KiePMMLDroolsAST drooledAST = new KiePMMLDroolsAST(types, rules);
PackageDescr packageDescr = KiePMMLDescrFactory.getBaseDescr(drooledAST, PACKAGE_NAME);
assertEquals(PACKAGE_NAME, packageDescr.getName());
checkImports(packageDescr.getImports());
checkGlobals(packageDescr.getGlobals());
checkRules(packageDescr.getRules());
}
Aggregations