CalvinKirs commented on a change in pull request #5774:
URL: https://github.com/apache/dolphinscheduler/pull/5774#discussion_r666361016
##########
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:
1:There is an ambiguity in using timesParam to store temporary
variables. timesParam mainly stores parameters of time type.
2:Is the result correct? Simply looking at the code, it does not seem to
complete the final replacement.
3:If we want to support it, we suggest that other task types adopt the same
approach to be consistent. (Maybe other tasks have the same need)
--
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]