Browse Source

[DSIP-39][parameter] Improvement startup parameters/global parameters/project parameters data type (#15967)

* [Improvement][parameter] New data types and type filtering

* [Improvement][parameter] Improvement startup parameters/global parameters data type

* fix api interfaces compatible

* add project parameter data type default value

* [Improvement][parameter] New data types and type filtering

* [Improvement][parameter] Improvement startup parameters/global parameters data type

* fix api interfaces compatible

* add project parameter data type default value

* improvement project code

* remove useless imports

* remove method onClearSearchTaskType

* add parameter doc

* optimisation logic

* code conflict resolution

* code conflict resolution

* [Improvement][Monitor] Show master && worker Busy Or Normal Status and Show Commands table list (#15978)

* update

* test

* add monitor enhance ui

* update

* update

* update doc

* fix spotless

* update

* update

* Update dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java

Co-authored-by: Wenjun Ruan <wenjun@apache.org>

* Update dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java

Co-authored-by: Wenjun Ruan <wenjun@apache.org>

* Update dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.java

Co-authored-by: Wenjun Ruan <wenjun@apache.org>

* Update dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.xml

Co-authored-by: Wenjun Ruan <wenjun@apache.org>

* Update dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/CommandMapper.java

Co-authored-by: Wenjun Ruan <wenjun@apache.org>

* Update dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ErrorCommandMapper.xml

Co-authored-by: Wenjun Ruan <wenjun@apache.org>

* update

* fix spotless

* update

---------

Co-authored-by: Wenjun Ruan <wenjun@apache.org>

* [Improvement][Monitor] Add UT for montor (#15998)

* formatting Code
upstream-dev
小可耐 6 months ago committed by GitHub
parent
commit
0fc2fe971a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      docs/docs/en/guide/parameter/global.md
  2. 2
      docs/docs/en/guide/parameter/project-parameter.md
  3. 2
      docs/docs/en/guide/parameter/startup-parameter.md
  4. 2
      docs/docs/zh/guide/parameter/global.md
  5. 2
      docs/docs/zh/guide/parameter/project-parameter.md
  6. 2
      docs/docs/zh/guide/parameter/startup-parameter.md
  7. BIN
      docs/img/new_ui/dev/parameter/context-subprocess02.png
  8. BIN
      docs/img/new_ui/dev/parameter/context_parameter04.png
  9. BIN
      docs/img/new_ui/dev/parameter/global_parameter02.png
  10. BIN
      docs/img/new_ui/dev/parameter/project_parameter01.png
  11. BIN
      docs/img/new_ui/dev/parameter/startup_parameter02.png
  12. BIN
      docs/img/new_ui/dev/parameter/startup_parameter04.png
  13. 18
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ExecutorController.java
  14. 17
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProjectParameterController.java
  15. 6
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
  16. 6
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectParameterService.java
  17. 13
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java
  18. 11
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectParameterServiceImpl.java
  19. 8
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ExecuteFunctionControllerTest.java
  20. 16
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProjectParameterControllerTest.java
  21. 40
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectParameterServiceTest.java
  22. 3
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectParameter.java
  23. 3
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectParameterMapper.java
  24. 7
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectParameterMapper.xml
  25. 1
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
  26. 1
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
  27. 1
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
  28. 4
      dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.2_schema/mysql/dolphinscheduler_ddl.sql
  29. 4
      dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.2_schema/postgresql/dolphinscheduler_ddl.sql
  30. 2
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectParameterMapperTest.java
  31. 23
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/expand/CuringParamsServiceImpl.java
  32. 64
      dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/PropertyUtils.java
  33. 2
      dolphinscheduler-ui/src/locales/en_US/project.ts
  34. 2
      dolphinscheduler-ui/src/locales/zh_CN/project.ts
  35. 3
      dolphinscheduler-ui/src/service/modules/projects-parameter/types.ts
  36. 20
      dolphinscheduler-ui/src/views/projects/parameter/components/parameter-modal.tsx
  37. 20
      dolphinscheduler-ui/src/views/projects/parameter/components/use-modal.ts
  38. 54
      dolphinscheduler-ui/src/views/projects/parameter/data_type.ts
  39. 15
      dolphinscheduler-ui/src/views/projects/parameter/index.tsx
  40. 9
      dolphinscheduler-ui/src/views/projects/parameter/use-table.ts
  41. 30
      dolphinscheduler-ui/src/views/projects/workflow/components/dag/dag-save-modal.tsx
  42. 1
      dolphinscheduler-ui/src/views/projects/workflow/components/dag/types.ts
  43. 115
      dolphinscheduler-ui/src/views/projects/workflow/definition/components/start-modal.tsx
  44. 10
      dolphinscheduler-ui/src/views/projects/workflow/definition/components/use-modal.ts
  45. 2
      dolphinscheduler-ui/src/views/projects/workflow/definition/create/index.tsx
  46. 2
      dolphinscheduler-ui/src/views/projects/workflow/definition/detail/index.tsx
  47. 2
      dolphinscheduler-ui/src/views/projects/workflow/instance/detail/index.tsx

2
docs/docs/en/guide/parameter/global.md

@ -22,7 +22,7 @@ Create a shell task and enter `echo ${dt}` in the script content. In this case,
### Save the workflow and set global parameters ### Save the workflow and set global parameters
Set global parameter: On the workflow definition page, click the plus sign to the right of "Set Global", after filling in the variable name and value, save it. Set global parameter: On the workflow definition page, click the plus sign to the right of "Set Global", after filling in the variable name and value, select the appropriate parameter value type, save it.
![global-parameter02](../../../../img/new_ui/dev/parameter/global_parameter02.png) ![global-parameter02](../../../../img/new_ui/dev/parameter/global_parameter02.png)

2
docs/docs/en/guide/parameter/project-parameter.md

@ -8,7 +8,7 @@ Project-level parameters are valid for all task nodes under the entire project.
### Define project-level parameters ### Define project-level parameters
On the project page, click Project Parameters and Create Parameters, and fill in the parameter name and parameter value. As shown below: On the project page, click Project Parameters and Create Parameters, and fill in the parameter name and parameter value, select the appropriate parameter value type. As shown below:
![project-parameter01](../../../../img/new_ui/dev/parameter/project_parameter01.png) ![project-parameter01](../../../../img/new_ui/dev/parameter/project_parameter01.png)

2
docs/docs/en/guide/parameter/startup-parameter.md

@ -6,7 +6,7 @@ Parameters are valid for all task nodes of the entire workflow. It can be config
## Usage ## Usage
Usage of startup parameters is: at the task launch page, click the '+' below the 'Startup Parameter' and fill in the key and value to save. The workflow will add them into global parameters. Usage of startup parameters is: at the task launch page, click the '+' below the 'Startup Parameter' and fill in the key and value, select the appropriate parameter value type then to save. The workflow will add them into global parameters.
## Example ## Example

2
docs/docs/zh/guide/parameter/global.md

@ -20,7 +20,7 @@
### 保存工作流,并设置全局参数 ### 保存工作流,并设置全局参数
全局参数配置方式如下:在工作流定义页面,点击“设置全局”右边的加号,填写对应的变量名称和对应的值,保存即可。如下图所示: 全局参数配置方式如下:在工作流定义页面,点击“设置全局”右边的加号,填写对应的变量名称和对应的值,选择相应的参数值类型,保存即可。如下图所示:
![global-parameter02](../../../../img/new_ui/dev/parameter/global_parameter02.png) ![global-parameter02](../../../../img/new_ui/dev/parameter/global_parameter02.png)

2
docs/docs/zh/guide/parameter/project-parameter.md

@ -8,7 +8,7 @@
### 定义项目级别参数 ### 定义项目级别参数
在项目管理页面,点击项目级别参数,点击创建项目级别参数,填写参数名称和参数值。如下图所示: 在项目管理页面,点击项目级别参数,点击创建项目级别参数,填写参数名称和参数值,选择相应的参数值类型。如下图所示:
![project-parameter01](../../../../img/new_ui/dev/parameter/project_parameter01.png) ![project-parameter01](../../../../img/new_ui/dev/parameter/project_parameter01.png)

2
docs/docs/zh/guide/parameter/startup-parameter.md

@ -6,7 +6,7 @@
## 使用方式 ## 使用方式
启动参数配置方式如下:在启动前参数设置界面,点击“启动参数“下面的加号,填写对应的参数名称和对应的值,点击确定,工作流会将启动参数加入全局参数中。 启动参数配置方式如下:在启动前参数设置界面,点击“启动参数“下面的加号,填写对应的参数名称和对应的值,选择相应的参数值类型,点击确定,工作流会将启动参数加入全局参数中。
## 任务样例 ## 任务样例

BIN
docs/img/new_ui/dev/parameter/context-subprocess02.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 327 KiB

BIN
docs/img/new_ui/dev/parameter/context_parameter04.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

After

Width:  |  Height:  |  Size: 338 KiB

BIN
docs/img/new_ui/dev/parameter/global_parameter02.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 326 KiB

BIN
docs/img/new_ui/dev/parameter/project_parameter01.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 MiB

After

Width:  |  Height:  |  Size: 118 KiB

BIN
docs/img/new_ui/dev/parameter/startup_parameter02.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 346 KiB

After

Width:  |  Height:  |  Size: 196 KiB

BIN
docs/img/new_ui/dev/parameter/startup_parameter04.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 KiB

After

Width:  |  Height:  |  Size: 195 KiB

18
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ExecutorController.java

@ -44,6 +44,8 @@ import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.extract.master.dto.WorkflowExecuteDto; import org.apache.dolphinscheduler.extract.master.dto.WorkflowExecuteDto;
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
import org.apache.dolphinscheduler.plugin.task.api.utils.PropertyUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -163,10 +165,8 @@ public class ExecutorController extends BaseController {
if (timeout == null) { if (timeout == null) {
timeout = Constants.MAX_TASK_TIMEOUT; timeout = Constants.MAX_TASK_TIMEOUT;
} }
Map<String, String> startParamMap = null;
if (startParams != null) { List<Property> startParamList = PropertyUtils.startParamsTransformPropertyList(startParams);
startParamMap = JSONUtils.toMap(startParams);
}
if (complementDependentMode == null) { if (complementDependentMode == null) {
complementDependentMode = ComplementDependentMode.OFF_MODE; complementDependentMode = ComplementDependentMode.OFF_MODE;
@ -175,7 +175,7 @@ public class ExecutorController extends BaseController {
Map<String, Object> result = execService.execProcessInstance(loginUser, projectCode, processDefinitionCode, Map<String, Object> result = execService.execProcessInstance(loginUser, projectCode, processDefinitionCode,
scheduleTime, execType, failureStrategy, scheduleTime, execType, failureStrategy,
startNodeList, taskDependType, warningType, warningGroupId, runMode, processInstancePriority, startNodeList, taskDependType, warningType, warningGroupId, runMode, processInstancePriority,
workerGroup, tenantCode, environmentCode, timeout, startParamMap, expectedParallelismNumber, dryRun, workerGroup, tenantCode, environmentCode, timeout, startParamList, expectedParallelismNumber, dryRun,
testFlag, testFlag,
complementDependentMode, version, allLevelDependent, executionOrder); complementDependentMode, version, allLevelDependent, executionOrder);
return returnDataList(result); return returnDataList(result);
@ -262,10 +262,7 @@ public class ExecutorController extends BaseController {
timeout = Constants.MAX_TASK_TIMEOUT; timeout = Constants.MAX_TASK_TIMEOUT;
} }
Map<String, String> startParamMap = null; List<Property> startParamList = PropertyUtils.startParamsTransformPropertyList(startParams);
if (startParams != null) {
startParamMap = JSONUtils.toMap(startParams);
}
if (complementDependentMode == null) { if (complementDependentMode == null) {
log.debug("Parameter complementDependentMode set to {} due to null.", ComplementDependentMode.OFF_MODE); log.debug("Parameter complementDependentMode set to {} due to null.", ComplementDependentMode.OFF_MODE);
@ -283,7 +280,8 @@ public class ExecutorController extends BaseController {
result = execService.execProcessInstance(loginUser, projectCode, processDefinitionCode, scheduleTime, result = execService.execProcessInstance(loginUser, projectCode, processDefinitionCode, scheduleTime,
execType, failureStrategy, execType, failureStrategy,
startNodeList, taskDependType, warningType, warningGroupId, runMode, processInstancePriority, startNodeList, taskDependType, warningType, warningGroupId, runMode, processInstancePriority,
workerGroup, tenantCode, environmentCode, timeout, startParamMap, expectedParallelismNumber, dryRun, workerGroup, tenantCode, environmentCode, timeout, startParamList, expectedParallelismNumber,
dryRun,
testFlag, testFlag,
complementDependentMode, null, allLevelDependent, executionOrder); complementDependentMode, null, allLevelDependent, executionOrder);

17
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProjectParameterController.java

@ -61,7 +61,8 @@ public class ProjectParameterController extends BaseController {
@Operation(summary = "createProjectParameter", description = "CREATE_PROJECT_PARAMETER_NOTES") @Operation(summary = "createProjectParameter", description = "CREATE_PROJECT_PARAMETER_NOTES")
@Parameters({ @Parameters({
@Parameter(name = "projectParameterName", description = "PROJECT_PARAMETER_NAME", schema = @Schema(implementation = String.class)), @Parameter(name = "projectParameterName", description = "PROJECT_PARAMETER_NAME", schema = @Schema(implementation = String.class)),
@Parameter(name = "projectParameterValue", description = "PROJECT_PARAMETER_VALUE", schema = @Schema(implementation = String.class)) @Parameter(name = "projectParameterValue", description = "PROJECT_PARAMETER_VALUE", schema = @Schema(implementation = String.class)),
@Parameter(name = "projectParameterDataType", description = "PROJECT_PARAMETER_DATA_TYPE", schema = @Schema(implementation = String.class))
}) })
@PostMapping() @PostMapping()
@ResponseStatus(HttpStatus.CREATED) @ResponseStatus(HttpStatus.CREATED)
@ -69,9 +70,10 @@ public class ProjectParameterController extends BaseController {
public Result createProjectParameter(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result createProjectParameter(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, @Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@RequestParam("projectParameterName") String projectParameterName, @RequestParam("projectParameterName") String projectParameterName,
@RequestParam(value = "projectParameterValue") String projectParameterValue) { @RequestParam(value = "projectParameterValue") String projectParameterValue,
@RequestParam(value = "projectParameterDataType", defaultValue = "VARCHAR") String projectParameterDataType) {
return projectParameterService.createProjectParameter(loginUser, projectCode, projectParameterName, return projectParameterService.createProjectParameter(loginUser, projectCode, projectParameterName,
projectParameterValue); projectParameterValue, projectParameterDataType);
} }
@Operation(summary = "updateProjectParameter", description = "UPDATE_PROJECT_PARAMETER_NOTES") @Operation(summary = "updateProjectParameter", description = "UPDATE_PROJECT_PARAMETER_NOTES")
@ -79,6 +81,7 @@ public class ProjectParameterController extends BaseController {
@Parameter(name = "code", description = "PROJECT_PARAMETER_CODE", schema = @Schema(implementation = long.class, example = "123456")), @Parameter(name = "code", description = "PROJECT_PARAMETER_CODE", schema = @Schema(implementation = long.class, example = "123456")),
@Parameter(name = "projectParameterName", description = "PROJECT_PARAMETER_NAME", schema = @Schema(implementation = String.class)), @Parameter(name = "projectParameterName", description = "PROJECT_PARAMETER_NAME", schema = @Schema(implementation = String.class)),
@Parameter(name = "projectParameterValue", description = "PROJECT_PARAMETER_VALUE", schema = @Schema(implementation = String.class)), @Parameter(name = "projectParameterValue", description = "PROJECT_PARAMETER_VALUE", schema = @Schema(implementation = String.class)),
@Parameter(name = "projectParameterDataType", description = "PROJECT_PARAMETER_DATA_TYPE", schema = @Schema(implementation = String.class))
}) })
@PutMapping(value = "/{code}") @PutMapping(value = "/{code}")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ -87,9 +90,10 @@ public class ProjectParameterController extends BaseController {
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, @Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@PathVariable("code") Long code, @PathVariable("code") Long code,
@RequestParam("projectParameterName") String projectParameterName, @RequestParam("projectParameterName") String projectParameterName,
@RequestParam(value = "projectParameterValue") String projectParameterValue) { @RequestParam(value = "projectParameterValue") String projectParameterValue,
@RequestParam(value = "projectParameterDataType") String projectParameterDataType) {
return projectParameterService.updateProjectParameter(loginUser, projectCode, code, projectParameterName, return projectParameterService.updateProjectParameter(loginUser, projectCode, code, projectParameterName,
projectParameterValue); projectParameterValue, projectParameterDataType);
} }
@Operation(summary = "deleteProjectParametersByCode", description = "DELETE_PROJECT_PARAMETER_NOTES") @Operation(summary = "deleteProjectParametersByCode", description = "DELETE_PROJECT_PARAMETER_NOTES")
@ -133,13 +137,14 @@ public class ProjectParameterController extends BaseController {
@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, @Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, @Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam(value = "searchVal", required = false) String searchVal,
@RequestParam(value = "projectParameterDataType", required = false) String projectParameterDataType,
@RequestParam("pageNo") Integer pageNo, @RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) { @RequestParam("pageSize") Integer pageSize) {
checkPageParams(pageNo, pageSize); checkPageParams(pageNo, pageSize);
searchVal = ParameterUtils.handleEscapes(searchVal); searchVal = ParameterUtils.handleEscapes(searchVal);
return projectParameterService.queryProjectParameterListPaging(loginUser, projectCode, pageSize, pageNo, return projectParameterService.queryProjectParameterListPaging(loginUser, projectCode, pageSize, pageNo,
searchVal); searchVal, projectParameterDataType);
} }
@Operation(summary = "queryProjectParameterByCode", description = "QUERY_PROJECT_PARAMETER_NOTES") @Operation(summary = "queryProjectParameterByCode", description = "QUERY_PROJECT_PARAMETER_NOTES")

6
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java

@ -30,7 +30,9 @@ import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.extract.master.dto.WorkflowExecuteDto; import org.apache.dolphinscheduler.extract.master.dto.WorkflowExecuteDto;
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -57,7 +59,7 @@ public interface ExecutorService {
* @param environmentCode environment code * @param environmentCode environment code
* @param runMode run mode * @param runMode run mode
* @param timeout timeout * @param timeout timeout
* @param startParams the global param values which pass to new process instance * @param startParamList the global param values which pass to new process instance
* @param expectedParallelismNumber the expected parallelism number when execute complement in parallel mode * @param expectedParallelismNumber the expected parallelism number when execute complement in parallel mode
* @param executionOrder the execution order when complementing data * @param executionOrder the execution order when complementing data
* @return execute process instance code * @return execute process instance code
@ -71,7 +73,7 @@ public interface ExecutorService {
Priority processInstancePriority, String workerGroup, String tenantCode, Priority processInstancePriority, String workerGroup, String tenantCode,
Long environmentCode, Long environmentCode,
Integer timeout, Integer timeout,
Map<String, String> startParams, Integer expectedParallelismNumber, List<Property> startParamList, Integer expectedParallelismNumber,
int dryRun, int testFlag, int dryRun, int testFlag,
ComplementDependentMode complementDependentMode, Integer version, ComplementDependentMode complementDependentMode, Integer version,
boolean allLevelDependent, ExecutionOrder executionOrder); boolean allLevelDependent, ExecutionOrder executionOrder);

6
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProjectParameterService.java

@ -23,17 +23,17 @@ import org.apache.dolphinscheduler.dao.entity.User;
public interface ProjectParameterService { public interface ProjectParameterService {
Result createProjectParameter(User loginUser, long projectCode, String projectParameterName, Result createProjectParameter(User loginUser, long projectCode, String projectParameterName,
String projectParameterValue); String projectParameterValue, String projectParameterDataType);
Result updateProjectParameter(User loginUser, long projectCode, long code, String projectParameterName, Result updateProjectParameter(User loginUser, long projectCode, long code, String projectParameterName,
String projectParameterValue); String projectParameterValue, String projectParameterDataType);
Result deleteProjectParametersByCode(User loginUser, long projectCode, long code); Result deleteProjectParametersByCode(User loginUser, long projectCode, long code);
Result batchDeleteProjectParametersByCodes(User loginUser, long projectCode, String codes); Result batchDeleteProjectParametersByCodes(User loginUser, long projectCode, String codes);
Result queryProjectParameterListPaging(User loginUser, long projectCode, Integer pageSize, Integer pageNo, Result queryProjectParameterListPaging(User loginUser, long projectCode, Integer pageSize, Integer pageNo,
String searchVal); String searchVal, String projectParameterDataType);
Result queryProjectParameterByCode(User loginUser, long projectCode, long code); Result queryProjectParameterByCode(User loginUser, long projectCode, long code);
} }

13
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ExecutorServiceImpl.java

@ -90,6 +90,7 @@ import org.apache.dolphinscheduler.extract.master.transportor.StreamingTaskTrigg
import org.apache.dolphinscheduler.extract.master.transportor.StreamingTaskTriggerResponse; import org.apache.dolphinscheduler.extract.master.transportor.StreamingTaskTriggerResponse;
import org.apache.dolphinscheduler.extract.master.transportor.WorkflowInstanceStateChangeEvent; import org.apache.dolphinscheduler.extract.master.transportor.WorkflowInstanceStateChangeEvent;
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants; import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
import org.apache.dolphinscheduler.registry.api.enums.RegistryNodeType; import org.apache.dolphinscheduler.registry.api.enums.RegistryNodeType;
import org.apache.dolphinscheduler.service.command.CommandService; import org.apache.dolphinscheduler.service.command.CommandService;
import org.apache.dolphinscheduler.service.cron.CronUtils; import org.apache.dolphinscheduler.service.cron.CronUtils;
@ -204,7 +205,7 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
* @param environmentCode environment code * @param environmentCode environment code
* @param runMode run mode * @param runMode run mode
* @param timeout timeout * @param timeout timeout
* @param startParams the global param values which pass to new process instance * @param startParamList the global param values which pass to new process instance
* @param expectedParallelismNumber the expected parallelism number when execute complement in parallel mode * @param expectedParallelismNumber the expected parallelism number when execute complement in parallel mode
* @param testFlag testFlag * @param testFlag testFlag
* @param executionOrder the execution order when complementing data * @param executionOrder the execution order when complementing data
@ -220,7 +221,7 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
Priority processInstancePriority, String workerGroup, Priority processInstancePriority, String workerGroup,
String tenantCode, String tenantCode,
Long environmentCode, Integer timeout, Long environmentCode, Integer timeout,
Map<String, String> startParams, Integer expectedParallelismNumber, List<Property> startParamList, Integer expectedParallelismNumber,
int dryRun, int testFlag, int dryRun, int testFlag,
ComplementDependentMode complementDependentMode, Integer version, ComplementDependentMode complementDependentMode, Integer version,
boolean allLevelDependent, ExecutionOrder executionOrder) { boolean allLevelDependent, ExecutionOrder executionOrder) {
@ -270,7 +271,7 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
startNodeList, startNodeList,
cronTime, warningType, loginUser.getId(), warningGroupId, runMode, processInstancePriority, cronTime, warningType, loginUser.getId(), warningGroupId, runMode, processInstancePriority,
workerGroup, tenantCode, workerGroup, tenantCode,
environmentCode, startParams, expectedParallelismNumber, dryRun, testFlag, environmentCode, startParamList, expectedParallelismNumber, dryRun, testFlag,
complementDependentMode, allLevelDependent, executionOrder); complementDependentMode, allLevelDependent, executionOrder);
if (create > 0) { if (create > 0) {
@ -732,7 +733,7 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
WarningType warningType, int executorId, Integer warningGroupId, RunMode runMode, WarningType warningType, int executorId, Integer warningGroupId, RunMode runMode,
Priority processInstancePriority, String workerGroup, String tenantCode, Priority processInstancePriority, String workerGroup, String tenantCode,
Long environmentCode, Long environmentCode,
Map<String, String> startParams, Integer expectedParallelismNumber, int dryRun, List<Property> startParamList, Integer expectedParallelismNumber, int dryRun,
int testFlag, ComplementDependentMode complementDependentMode, int testFlag, ComplementDependentMode complementDependentMode,
boolean allLevelDependent, ExecutionOrder executionOrder) { boolean allLevelDependent, ExecutionOrder executionOrder) {
@ -761,8 +762,8 @@ public class ExecutorServiceImpl extends BaseServiceImpl implements ExecutorServ
if (warningType != null) { if (warningType != null) {
command.setWarningType(warningType); command.setWarningType(warningType);
} }
if (startParams != null && startParams.size() > 0) { if (CollectionUtils.isNotEmpty(startParamList)) {
cmdParam.put(CMD_PARAM_START_PARAMS, JSONUtils.toJsonString(startParams)); cmdParam.put(CMD_PARAM_START_PARAMS, JSONUtils.toJsonString(startParamList));
} }
command.setCommandParam(JSONUtils.toJsonString(cmdParam)); command.setCommandParam(JSONUtils.toJsonString(cmdParam));
command.setExecutorId(executorId); command.setExecutorId(executorId);

11
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectParameterServiceImpl.java

@ -68,7 +68,7 @@ public class ProjectParameterServiceImpl extends BaseServiceImpl implements Proj
@Override @Override
@Transactional @Transactional
public Result createProjectParameter(User loginUser, long projectCode, String projectParameterName, public Result createProjectParameter(User loginUser, long projectCode, String projectParameterName,
String projectParameterValue) { String projectParameterValue, String projectParameterDataType) {
Result result = new Result(); Result result = new Result();
// check if user have write perm for project // check if user have write perm for project
@ -97,6 +97,7 @@ public class ProjectParameterServiceImpl extends BaseServiceImpl implements Proj
.builder() .builder()
.paramName(projectParameterName) .paramName(projectParameterName)
.paramValue(projectParameterValue) .paramValue(projectParameterValue)
.paramDataType(projectParameterDataType)
.code(CodeGenerateUtils.genCode()) .code(CodeGenerateUtils.genCode())
.projectCode(projectCode) .projectCode(projectCode)
.userId(loginUser.getId()) .userId(loginUser.getId())
@ -122,7 +123,7 @@ public class ProjectParameterServiceImpl extends BaseServiceImpl implements Proj
@Override @Override
public Result updateProjectParameter(User loginUser, long projectCode, long code, String projectParameterName, public Result updateProjectParameter(User loginUser, long projectCode, long code, String projectParameterName,
String projectParameterValue) { String projectParameterValue, String projectParameterDataType) {
Result result = new Result(); Result result = new Result();
// check if user have write perm for project // check if user have write perm for project
@ -155,6 +156,7 @@ public class ProjectParameterServiceImpl extends BaseServiceImpl implements Proj
projectParameter.setParamName(projectParameterName); projectParameter.setParamName(projectParameterName);
projectParameter.setParamValue(projectParameterValue); projectParameter.setParamValue(projectParameterValue);
projectParameter.setParamDataType(projectParameterDataType);
projectParameter.setUpdateTime(new Date()); projectParameter.setUpdateTime(new Date());
projectParameter.setOperator(loginUser.getId()); projectParameter.setOperator(loginUser.getId());
@ -236,7 +238,7 @@ public class ProjectParameterServiceImpl extends BaseServiceImpl implements Proj
@Override @Override
public Result queryProjectParameterListPaging(User loginUser, long projectCode, Integer pageSize, Integer pageNo, public Result queryProjectParameterListPaging(User loginUser, long projectCode, Integer pageSize, Integer pageNo,
String searchVal) { String searchVal, String projectParameterDataType) {
Result result = new Result(); Result result = new Result();
Project project = projectMapper.queryByCode(projectCode); Project project = projectMapper.queryByCode(projectCode);
@ -249,7 +251,8 @@ public class ProjectParameterServiceImpl extends BaseServiceImpl implements Proj
Page<ProjectParameter> page = new Page<>(pageNo, pageSize); Page<ProjectParameter> page = new Page<>(pageNo, pageSize);
IPage<ProjectParameter> iPage = IPage<ProjectParameter> iPage =
projectParameterMapper.queryProjectParameterListPaging(page, projectCode, null, searchVal); projectParameterMapper.queryProjectParameterListPaging(page, projectCode, null, searchVal,
projectParameterDataType);
List<ProjectParameter> projectParameterList = iPage.getRecords(); List<ProjectParameter> projectParameterList = iPage.getRecords();

8
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ExecuteFunctionControllerTest.java

@ -38,8 +38,13 @@ import org.apache.dolphinscheduler.common.enums.RunMode;
import org.apache.dolphinscheduler.common.enums.TaskDependType; import org.apache.dolphinscheduler.common.enums.TaskDependType;
import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.plugin.task.api.enums.DataType;
import org.apache.dolphinscheduler.plugin.task.api.enums.Direct;
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -75,7 +80,8 @@ public class ExecuteFunctionControllerTest extends AbstractControllerTest {
final String tenantCode = "root"; final String tenantCode = "root";
final Long environmentCode = 4L; final Long environmentCode = 4L;
final Integer timeout = 5; final Integer timeout = 5;
final ImmutableMap<String, String> startParams = ImmutableMap.of("start", "params"); final List<Property> startParams =
Collections.singletonList(new Property("start", Direct.IN, DataType.VARCHAR, "params"));
final Integer expectedParallelismNumber = 6; final Integer expectedParallelismNumber = 6;
final int dryRun = 7; final int dryRun = 7;
final int testFlag = 0; final int testFlag = 0;

16
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProjectParameterControllerTest.java

@ -22,6 +22,7 @@ import org.apache.dolphinscheduler.api.service.impl.ProjectParameterServiceImpl;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.plugin.task.api.enums.DataType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -48,8 +49,9 @@ public class ProjectParameterControllerTest {
User loginUser = getGeneralUser(); User loginUser = getGeneralUser();
Mockito.when(projectParameterService.createProjectParameter(Mockito.any(), Mockito.anyLong(), Mockito.any(), Mockito.when(projectParameterService.createProjectParameter(Mockito.any(), Mockito.anyLong(), Mockito.any(),
Mockito.any())).thenReturn(getSuccessResult()); Mockito.any(), Mockito.any())).thenReturn(getSuccessResult());
Result result = projectParameterController.createProjectParameter(loginUser, 1, "key", "value"); Result result = projectParameterController.createProjectParameter(loginUser, 1, "key", "value",
DataType.VARCHAR.name());
Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode()); Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode());
} }
@ -58,8 +60,9 @@ public class ProjectParameterControllerTest {
User loginUser = getGeneralUser(); User loginUser = getGeneralUser();
Mockito.when(projectParameterService.updateProjectParameter(Mockito.any(), Mockito.anyLong(), Mockito.anyLong(), Mockito.when(projectParameterService.updateProjectParameter(Mockito.any(), Mockito.anyLong(), Mockito.anyLong(),
Mockito.any(), Mockito.any())).thenReturn(getSuccessResult()); Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(getSuccessResult());
Result result = projectParameterController.updateProjectParameter(loginUser, 1, 1L, "key", "value"); Result result = projectParameterController.updateProjectParameter(loginUser, 1, 1L, "key", "value",
DataType.LONG.name());
Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode()); Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode());
} }
@ -88,8 +91,9 @@ public class ProjectParameterControllerTest {
User loginUser = getGeneralUser(); User loginUser = getGeneralUser();
Mockito.when(projectParameterService.queryProjectParameterListPaging(Mockito.any(), Mockito.anyLong(), Mockito.when(projectParameterService.queryProjectParameterListPaging(Mockito.any(), Mockito.anyLong(),
Mockito.anyInt(), Mockito.anyInt(), Mockito.any())).thenReturn(getSuccessResult()); Mockito.anyInt(), Mockito.anyInt(), Mockito.any(), Mockito.any())).thenReturn(getSuccessResult());
Result result = projectParameterController.queryProjectParameterListPaging(loginUser, 1, "1", 1, 10); Result result = projectParameterController.queryProjectParameterListPaging(loginUser, 1, "1",
DataType.VARCHAR.name(), 1, 10);
Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode()); Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode());
} }

40
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectParameterServiceTest.java

@ -36,6 +36,7 @@ import org.apache.dolphinscheduler.dao.entity.ProjectParameter;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectParameterMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectParameterMapper;
import org.apache.dolphinscheduler.plugin.task.api.enums.DataType;
import java.util.Collections; import java.util.Collections;
@ -76,7 +77,8 @@ public class ProjectParameterServiceTest {
// PERMISSION DENIED // PERMISSION DENIED
when(projectService.hasProjectAndWritePerm(Mockito.any(), Mockito.any(), Mockito.any(Result.class))) when(projectService.hasProjectAndWritePerm(Mockito.any(), Mockito.any(), Mockito.any(Result.class)))
.thenReturn(false); .thenReturn(false);
Result result = projectParameterService.createProjectParameter(loginUser, projectCode, "key", "value"); Result result = projectParameterService.createProjectParameter(loginUser, projectCode, "key", "value",
DataType.VARCHAR.name());
assertNull(result.getData()); assertNull(result.getData());
assertNull(result.getCode()); assertNull(result.getCode());
assertNull(result.getMsg()); assertNull(result.getMsg());
@ -88,25 +90,29 @@ public class ProjectParameterServiceTest {
try (MockedStatic<CodeGenerateUtils> ignored = Mockito.mockStatic(CodeGenerateUtils.class)) { try (MockedStatic<CodeGenerateUtils> ignored = Mockito.mockStatic(CodeGenerateUtils.class)) {
when(CodeGenerateUtils.genCode()).thenThrow(CodeGenerateUtils.CodeGenerateException.class); when(CodeGenerateUtils.genCode()).thenThrow(CodeGenerateUtils.CodeGenerateException.class);
result = projectParameterService.createProjectParameter(loginUser, projectCode, "key", "value"); result = projectParameterService.createProjectParameter(loginUser, projectCode, "key", "value",
DataType.VARCHAR.name());
assertEquals(Status.CREATE_PROJECT_PARAMETER_ERROR.getCode(), result.getCode()); assertEquals(Status.CREATE_PROJECT_PARAMETER_ERROR.getCode(), result.getCode());
} }
// PROJECT_PARAMETER_ALREADY_EXISTS // PROJECT_PARAMETER_ALREADY_EXISTS
when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode));
when(projectParameterMapper.selectOne(Mockito.any())).thenReturn(getProjectParameter()); when(projectParameterMapper.selectOne(Mockito.any())).thenReturn(getProjectParameter());
result = projectParameterService.createProjectParameter(loginUser, projectCode, "key", "value"); result = projectParameterService.createProjectParameter(loginUser, projectCode, "key", "value",
DataType.VARCHAR.name());
assertEquals(Status.PROJECT_PARAMETER_ALREADY_EXISTS.getCode(), result.getCode()); assertEquals(Status.PROJECT_PARAMETER_ALREADY_EXISTS.getCode(), result.getCode());
// INSERT DATA ERROR // INSERT DATA ERROR
when(projectParameterMapper.selectOne(Mockito.any())).thenReturn(null); when(projectParameterMapper.selectOne(Mockito.any())).thenReturn(null);
when(projectParameterMapper.insert(Mockito.any())).thenReturn(-1); when(projectParameterMapper.insert(Mockito.any())).thenReturn(-1);
result = projectParameterService.createProjectParameter(loginUser, projectCode, "key1", "value"); result = projectParameterService.createProjectParameter(loginUser, projectCode, "key1", "value",
DataType.VARCHAR.name());
assertEquals(Status.CREATE_PROJECT_PARAMETER_ERROR.getCode(), result.getCode()); assertEquals(Status.CREATE_PROJECT_PARAMETER_ERROR.getCode(), result.getCode());
// SUCCESS // SUCCESS
when(projectParameterMapper.insert(Mockito.any())).thenReturn(1); when(projectParameterMapper.insert(Mockito.any())).thenReturn(1);
result = projectParameterService.createProjectParameter(loginUser, projectCode, "key1", "value"); result = projectParameterService.createProjectParameter(loginUser, projectCode, "key1", "value",
DataType.VARCHAR.name());
assertEquals(Status.SUCCESS.getCode(), result.getCode()); assertEquals(Status.SUCCESS.getCode(), result.getCode());
} }
@ -117,7 +123,8 @@ public class ProjectParameterServiceTest {
// NO PERMISSION // NO PERMISSION
when(projectService.hasProjectAndWritePerm(Mockito.any(), Mockito.any(), Mockito.any(Result.class))) when(projectService.hasProjectAndWritePerm(Mockito.any(), Mockito.any(), Mockito.any(Result.class)))
.thenReturn(false); .thenReturn(false);
Result result = projectParameterService.updateProjectParameter(loginUser, projectCode, 1, "key", "value"); Result result = projectParameterService.updateProjectParameter(loginUser, projectCode, 1, "key", "value",
DataType.VARCHAR.name());
assertNull(result.getData()); assertNull(result.getData());
assertNull(result.getCode()); assertNull(result.getCode());
assertNull(result.getMsg()); assertNull(result.getMsg());
@ -127,28 +134,33 @@ public class ProjectParameterServiceTest {
when(projectService.hasProjectAndWritePerm(Mockito.any(), Mockito.any(), Mockito.any(Result.class))) when(projectService.hasProjectAndWritePerm(Mockito.any(), Mockito.any(), Mockito.any(Result.class)))
.thenReturn(true); .thenReturn(true);
when(projectParameterMapper.queryByCode(Mockito.anyLong())).thenReturn(null); when(projectParameterMapper.queryByCode(Mockito.anyLong())).thenReturn(null);
result = projectParameterService.updateProjectParameter(loginUser, projectCode, 1, "key", "value"); result = projectParameterService.updateProjectParameter(loginUser, projectCode, 1, "key", "value",
DataType.VARCHAR.name());
assertEquals(Status.PROJECT_PARAMETER_NOT_EXISTS.getCode(), result.getCode()); assertEquals(Status.PROJECT_PARAMETER_NOT_EXISTS.getCode(), result.getCode());
// PROJECT_PARAMETER_ALREADY_EXISTS // PROJECT_PARAMETER_ALREADY_EXISTS
when(projectParameterMapper.queryByCode(Mockito.anyLong())).thenReturn(getProjectParameter()); when(projectParameterMapper.queryByCode(Mockito.anyLong())).thenReturn(getProjectParameter());
when(projectParameterMapper.selectOne(Mockito.any())).thenReturn(getProjectParameter()); when(projectParameterMapper.selectOne(Mockito.any())).thenReturn(getProjectParameter());
result = projectParameterService.updateProjectParameter(loginUser, projectCode, 1, "key", "value"); result = projectParameterService.updateProjectParameter(loginUser, projectCode, 1, "key", "value",
DataType.VARCHAR.name());
assertEquals(Status.PROJECT_PARAMETER_ALREADY_EXISTS.getCode(), result.getCode()); assertEquals(Status.PROJECT_PARAMETER_ALREADY_EXISTS.getCode(), result.getCode());
// PROJECT_UPDATE_ERROR // PROJECT_UPDATE_ERROR
when(projectParameterMapper.selectOne(Mockito.any())).thenReturn(null); when(projectParameterMapper.selectOne(Mockito.any())).thenReturn(null);
when(projectParameterMapper.updateById(Mockito.any())).thenReturn(-1); when(projectParameterMapper.updateById(Mockito.any())).thenReturn(-1);
result = projectParameterService.updateProjectParameter(loginUser, projectCode, 1, "key1", "value"); result = projectParameterService.updateProjectParameter(loginUser, projectCode, 1, "key1", "value",
DataType.VARCHAR.name());
assertEquals(Status.UPDATE_PROJECT_PARAMETER_ERROR.getCode(), result.getCode()); assertEquals(Status.UPDATE_PROJECT_PARAMETER_ERROR.getCode(), result.getCode());
// SUCCESS // SUCCESS
when(projectParameterMapper.updateById(Mockito.any())).thenReturn(1); when(projectParameterMapper.updateById(Mockito.any())).thenReturn(1);
result = projectParameterService.updateProjectParameter(loginUser, projectCode, 1, "key1", "value"); result = projectParameterService.updateProjectParameter(loginUser, projectCode, 1, "key1", "value",
DataType.LONG.name());
assertEquals(Status.SUCCESS.getCode(), result.getCode()); assertEquals(Status.SUCCESS.getCode(), result.getCode());
ProjectParameter projectParameter = (ProjectParameter) result.getData(); ProjectParameter projectParameter = (ProjectParameter) result.getData();
assertNotNull(projectParameter.getOperator()); assertNotNull(projectParameter.getOperator());
assertNotNull(projectParameter.getUpdateTime()); assertNotNull(projectParameter.getUpdateTime());
assertEquals(DataType.LONG.name(), projectParameter.getParamDataType());
} }
@Test @Test
@ -223,7 +235,8 @@ public class ProjectParameterServiceTest {
.thenReturn(false); .thenReturn(false);
Result result = Result result =
projectParameterService.queryProjectParameterListPaging(loginUser, projectCode, pageSize, pageNo, null); projectParameterService.queryProjectParameterListPaging(loginUser, projectCode, pageSize, pageNo, null,
DataType.VARCHAR.name());
assertNull(result.getData()); assertNull(result.getData());
assertNull(result.getCode()); assertNull(result.getCode());
assertNull(result.getMsg()); assertNull(result.getMsg());
@ -235,9 +248,10 @@ public class ProjectParameterServiceTest {
Page<ProjectParameter> page = new Page<>(pageNo, pageSize); Page<ProjectParameter> page = new Page<>(pageNo, pageSize);
page.setRecords(Collections.singletonList(getProjectParameter())); page.setRecords(Collections.singletonList(getProjectParameter()));
when(projectParameterMapper.queryProjectParameterListPaging(any(), anyLong(), any(), any())).thenReturn(page); when(projectParameterMapper.queryProjectParameterListPaging(any(), anyLong(), any(), any(), any()))
.thenReturn(page);
result = projectParameterService.queryProjectParameterListPaging(loginUser, projectCode, pageSize, pageNo, result = projectParameterService.queryProjectParameterListPaging(loginUser, projectCode, pageSize, pageNo,
null); null, null);
assertEquals(Status.SUCCESS.getCode(), result.getCode()); assertEquals(Status.SUCCESS.getCode(), result.getCode());
} }

3
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProjectParameter.java

@ -55,6 +55,9 @@ public class ProjectParameter {
@TableField("param_value") @TableField("param_value")
private String paramValue; private String paramValue;
@TableField("param_data_type")
private String paramDataType;
private Date createTime; private Date createTime;
private Date updateTime; private Date updateTime;

3
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProjectParameterMapper.java

@ -38,7 +38,8 @@ public interface ProjectParameterMapper extends BaseMapper<ProjectParameter> {
IPage<ProjectParameter> queryProjectParameterListPaging(IPage<ProjectParameter> page, IPage<ProjectParameter> queryProjectParameterListPaging(IPage<ProjectParameter> page,
@Param("projectCode") long projectCode, @Param("projectCode") long projectCode,
@Param("projectParameterIds") List<Integer> projectParameterIds, @Param("projectParameterIds") List<Integer> projectParameterIds,
@Param("searchName") String searchName); @Param("searchName") String searchName,
@Param("projectParameterDataType") String projectParameterDataType);
List<ProjectParameter> queryByProjectCode(@Param("projectCode") long projectCode); List<ProjectParameter> queryByProjectCode(@Param("projectCode") long projectCode);
} }

7
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectParameterMapper.xml

@ -19,7 +19,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProjectParameterMapper"> <mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProjectParameterMapper">
<sql id="baseSql"> <sql id="baseSql">
id, param_name, param_value, code, project_code, user_id, operator, create_time, update_time id, param_name, param_value, param_data_type, code, project_code, user_id, operator, create_time, update_time
</sql> </sql>
<select id="queryByCode" resultType="org.apache.dolphinscheduler.dao.entity.ProjectParameter"> <select id="queryByCode" resultType="org.apache.dolphinscheduler.dao.entity.ProjectParameter">
@ -51,7 +51,7 @@
<select id="queryProjectParameterListPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProjectParameter"> <select id="queryProjectParameterListPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProjectParameter">
select select
pp.id, param_name, param_value, code, project_code, user_id, operator, pp.create_time, pp.update_time, pp.id, param_name, param_value, param_data_type, code, project_code, user_id, operator, pp.create_time, pp.update_time,
u.user_name as create_user, u.user_name as create_user,
u2.user_name as modify_user u2.user_name as modify_user
from t_ds_project_parameter pp from t_ds_project_parameter pp
@ -69,6 +69,9 @@
OR param_value LIKE concat('%', #{searchName}, '%') OR param_value LIKE concat('%', #{searchName}, '%')
) )
</if> </if>
<if test="projectParameterDataType!=null and projectParameterDataType != ''">
AND param_data_type = #{projectParameterDataType}
</if>
order by pp.update_time desc order by pp.update_time desc
</select> </select>

1
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql

@ -667,6 +667,7 @@ CREATE TABLE t_ds_project_parameter
id int(11) NOT NULL AUTO_INCREMENT, id int(11) NOT NULL AUTO_INCREMENT,
param_name varchar(255) NOT NULL, param_name varchar(255) NOT NULL,
param_value text NOT NULL, param_value text NOT NULL,
param_data_type varchar(50) DEFAULT 'VARCHAR',
code bigint(20) NOT NULL, code bigint(20) NOT NULL,
project_code bigint(20) NOT NULL, project_code bigint(20) NOT NULL,
user_id int(11) DEFAULT NULL, user_id int(11) DEFAULT NULL,

1
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql

@ -668,6 +668,7 @@ CREATE TABLE `t_ds_project_parameter` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key', `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key',
`param_name` varchar(255) NOT NULL COMMENT 'project parameter name', `param_name` varchar(255) NOT NULL COMMENT 'project parameter name',
`param_value` text NOT NULL COMMENT 'project parameter value', `param_value` text NOT NULL COMMENT 'project parameter value',
`param_data_type` varchar(50) DEFAULT 'VARCHAR' COMMENT 'project parameter data type',
`code` bigint(20) NOT NULL COMMENT 'encoding', `code` bigint(20) NOT NULL COMMENT 'encoding',
`project_code` bigint(20) NOT NULL COMMENT 'project code', `project_code` bigint(20) NOT NULL COMMENT 'project code',
`user_id` int(11) DEFAULT NULL COMMENT 'creator id', `user_id` int(11) DEFAULT NULL COMMENT 'creator id',

1
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql

@ -595,6 +595,7 @@ CREATE TABLE t_ds_project_parameter (
id int NOT NULL , id int NOT NULL ,
param_name varchar(255) NOT NULL , param_name varchar(255) NOT NULL ,
param_value text NOT NULL , param_value text NOT NULL ,
param_data_type varchar(50) DEFAULT 'VARCHAR',
code bigint NOT NULL, code bigint NOT NULL,
project_code bigint NOT NULL, project_code bigint NOT NULL,
user_id int DEFAULT NULL , user_id int DEFAULT NULL ,

4
dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.2_schema/mysql/dolphinscheduler_ddl.sql

@ -53,4 +53,6 @@ END;
d// d//
delimiter ; delimiter ;
CALL modify_data_t_ds_audit_log_input_entry; CALL modify_data_t_ds_audit_log_input_entry;
DROP PROCEDURE modify_data_t_ds_audit_log_input_entry; DROP PROCEDURE modify_data_t_ds_audit_log_input_entry;
ALTER TABLE t_ds_project_parameter ADD `param_data_type` varchar (50) DEFAULT 'VARCHAR' COMMENT 'project parameter data type';

4
dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.2_schema/postgresql/dolphinscheduler_ddl.sql

@ -56,4 +56,6 @@ $$ LANGUAGE plpgsql;
d// d//
select modify_data_t_ds_audit_log_input_entry(); select modify_data_t_ds_audit_log_input_entry();
DROP FUNCTION IF EXISTS modify_data_t_ds_audit_log_input_entry(); DROP FUNCTION IF EXISTS modify_data_t_ds_audit_log_input_entry();
ALTER TABLE t_ds_project_parameter ADD COLUMN IF NOT EXISTS param_data_type varchar(50) DEFAULT 'VARCHAR';

2
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectParameterMapperTest.java

@ -89,7 +89,7 @@ public class ProjectParameterMapperTest extends BaseDaoTest {
insertOne(2, "name2", 2); insertOne(2, "name2", 2);
Page<ProjectParameter> page = new Page(1, 3); Page<ProjectParameter> page = new Page(1, 3);
IPage<ProjectParameter> res = projectParameterMapper.queryProjectParameterListPaging(page, 1, null, null); IPage<ProjectParameter> res = projectParameterMapper.queryProjectParameterListPaging(page, 1, null, null, null);
Assertions.assertEquals(1, res.getRecords().size()); Assertions.assertEquals(1, res.getRecords().size());
} }
} }

23
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/expand/CuringParamsServiceImpl.java

@ -45,7 +45,9 @@ import org.apache.dolphinscheduler.plugin.task.api.model.Property;
import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils; import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
import org.apache.dolphinscheduler.plugin.task.api.utils.PropertyUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.Date; import java.util.Date;
@ -54,6 +56,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -150,9 +153,11 @@ public class CuringParamsServiceImpl implements CuringParamsService {
return new HashMap<>(); return new HashMap<>();
} }
String startParamJson = cmdParam.get(CommandKeyConstants.CMD_PARAM_START_PARAMS); String startParamJson = cmdParam.get(CommandKeyConstants.CMD_PARAM_START_PARAMS);
Map<String, String> startParamMap = JSONUtils.toMap(startParamJson); List<Property> propertyList = PropertyUtils.startParamsTransformPropertyList(startParamJson);
return startParamMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, if (CollectionUtils.isEmpty(propertyList)) {
entry -> new Property(entry.getKey(), Direct.IN, DataType.VARCHAR, entry.getValue()))); return new HashMap<>();
}
return propertyList.stream().collect(Collectors.toMap(Property::getProp, Function.identity()));
} }
@Override @Override
@ -181,8 +186,7 @@ public class CuringParamsServiceImpl implements CuringParamsService {
Map<String, Property> prepareParamsMap = new HashMap<>(); Map<String, Property> prepareParamsMap = new HashMap<>();
// assign value to definedParams here // assign value to definedParams here
Map<String, String> globalParamsMap = setGlobalParamsMap(processInstance); Map<String, Property> globalParams = setGlobalParamsMap(processInstance);
Map<String, Property> globalParams = ParameterUtils.getUserDefParamsMap(globalParamsMap);
// combining local and global parameters // combining local and global parameters
Map<String, Property> localParams = parameters.getInputLocalParametersMap(); Map<String, Property> localParams = parameters.getInputLocalParametersMap();
@ -287,15 +291,16 @@ public class CuringParamsServiceImpl implements CuringParamsService {
Long.toString(taskInstance.getProcessInstance().getProcessDefinition().getProjectCode())); Long.toString(taskInstance.getProcessInstance().getProcessDefinition().getProjectCode()));
return params; return params;
} }
private Map<String, String> setGlobalParamsMap(ProcessInstance processInstance) { private Map<String, Property> setGlobalParamsMap(ProcessInstance processInstance) {
Map<String, String> globalParamsMap = new HashMap<>(16); Map<String, Property> globalParamsMap = new HashMap<>(16);
// global params string // global params string
String globalParamsStr = processInstance.getGlobalParams(); String globalParamsStr = processInstance.getGlobalParams();
if (globalParamsStr != null) { if (globalParamsStr != null) {
List<Property> globalParamsList = JSONUtils.toList(globalParamsStr, Property.class); List<Property> globalParamsList = JSONUtils.toList(globalParamsStr, Property.class);
globalParamsMap globalParamsMap
.putAll(globalParamsList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue))); .putAll(globalParamsList.stream()
.collect(Collectors.toMap(Property::getProp, Function.identity())));
} }
return globalParamsMap; return globalParamsMap;
} }
@ -323,7 +328,7 @@ public class CuringParamsServiceImpl implements CuringParamsService {
projectParameterList.forEach(projectParameter -> { projectParameterList.forEach(projectParameter -> {
Property property = new Property(projectParameter.getParamName(), Property property = new Property(projectParameter.getParamName(),
Direct.IN, Direct.IN,
DataType.VARCHAR, Enum.valueOf(DataType.class, projectParameter.getParamDataType()),
projectParameter.getParamValue()); projectParameter.getParamValue());
result.put(projectParameter.getParamName(), property); result.put(projectParameter.getParamName(), property);
}); });

64
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/PropertyUtils.java

@ -0,0 +1,64 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.plugin.task.api.utils;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.enums.DataType;
import org.apache.dolphinscheduler.plugin.task.api.enums.Direct;
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
/**
* property utils
*/
public class PropertyUtils {
private PropertyUtils() {
throw new IllegalStateException("PropertyUtils class");
}
/**
* startParams transform propertyList
*
* @param startParams startParams
* @return startParamList
*/
public static List<Property> startParamsTransformPropertyList(String startParams) {
List<Property> startParamList = null;
if (startParams != null) {
JsonElement jsonElement = JsonParser.parseString(startParams);
boolean isJson = jsonElement.isJsonObject();
if (isJson) {
Map<String, String> startParamMap = JSONUtils.toMap(startParams);
startParamList = startParamMap.entrySet().stream()
.map(entry -> new Property(entry.getKey(), Direct.IN, DataType.VARCHAR, entry.getValue()))
.collect(Collectors.toList());
} else {
startParamList = JSONUtils.toList(startParams, Property.class);
}
}
return startParamList;
}
}

2
dolphinscheduler-ui/src/locales/en_US/project.ts

@ -930,12 +930,14 @@ export default {
code: 'Parameter Code', code: 'Parameter Code',
name: 'Parameter Name', name: 'Parameter Name',
value: 'Parameter Value', value: 'Parameter Value',
data_type: 'Parameter Data Type',
create_user: 'Create User', create_user: 'Create User',
modify_user: 'Modify User', modify_user: 'Modify User',
create_time: 'Create Time', create_time: 'Create Time',
update_time: 'Update Time', update_time: 'Update Time',
name_tips: 'Please enter your parameter name', name_tips: 'Please enter your parameter name',
value_tips: 'Please enter your parameter value', value_tips: 'Please enter your parameter value',
data_type_tips: 'Please choose your parameter data type',
operation: 'Operation', operation: 'Operation',
edit: 'Edit', edit: 'Edit',
delete: 'Delete', delete: 'Delete',

2
dolphinscheduler-ui/src/locales/zh_CN/project.ts

@ -900,12 +900,14 @@ export default {
code: '参数编码', code: '参数编码',
name: '参数名称', name: '参数名称',
value: '参数值', value: '参数值',
data_type: '参数类型',
create_user: '创建用户', create_user: '创建用户',
modify_user: '修改用户', modify_user: '修改用户',
create_time: '创建时间', create_time: '创建时间',
update_time: '更新时间', update_time: '更新时间',
name_tips: '请输入参数名称', name_tips: '请输入参数名称',
value_tips: '请输入参数值', value_tips: '请输入参数值',
data_type_tips: '请选择参数类型',
operation: '操作', operation: '操作',
edit: '编辑', edit: '编辑',
delete: '删除', delete: '删除',

3
dolphinscheduler-ui/src/service/modules/projects-parameter/types.ts

@ -19,6 +19,7 @@ interface ListReq {
pageNo: number pageNo: number
pageSize: number pageSize: number
searchVal?: string searchVal?: string
projectParameterDataType?: string
} }
interface ProjectParameterCodeReq { interface ProjectParameterCodeReq {
@ -28,6 +29,7 @@ interface ProjectParameterCodeReq {
interface ProjectParameterReq { interface ProjectParameterReq {
projectParameterName: string projectParameterName: string
projectParameterValue: string projectParameterValue: string
projectParameterDataType: string
} }
interface UpdateProjectParameterReq extends ProjectParameterReq { interface UpdateProjectParameterReq extends ProjectParameterReq {
@ -39,6 +41,7 @@ interface ProjectParameterList {
code: number code: number
name: string name: string
value: string value: string
data_type: string
createTime: string createTime: string
updateTime: string updateTime: string
} }

20
dolphinscheduler-ui/src/views/projects/parameter/components/parameter-modal.tsx

@ -23,9 +23,10 @@ import {
watch watch
} from 'vue' } from 'vue'
import Modal from '@/components/modal' import Modal from '@/components/modal'
import { NForm, NFormItem, NInput } from 'naive-ui' import { NForm, NFormItem, NInput, NSelect } from 'naive-ui'
import { useModal } from './use-modal' import { useModal } from './use-modal'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { DATA_TYPES_MAP, DEFAULT_DATA_TYPE } from "@/views/projects/parameter/data_type"
const ParameterModal = defineComponent({ const ParameterModal = defineComponent({
name: 'ParameterModal', name: 'ParameterModal',
@ -52,9 +53,11 @@ const ParameterModal = defineComponent({
if (props.statusRef === 0) { if (props.statusRef === 0) {
variables.model.projectParameterName = '' variables.model.projectParameterName = ''
variables.model.projectParameterValue = '' variables.model.projectParameterValue = ''
variables.model.projectParameterDataType = DEFAULT_DATA_TYPE
} else { } else {
variables.model.projectParameterName = props.row.paramName variables.model.projectParameterName = props.row.paramName
variables.model.projectParameterValue = props.row.paramValue variables.model.projectParameterValue = props.row.paramValue
variables.model.projectParameterDataType = props.row.paramDataType
} }
ctx.emit('cancelModal', props.showModalRef) ctx.emit('cancelModal', props.showModalRef)
} }
@ -78,10 +81,12 @@ const ParameterModal = defineComponent({
if (props.statusRef === 0) { if (props.statusRef === 0) {
variables.model.projectParameterName = '' variables.model.projectParameterName = ''
variables.model.projectParameterValue = '' variables.model.projectParameterValue = ''
variables.model.projectParameterDataType = DEFAULT_DATA_TYPE
} else { } else {
variables.model.code = props.row.code variables.model.code = props.row.code
variables.model.projectParameterName = props.row.paramName variables.model.projectParameterName = props.row.paramName
variables.model.projectParameterValue = props.row.paramValue variables.model.projectParameterValue = props.row.paramValue
variables.model.projectParameterDataType = props.row.paramDataType
} }
} }
) )
@ -92,6 +97,7 @@ const ParameterModal = defineComponent({
variables.model.code = props.row.code variables.model.code = props.row.code
variables.model.projectParameterName = props.row.paramName variables.model.projectParameterName = props.row.paramName
variables.model.projectParameterValue = props.row.paramValue variables.model.projectParameterValue = props.row.paramValue
variables.model.projectParameterDataType = props.row.paramDataType
} }
) )
@ -112,7 +118,8 @@ const ParameterModal = defineComponent({
onConfirm={this.confirmModal} onConfirm={this.confirmModal}
confirmDisabled={ confirmDisabled={
!this.model.projectParameterName || !this.model.projectParameterName ||
!this.model.projectParameterValue !this.model.projectParameterValue ||
!this.model.projectParameterDataType
} }
confirmClassName='btn-submit' confirmClassName='btn-submit'
cancelClassName='btn-cancel' cancelClassName='btn-cancel'
@ -135,6 +142,15 @@ const ParameterModal = defineComponent({
v-model={[this.model.projectParameterValue, 'value']} v-model={[this.model.projectParameterValue, 'value']}
/> />
</NFormItem> </NFormItem>
<NFormItem label={t('project.parameter.data_type')} path='data_type'>
<NSelect
placeholder={t('project.parameter.data_type_tips')}
options={Object.keys(DATA_TYPES_MAP).map((item) => {
return { value: item, label: item }
})}
v-model={[this.model.projectParameterDataType, 'value']}
/>
</NFormItem>
</NForm> </NForm>
) )
}} }}

20
dolphinscheduler-ui/src/views/projects/parameter/components/use-modal.ts

@ -27,6 +27,7 @@ import {
UpdateProjectParameterReq UpdateProjectParameterReq
} from '@/service/modules/projects-parameter/types' } from '@/service/modules/projects-parameter/types'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { DEFAULT_DATA_TYPE } from "@/views/projects/parameter/data_type";
export function useModal( export function useModal(
props: any, props: any,
@ -41,7 +42,8 @@ export function useModal(
model: { model: {
code: ref<number>(-1), code: ref<number>(-1),
projectParameterName: ref(''), projectParameterName: ref(''),
projectParameterValue: ref('') projectParameterValue: ref(''),
projectParameterDataType: ref(DEFAULT_DATA_TYPE)
}, },
saving: false, saving: false,
rules: { rules: {
@ -62,6 +64,15 @@ export function useModal(
return new Error(t('project.parameter.value_tips')) return new Error(t('project.parameter.value_tips'))
} }
} }
},
data_type: {
required: true,
trigger: ['input', 'blur'],
validator() {
if (variables.model.projectParameterDataType === '') {
return new Error(t('project.parameter.data_type_tips'))
}
}
} }
} }
}) })
@ -83,12 +94,14 @@ export function useModal(
const submitModal = () => { const submitModal = () => {
const data: ProjectParameterReq = { const data: ProjectParameterReq = {
projectParameterName: variables.model.projectParameterName, projectParameterName: variables.model.projectParameterName,
projectParameterValue: variables.model.projectParameterValue projectParameterValue: variables.model.projectParameterValue,
projectParameterDataType: variables.model.projectParameterDataType
} }
createProjectParameter(data, variables.projectCode).then(() => { createProjectParameter(data, variables.projectCode).then(() => {
variables.model.projectParameterName = '' variables.model.projectParameterName = ''
variables.model.projectParameterValue = '' variables.model.projectParameterValue = ''
variables.model.projectParameterDataType = DEFAULT_DATA_TYPE
ctx.emit('confirmModal', props.showModalRef) ctx.emit('confirmModal', props.showModalRef)
}) })
} }
@ -97,7 +110,8 @@ export function useModal(
const data: UpdateProjectParameterReq = { const data: UpdateProjectParameterReq = {
code: variables.model.code, code: variables.model.code,
projectParameterName: variables.model.projectParameterName, projectParameterName: variables.model.projectParameterName,
projectParameterValue: variables.model.projectParameterValue projectParameterValue: variables.model.projectParameterValue,
projectParameterDataType: variables.model.projectParameterDataType
} }
updateProjectParameter(data, variables.projectCode).then(() => { updateProjectParameter(data, variables.projectCode).then(() => {

54
dolphinscheduler-ui/src/views/projects/parameter/data_type.ts

@ -0,0 +1,54 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const DATA_TYPES_MAP = {
VARCHAR: {
alias: 'VARCHAR'
},
INTEGER: {
alias: 'INTEGER'
},
LONG: {
alias: 'LONG'
},
FLOAT: {
alias: 'FLOAT'
},
DOUBLE: {
alias: 'DOUBLE'
},
DATE: {
alias: 'DATE'
},
TIME: {
alias: 'TIME'
},
TIMESTAMP: {
alias: 'TIMESTAMP'
},
BOOLEAN: {
alias: 'BOOLEAN'
},
LIST: {
alias: 'LIST'
},
FILE: {
alias: 'FILE'
}
}
export const DEFAULT_DATA_TYPE = 'VARCHAR'

15
dolphinscheduler-ui/src/views/projects/parameter/index.tsx

@ -21,7 +21,8 @@ import {
NInput, NInput,
NPagination, NPagination,
NSpace, NSpace,
NButton NButton,
NSelect
} from 'naive-ui' } from 'naive-ui'
import { defineComponent, onMounted, toRefs, watch } from 'vue' import { defineComponent, onMounted, toRefs, watch } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
@ -29,6 +30,7 @@ import { useTable } from '@/views/projects/parameter/use-table'
import Card from '@/components/card' import Card from '@/components/card'
import ParameterModal from '@/views/projects/parameter/components/parameter-modal' import ParameterModal from '@/views/projects/parameter/components/parameter-modal'
import { SearchOutlined } from '@vicons/antd' import { SearchOutlined } from '@vicons/antd'
import { DATA_TYPES_MAP } from "@/views/projects/parameter/data_type"
export default defineComponent({ export default defineComponent({
name: 'ProjectParameterList', name: 'ProjectParameterList',
@ -40,6 +42,7 @@ export default defineComponent({
pageSize: variables.pageSize, pageSize: variables.pageSize,
pageNo: variables.page, pageNo: variables.page,
searchVal: variables.searchVal, searchVal: variables.searchVal,
projectParameterDataType: variables.projectParameterDataType,
projectCode: variables.projectCode projectCode: variables.projectCode
}) })
} }
@ -116,6 +119,16 @@ export default defineComponent({
v-model={[this.searchVal, 'value']} v-model={[this.searchVal, 'value']}
placeholder={t('project.parameter.name')} placeholder={t('project.parameter.name')}
/> />
<NSelect
v-model={[this.projectParameterDataType, 'value']}
size='small'
options={Object.keys(DATA_TYPES_MAP).map((item) => {
return { value: item, label: item }
})}
placeholder={t('project.parameter.data_type_tips')}
style={{ width: '180px' }}
clearable
/>
<NButton size='small' type='primary' onClick={handleSearch}> <NButton size='small' type='primary' onClick={handleSearch}>
<NIcon> <NIcon>
<SearchOutlined /> <SearchOutlined />

9
dolphinscheduler-ui/src/views/projects/parameter/use-table.ts

@ -45,6 +45,7 @@ export function useTable() {
page: ref(1), page: ref(1),
pageSize: ref(10), pageSize: ref(10),
searchVal: ref(), searchVal: ref(),
projectParameterDataType: ref(),
totalPage: ref(1), totalPage: ref(1),
showRef: ref(false), showRef: ref(false),
statusRef: ref(0), statusRef: ref(0),
@ -69,6 +70,11 @@ export function useTable() {
key: 'paramValue', key: 'paramValue',
...COLUMN_WIDTH_CONFIG['name'] ...COLUMN_WIDTH_CONFIG['name']
}, },
{
title: t('project.parameter.data_type'),
key: 'paramDataType',
...COLUMN_WIDTH_CONFIG['name']
},
{ {
title: t('project.parameter.create_user'), title: t('project.parameter.create_user'),
key: 'createUser', key: 'createUser',
@ -192,7 +198,8 @@ export function useTable() {
getTableData({ getTableData({
pageSize: variables.pageSize, pageSize: variables.pageSize,
pageNo: variables.page, pageNo: variables.page,
searchVal: variables.searchVal searchVal: variables.searchVal,
projectParameterDataType: variables.projectParameterDataType
}) })
}) })
} }

30
dolphinscheduler-ui/src/views/projects/workflow/components/dag/dag-save-modal.tsx

@ -154,7 +154,8 @@ export default defineComponent({
formValue.value.globalParams = process.globalParamList.map((param) => ({ formValue.value.globalParams = process.globalParamList.map((param) => ({
key: param.prop, key: param.prop,
value: param.value, value: param.value,
direct: param.direct direct: param.direct,
type: param.type
})) }))
} }
} }
@ -239,6 +240,7 @@ export default defineComponent({
return { return {
key: '', key: '',
direct: 'IN', direct: 'IN',
type: 'VARCHAR',
value: '' value: ''
} }
}} }}
@ -246,16 +248,16 @@ export default defineComponent({
> >
{{ {{
default: (param: { default: (param: {
value: { key: string; direct: string; value: string } value: { key: string; direct: string; type: string; value: string }
}) => ( }) => (
<NGrid xGap={12} cols={24}> <NGrid xGap={12} cols={24}>
<NGridItem span={9}> <NGridItem span={6}>
<NInput <NInput
v-model:value={param.value.key} v-model:value={param.value.key}
placeholder={t('project.dag.key')} placeholder={t('project.dag.key')}
/> />
</NGridItem> </NGridItem>
<NGridItem span={6}> <NGridItem span={5}>
<NSelect <NSelect
options={[ options={[
{ value: 'IN', label: 'IN' }, { value: 'IN', label: 'IN' },
@ -265,7 +267,25 @@ export default defineComponent({
defaultValue={'IN'} defaultValue={'IN'}
/> />
</NGridItem> </NGridItem>
<NGridItem span={9}> <NGridItem span={7}>
<NSelect
options={[
{ value: 'VARCHAR', label: 'VARCHAR' },
{ value: 'INTEGER', label: 'INTEGER' },
{ value: 'LONG', label: 'LONG' },
{ value: 'FLOAT', label: 'FLOAT' },
{ value: 'DOUBLE', label: 'DOUBLE' },
{ value: 'DATE', label: 'DATE' },
{ value: 'TIME', label: 'TIME' },
{ value: 'BOOLEAN', label: 'BOOLEAN' },
{ value: 'LIST', label: 'LIST' },
{ value: 'FILE', label: 'FILE' }
]}
v-model:value={param.value.type}
defaultValue={'VARCHAR'}
/>
</NGridItem>
<NGridItem span={6}>
<NInput <NInput
v-model:value={param.value.value} v-model:value={param.value.value}
placeholder={t('project.dag.value')} placeholder={t('project.dag.value')}

1
dolphinscheduler-ui/src/views/projects/workflow/components/dag/types.ts

@ -138,6 +138,7 @@ export interface Coordinate {
export interface GlobalParam { export interface GlobalParam {
key: string key: string
direct: string direct: string
type: string
value: string value: string
} }

115
dolphinscheduler-ui/src/views/projects/workflow/definition/components/start-modal.tsx

@ -34,7 +34,6 @@ import { useModal } from './use-modal'
import { import {
NForm, NForm,
NFormItem, NFormItem,
NButton,
NIcon, NIcon,
NInput, NInput,
NSpace, NSpace,
@ -45,13 +44,14 @@ import {
NCheckbox, NCheckbox,
NDatePicker, NDatePicker,
NRadioButton, NRadioButton,
NInputNumber NInputNumber,
NDynamicInput,
NGrid,
NGridItem
} from 'naive-ui' } from 'naive-ui'
import { import {
ArrowDownOutlined, ArrowDownOutlined,
ArrowUpOutlined, ArrowUpOutlined
DeleteOutlined,
PlusCircleOutlined
} from '@vicons/antd' } from '@vicons/antd'
import { IDefinitionData } from '../types' import { IDefinitionData } from '../types'
import styles from '../index.module.scss' import styles from '../index.module.scss'
@ -580,50 +580,67 @@ export default defineComponent({
label={t('project.workflow.startup_parameter')} label={t('project.workflow.startup_parameter')}
path='startup_parameter' path='startup_parameter'
> >
{this.startParamsList.length === 0 ? ( <NDynamicInput
<NButton text type='primary' onClick={this.addStartParams}> v-model:value={this.startParamsList}
<NIcon> onCreate={() => {
<PlusCircleOutlined /> return {
</NIcon> key: '',
</NButton> direct: 'IN',
) : ( type: 'VARCHAR',
<NSpace vertical> value: ''
{this.startParamsList.map((item, index) => ( }
<NSpace class={styles.startup} key={Date.now() + index}> }}
<NInput class='input-startup-params'
allowInput={this.trim} >
pair {{
separator=':' default: (param: {
placeholder={['prop', 'value']} value: { prop: string; direct: string; type: string; value: string }
defaultValue={[item.prop, item.value]} }) => (
onUpdateValue={(param) => <NGrid xGap={12} cols={24}>
this.updateParamsList(index, param) <NGridItem span={6}>
} <NInput
/> v-model:value={param.value.prop}
<NButton placeholder={t('project.dag.key')}
text />
type='error' </NGridItem>
onClick={() => this.removeStartParams(index)} <NGridItem span={5}>
class='btn-delete-custom-parameter' <NSelect
> options={[
<NIcon> { value: 'IN', label: 'IN' },
<DeleteOutlined /> { value: 'OUT', label: 'OUT' }
</NIcon> ]}
</NButton> v-model:value={param.value.direct}
<NButton defaultValue={'IN'}
text />
type='primary' </NGridItem>
onClick={this.addStartParams} <NGridItem span={7}>
class='btn-create-custom-parameter' <NSelect
> options={[
<NIcon> { value: 'VARCHAR', label: 'VARCHAR' },
<PlusCircleOutlined /> { value: 'INTEGER', label: 'INTEGER' },
</NIcon> { value: 'LONG', label: 'LONG' },
</NButton> { value: 'FLOAT', label: 'FLOAT' },
</NSpace> { value: 'DOUBLE', label: 'DOUBLE' },
))} { value: 'DATE', label: 'DATE' },
</NSpace> { value: 'TIME', label: 'TIME' },
)} { value: 'BOOLEAN', label: 'BOOLEAN' },
{ value: 'LIST', label: 'LIST' },
{ value: 'FILE', label: 'FILE' }
]}
v-model:value={param.value.type}
defaultValue={'VARCHAR'}
/>
</NGridItem>
<NGridItem span={6}>
<NInput
v-model:value={param.value.value}
placeholder={t('project.dag.value')}
/>
</NGridItem>
</NGrid>
)
}}
</NDynamicInput>
</NFormItem> </NFormItem>
<NFormItem <NFormItem
label={t('project.workflow.whether_dry_run')} label={t('project.workflow.whether_dry_run')}

10
dolphinscheduler-ui/src/views/projects/workflow/definition/components/use-modal.ts

@ -119,14 +119,8 @@ export function useModal(
}) })
} }
const startParams = {} as any params.startParams = !_.isEmpty(variables.startParamsList)
for (const item of variables.startParamsList) { ? JSON.stringify(variables.startParamsList)
if (item.value !== '') {
startParams[item.prop] = item.value
}
}
params.startParams = !_.isEmpty(startParams)
? JSON.stringify(startParams)
: '' : ''
await startProcessInstance(params, variables.projectCode) await startProcessInstance(params, variables.projectCode)
window.$message.success(t('project.workflow.success')) window.$message.success(t('project.workflow.success'))

2
dolphinscheduler-ui/src/views/projects/workflow/definition/create/index.tsx

@ -59,7 +59,7 @@ export default defineComponent({
prop: p.key, prop: p.key,
value: p.value, value: p.value,
direct: p.direct, direct: p.direct,
type: 'VARCHAR' type: p.type
} }
}) })

2
dolphinscheduler-ui/src/views/projects/workflow/definition/detail/index.tsx

@ -85,7 +85,7 @@ export default defineComponent({
prop: p.key, prop: p.key,
value: p.value, value: p.value,
direct: p.direct, direct: p.direct,
type: 'VARCHAR' type: p.type
} }
}) })

2
dolphinscheduler-ui/src/views/projects/workflow/instance/detail/index.tsx

@ -82,7 +82,7 @@ export default defineComponent({
prop: p.key, prop: p.key,
value: p.value, value: p.value,
direct: p.direct, direct: p.direct,
type: 'VARCHAR' type: p.type
} }
}) })

Loading…
Cancel
Save