This is an automated email from the ASF dual-hosted git repository.
wenhemin pushed a commit to branch json_split
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git
The following commit(s) were added to refs/heads/json_split by this push:
new 1eaf1f6 [Feature][JsonSplit] fix taskId in processDefinitionJson
(#5136)
1eaf1f6 is described below
commit 1eaf1f62349cdd469bce092297bacfc7893d1d0d
Author: JinyLeeChina <[email protected]>
AuthorDate: Wed Mar 24 11:44:14 2021 +0800
[Feature][JsonSplit] fix taskId in processDefinitionJson (#5136)
* modify checkDAGRing and ProcessService method
* merge
* modify dagRing
* modify process instance for project home page
* fix save process bug
* codeStyle
* Fix logical bug in saving process definition
* codeSytle
* Fix bug in interface of queryProcessDefinitionList
* codeSytle
* Fix api bug"
* fix taskId in processDefinitionJson
Co-authored-by: JinyLeeChina <[email protected]>
---
.../dolphinscheduler/common/utils/StringUtils.java | 30 ++++++++++++++++++++++
.../service/process/ProcessService.java | 8 +++---
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/StringUtils.java
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/StringUtils.java
index e6cd041..3ec1a2e 100644
---
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/StringUtils.java
+++
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/StringUtils.java
@@ -23,6 +23,8 @@ public class StringUtils {
public static final String EMPTY = "";
+ public static final int INDEX_NOT_FOUND = -1;
+
private StringUtils() {
throw new UnsupportedOperationException("Construct StringUtils");
}
@@ -89,4 +91,32 @@ public class StringUtils {
public static boolean equalsIgnoreCase(String str1, String str2) {
return str1 == null ? str2 == null : str1.equalsIgnoreCase(str2);
}
+
+ public static String substringBefore(final String str, final String
separator) {
+ if (isEmpty(str) || separator == null) {
+ return str;
+ }
+ if (separator.isEmpty()) {
+ return EMPTY;
+ }
+ final int pos = str.indexOf(separator);
+ if (pos == INDEX_NOT_FOUND) {
+ return str;
+ }
+ return str.substring(0, pos);
+ }
+
+ public static String substringAfter(final String str, final String
separator) {
+ if (isEmpty(str)) {
+ return str;
+ }
+ if (separator == null) {
+ return EMPTY;
+ }
+ final int pos = str.indexOf(separator);
+ if (pos == INDEX_NOT_FOUND) {
+ return EMPTY;
+ }
+ return str.substring(pos + separator.length());
+ }
}
diff --git
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
index a1f5eca..2c826dc 100644
---
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
+++
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
@@ -2239,7 +2239,8 @@ public class ProcessService {
}
private void setTaskFromTaskNode(TaskNode taskNode, TaskDefinition
taskDefinition) {
- taskDefinition.setName(taskNode.getName());
+ // TODO for the front-end UI, name with id
+ taskDefinition.setName(taskNode.getId() + "|" + taskNode.getName());
taskDefinition.setDescription(taskNode.getDesc());
taskDefinition.setTaskType(TaskType.of(taskNode.getType()));
taskDefinition.setTaskParams(TaskType.of(taskNode.getType()) ==
TaskType.DEPENDENT ? taskNode.getDependence() : taskNode.getParams());
@@ -2499,9 +2500,10 @@ public class ProcessService {
Map<Long, TaskDefinitionLog> taskDefinitionLogMap =
taskDefinitionLogs.stream().collect(Collectors.toMap(TaskDefinitionLog::getCode,
log -> log));
taskNodeMap.forEach((k, v) -> {
TaskDefinitionLog taskDefinitionLog = taskDefinitionLogMap.get(k);
- v.setId("task-" + taskDefinitionLog.getId());
+ // TODO split from name
+ v.setId(StringUtils.substringBefore(taskDefinitionLog.getName(),
"|"));
v.setCode(taskDefinitionLog.getCode());
- v.setName(taskDefinitionLog.getName());
+ v.setName(StringUtils.substringAfter(taskDefinitionLog.getName(),
"|"));
v.setDesc(taskDefinitionLog.getDescription());
v.setType(taskDefinitionLog.getTaskType().getDescp().toUpperCase());
v.setRunFlag(taskDefinitionLog.getFlag() == Flag.YES ?
Constants.FLOWNODE_RUN_FLAG_NORMAL : Constants.FLOWNODE_RUN_FLAG_FORBIDDEN);