@Test public void setConstructor() { Model model = new TreeModel(); PMML_MODEL pmmlModel = PMML_MODEL.byName(model.getClass().getSimpleName()); ConstructorDeclaration constructorDeclaration = MODEL_TEMPLATE.getDefaultConstructor().get(); SimpleName tableName = new SimpleName("TABLE_NAME"); String targetField = "TARGET_FIELD"; MINING_FUNCTION miningFunction = MINING_FUNCTION.CLASSIFICATION; KiePMMLDroolsModelFactoryUtils.setConstructor(model, constructorDeclaration, tableName, targetField, miningFunction); Map<Integer, Expression> superInvocationExpressionsMap = new HashMap<>(); Map<String, Expression> assignExpressionMap = new HashMap<>(); assignExpressionMap.put("targetField", new StringLiteralExpr(targetField)); assignExpressionMap.put("miningFunction", new NameExpr(miningFunction.getClass().getName() + "." + miningFunction.name())); assignExpressionMap.put("pmmlMODEL", new NameExpr(pmmlModel.getClass().getName() + "." + pmmlModel.name())); assertTrue(commonEvaluateConstructor(constructorDeclaration, tableName.asString(), superInvocationExpressionsMap, assignExpressionMap)); }
static void setConstructor(final Model model, final ConstructorDeclaration constructorDeclaration, final SimpleName tableName, final String targetField, final MINING_FUNCTION miningFunction) { constructorDeclaration.setName(tableName); final BlockStmt body = constructorDeclaration.getBody(); CommonCodegenUtils.setAssignExpressionValue(body, "targetField", new StringLiteralExpr(targetField)); CommonCodegenUtils.setAssignExpressionValue(body, "miningFunction", new NameExpr(miningFunction.getClass().getName() + "." + miningFunction.name())); PMML_MODEL pmmlModel = PMML_MODEL.byName(model.getClass().getSimpleName()); CommonCodegenUtils.setAssignExpressionValue(body, "pmmlMODEL", new NameExpr(pmmlModel.getClass().getName() + "." + pmmlModel.name())); }
KiePMMLDroolsModelFactoryUtils { static void setConstructor(final Model model, final ConstructorDeclaration constructorDeclaration, final SimpleName tableName, final String targetField, final MINING_FUNCTION miningFunction) { constructorDeclaration.setName(tableName); final BlockStmt body = constructorDeclaration.getBody(); CommonCodegenUtils.setAssignExpressionValue(body, "targetField", new StringLiteralExpr(targetField)); CommonCodegenUtils.setAssignExpressionValue(body, "miningFunction", new NameExpr(miningFunction.getClass().getName() + "." + miningFunction.name())); PMML_MODEL pmmlModel = PMML_MODEL.byName(model.getClass().getSimpleName()); CommonCodegenUtils.setAssignExpressionValue(body, "pmmlMODEL", new NameExpr(pmmlModel.getClass().getName() + "." + pmmlModel.name())); } }
KiePMMLDroolsModelFactoryUtils { static void setConstructor(final Model model, final ConstructorDeclaration constructorDeclaration, final SimpleName tableName, final String targetField, final MINING_FUNCTION miningFunction) { constructorDeclaration.setName(tableName); final BlockStmt body = constructorDeclaration.getBody(); CommonCodegenUtils.setAssignExpressionValue(body, "targetField", new StringLiteralExpr(targetField)); CommonCodegenUtils.setAssignExpressionValue(body, "miningFunction", new NameExpr(miningFunction.getClass().getName() + "." + miningFunction.name())); PMML_MODEL pmmlModel = PMML_MODEL.byName(model.getClass().getSimpleName()); CommonCodegenUtils.setAssignExpressionValue(body, "pmmlMODEL", new NameExpr(pmmlModel.getClass().getName() + "." + pmmlModel.name())); } private  KiePMMLDroolsModelFactoryUtils(); }
KiePMMLDroolsModelFactoryUtils { static void setConstructor(final Model model, final ConstructorDeclaration constructorDeclaration, final SimpleName tableName, final String targetField, final MINING_FUNCTION miningFunction) { constructorDeclaration.setName(tableName); final BlockStmt body = constructorDeclaration.getBody(); CommonCodegenUtils.setAssignExpressionValue(body, "targetField", new StringLiteralExpr(targetField)); CommonCodegenUtils.setAssignExpressionValue(body, "miningFunction", new NameExpr(miningFunction.getClass().getName() + "." + miningFunction.name())); PMML_MODEL pmmlModel = PMML_MODEL.byName(model.getClass().getSimpleName()); CommonCodegenUtils.setAssignExpressionValue(body, "pmmlMODEL", new NameExpr(pmmlModel.getClass().getName() + "." + pmmlModel.name())); } private  KiePMMLDroolsModelFactoryUtils(); static CompilationUnit getKiePMMLModelCompilationUnit(final DataDictionary dataDictionary,
                                                                 final Model model,
                                                                 final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap,
                                                                 final String packageName,
                                                                 final String javaTemplate,
                                                                 final String modelClassName); }
KiePMMLDroolsModelFactoryUtils { static void setConstructor(final Model model, final ConstructorDeclaration constructorDeclaration, final SimpleName tableName, final String targetField, final MINING_FUNCTION miningFunction) { constructorDeclaration.setName(tableName); final BlockStmt body = constructorDeclaration.getBody(); CommonCodegenUtils.setAssignExpressionValue(body, "targetField", new StringLiteralExpr(targetField)); CommonCodegenUtils.setAssignExpressionValue(body, "miningFunction", new NameExpr(miningFunction.getClass().getName() + "." + miningFunction.name())); PMML_MODEL pmmlModel = PMML_MODEL.byName(model.getClass().getSimpleName()); CommonCodegenUtils.setAssignExpressionValue(body, "pmmlMODEL", new NameExpr(pmmlModel.getClass().getName() + "." + pmmlModel.name())); } private  KiePMMLDroolsModelFactoryUtils(); static CompilationUnit getKiePMMLModelCompilationUnit(final DataDictionary dataDictionary,
                                                                 final Model model,
                                                                 final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap,
                                                                 final String packageName,
                                                                 final String javaTemplate,
                                                                 final String modelClassName);  }