use of org.dmg.pmml.DefineFunction in project drools by kiegroup.
the class InstanceFactoriesTestCommon method commonVerifyKiePMMLDefineFunction.
static void commonVerifyKiePMMLDefineFunction(KiePMMLDefineFunction toVerify, DefineFunction source) {
assertNotNull(toVerify);
assertEquals(source.getName(), toVerify.getName());
DATA_TYPE expectedDataType = DATA_TYPE.byName(source.getDataType().value());
assertEquals(expectedDataType, toVerify.getDataType());
OP_TYPE expectedOpType = OP_TYPE.byName(source.getOpType().value());
assertEquals(expectedOpType, toVerify.getOpType());
commonVerifyKiePMMLExpression(toVerify.getKiePMMLExpression(), source.getExpression());
List<ParameterField> sourcesParameterFields = source.getParameterFields();
List<KiePMMLParameterField> toVerifyList = toVerify.getParameterFields();
assertEquals(sourcesParameterFields.size(), toVerifyList.size());
sourcesParameterFields.forEach(paramSource -> {
Optional<KiePMMLParameterField> parameterToVerify = toVerifyList.stream().filter(param -> param.getName().equals(paramSource.getName().getValue())).findFirst();
assertTrue(parameterToVerify.isPresent());
commonVerifyKiePMMLParameterField(parameterToVerify.get(), paramSource);
});
}
use of org.dmg.pmml.DefineFunction in project drools by kiegroup.
the class KiePMMLTransformationDictionaryFactory method addDefineFunctions.
static NodeList<Expression> addDefineFunctions(final BlockStmt body, final List<DefineFunction> defineFunctions) {
NodeList<Expression> arguments = new NodeList<>();
for (DefineFunction defineFunction : defineFunctions) {
arguments.add(new NameExpr(defineFunction.getName()));
BlockStmt toAdd = getDefineFunctionVariableDeclaration(defineFunction);
toAdd.getStatements().forEach(body::addStatement);
}
return getArraysAsListInvocation(arguments);
}
Aggregations