@Test public void setConstructor() { ConstructorDeclaration constructorDeclaration = modelTemplate.getDefaultConstructor().get(); SimpleName generatedClassName = new SimpleName("GeneratedClassName"); String targetField = "targetField"; REGRESSION_NORMALIZATION_METHOD regressionNormalizationMethod = REGRESSION_NORMALIZATION_METHOD.CAUCHIT; OP_TYPE opType = OP_TYPE.CATEGORICAL; KiePMMLRegressionTableClassificationFactory.setConstructor(constructorDeclaration, generatedClassName, targetField, regressionNormalizationMethod, opType); Map<Integer, Expression> superInvocationExpressionsMap = new HashMap<>(); Map<String, Expression> assignExpressionMap = new HashMap<>(); assignExpressionMap.put("targetField", new StringLiteralExpr(targetField)); assignExpressionMap.put("regressionNormalizationMethod", new NameExpr(regressionNormalizationMethod.getClass().getSimpleName() + "." + regressionNormalizationMethod.name())); assignExpressionMap.put("opType", new NameExpr(opType.getClass().getSimpleName() + "." + opType.name())); assertTrue(commonEvaluateConstructor(constructorDeclaration, generatedClassName.asString(), superInvocationExpressionsMap, assignExpressionMap)); }
static void setConstructor(final ConstructorDeclaration constructorDeclaration, final SimpleName generatedClassName, final String targetField, final REGRESSION_NORMALIZATION_METHOD regressionNormalizationMethod, final OP_TYPE opType) { constructorDeclaration.setName(generatedClassName); final BlockStmt body = constructorDeclaration.getBody(); CommonCodegenUtils.setAssignExpressionValue(body, "targetField", new StringLiteralExpr(targetField)); CommonCodegenUtils.setAssignExpressionValue(body, "regressionNormalizationMethod", new NameExpr(regressionNormalizationMethod.getClass().getSimpleName() + "." + regressionNormalizationMethod.name())); if (opType != null) { CommonCodegenUtils.setAssignExpressionValue(body, "opType", new NameExpr(opType.getClass().getSimpleName() + "." + opType.name())); } }
KiePMMLRegressionTableClassificationFactory { static void setConstructor(final ConstructorDeclaration constructorDeclaration, final SimpleName generatedClassName, final String targetField, final REGRESSION_NORMALIZATION_METHOD regressionNormalizationMethod, final OP_TYPE opType) { constructorDeclaration.setName(generatedClassName); final BlockStmt body = constructorDeclaration.getBody(); CommonCodegenUtils.setAssignExpressionValue(body, "targetField", new StringLiteralExpr(targetField)); CommonCodegenUtils.setAssignExpressionValue(body, "regressionNormalizationMethod", new NameExpr(regressionNormalizationMethod.getClass().getSimpleName() + "." + regressionNormalizationMethod.name())); if (opType != null) { CommonCodegenUtils.setAssignExpressionValue(body, "opType", new NameExpr(opType.getClass().getSimpleName() + "." + opType.name())); } } }
KiePMMLRegressionTableClassificationFactory { static void setConstructor(final ConstructorDeclaration constructorDeclaration, final SimpleName generatedClassName, final String targetField, final REGRESSION_NORMALIZATION_METHOD regressionNormalizationMethod, final OP_TYPE opType) { constructorDeclaration.setName(generatedClassName); final BlockStmt body = constructorDeclaration.getBody(); CommonCodegenUtils.setAssignExpressionValue(body, "targetField", new StringLiteralExpr(targetField)); CommonCodegenUtils.setAssignExpressionValue(body, "regressionNormalizationMethod", new NameExpr(regressionNormalizationMethod.getClass().getSimpleName() + "." + regressionNormalizationMethod.name())); if (opType != null) { CommonCodegenUtils.setAssignExpressionValue(body, "opType", new NameExpr(opType.getClass().getSimpleName() + "." + opType.name())); } } private  KiePMMLRegressionTableClassificationFactory(); }
KiePMMLRegressionTableClassificationFactory { static void setConstructor(final ConstructorDeclaration constructorDeclaration, final SimpleName generatedClassName, final String targetField, final REGRESSION_NORMALIZATION_METHOD regressionNormalizationMethod, final OP_TYPE opType) { constructorDeclaration.setName(generatedClassName); final BlockStmt body = constructorDeclaration.getBody(); CommonCodegenUtils.setAssignExpressionValue(body, "targetField", new StringLiteralExpr(targetField)); CommonCodegenUtils.setAssignExpressionValue(body, "regressionNormalizationMethod", new NameExpr(regressionNormalizationMethod.getClass().getSimpleName() + "." + regressionNormalizationMethod.name())); if (opType != null) { CommonCodegenUtils.setAssignExpressionValue(body, "opType", new NameExpr(opType.getClass().getSimpleName() + "." + opType.name())); } } private  KiePMMLRegressionTableClassificationFactory(); static Map<String, KiePMMLTableSourceCategory> getRegressionTables(final List<RegressionTable> regressionTables, final RegressionModel.NormalizationMethod normalizationMethod, final OpType opType, final List<KiePMMLOutputField> outputFields, final String targetField, final String packageName); static Map.Entry<String, String> getRegressionTable(final LinkedHashMap<String, KiePMMLTableSourceCategory> regressionTablesMap, final RegressionModel.NormalizationMethod normalizationMethod, final OpType opType, final List<KiePMMLOutputField> outputFields, final String targetField, final String packageName); }
KiePMMLRegressionTableClassificationFactory { static void setConstructor(final ConstructorDeclaration constructorDeclaration, final SimpleName generatedClassName, final String targetField, final REGRESSION_NORMALIZATION_METHOD regressionNormalizationMethod, final OP_TYPE opType) { constructorDeclaration.setName(generatedClassName); final BlockStmt body = constructorDeclaration.getBody(); CommonCodegenUtils.setAssignExpressionValue(body, "targetField", new StringLiteralExpr(targetField)); CommonCodegenUtils.setAssignExpressionValue(body, "regressionNormalizationMethod", new NameExpr(regressionNormalizationMethod.getClass().getSimpleName() + "." + regressionNormalizationMethod.name())); if (opType != null) { CommonCodegenUtils.setAssignExpressionValue(body, "opType", new NameExpr(opType.getClass().getSimpleName() + "." + opType.name())); } } private  KiePMMLRegressionTableClassificationFactory(); static Map<String, KiePMMLTableSourceCategory> getRegressionTables(final List<RegressionTable> regressionTables, final RegressionModel.NormalizationMethod normalizationMethod, final OpType opType, final List<KiePMMLOutputField> outputFields, final String targetField, final String packageName); static Map.Entry<String, String> getRegressionTable(final LinkedHashMap<String, KiePMMLTableSourceCategory> regressionTablesMap, final RegressionModel.NormalizationMethod normalizationMethod, final OpType opType, final List<KiePMMLOutputField> outputFields, final String targetField, final String packageName); static final String KIE_PMML_REGRESSION_TABLE_CLASSIFICATION_TEMPLATE_JAVA; static final String KIE_PMML_REGRESSION_TABLE_CLASSIFICATION_TEMPLATE; }