use of org.kie.pmml.api.enums.REASONCODE_ALGORITHM in project drools by kiegroup.
the class KiePMMLScorecardModelFactory method setConstructor.
static void setConstructor(final ScorecardCompilationDTO compilationDTO, final ClassOrInterfaceDeclaration modelTemplate, final String fullCharacteristicsClassName) {
KiePMMLModelFactoryUtils.init(compilationDTO, modelTemplate);
final ConstructorDeclaration constructorDeclaration = modelTemplate.getDefaultConstructor().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_DEFAULT_CONSTRUCTOR, modelTemplate.getName())));
final BlockStmt body = constructorDeclaration.getBody();
final ExplicitConstructorInvocationStmt superStatement = CommonCodegenUtils.getExplicitConstructorInvocationStmt(body).orElseThrow(() -> new KiePMMLException(String.format(MISSING_CONSTRUCTOR_IN_BODY, body)));
ClassOrInterfaceType characteristicsClass = parseClassOrInterfaceType(fullCharacteristicsClassName);
ObjectCreationExpr characteristicsReference = new ObjectCreationExpr();
characteristicsReference.setType(characteristicsClass);
superStatement.setArgument(2, characteristicsReference);
superStatement.setArgument(3, getExpressionForObject(compilationDTO.getInitialScore()));
superStatement.setArgument(4, getExpressionForObject(compilationDTO.isUseReasonCodes()));
REASONCODE_ALGORITHM reasoncodeAlgorithm = compilationDTO.getREASONCODE_ALGORITHM();
NameExpr reasonCodeExpr = new NameExpr(REASONCODE_ALGORITHM.class.getName() + "." + reasoncodeAlgorithm.name());
superStatement.setArgument(5, reasonCodeExpr);
superStatement.setArgument(6, getExpressionForObject(compilationDTO.getBaselineScore()));
}
Aggregations