Skip to content

Commit afc23da

Browse files
committed
更改 batchEditNodeContent 返回格式
1 parent 7410781 commit afc23da

File tree

4 files changed

+93
-12
lines changed

4 files changed

+93
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.webank.wedatasphere.dss.workflow.entity.response;
2+
3+
import java.util.List;
4+
5+
public class BatchEditNodeContentResponse {
6+
7+
private Long orchestratorId;
8+
private String orchestratorName;
9+
10+
private List<String> failNodeName;
11+
private List<String> successNodeName;
12+
13+
private String errorMsg;
14+
public Long getOrchestratorId() {
15+
return orchestratorId;
16+
}
17+
18+
public void setOrchestratorId(Long orchestratorId) {
19+
this.orchestratorId = orchestratorId;
20+
}
21+
22+
public String getOrchestratorName() {
23+
return orchestratorName;
24+
}
25+
26+
public void setOrchestratorName(String orchestratorName) {
27+
this.orchestratorName = orchestratorName;
28+
}
29+
30+
31+
public List<String> getFailNodeName() {
32+
return failNodeName;
33+
}
34+
35+
public void setFailNodeName(List<String> failNodeName) {
36+
this.failNodeName = failNodeName;
37+
}
38+
39+
public List<String> getSuccessNodeName() {
40+
return successNodeName;
41+
}
42+
43+
public void setSuccessNodeName(List<String> successNodeName) {
44+
this.successNodeName = successNodeName;
45+
}
46+
47+
public String getErrorMsg() {
48+
return errorMsg;
49+
}
50+
51+
public void setErrorMsg(String errorMsg) {
52+
this.errorMsg = errorMsg;
53+
}
54+
}

dss-orchestrator/orchestrators/dss-workflow/dss-workflow-server/src/main/java/com/webank/wedatasphere/dss/workflow/restful/FlowRestfulApi.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.webank.wedatasphere.dss.workflow.dao.LockMapper;
4545
import com.webank.wedatasphere.dss.workflow.entity.DSSFlowEditLock;
4646
import com.webank.wedatasphere.dss.workflow.entity.request.*;
47+
import com.webank.wedatasphere.dss.workflow.entity.response.BatchEditNodeContentResponse;
4748
import com.webank.wedatasphere.dss.workflow.entity.vo.ExtraToolBarsVO;
4849
import com.webank.wedatasphere.dss.workflow.lock.DSSFlowEditLockManager;
4950
import com.webank.wedatasphere.dss.common.service.BMLService;
@@ -448,14 +449,19 @@ public Message batchEditNodeContent(@RequestBody BatchEditNodeContentRequest bat
448449
String ticketId = Arrays.stream(cookies).filter(cookie -> DSSWorkFlowConstant.BDP_USER_TICKET_ID.equals(cookie.getName())).findFirst().map(Cookie::getValue).get();
449450
batchEditNodeContentRequest.setUsername(userName);
450451
LOGGER.info("batchEditNodeContent params is {}",batchEditNodeContentRequest);
451-
flowService.batchEditNodeContent(batchEditNodeContentRequest,ticketId);
452+
BatchEditNodeContentResponse batchEditNodeContentResponse = flowService.batchEditNodeContent(batchEditNodeContentRequest,ticketId);
452453

454+
if(batchEditNodeContentResponse !=null && !CollectionUtils.isNotEmpty(batchEditNodeContentResponse.getFailNodeName())){
455+
return Message.error(String.format("批量编辑节点失败")).data("data",batchEditNodeContentResponse);
456+
}
457+
458+
return Message.ok("批量编辑节点完成").data("data",batchEditNodeContentResponse);
453459
}catch (Exception e){
454460
LOGGER.error("批量编辑节点失败", e);
455461
return Message.error(String.format("批量编辑节点失败,原因为:%s" , e.getMessage()));
456462
}
457463

458-
return Message.ok("批量编辑节点成功");
464+
459465
}
460466

461467

dss-orchestrator/orchestrators/dss-workflow/dss-workflow-server/src/main/java/com/webank/wedatasphere/dss/workflow/service/DSSFlowService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ QueryNodeInfoByPathResponse queryNodeInfo(Long projectId,
128128

129129
void editNodeContent(EditNodeContentRequest editNodeContentRequest,String ticketId) throws Exception;
130130

131-
void batchEditNodeContent(BatchEditNodeContentRequest batchEditNodeContentRequest,String ticketId) throws Exception;
131+
BatchEditNodeContentResponse batchEditNodeContent(BatchEditNodeContentRequest batchEditNodeContentRequest,String ticketId) throws Exception;
132132

133133

134134
List<DSSNodeDefault> getNodeInfoByName(QueryNodeInfoByNameRequest queryNodeInfoByNameRequest);

dss-orchestrator/orchestrators/dss-workflow/dss-workflow-server/src/main/java/com/webank/wedatasphere/dss/workflow/service/impl/DSSFlowServiceImpl.java

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2941,7 +2941,7 @@ public void editNodeContent(EditNodeContentRequest editNodeContentRequest,String
29412941

29422942

29432943
@Override
2944-
public void batchEditNodeContent(BatchEditNodeContentRequest batchEditNodeContentRequest,String ticketId) throws Exception {
2944+
public BatchEditNodeContentResponse batchEditNodeContent(BatchEditNodeContentRequest batchEditNodeContentRequest,String ticketId) throws Exception {
29452945

29462946
String username = batchEditNodeContentRequest.getUsername();
29472947
Long projectId = batchEditNodeContentRequest.getProjectId();
@@ -2981,12 +2981,18 @@ public void batchEditNodeContent(BatchEditNodeContentRequest batchEditNodeConten
29812981
// 校验工作流是否锁定
29822982
validateFlowLock(rootFlow, ticketId);
29832983

2984+
BatchEditNodeContentResponse batchEditNodeContentResponse = new BatchEditNodeContentResponse();
2985+
batchEditNodeContentResponse.setOrchestratorId(dssOrchestratorInfo.getId());
2986+
batchEditNodeContentResponse.setOrchestratorName(dssOrchestratorInfo.getName());
2987+
29842988
// 锁定工作流
29852989
lockFlow(rootFlow, username, ticketId);
29862990

29872991
try {
29882992

29892993
Map<Long,DSSFlow> flowMap = new HashMap<>();
2994+
2995+
Map<Long,List<String>> flowNodeMap = new HashMap<>();
29902996
// 查找出节点所属的工作流 并分组
29912997
for(BatchEditNodeContentRequest.NodeContent nodeContent: nodeContentList){
29922998

@@ -3011,26 +3017,41 @@ public void batchEditNodeContent(BatchEditNodeContentRequest batchEditNodeConten
30113017

30123018
flowMap.put(flow.getId(),flow);
30133019

3020+
flowNodeMap.getOrDefault(flow.getId(), new ArrayList<>()).add(nodeContent.getNodeName());
3021+
30143022
}
30153023

3024+
30163025
// 保存工作流
30173026
for(Long flowId: flowMap.keySet()){
30183027

3019-
DSSFlow dssFlow = flowMap.get(flowId);
3020-
logger.info("orchestrator is [{},{}],flow is [{},{}],update dssFlow json is {}",
3021-
dssOrchestratorInfo.getName(),dssOrchestratorInfo.getId(),
3022-
flowId,dssFlow.getName(),
3023-
dssFlow.getFlowJson());
3024-
saveFlow(flowId,dssFlow.getFlowJson(),username,dssFlow.getDescription(),
3025-
dssProject.getWorkspaceName(),dssProject.getName(),null);
3028+
try {
3029+
DSSFlow dssFlow = flowMap.get(flowId);
3030+
logger.info("orchestrator is [{},{}],flow is [{},{}],update dssFlow json is {}",
3031+
dssOrchestratorInfo.getName(),dssOrchestratorInfo.getId(),
3032+
flowId,dssFlow.getName(),
3033+
dssFlow.getFlowJson());
3034+
saveFlow(flowId,dssFlow.getFlowJson(),username,dssFlow.getDescription(),
3035+
dssProject.getWorkspaceName(),dssProject.getName(),null);
3036+
3037+
batchEditNodeContentResponse.setSuccessNodeName(flowNodeMap.get(flowId));
3038+
}catch (Exception e){
3039+
batchEditNodeContentResponse.setFailNodeName(flowNodeMap.get(flowId));
3040+
batchEditNodeContentResponse.setErrorMsg(e.getMessage());
3041+
logger.error("保存工作流失败", e);
3042+
break;
3043+
}
3044+
30263045
}
30273046

30283047
}catch (Exception e){
3029-
logger.error("保存工作流失败", e);
3048+
logger.error("保存编排失败", e);
30303049
throw new DSSErrorException(80001,"保存失败,原因为:" + e.getMessage());
30313050
}finally {
30323051
workFlowManager.unlockWorkflow(username,dssOrchestratorVersion.getAppId(),true,workspace);
30333052
}
3053+
3054+
return batchEditNodeContentResponse;
30343055

30353056
}
30363057

0 commit comments

Comments
 (0)