JinyLeeChina commented on a change in pull request #6888:
URL: https://github.com/apache/dolphinscheduler/pull/6888#discussion_r751975481



##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessTaskRelationServiceImpl.java
##########
@@ -133,7 +145,20 @@
      */
     @Override
     public Map<String, Object> queryUpstreamRelation(User loginUser, long 
projectCode, long taskCode) {
-        return null;
+        Map<String, Object> result = 
taskDefinitionService.checkTaskDefinitionAndAuth(loginUser,projectCode,taskCode);
+        if (result.get(Constants.STATUS) != Status.SUCCESS) {
+            return result;
+        }
+        List<ProcessTaskRelation> processTaskRelationList = 
processTaskRelationMapper.queryByTaskCode(taskCode);

Review comment:
       `processTaskRelationMapper.queryByTaskCode(taskCode)` can't get right 
upstream

##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessTaskRelationServiceImpl.java
##########
@@ -146,6 +171,20 @@
      */
     @Override
     public Map<String, Object> queryDownstreamRelation(User loginUser, long 
projectCode, long taskCode) {
-        return null;
+
+        Map<String, Object> result = 
taskDefinitionService.checkTaskDefinitionAndAuth(loginUser,projectCode,taskCode);
+        if (result.get(Constants.STATUS) != Status.SUCCESS) {
+            return result;
+        }
+        List<ProcessTaskRelation> processTaskRelationList = 
processTaskRelationMapper.queryByTaskCode(taskCode);

Review comment:
       Please check

##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessTaskRelationServiceImpl.java
##########
@@ -133,7 +145,20 @@
      */
     @Override
     public Map<String, Object> queryUpstreamRelation(User loginUser, long 
projectCode, long taskCode) {
-        return null;
+        Map<String, Object> result = 
taskDefinitionService.checkTaskDefinitionAndAuth(loginUser,projectCode,taskCode);
+        if (result.get(Constants.STATUS) != Status.SUCCESS) {
+            return result;
+        }
+        List<ProcessTaskRelation> processTaskRelationList = 
processTaskRelationMapper.queryByTaskCode(taskCode);
+        if (CollectionUtils.isNotEmpty(processTaskRelationList)) {
+            // check taskCode equal to postTaskCode
+            List<ProcessTaskRelation> upstreamRelationList = 
processTaskRelationList.stream().filter(processTask -> 
processTask.getPostTaskCode() == taskCode).collect(Collectors.toList());

Review comment:
       Here should get taskDefinitionList as the return value.

##########
File path: 
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessTaskRelationServiceImpl.java
##########
@@ -146,6 +171,20 @@
      */
     @Override
     public Map<String, Object> queryDownstreamRelation(User loginUser, long 
projectCode, long taskCode) {
-        return null;
+
+        Map<String, Object> result = 
taskDefinitionService.checkTaskDefinitionAndAuth(loginUser,projectCode,taskCode);
+        if (result.get(Constants.STATUS) != Status.SUCCESS) {
+            return result;
+        }
+        List<ProcessTaskRelation> processTaskRelationList = 
processTaskRelationMapper.queryByTaskCode(taskCode);
+        if (CollectionUtils.isNotEmpty(processTaskRelationList)) {
+            // check taskCode equal to preTaskCode
+            List<ProcessTaskRelation> downstreamRelationList = 
processTaskRelationList.stream().filter(processTask -> 
processTask.getPreTaskCode() == taskCode).collect(Collectors.toList());

Review comment:
       Please check




-- 
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]


Reply via email to