|
32 | 32 | import com.webank.wedatasphere.dss.common.entity.workspace.DSSStarRocksCluster; |
33 | 33 | import com.webank.wedatasphere.dss.common.exception.DSSErrorException; |
34 | 34 | import com.webank.wedatasphere.dss.common.exception.DSSRuntimeException; |
| 35 | +import com.webank.wedatasphere.dss.standard.common.exception.operation.ExternalOperationFailedException; |
35 | 36 | import com.webank.wedatasphere.dss.common.label.DSSLabel; |
| 37 | +import com.webank.wedatasphere.dss.common.label.EnvDSSLabel; |
36 | 38 | import com.webank.wedatasphere.dss.common.label.LabelRouteVO; |
37 | 39 | import com.webank.wedatasphere.dss.common.protocol.project.*; |
38 | 40 | import com.webank.wedatasphere.dss.common.protocol.workspace.StarRocksClusterListRequest; |
@@ -2540,6 +2542,9 @@ public void batchEditFlow(BatchEditFlowRequest batchEditFlowRequest, String tick |
2540 | 2542 | List<EditFlowRequest> editFlowRequestsList = editFlowRequestTOFlowIDMap.containsKey(targetFlowId) ? |
2541 | 2543 | editFlowRequestTOFlowIDMap.get(targetFlowId) : new ArrayList<>(); |
2542 | 2544 |
|
| 2545 | + // 校验 tableau/tableauDataRefre 节点的 viewId/datasourceId |
| 2546 | + validateTableauNode(editFlowRequest, nodeContentByContentId, targetFlowId, workspace, userName); |
| 2547 | + |
2543 | 2548 | // 处理starrocks节点 |
2544 | 2549 | if ("linkis.jdbc.starrocks".equals(nodeContentByContentId.getJobType())) { |
2545 | 2550 | starRocksNodeParamsHandle(editFlowRequest, starRocksClusterMap); |
@@ -2586,6 +2591,72 @@ public void batchEditFlow(BatchEditFlowRequest batchEditFlowRequest, String tick |
2586 | 2591 | } |
2587 | 2592 |
|
2588 | 2593 |
|
| 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 | + |
2589 | 2660 | private void validNodeDisableEdit(List<Long> contentIdList) { |
2590 | 2661 |
|
2591 | 2662 | List<String> disableEditNodeList = new ArrayList<>(); |
|
0 commit comments