calvinjiang commented on a change in pull request #5774:
URL: https://github.com/apache/dolphinscheduler/pull/5774#discussion_r672244311
##########
File path:
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ParamUtils.java
##########
@@ -95,6 +101,67 @@
return globalParams;
}
+ /**
+ * parameter conversion
+ * @param taskExecutionContext the context of this task instance
+ * @param parameters the parameters
+ * @return global params
+ */
+ public static Map<String,Property> convert(TaskExecutionContext
taskExecutionContext, AbstractParameters parameters) {
+ Preconditions.checkNotNull(taskExecutionContext);
+ Preconditions.checkNotNull(parameters);
+ Map<String,Property> globalParams =
getUserDefParamsMap(taskExecutionContext.getDefinedParams());
+ Map<String,String> globalParamsMap =
taskExecutionContext.getDefinedParams();
+ CommandType commandType =
CommandType.of(taskExecutionContext.getCmdTypeIfComplement());
+ Date scheduleTime = taskExecutionContext.getScheduleTime();
+
+ Map<String,Property> localParams = parameters.getLocalParametersMap();
+
+ if (globalParams == null && localParams == null) {
+ return null;
+ }
+ // if it is a complement,
+ // you need to pass in the task instance id to locate the time
+ // of the process instance complement
+ Map<String,String> timeParams = BusinessTimeUtils
+ .getBusinessTime(commandType,
+ scheduleTime);
+
+ if (globalParamsMap != null) {
+ timeParams.putAll(globalParamsMap);
+ }
+
+ if (Strings.isNotBlank(taskExecutionContext.getExecutePath())) {
+
timeParams.put(Constants.PARAMETER_TASK_EXECUTE_PATH,taskExecutionContext.getExecutePath());
+ }
+
timeParams.put(Constants.PARAMETER_TASK_INSTANCE_ID,Integer.toString(taskExecutionContext.getTaskInstanceId()));
+
Review comment:
> hi,how is it getting?
First of all: create a new shell task, and then add this two parameters in
the field of customer defined parameter. You can use these self-designed
parameters in the script.

Second: save this task and run this flow to check this result.

##########
File path:
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ParamUtils.java
##########
@@ -95,6 +101,67 @@
return globalParams;
}
+ /**
+ * parameter conversion
+ * @param taskExecutionContext the context of this task instance
+ * @param parameters the parameters
+ * @return global params
+ */
+ public static Map<String,Property> convert(TaskExecutionContext
taskExecutionContext, AbstractParameters parameters) {
+ Preconditions.checkNotNull(taskExecutionContext);
+ Preconditions.checkNotNull(parameters);
+ Map<String,Property> globalParams =
getUserDefParamsMap(taskExecutionContext.getDefinedParams());
+ Map<String,String> globalParamsMap =
taskExecutionContext.getDefinedParams();
+ CommandType commandType =
CommandType.of(taskExecutionContext.getCmdTypeIfComplement());
+ Date scheduleTime = taskExecutionContext.getScheduleTime();
+
+ Map<String,Property> localParams = parameters.getLocalParametersMap();
+
+ if (globalParams == null && localParams == null) {
+ return null;
+ }
+ // if it is a complement,
+ // you need to pass in the task instance id to locate the time
+ // of the process instance complement
+ Map<String,String> timeParams = BusinessTimeUtils
+ .getBusinessTime(commandType,
+ scheduleTime);
+
+ if (globalParamsMap != null) {
+ timeParams.putAll(globalParamsMap);
+ }
+
+ if (Strings.isNotBlank(taskExecutionContext.getExecutePath())) {
+
timeParams.put(Constants.PARAMETER_TASK_EXECUTE_PATH,taskExecutionContext.getExecutePath());
+ }
+
timeParams.put(Constants.PARAMETER_TASK_INSTANCE_ID,Integer.toString(taskExecutionContext.getTaskInstanceId()));
+
Review comment:
> I am referring to legacy question.:)
Got it. I've made a new issue for that. I'll implement this function to
support the rest of type of tasks ASAP.
New issue is :https://github.com/apache/dolphinscheduler/issues/5852
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]