shaolei7788 commented on code in PR #17945:
URL:
https://github.com/apache/dolphinscheduler/pull/17945#discussion_r2772903496
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-dinky/src/main/java/org/apache/dolphinscheduler/plugin/task/dinky/DinkyTask.java:
##########
@@ -338,23 +339,43 @@ public void cancelApplication() throws TaskException {
private Map<String, String> generateVariables() {
Map<String, String> variables = new ConcurrentHashMap<>();
- List<Property> propertyList =
JSONUtils.toList(taskExecutionContext.getGlobalParams(), Property.class);
- if (propertyList != null && !propertyList.isEmpty()) {
- for (Property property : propertyList) {
- variables.put(property.getProp(), property.getValue());
+ Map<String, Property> prepareParamsMap =
taskExecutionContext.getPrepareParamsMap();
+
+ prepareParamsMap.forEach((key, property) -> {
+ if (Objects.nonNull(property) &&
Objects.nonNull(property.getValue())) {
+ variables.put(key, property.getValue());
}
- }
+ });
+
List<Property> localParams = this.dinkyParameters.getLocalParams();
- Map<String, Property> prepareParamsMap =
taskExecutionContext.getPrepareParamsMap();
- if (localParams == null || localParams.isEmpty()) {
- return variables;
- }
- Map<String, String> convertMap =
ParameterUtils.convert(prepareParamsMap);
- for (Property property : localParams) {
- String propertyValue = property.getValue();
- String value = PlaceholderUtils.replacePlaceholders(propertyValue,
convertMap, true);
- variables.put(property.getProp(), value);
+ List<Property> globalParams =
JSONUtils.toList(taskExecutionContext.getGlobalParams(), Property.class);
+
+ if (!localParams.isEmpty()) {
+ for (Property localParam : localParams) {
+ if (Objects.isNull(variables.get(localParam.getProp())) ||
variables.get(localParam.getProp()).isEmpty()) {
+ if (localParam.getValue() != null &&
!localParam.getValue().isEmpty()) {
+ String value =
ParameterUtils.convertParameterPlaceholders(localParam.getValue(), variables);
+ if (StringUtils.isNotBlank(value)) {
+ variables.put(localParam.getProp(), value);
+ }
+ } else {
+ if (!globalParams.isEmpty()) {
+ for (Property globalParam : globalParams) {
+ if
(globalParam.getProp().equals(localParam.getProp())) {
+ if (globalParam.getValue() != null &&
!globalParam.getValue().isEmpty()) {
+ String value =
ParameterUtils.convertParameterPlaceholders(globalParam.getValue(), variables);
+ if (StringUtils.isNotBlank(value)) {
+
variables.put(localParam.getProp(), value);
+ }
+ }
+ }
Review Comment:
ok, I've made the changes
--
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]