Skip to content

Commit f72300c

Browse files
committed
批量编辑tableu节点视图ID属性 #AI commit#
1 parent 76bc582 commit f72300c

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

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

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
import com.webank.wedatasphere.dss.common.entity.workspace.DSSStarRocksCluster;
3333
import com.webank.wedatasphere.dss.common.exception.DSSErrorException;
3434
import com.webank.wedatasphere.dss.common.exception.DSSRuntimeException;
35+
import com.webank.wedatasphere.dss.standard.common.exception.operation.ExternalOperationFailedException;
3536
import com.webank.wedatasphere.dss.common.label.DSSLabel;
37+
import com.webank.wedatasphere.dss.common.label.EnvDSSLabel;
3638
import com.webank.wedatasphere.dss.common.label.LabelRouteVO;
3739
import com.webank.wedatasphere.dss.common.protocol.project.*;
3840
import com.webank.wedatasphere.dss.common.protocol.workspace.StarRocksClusterListRequest;
@@ -2540,6 +2542,9 @@ public void batchEditFlow(BatchEditFlowRequest batchEditFlowRequest, String tick
25402542
List<EditFlowRequest> editFlowRequestsList = editFlowRequestTOFlowIDMap.containsKey(targetFlowId) ?
25412543
editFlowRequestTOFlowIDMap.get(targetFlowId) : new ArrayList<>();
25422544

2545+
// 校验 tableau/tableauDataRefre 节点的 viewId/datasourceId
2546+
validateTableauNode(editFlowRequest, nodeContentByContentId, targetFlowId, workspace, userName);
2547+
25432548
// 处理starrocks节点
25442549
if ("linkis.jdbc.starrocks".equals(nodeContentByContentId.getJobType())) {
25452550
starRocksNodeParamsHandle(editFlowRequest, starRocksClusterMap);
@@ -2586,6 +2591,72 @@ public void batchEditFlow(BatchEditFlowRequest batchEditFlowRequest, String tick
25862591
}
25872592

25882593

2594+
/**
2595+
* 判断是否为 tableau 或 tableauDataRefre 节点
2596+
*/
2597+
private boolean isTableauNode(String nodeType) {
2598+
return "linkis.appconn.newVisualis.tableau".equals(nodeType)
2599+
|| "linkis.appconn.newVisualis.tableauDataRefre".equals(nodeType);
2600+
}
2601+
2602+
/**
2603+
* 校验 tableau/tableauDataRefre 节点的 viewId/datasourceId
2604+
* 1. 必填校验:tableau节点viewId不能为空,tableauDataRefre节点datasourceId不能为空
2605+
* 2. 真实性校验:通过调用 workflowNodeService.updateNode 触发 AppConn 校验
2606+
*/
2607+
private void validateTableauNode(EditFlowRequest editFlowRequest, NodeContentDO nodeContentDO,
2608+
Long flowId, Workspace workspace, String userName) throws ExternalOperationFailedException {
2609+
String nodeType = nodeContentDO.getJobType();
2610+
2611+
// 只处理 tableau 相关节点
2612+
if (!isTableauNode(nodeType)) {
2613+
return;
2614+
}
2615+
2616+
String viewId = editFlowRequest.getViewId();
2617+
String datasourceId = editFlowRequest.getDatasourceId();
2618+
2619+
// 必填校验
2620+
if ("linkis.appconn.newVisualis.tableau".equals(nodeType) && StringUtils.isEmpty(viewId)) {
2621+
throw new ExternalOperationFailedException(80001, "视图ID不能为空");
2622+
}
2623+
if ("linkis.appconn.newVisualis.tableauDataRefre".equals(nodeType) && StringUtils.isEmpty(datasourceId)) {
2624+
throw new ExternalOperationFailedException(80001, "数据源ID或视图不能为空");
2625+
}
2626+
2627+
// 真实性校验:构建 jobContent 并调用 updateNode
2628+
Map<String, Object> jobContent = new HashMap<>();
2629+
if (StringUtils.isNotEmpty(viewId)) {
2630+
jobContent.put("viewId", viewId);
2631+
}
2632+
if (StringUtils.isNotEmpty(datasourceId)) {
2633+
jobContent.put("datasourceId", datasourceId);
2634+
}
2635+
if (StringUtils.isNotEmpty(editFlowRequest.getTitle())) {
2636+
jobContent.put("title", editFlowRequest.getTitle());
2637+
}
2638+
if (StringUtils.isNotEmpty(editFlowRequest.getDesc())) {
2639+
jobContent.put("desc", editFlowRequest.getDesc());
2640+
}
2641+
2642+
// 获取 projectId
2643+
DSSFlow flow = getFlow(flowId);
2644+
Long projectId = flow.getProjectId();
2645+
2646+
// 构建 CommonAppConnNode
2647+
CommonAppConnNode node = new CommonAppConnNode();
2648+
node.setNodeType(nodeType);
2649+
node.setFlowId(flowId);
2650+
node.setProjectId(projectId);
2651+
node.setJobContent(jobContent);
2652+
node.setWorkspace(workspace);
2653+
node.setParams(jobContent);
2654+
node.setDssLabels(Collections.singletonList(new EnvDSSLabel(DSSCommonUtils.ENV_LABEL_VALUE_DEV)));
2655+
logger.info("validateTableauNode node:{}", DSSCommonUtils.COMMON_GSON.toJson(node));
2656+
// 调用 updateNode 进行校验,如果校验失败会抛出异常
2657+
workflowNodeService.updateNode(userName, node);
2658+
}
2659+
25892660
private void validNodeDisableEdit(List<Long> contentIdList) {
25902661

25912662
List<String> disableEditNodeList = new ArrayList<>();

0 commit comments

Comments
 (0)