lgcareer commented on a change in pull request #4778:
URL:
https://github.com/apache/incubator-dolphinscheduler/pull/4778#discussion_r579585659
##########
File path:
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
##########
@@ -1797,5 +1800,94 @@ private void checkBatchOperateResult(String
srcProjectName, String targetProject
}
}
+ public Map<String, Object> queryUpstreamTaskDependencies(Integer
processId, String taskName) {
+ Map<String, Object> result = new HashMap<>();
+ List<String> depList = new ArrayList<>();
+
+ ProcessDefinition processDefinition =
processDefineMapper.selectById(processId);
+ if (processDefinition == null) {
+ logger.info("Upstream dependencies process define not exists");
+ putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId);
+ return result;
+ }
+
+ String processDefinitionJson =
processDefinition.getProcessDefinitionJson();
+
+ ProcessData processData = JSONUtils.parseObject(processDefinitionJson,
ProcessData.class);
+
+ //process data check
+ if (null == processData) {
+ logger.error("Upstream dependencies process data is null");
+ putMsg(result, Status.DATA_IS_NOT_VALID, processDefinitionJson);
+ return result;
+ }
+
+ List<TaskNode> taskNodeList = (processData.getTasks() == null) ? new
ArrayList<>() : processData.getTasks();
+
+ for (TaskNode taskNode : taskNodeList) {
+ if (taskNode.getName().equals(taskName)) {
+ //getPreTasks() holds inner dependency information
+ depList.add(taskNode.getPreTasks());
+ }
+
+ }
+
Review comment:
You can also abstract a class to describe the dependent item,it need
includes common attributes:project id,process definition id,task name
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]