This is an automated email from the ASF dual-hosted git repository.
zihaoxiang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 0c71157ec5 [Improvement-18056] Remove unused code in tools module
(#18116)
0c71157ec5 is described below
commit 0c71157ec59aab196d31139b548bd2a1737b2275
Author: xiangzihao <[email protected]>
AuthorDate: Wed Apr 1 17:33:09 2026 +0800
[Improvement-18056] Remove unused code in tools module (#18116)
---
docs/configs/docsdev.js | 8 -
docs/docs/en/guide/demo.md | 39 -
docs/docs/zh/guide/demo.md | 39 -
.../src/main/bin/create-demo-processes.sh | 32 -
.../tools/demo/CreateDemoTenant.java | 55 --
.../tools/demo/CreateWorkflowDemo.java | 59 --
.../dolphinscheduler/tools/demo/DemoConstants.java | 32 -
.../dolphinscheduler/tools/demo/ProxyResult.java | 54 --
.../demo/ProxyWorkflowDefinitionController.java | 79 --
.../tools/demo/WorkflowDefinitionDemo.java | 805 ---------------------
.../tools/resource/MigrateResourceService.java | 1 -
.../src/main/resources/application.yaml | 5 -
.../src/test/resources/application-mysql.yaml | 6 -
.../src/test/resources/application-postgresql.yaml | 6 -
14 files changed, 1220 deletions(-)
diff --git a/docs/configs/docsdev.js b/docs/configs/docsdev.js
index 541f314645..12b1c309c0 100644
--- a/docs/configs/docsdev.js
+++ b/docs/configs/docsdev.js
@@ -474,10 +474,6 @@ export default {
title: 'Expansion and Reduction',
link:
'/en-us/docs/dev/user_doc/guide/expansion-reduction.html',
},
- {
- title: 'Demo',
- link: '/en-us/docs/dev/user_doc/guide/demo.html',
- },
],
},
{
@@ -1186,10 +1182,6 @@ export default {
title: '扩/缩容',
link:
'/zh-cn/docs/dev/user_doc/guide/expansion-reduction.html',
},
- {
- title: 'Demo',
- link: '/zh-cn/docs/dev/user_doc/guide/demo.html',
- },
],
},
{
diff --git a/docs/docs/en/guide/demo.md b/docs/docs/en/guide/demo.md
deleted file mode 100644
index 524cf9bd22..0000000000
--- a/docs/docs/en/guide/demo.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# DolphinScheduler Initialize The Workflow Demo
-
-## Prepare
-
-### Backup Previous Version's Files and Database
-
-To prevent data loss by some miss-operation, it is recommended to back up data
before initializing the workflow demo. The backup way according to your
environment.
-
-### Download the Latest Version Installation Package
-
-Download the latest binary distribute package from
[download](https://dolphinscheduler.apache.org/en-us/download) and then put it
in the different
-directory where current service running. And all below command is running in
this directory.
-
-## Start
-
-### Start Services of DolphinScheduler
-
-Start all services of dolphinscheduler according to your deployment method. If
you deploy your dolphinscheduler according to [cluster
deployment](installation/cluster.md), you can start all services by command `sh
./script/start-all.sh`.
-
-### Database Configuration
-
-Initializing the workflow demo needs to store metabase in other database like
MySQL or PostgreSQL, they have to change some configuration. Follow the
instructions in [datasource-setting](installation/datasource-setting.md)
`Standalone Switching Metadata Database Configuration` section to create and
initialize database.
-
-### Tenant Configuration
-
-#### Change `dolphinscheduler-tools/resources/application.yaml` Placement
Details
-
-```
-demo:
- tenant-code: default
- domain-name: localhost
- api-server-port: 5173
-```
-
-Mentioned above, tenant-code is the default tenant, users can modify the user
name according to their operating system, this replaces the manual tenant
creation action, api-server-port is the port number of the service.
-
-Then execute the startup script that initializes the workflow demo service:
`sh ./tools/bin/create-demo-processes.sh` to start the service.
-
-To create a demo, you can refer to [Quick Start](start/quick-start.md)
diff --git a/docs/docs/zh/guide/demo.md b/docs/docs/zh/guide/demo.md
deleted file mode 100644
index 63d098ef07..0000000000
--- a/docs/docs/zh/guide/demo.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# DolphinScheduler 初始化工作流 demo
-
-## 准备工作
-
-### 备份上一版本文件和数据库
-
-为了防止操作错误导致数据丢失,建议初始化工作流 demo 服务之前备份数据,备份方法请结合你数据库的情况来定
-
-### 下载新版本的安装包
-
-在[下载](https://dolphinscheduler.apache.org/zh-cn/download)页面下载最新版本的二进制安装包,并将二进制包放到与当前
dolphinscheduler 服务不一样的路径中,以下服务启动操作都需要在新版本的目录进行。
-
-## 服务启动步骤
-
-### 开启 dolphinscheduler 服务
-
-根据你部署方式开启 dolphinscheduler 的所有服务,如果你是通过 [集群部署](installation/cluster.md) 来部署你的
dolphinscheduler 的话,可以通过 `sh ./script/start-all.sh` 开启全部服务。
-
-### 数据库配置
-
-初始化工作流 demo 服务需要使用 MySQL 或 PostgreSQL 等其他数据库作为其元数据存储数据,因此必须更改一些配置。
-请参考[数据源配置](installation/datasource-setting.md) `Standalone 切换元数据库`创建并初始化数据库
,然后运行 demo 服务启动脚本。
-
-### 租户配置
-
-#### 修改 `dolphinscheduler-tools/resources/application.yaml` 配置内容
-
-```
-demo:
- tenant-code: default
- domain-name: localhost
- api-server-port: 5173
-```
-
-其中 tenant-code 是默认租户 default ,用户可以根据自己操作系统用户名修改,从而代替手动创建租户操作。api-server-port 是
dolphinscheduler 服务的端口号
-
-然后执行初始化工作流 demo 服务的启动脚本:`sh ./tools/bin/create-demo-processes.sh` 来启动服务。
-
-创建 demo 可以参考[快速上手](start/quick-start.md)
diff --git a/dolphinscheduler-tools/src/main/bin/create-demo-processes.sh
b/dolphinscheduler-tools/src/main/bin/create-demo-processes.sh
deleted file mode 100755
index 329862eb80..0000000000
--- a/dolphinscheduler-tools/src/main/bin/create-demo-processes.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-BIN_DIR=$(dirname $0)
-DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd ${BIN_DIR}/../..;pwd)}
-TOOLS_HOME=$(cd ${BIN_DIR}/..;pwd)
-
-if [ "$DOCKER" != "true" ]; then
- source "$DOLPHINSCHEDULER_HOME/bin/env/dolphinscheduler_env.sh"
-fi
-
-JAVA_OPTS=${JAVA_OPTS:-"-server -Duser.timezone=${SPRING_JACKSON_TIME_ZONE}
-Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"}
-
-$JAVA_HOME/bin/java $JAVA_OPTS \
- -cp "$TOOLS_HOME/conf":"$TOOLS_HOME/sql":"$TOOLS_HOME/libs/*" \
- -Dspring.profiles.active=demo,${DATABASE} \
- org.apache.dolphinscheduler.tools.demo.CreateProcessDemo
diff --git
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/CreateDemoTenant.java
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/CreateDemoTenant.java
deleted file mode 100644
index 2a5b0cebf3..0000000000
---
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/CreateDemoTenant.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dolphinscheduler.tools.demo;
-
-import org.apache.dolphinscheduler.dao.entity.Tenant;
-import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
-
-import java.util.Date;
-
-import lombok.extern.slf4j.Slf4j;
-
-import org.springframework.beans.factory.annotation.Autowired;
-
-@Slf4j
-public class CreateDemoTenant {
-
- @Autowired
- private TenantMapper tenantMapper;
-
- public void createTenantCode(String tenantCode) {
- Date now = new Date();
-
- if (!tenantCode.equals("default")) {
- Boolean existTenant = tenantMapper.existTenant(tenantCode);
- if (!Boolean.TRUE.equals(existTenant)) {
- Tenant tenant = new Tenant();
- tenant.setTenantCode(tenantCode);
- tenant.setQueueId(1);
- tenant.setDescription("");
- tenant.setCreateTime(now);
- tenant.setUpdateTime(now);
- // save
- tenantMapper.insert(tenant);
- log.info("create tenant success");
- } else {
- log.warn("os tenant code already exists");
- }
- }
- }
-}
diff --git
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/CreateWorkflowDemo.java
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/CreateWorkflowDemo.java
deleted file mode 100644
index 184d669f3e..0000000000
---
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/CreateWorkflowDemo.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dolphinscheduler.tools.demo;
-
-import lombok.extern.slf4j.Slf4j;
-
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.FilterType;
-import org.springframework.context.annotation.Profile;
-import org.springframework.stereotype.Component;
-
-@SpringBootApplication
-@ComponentScan(value = "org.apache.dolphinscheduler", excludeFilters = {
- @ComponentScan.Filter(type = FilterType.REGEX, pattern = {
- "org.apache.dolphinscheduler.tools.datasource.*",
- })
-})
-public class CreateWorkflowDemo {
-
- public static void main(String[] args) {
- SpringApplication.run(CreateWorkflowDemo.class, args);
- }
-
- @Component
- @Profile("demo")
- @Slf4j
- static class DemoRunner implements CommandLineRunner {
-
- private final WorkflowDefinitionDemo workflowDefinitionDemo;
-
- DemoRunner(WorkflowDefinitionDemo workflowDefinitionDemo) {
- this.workflowDefinitionDemo = workflowDefinitionDemo;
- }
-
- @Override
- public void run(String... args) throws Exception {
- workflowDefinitionDemo.createWorkflowDefinitionDemo();
- log.info("create workflow definition demo success");
- }
- }
-}
diff --git
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/DemoConstants.java
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/DemoConstants.java
deleted file mode 100644
index 418a52d30b..0000000000
---
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/DemoConstants.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dolphinscheduler.tools.demo;
-
-public class DemoConstants {
-
- public static final String PARAMETER_CONTEXT_PARAMS =
-
"[{\"prop\":\"output\",\"value\":\"100\",\"direct\":\"IN\",\"type\":\"VARCHAR\"},{\"prop\":\"value\",\"value\":\"99\",\"direct\":\"IN\",\"type\":\"VARCHAR\"}]";
-
- public static final String SHELL_GLOBAL_PARAMS =
- "[{\"prop\":\"resources\",\"value\":\"Processing
information\",\"direct\":\"IN\",\"type\":\"VARCHAR\"}]";
-
- public static final String SWITCH_GLOBAL_PARAMS =
-
"[{\"prop\":\"switchValue\",\"value\":\"A\",\"direct\":\"IN\",\"type\":\"VARCHAR\"}]";
-
- public static final String Expire_Time = "2050-09-30 15:59:23";
-}
diff --git
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProxyResult.java
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProxyResult.java
deleted file mode 100644
index 37b558c397..0000000000
---
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProxyResult.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dolphinscheduler.tools.demo;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class ProxyResult<T> {
-
- private Integer code;
-
- private String msg;
-
- private T data;
-
- public static <T> ProxyResult<T> success(T data) {
- return new ProxyResult<>(0, "success", data);
- }
-
- public static ProxyResult success() {
- return success(null);
- }
-
- public boolean isSuccess() {
- if (code == 0) {
- return true;
- }
- return false;
- }
-
- public boolean isFailed() {
- return !this.isSuccess();
- }
-
-}
diff --git
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProxyWorkflowDefinitionController.java
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProxyWorkflowDefinitionController.java
deleted file mode 100644
index c0c9e297ef..0000000000
---
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/ProxyWorkflowDefinitionController.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dolphinscheduler.tools.demo;
-
-import org.apache.dolphinscheduler.common.enums.WorkflowExecutionTypeEnum;
-import org.apache.dolphinscheduler.common.utils.JSONUtils;
-import org.apache.dolphinscheduler.common.utils.OkHttpUtils;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-@Service
-public class ProxyWorkflowDefinitionController {
-
- @Value("${demo.api-server-port}")
- private String ServerPort;
-
- @Value("${demo.domain-name}")
- private String DomainName;
-
- public ProxyResult createProcessDefinition(String token,
- long projectCode,
- String name,
- String description,
- String globalParams,
- String locations,
- int timeout,
- String tenantCode,
- String taskRelationJson,
- String taskDefinitionJson,
- WorkflowExecutionTypeEnum
executionType) {
- ProxyResult proxyResult = new ProxyResult();
- String url =
- "http://" + DomainName + ":" + ServerPort +
"/dolphinscheduler/projects/" + projectCode
- + "/process-definition";
- String responseBody;
- Map<String, Object> requestBodyMap = new HashMap<>();
-
- requestBodyMap.put("name", name);
- requestBodyMap.put("description", description);
- requestBodyMap.put("globalParams", globalParams);
- requestBodyMap.put("locations", locations);
- requestBodyMap.put("timeout", timeout);
- requestBodyMap.put("tenantCode", tenantCode);
- requestBodyMap.put("taskRelationJson", taskRelationJson);
- requestBodyMap.put("taskDefinitionJson", taskDefinitionJson);
- requestBodyMap.put("otherParamsJson", null);
- requestBodyMap.put("executionType", executionType);
-
- try {
- responseBody = OkHttpUtils.demoPost(url, token, requestBodyMap);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- proxyResult = JSONUtils.parseObject(responseBody, ProxyResult.class);
-
- return proxyResult;
-
- }
-}
diff --git
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/WorkflowDefinitionDemo.java
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/WorkflowDefinitionDemo.java
deleted file mode 100644
index 434cbaf213..0000000000
---
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/demo/WorkflowDefinitionDemo.java
+++ /dev/null
@@ -1,805 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dolphinscheduler.tools.demo;
-
-import static org.apache.dolphinscheduler.common.enums.ConditionType.NONE;
-import static org.apache.dolphinscheduler.common.enums.Flag.YES;
-import static org.apache.dolphinscheduler.common.enums.Priority.MEDIUM;
-import static
org.apache.dolphinscheduler.common.enums.WorkflowExecutionTypeEnum.PARALLEL;
-
-import org.apache.dolphinscheduler.common.enums.TimeoutFlag;
-import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils;
-import org.apache.dolphinscheduler.common.utils.DateUtils;
-import org.apache.dolphinscheduler.common.utils.EncryptionUtils;
-import org.apache.dolphinscheduler.common.utils.JSONUtils;
-import org.apache.dolphinscheduler.dao.entity.AccessToken;
-import org.apache.dolphinscheduler.dao.entity.Project;
-import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog;
-import org.apache.dolphinscheduler.dao.entity.User;
-import org.apache.dolphinscheduler.dao.entity.WorkflowDefinitionLog;
-import org.apache.dolphinscheduler.dao.entity.WorkflowTaskRelationLog;
-import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper;
-import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
-import org.apache.dolphinscheduler.dao.mapper.UserMapper;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import lombok.extern.slf4j.Slf4j;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-@Component
-@Slf4j
-public class WorkflowDefinitionDemo {
-
- @Value("${demo.tenant-code}")
- private String tenantCode;
-
- @Autowired
- private ProjectMapper projectMapper;
-
- @Autowired
- private UserMapper userMapper;
-
- @Autowired
- private AccessTokenMapper accessTokenMapper;
-
- @Autowired
- private ProxyWorkflowDefinitionController
proxyWorkflowDefinitionController;
-
- public void createWorkflowDefinitionDemo() throws Exception {
- // get user
- User loginUser = userMapper.selectById("1");
- Date now = new Date();
-
- // create demo tenantCode
- CreateDemoTenant createDemoTenant = new CreateDemoTenant();
- createDemoTenant.createTenantCode(tenantCode);
-
- // create and get demo projectCode
- Project project = projectMapper.queryByName("demo");
- if (project != null) {
- log.warn("Project {} already exists.", project.getName());
- }
- project = Project
- .builder()
- .name("demo")
- .code(CodeGenerateUtils.genCode())
- .description("")
- .userId(loginUser.getId())
- .userName(loginUser.getUserName())
- .createTime(now)
- .updateTime(now)
- .build();
-
- if (projectMapper.insert(project) > 0) {
- log.info("create project success");
- } else {
- throw new Exception("create project error");
- }
- Long projectCode = null;
- try {
- projectCode = project.getCode();
- } catch (NullPointerException e) {
- log.error("project code is null", e);
- }
-
- // generate access token
- String expireTime = DemoConstants.Expire_Time;
- String token = EncryptionUtils.getMd5(1 + expireTime +
System.currentTimeMillis());
- AccessToken accessToken = new AccessToken();
- accessToken.setUserId(1);
- accessToken.setExpireTime(DateUtils.stringToDate(expireTime));
- accessToken.setToken(token);
- accessToken.setCreateTime(new Date());
- accessToken.setUpdateTime(new Date());
-
- int insert = accessTokenMapper.insert(accessToken);
-
- if (insert > 0) {
- log.info("create access token success");
- } else {
- log.info("create access token error");
- }
-
- // creat process definition demo
- // shell demo
- ProxyResult shellResult = shellDemo(token, projectCode, tenantCode);
- log.info("create shell demo {}", shellResult.getMsg());
-
- // subprocess demo
- LinkedHashMap<String, Object> subProcess = (LinkedHashMap<String,
Object>) shellResult.getData();
- String subProcessCode = String.valueOf(subProcess.get("code"));
- ProxyResult subProcessResult = subProcessDemo(token, projectCode,
tenantCode, subProcessCode);
- log.info("create subprocess demo {}", subProcessResult.getMsg());
-
- // switch demo
- ProxyResult switchResult = swicthDemo(token, projectCode, tenantCode);
- log.info("create switch demo {}", switchResult.getMsg());
-
- // condition demo
- ProxyResult conditionResult = conditionDemo(token, projectCode,
tenantCode);
- log.info("create condition demo {}", conditionResult.getMsg());
-
- // dependent demo
- LinkedHashMap<String, Object> switchProcess = (LinkedHashMap<String,
Object>) switchResult.getData();
- String switchProcessCode = String.valueOf(switchProcess.get("code"));
- ProxyResult dependentResult =
- dependentProxyResultDemo(token, projectCode, tenantCode,
subProcessCode, switchProcessCode);
- log.info("create dependent demo {}", dependentResult.getMsg());
-
- // parameter context demo
- ProxyResult parameterContextResult = parameterContextDemo(token,
projectCode, tenantCode);
- log.info("create parameter context demo {}",
parameterContextResult.getMsg());
-
- // clear log demo
- ProxyResult clearLogResult = clearLogDemo(token, projectCode,
tenantCode);
- log.info("create clear log demo {}", clearLogResult.getMsg());
-
- }
-
- public ProxyResult clearLogDemo(String token, long projectCode, String
tenantCode) {
-
- // get demo taskcode
- List<Long> taskCodes = new ArrayList<>();
- for (int i = 0; i < 1; i++) {
- taskCodes.add(CodeGenerateUtils.genCode());
- }
-
- String taskCodeFirst =
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
- String absolutePath = System.getProperty("user.dir");
-
- WorkflowDefinitionLog processDefinitionLog = new
WorkflowDefinitionLog();
- processDefinitionLog.setName("demo_clear_log");
- processDefinitionLog.setDescription("Clear the DS log files from 30
days ago");
- processDefinitionLog.setGlobalParams("[]");
- processDefinitionLog.setLocations(null);
- processDefinitionLog.setTimeout(0);
-
- List<WorkflowTaskRelationLog> processTaskRelationLogs = new
ArrayList<>();
- for (int i = 0; i < 1; i++) {
- WorkflowTaskRelationLog processTaskRelationLog = new
WorkflowTaskRelationLog();
- processTaskRelationLog.setName("");
- processTaskRelationLog.setConditionType(NONE);
- processTaskRelationLog.setConditionParams("{}");
- processTaskRelationLogs.add(processTaskRelationLog);
- }
- WorkflowTaskRelationLog processTaskRelationLogFirst =
processTaskRelationLogs.get(0);
- processTaskRelationLogFirst.setPreTaskCode(0);
- processTaskRelationLogFirst.setPreTaskVersion(0);
- processTaskRelationLogFirst.setPostTaskCode(taskCodes.get(0));
- processTaskRelationLogFirst.setPostTaskVersion(1);
-
- String taskRelationJson =
JSONUtils.toJsonString(processTaskRelationLogs);
-
- List<TaskDefinitionLog> taskDefinitionLogs = new ArrayList<>();
- for (int i = 0; i < 1; i++) {
- TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog();
- taskDefinitionLog.setFlag(YES);
- taskDefinitionLog.setDelayTime(0);
- taskDefinitionLog.setEnvironmentCode(-1);
- taskDefinitionLog.setFailRetryInterval(1);
- taskDefinitionLog.setFailRetryTimes(0);
- taskDefinitionLog.setTaskPriority(MEDIUM);
- taskDefinitionLog.setTimeout(0);
- taskDefinitionLog.setTimeoutFlag(TimeoutFlag.CLOSE);
- taskDefinitionLog.setTimeoutNotifyStrategy(null);
- taskDefinitionLog.setWorkerGroup("default");
- taskDefinitionLog.setTaskType("SHELL");
- taskDefinitionLogs.add(taskDefinitionLog);
- }
- TaskDefinitionLog taskDefinitionLogFirst = taskDefinitionLogs.get(0);
- taskDefinitionLogFirst.setCode(taskCodes.get(0));
- taskDefinitionLogFirst.setName("Clear log node");
- taskDefinitionLogFirst.setDescription("");
-
taskDefinitionLogFirst.setTaskParams("{\"localParams\":[],\"rawScript\":\"cd cd
" + absolutePath
- + "\\r\\nfind ./logs/ -mtime +30 -name \\\"*.log\\\" -exec rm
-rf {} \\\\;\",\"resourceList\":[]}");
-
- String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
-
- ProxyResult ProxyResult =
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
- processDefinitionLog.getName(),
- processDefinitionLog.getDescription(),
- processDefinitionLog.getGlobalParams(),
- processDefinitionLog.getLocations(),
- processDefinitionLog.getTimeout(),
- tenantCode,
- taskRelationJson,
- taskDefinitionJson,
- PARALLEL);
- return ProxyResult;
- }
- public ProxyResult dependentProxyResultDemo(String token, long
projectCode, String tenantCode,
- String shellProcessCode,
String switchProcessCode) {
-
- // get demo taskcode
- List<Long> taskCodes = new ArrayList<>();
-
- for (int i = 0; i < 2; i++) {
- taskCodes.add(CodeGenerateUtils.genCode());
- }
-
- String taskCodeFirst =
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
- String taskCodeSecond =
String.valueOf(taskCodes.get(1)).replaceAll("\\[|\\]", "");
-
- WorkflowDefinitionLog processDefinitionLog = new
WorkflowDefinitionLog();
- processDefinitionLog.setName("demo_dependent");
- processDefinitionLog.setDescription("Check the completion of daily
tasks");
- processDefinitionLog.setGlobalParams("[]");
- processDefinitionLog.setLocations(null);
- processDefinitionLog.setTimeout(0);
-
- List<WorkflowTaskRelationLog> processTaskRelationLogs = new
ArrayList<>();
- for (int i = 0; i < 2; i++) {
- WorkflowTaskRelationLog processTaskRelationLog = new
WorkflowTaskRelationLog();
- processTaskRelationLog.setName("");
- processTaskRelationLog.setConditionType(NONE);
- processTaskRelationLog.setConditionParams("{}");
- processTaskRelationLogs.add(processTaskRelationLog);
- }
- WorkflowTaskRelationLog processTaskRelationLogFirst =
processTaskRelationLogs.get(0);
- processTaskRelationLogFirst.setPreTaskCode(0);
- processTaskRelationLogFirst.setPreTaskVersion(0);
- processTaskRelationLogFirst.setPostTaskCode(taskCodes.get(0));
- processTaskRelationLogFirst.setPostTaskVersion(1);
-
- WorkflowTaskRelationLog processTaskRelationLogSecond =
processTaskRelationLogs.get(1);
- processTaskRelationLogSecond.setPreTaskCode(taskCodes.get(0));
- processTaskRelationLogSecond.setPreTaskVersion(1);
- processTaskRelationLogSecond.setPostTaskCode(taskCodes.get(1));
- processTaskRelationLogSecond.setPostTaskVersion(1);
-
- String taskRelationJson =
JSONUtils.toJsonString(processTaskRelationLogs);
-
- List<TaskDefinitionLog> taskDefinitionLogs = new ArrayList<>();
- for (int i = 0; i < 2; i++) {
- TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog();
- taskDefinitionLog.setFlag(YES);
- taskDefinitionLog.setDelayTime(0);
- taskDefinitionLog.setEnvironmentCode(-1);
- taskDefinitionLog.setFailRetryInterval(1);
- taskDefinitionLog.setFailRetryTimes(0);
- taskDefinitionLog.setTaskPriority(MEDIUM);
- taskDefinitionLog.setTimeout(0);
- taskDefinitionLog.setTimeoutFlag(TimeoutFlag.CLOSE);
- taskDefinitionLog.setTimeoutNotifyStrategy(null);
- taskDefinitionLog.setWorkerGroup("default");
- taskDefinitionLogs.add(taskDefinitionLog);
- }
- TaskDefinitionLog taskDefinitionLogFirst = taskDefinitionLogs.get(0);
- taskDefinitionLogFirst.setCode(taskCodes.get(0));
- taskDefinitionLogFirst.setName("Weekly report task");
- taskDefinitionLogFirst.setDescription(
- "The weekly report task requires the demo_shell and
demo_switch tasks to be successfully executed every day of the last week");
- taskDefinitionLogFirst.setTaskParams(
-
"{\"localParams\":[],\"resourceList\":[],\"dependence\":{\"relation\":\"AND\",\"dependTaskList\":[{\"relation\":\"AND\",\"dependItemList\":[{\"projectCode\":"
- + projectCode + ",\"definitionCode\":" +
shellProcessCode
- +
",\"depTaskCode\":0,\"cycle\":\"day\",\"dateValue\":\"last1Days\",\"state\":null},{\"projectCode\":"
- + projectCode + ",\"definitionCode\":" +
switchProcessCode
- +
",\"depTaskCode\":0,\"cycle\":\"day\",\"dateValue\":\"last1Days\",\"state\":null}]}]}}");
- taskDefinitionLogFirst.setTaskType("DEPENDENT");
-
- TaskDefinitionLog taskDefinitionLogSecond = taskDefinitionLogs.get(1);
- taskDefinitionLogSecond.setCode(taskCodes.get(1));
- taskDefinitionLogSecond.setName("Weekly Report Task Result");
- taskDefinitionLogSecond.setDescription("Result report after the
completion of the weekly report task");
- taskDefinitionLogSecond
- .setTaskParams("{\"localParams\":[],\"rawScript\":\"echo
\\\"end of report\\\"\",\"resourceList\":[]}");
- taskDefinitionLogSecond.setTaskType("SHELL");
- String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
-
- ProxyResult ProxyResult =
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
- processDefinitionLog.getName(),
- processDefinitionLog.getDescription(),
- processDefinitionLog.getGlobalParams(),
- processDefinitionLog.getLocations(),
- processDefinitionLog.getTimeout(),
- tenantCode,
- taskRelationJson,
- taskDefinitionJson,
- PARALLEL);
- return ProxyResult;
- }
- public ProxyResult parameterContextDemo(String token, long projectCode,
String tenantCode) {
-
- // get demo taskcode
- List<Long> taskCodes = new ArrayList<>();
-
- for (int i = 0; i < 2; i++) {
- taskCodes.add(CodeGenerateUtils.genCode());
- }
-
- String taskCodeFirst =
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
- String taskCodeSecond =
String.valueOf(taskCodes.get(1)).replaceAll("\\[|\\]", "");
-
- WorkflowDefinitionLog processDefinitionLog = new
WorkflowDefinitionLog();
- processDefinitionLog.setName("demo_parameter_context");
- processDefinitionLog.setDescription("Upstream and downstream task node
parameter transfer");
-
processDefinitionLog.setGlobalParams(DemoConstants.PARAMETER_CONTEXT_PARAMS);
- processDefinitionLog.setLocations(null);
- processDefinitionLog.setTimeout(0);
-
- List<WorkflowTaskRelationLog> processTaskRelationLogs = new
ArrayList<>();
- for (int i = 0; i < 2; i++) {
- WorkflowTaskRelationLog processTaskRelationLog = new
WorkflowTaskRelationLog();
- processTaskRelationLog.setName("");
- processTaskRelationLog.setConditionType(NONE);
- processTaskRelationLog.setConditionParams("{}");
- processTaskRelationLogs.add(processTaskRelationLog);
- }
- WorkflowTaskRelationLog processTaskRelationLogFirst =
processTaskRelationLogs.get(0);
- processTaskRelationLogFirst.setPreTaskCode(0);
- processTaskRelationLogFirst.setPreTaskVersion(0);
- processTaskRelationLogFirst.setPostTaskCode(taskCodes.get(0));
- processTaskRelationLogFirst.setPostTaskVersion(1);
-
- WorkflowTaskRelationLog processTaskRelationLogSecond =
processTaskRelationLogs.get(1);
- processTaskRelationLogSecond.setPreTaskCode(taskCodes.get(0));
- processTaskRelationLogSecond.setPreTaskVersion(1);
- processTaskRelationLogSecond.setPostTaskCode(taskCodes.get(1));
- processTaskRelationLogSecond.setPostTaskVersion(1);
-
- String taskRelationJson =
JSONUtils.toJsonString(processTaskRelationLogs);
-
- List<TaskDefinitionLog> taskDefinitionLogs = new ArrayList<>();
- for (int i = 0; i < 2; i++) {
- TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog();
- taskDefinitionLog.setFlag(YES);
- taskDefinitionLog.setDelayTime(0);
- taskDefinitionLog.setEnvironmentCode(-1);
- taskDefinitionLog.setFailRetryInterval(1);
- taskDefinitionLog.setFailRetryTimes(0);
- taskDefinitionLog.setTaskPriority(MEDIUM);
- taskDefinitionLog.setTimeout(0);
- taskDefinitionLog.setTimeoutFlag(TimeoutFlag.CLOSE);
- taskDefinitionLog.setTimeoutNotifyStrategy(null);
- taskDefinitionLog.setWorkerGroup("default");
- taskDefinitionLog.setTaskType("SHELL");
- taskDefinitionLogs.add(taskDefinitionLog);
- }
- TaskDefinitionLog taskDefinitionLogFirst = taskDefinitionLogs.get(0);
- taskDefinitionLogFirst.setCode(taskCodes.get(0));
- taskDefinitionLogFirst.setName("Upstream task node");
- taskDefinitionLogFirst.setDescription("Create a local parameter and
pass the assignment to the downstream");
- taskDefinitionLogFirst.setTaskParams(
-
"{\"localParams\":[{\"prop\":\"value\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"0\"},{\"prop\":\"output\",\"direct\":\"OUT\",\"type\":\"VARCHAR\",\"value\":\"\"}],\"rawScript\":\"echo
\\\"====Node start====\\\"\\r\\necho '${setValue(output=1)}'\\r\\n\\r\\necho
${output}\\r\\necho ${value}\\r\\n\\r\\necho \\\"====Node
end====\\\"\",\"resourceList\":[]}");
-
- TaskDefinitionLog taskDefinitionLogSecond = taskDefinitionLogs.get(1);
- taskDefinitionLogSecond.setCode(taskCodes.get(1));
- taskDefinitionLogSecond.setName("Downstream task node");
- taskDefinitionLogSecond.setDescription("Test outputs the parameters
passed by the upstream task");
- taskDefinitionLogSecond.setTaskParams(
- "{\"localParams\":[],\"rawScript\":\"echo \\\"====node
start====\\\"\\r\\n\\r\\necho ${output}\\r\\n\\r\\necho
${value}\\r\\n\\r\\necho \\\"====Node end====\\\"\",\"resourceList\":[]}");
- String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
-
- ProxyResult ProxyResult =
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
- processDefinitionLog.getName(),
- processDefinitionLog.getDescription(),
- processDefinitionLog.getGlobalParams(),
- processDefinitionLog.getLocations(),
- processDefinitionLog.getTimeout(),
- tenantCode,
- taskRelationJson,
- taskDefinitionJson,
- PARALLEL);
- return ProxyResult;
- }
- public ProxyResult conditionDemo(String token, long projectCode, String
tenantCode) {
-
- // get demo taskcode
- List<Long> taskCodes = new ArrayList<>();
- for (int i = 0; i < 4; i++) {
- taskCodes.add(CodeGenerateUtils.genCode());
- }
-
- String taskCodeFirst =
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
- String taskCodeSecond =
String.valueOf(taskCodes.get(1)).replaceAll("\\[|\\]", "");
- String taskCodeThird =
String.valueOf(taskCodes.get(2)).replaceAll("\\[|\\]", "");
- String taskCodeFourth =
String.valueOf(taskCodes.get(3)).replaceAll("\\[|\\]", "");
-
- WorkflowDefinitionLog processDefinitionLog = new
WorkflowDefinitionLog();
- processDefinitionLog.setName("demo_condition");
- processDefinitionLog.setDescription("Coin Toss");
- processDefinitionLog.setGlobalParams("[]");
- processDefinitionLog.setLocations(null);
- processDefinitionLog.setTimeout(0);
-
- List<WorkflowTaskRelationLog> processTaskRelationLogs = new
ArrayList<>();
- for (int i = 0; i < 4; i++) {
- WorkflowTaskRelationLog processTaskRelationLog = new
WorkflowTaskRelationLog();
- processTaskRelationLog.setName("");
- processTaskRelationLog.setConditionType(NONE);
- processTaskRelationLog.setConditionParams("{}");
- processTaskRelationLogs.add(processTaskRelationLog);
- }
- WorkflowTaskRelationLog processTaskRelationLogFirst =
processTaskRelationLogs.get(0);
- processTaskRelationLogFirst.setPreTaskCode(0);
- processTaskRelationLogFirst.setPreTaskVersion(0);
- processTaskRelationLogFirst.setPostTaskCode(taskCodes.get(1));
- processTaskRelationLogFirst.setPostTaskVersion(1);
-
- WorkflowTaskRelationLog processTaskRelationLogSecond =
processTaskRelationLogs.get(1);
- processTaskRelationLogSecond.setPreTaskCode(taskCodes.get(0));
- processTaskRelationLogSecond.setPreTaskVersion(1);
- processTaskRelationLogSecond.setPostTaskCode(taskCodes.get(2));
- processTaskRelationLogSecond.setPostTaskVersion(1);
-
- WorkflowTaskRelationLog processTaskRelationLogThird =
processTaskRelationLogs.get(2);
- processTaskRelationLogThird.setPreTaskCode(taskCodes.get(0));
- processTaskRelationLogThird.setPreTaskVersion(1);
- processTaskRelationLogThird.setPostTaskCode(taskCodes.get(3));
- processTaskRelationLogThird.setPostTaskVersion(1);
-
- WorkflowTaskRelationLog processTaskRelationLogFourth =
processTaskRelationLogs.get(3);
- processTaskRelationLogFourth.setPreTaskCode(taskCodes.get(1));
- processTaskRelationLogFourth.setPreTaskVersion(1);
- processTaskRelationLogFourth.setPostTaskCode(taskCodes.get(0));
- processTaskRelationLogFourth.setPostTaskVersion(1);
- String taskRelationJson =
JSONUtils.toJsonString(processTaskRelationLogs);
-
- List<TaskDefinitionLog> taskDefinitionLogs = new ArrayList<>();
- for (int i = 0; i < 4; i++) {
- TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog();
- taskDefinitionLog.setFlag(YES);
- taskDefinitionLog.setDelayTime(0);
- taskDefinitionLog.setEnvironmentCode(-1);
- taskDefinitionLog.setFailRetryInterval(1);
- taskDefinitionLog.setFailRetryTimes(0);
- taskDefinitionLog.setTaskPriority(MEDIUM);
- taskDefinitionLog.setTimeout(0);
- taskDefinitionLog.setTimeoutFlag(TimeoutFlag.CLOSE);
- taskDefinitionLog.setTimeoutNotifyStrategy(null);
- taskDefinitionLog.setWorkerGroup("default");
- taskDefinitionLogs.add(taskDefinitionLog);
- }
- TaskDefinitionLog taskDefinitionLogFirst = taskDefinitionLogs.get(0);
- taskDefinitionLogFirst.setCode(taskCodes.get(0));
- taskDefinitionLogFirst.setName("condition");
- taskDefinitionLogFirst.setDescription("head is the status of success,
tail is the status of failure");
- taskDefinitionLogFirst.setTaskParams(
-
"{\"localParams\":[],\"resourceList\":[],\"dependence\":{\"relation\":\"AND\",\"dependTaskList\":[]},\"conditionResult\":{\"successNode\":["
- + taskCodeThird + "],\"failedNode\":[" +
taskCodeFourth + "]}}");
- taskDefinitionLogFirst.setTaskType("CONDITIONS");
-
- TaskDefinitionLog taskDefinitionLogSecond = taskDefinitionLogs.get(1);
- taskDefinitionLogSecond.setCode(taskCodes.get(1));
- taskDefinitionLogSecond.setName("coin");
- taskDefinitionLogSecond.setDescription("Toss a coin");
- taskDefinitionLogSecond
- .setTaskParams("{\"localParams\":[],\"rawScript\":\"echo
\\\"Start\\\"\",\"resourceList\":[]}");
- taskDefinitionLogSecond.setTaskType("SHELL");
-
- TaskDefinitionLog taskDefinitionLogThird = taskDefinitionLogs.get(2);
- taskDefinitionLogThird.setCode(taskCodes.get(2));
- taskDefinitionLogThird.setName("head");
- taskDefinitionLogThird.setDescription("Choose to learn if the result
is head");
- taskDefinitionLogThird.setTaskParams(
- "{\"localParams\":[],\"rawScript\":\"echo \\\"Start
learning\\\"\",\"resourceList\":[]}");
- taskDefinitionLogThird.setTaskType("SHELL");
-
- TaskDefinitionLog taskDefinitionLogFourth = taskDefinitionLogs.get(3);
- taskDefinitionLogFourth.setCode(taskCodes.get(3));
- taskDefinitionLogFourth.setName("tail");
- taskDefinitionLogFourth.setDescription("Choose to play if the result
is tail");
- taskDefinitionLogFourth
- .setTaskParams("{\"localParams\":[],\"rawScript\":\"echo
\\\"Start playing\\\"\",\"resourceList\":[]}");
- taskDefinitionLogFourth.setTaskType("SHELL");
- String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
-
- ProxyResult ProxyResult =
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
- processDefinitionLog.getName(),
- processDefinitionLog.getDescription(),
- processDefinitionLog.getGlobalParams(),
- processDefinitionLog.getLocations(),
- processDefinitionLog.getTimeout(),
- tenantCode,
- taskRelationJson,
- taskDefinitionJson,
- PARALLEL);
- return ProxyResult;
- }
- public ProxyResult swicthDemo(String token, long projectCode, String
tenantCode) {
-
- // get demo taskcode
- List<Long> taskCodes = new ArrayList<>();
-
- for (int i = 0; i < 4; i++) {
- taskCodes.add(CodeGenerateUtils.genCode());
- }
-
- String taskCodeFirst =
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
- String taskCodeSecond =
String.valueOf(taskCodes.get(1)).replaceAll("\\[|\\]", "");
- String taskCodeThird =
String.valueOf(taskCodes.get(2)).replaceAll("\\[|\\]", "");
- String taskCodeFourth =
String.valueOf(taskCodes.get(3)).replaceAll("\\[|\\]", "");
-
- WorkflowDefinitionLog processDefinitionLog = new
WorkflowDefinitionLog();
- processDefinitionLog.setName("demo_switch");
- processDefinitionLog.setDescription("Determine which task to perform
based on conditions");
-
processDefinitionLog.setGlobalParams(DemoConstants.SWITCH_GLOBAL_PARAMS);
- processDefinitionLog.setLocations(null);
- processDefinitionLog.setTimeout(0);
-
- List<WorkflowTaskRelationLog> processTaskRelationLogs = new
ArrayList<>();
- for (int i = 0; i < 4; i++) {
- WorkflowTaskRelationLog processTaskRelationLog = new
WorkflowTaskRelationLog();
- processTaskRelationLog.setName("");
- processTaskRelationLog.setConditionType(NONE);
- processTaskRelationLog.setConditionParams("{}");
- processTaskRelationLogs.add(processTaskRelationLog);
- }
- WorkflowTaskRelationLog processTaskRelationLogFirst =
processTaskRelationLogs.get(0);
- processTaskRelationLogFirst.setPreTaskCode(0);
- processTaskRelationLogFirst.setPreTaskVersion(0);
- processTaskRelationLogFirst.setPostTaskCode(taskCodes.get(0));
- processTaskRelationLogFirst.setPostTaskVersion(1);
-
- WorkflowTaskRelationLog processTaskRelationLogSecond =
processTaskRelationLogs.get(1);
- processTaskRelationLogSecond.setPreTaskCode(taskCodes.get(0));
- processTaskRelationLogSecond.setPreTaskVersion(1);
- processTaskRelationLogSecond.setPostTaskCode(taskCodes.get(1));
- processTaskRelationLogSecond.setPostTaskVersion(1);
-
- WorkflowTaskRelationLog processTaskRelationLogThird =
processTaskRelationLogs.get(2);
- processTaskRelationLogThird.setPreTaskCode(taskCodes.get(0));
- processTaskRelationLogThird.setPreTaskVersion(1);
- processTaskRelationLogThird.setPostTaskCode(taskCodes.get(2));
- processTaskRelationLogThird.setPostTaskVersion(1);
-
- WorkflowTaskRelationLog processTaskRelationLogFourth =
processTaskRelationLogs.get(3);
- processTaskRelationLogFourth.setPreTaskCode(taskCodes.get(0));
- processTaskRelationLogFourth.setPreTaskVersion(1);
- processTaskRelationLogFourth.setPostTaskCode(taskCodes.get(3));
- processTaskRelationLogFourth.setPostTaskVersion(1);
- String taskRelationJson =
JSONUtils.toJsonString(processTaskRelationLogs);
-
- List<TaskDefinitionLog> taskDefinitionLogs = new ArrayList<>();
- for (int i = 0; i < 4; i++) {
- TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog();
- taskDefinitionLog.setFlag(YES);
- taskDefinitionLog.setDelayTime(0);
- taskDefinitionLog.setEnvironmentCode(-1);
- taskDefinitionLog.setFailRetryInterval(1);
- taskDefinitionLog.setFailRetryTimes(0);
- taskDefinitionLog.setTaskPriority(MEDIUM);
- taskDefinitionLog.setTimeout(0);
- taskDefinitionLog.setTimeoutFlag(TimeoutFlag.CLOSE);
- taskDefinitionLog.setTimeoutNotifyStrategy(null);
- taskDefinitionLog.setWorkerGroup("default");
- taskDefinitionLogs.add(taskDefinitionLog);
- }
- TaskDefinitionLog taskDefinitionLogFirst = taskDefinitionLogs.get(0);
- taskDefinitionLogFirst.setCode(taskCodes.get(0));
- taskDefinitionLogFirst.setName("switch node");
- taskDefinitionLogFirst.setDescription(
- "The global parameter is to execute TaskA for A, and for B to
execute TaskB, otherwise the default task is executed");
- taskDefinitionLogFirst.setTaskParams(
-
"{\"localParams\":[],\"rawScript\":\"\",\"resourceList\":[],\"switchResult\":{\"dependTaskList\":[{\"condition\":\"${switchValue}
== \\\"A\\\"\",\"nextNode\":"
- + taskCodeThird + "},{\"condition\":\"${switchValue}
== \\\"B\\\"\",\"nextNode\":"
- + taskCodeFourth + "}],\"nextNode\":" + taskCodeSecond
+ "}}");
- taskDefinitionLogFirst.setTaskType("SWITCH");
-
- TaskDefinitionLog taskDefinitionLogSecond = taskDefinitionLogs.get(1);
- taskDefinitionLogSecond.setCode(taskCodes.get(1));
- taskDefinitionLogSecond.setName("default");
- taskDefinitionLogSecond.setDescription("executed default task");
- taskDefinitionLogSecond
- .setTaskParams("{\"localParams\":[],\"rawScript\":\"echo
\\\"default\\\"\",\"resourceList\":[]}");
- taskDefinitionLogSecond.setTaskType("SHELL");
-
- TaskDefinitionLog taskDefinitionLogThird = taskDefinitionLogs.get(2);
- taskDefinitionLogThird.setCode(taskCodes.get(2));
- taskDefinitionLogThird.setName("TaskA");
- taskDefinitionLogThird.setDescription("execute TaskA");
- taskDefinitionLogThird
- .setTaskParams("{\"localParams\":[],\"rawScript\":\"echo
\\\"TaskA\\\"\",\"resourceList\":[]}");
- taskDefinitionLogThird.setTaskType("SHELL");
-
- TaskDefinitionLog taskDefinitionLogFourth = taskDefinitionLogs.get(3);
- taskDefinitionLogFourth.setCode(taskCodes.get(3));
- taskDefinitionLogFourth.setName("TaskB");
- taskDefinitionLogFourth.setDescription("execute TaskB");
- taskDefinitionLogFourth
- .setTaskParams("{\"localParams\":[],\"rawScript\":\"echo
\\\"TaskB\\\"\",\"resourceList\":[]}");
- taskDefinitionLogFourth.setTaskType("SHELL");
- String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
-
- ProxyResult ProxyResult =
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
- processDefinitionLog.getName(),
- processDefinitionLog.getDescription(),
- processDefinitionLog.getGlobalParams(),
- processDefinitionLog.getLocations(),
- processDefinitionLog.getTimeout(),
- tenantCode,
- taskRelationJson,
- taskDefinitionJson,
- PARALLEL);
- return ProxyResult;
- }
- public ProxyResult shellDemo(String token, long projectCode, String
tenantCode) {
-
- // get demo taskcode
- List<Long> taskCodes = new ArrayList<>();
- for (int i = 0; i < 3; i++) {
- taskCodes.add(CodeGenerateUtils.genCode());
- }
-
- String taskCodeFirst =
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
- String taskCodeSecond =
String.valueOf(taskCodes.get(1)).replaceAll("\\[|\\]", "");
- String taskCodeThird =
String.valueOf(taskCodes.get(2)).replaceAll("\\[|\\]", "");
-
- WorkflowDefinitionLog processDefinitionLog = new
WorkflowDefinitionLog();
- processDefinitionLog.setName("demo_shell");
- processDefinitionLog.setDescription("Production, processing and sales
of a series of processes");
-
processDefinitionLog.setGlobalParams(DemoConstants.SHELL_GLOBAL_PARAMS);
- processDefinitionLog.setLocations(null);
- processDefinitionLog.setTimeout(0);
-
- List<WorkflowTaskRelationLog> processTaskRelationLogs = new
ArrayList<>();
- for (int i = 0; i < 3; i++) {
- WorkflowTaskRelationLog processTaskRelationLog = new
WorkflowTaskRelationLog();
- processTaskRelationLog.setName("");
- processTaskRelationLog.setConditionType(NONE);
- processTaskRelationLog.setConditionParams("{}");
- processTaskRelationLogs.add(processTaskRelationLog);
- }
- WorkflowTaskRelationLog processTaskRelationLogFirst =
processTaskRelationLogs.get(0);
- processTaskRelationLogFirst.setPreTaskCode(0);
- processTaskRelationLogFirst.setPreTaskVersion(0);
- processTaskRelationLogFirst.setPostTaskCode(taskCodes.get(0));
- processTaskRelationLogFirst.setPostTaskVersion(1);
-
- WorkflowTaskRelationLog processTaskRelationLogSecond =
processTaskRelationLogs.get(1);
- processTaskRelationLogSecond.setPreTaskCode(taskCodes.get(0));
- processTaskRelationLogSecond.setPreTaskVersion(1);
- processTaskRelationLogSecond.setPostTaskCode(taskCodes.get(1));
- processTaskRelationLogSecond.setPostTaskVersion(1);
-
- WorkflowTaskRelationLog processTaskRelationLogThird =
processTaskRelationLogs.get(2);
- processTaskRelationLogThird.setPreTaskCode(taskCodes.get(1));
- processTaskRelationLogThird.setPreTaskVersion(1);
- processTaskRelationLogThird.setPostTaskCode(taskCodes.get(2));
- processTaskRelationLogThird.setPostTaskVersion(1);
- String taskRelationJson =
JSONUtils.toJsonString(processTaskRelationLogs);
-
- List<TaskDefinitionLog> taskDefinitionLogs = new ArrayList<>();
- for (int i = 0; i < 3; i++) {
- TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog();
- taskDefinitionLog.setFlag(YES);
- taskDefinitionLog.setDelayTime(0);
- taskDefinitionLog.setEnvironmentCode(-1);
- taskDefinitionLog.setFailRetryInterval(1);
- taskDefinitionLog.setFailRetryTimes(0);
- taskDefinitionLog.setTaskPriority(MEDIUM);
- taskDefinitionLog.setTimeout(0);
- taskDefinitionLog.setTimeoutFlag(TimeoutFlag.CLOSE);
- taskDefinitionLog.setTimeoutNotifyStrategy(null);
- taskDefinitionLog.setWorkerGroup("default");
- taskDefinitionLog.setTaskType("SHELL");
- taskDefinitionLogs.add(taskDefinitionLog);
- }
- TaskDefinitionLog taskDefinitionLogFirst = taskDefinitionLogs.get(0);
- taskDefinitionLogFirst.setCode(taskCodes.get(0));
- taskDefinitionLogFirst.setName("001");
- taskDefinitionLogFirst.setDescription("Make production order");
- taskDefinitionLogFirst
- .setTaskParams("{\"localParams\":[],\"rawScript\":\"echo
\\\"start\\\"\",\"resourceList\":[]}");
-
- TaskDefinitionLog taskDefinitionLogSecond = taskDefinitionLogs.get(1);
- taskDefinitionLogSecond.setCode(taskCodes.get(1));
- taskDefinitionLogSecond.setName("002");
- taskDefinitionLogSecond.setDescription("Get Information Processing");
- taskDefinitionLogSecond
- .setTaskParams("{\"localParams\":[],\"rawScript\":\"echo
${resources}\",\"resourceList\":[]}");
-
- TaskDefinitionLog taskDefinitionLogThird = taskDefinitionLogs.get(2);
- taskDefinitionLogThird.setCode(taskCodes.get(2));
- taskDefinitionLogThird.setName("003");
- taskDefinitionLogThird.setDescription("Sell after completion");
- taskDefinitionLogThird
- .setTaskParams("{\"localParams\":[],\"rawScript\":\"echo
\\\"end\\\"\",\"resourceList\":[]}");
- String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
-
- ProxyResult ProxyResult =
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
- processDefinitionLog.getName(),
- processDefinitionLog.getDescription(),
- processDefinitionLog.getGlobalParams(),
- processDefinitionLog.getLocations(),
- processDefinitionLog.getTimeout(),
- tenantCode,
- taskRelationJson,
- taskDefinitionJson,
- PARALLEL);
- return ProxyResult;
- }
- public ProxyResult subProcessDemo(String token, long projectCode, String
tenantCode, String subProcessCode) {
-
- // get demo taskcode
- List<Long> taskCodes = new ArrayList<>();
- for (int i = 0; i < 1; i++) {
- taskCodes.add(CodeGenerateUtils.genCode());
- }
-
- String taskCode =
String.valueOf(taskCodes.get(0)).replaceAll("\\[|\\]", "");
-
- WorkflowDefinitionLog processDefinitionLog = new
WorkflowDefinitionLog();
- processDefinitionLog.setName("demo_sub_workflow");
- processDefinitionLog.setDescription("Start the production line");
- processDefinitionLog.setGlobalParams("[]");
- processDefinitionLog.setLocations(null);
- processDefinitionLog.setTimeout(0);
-
- List<WorkflowTaskRelationLog> processTaskRelationLogs = new
ArrayList<>();
- for (int i = 0; i < 1; i++) {
- WorkflowTaskRelationLog processTaskRelationLog = new
WorkflowTaskRelationLog();
- processTaskRelationLog.setName("");
- processTaskRelationLog.setConditionType(NONE);
- processTaskRelationLog.setConditionParams("{}");
- processTaskRelationLogs.add(processTaskRelationLog);
- }
- WorkflowTaskRelationLog processTaskRelationLogFirst =
processTaskRelationLogs.get(0);
- processTaskRelationLogFirst.setPreTaskCode(0);
- processTaskRelationLogFirst.setPreTaskVersion(0);
- processTaskRelationLogFirst.setPostTaskCode(taskCodes.get(0));
- processTaskRelationLogFirst.setPostTaskVersion(1);
-
- String taskRelationJson =
JSONUtils.toJsonString(processTaskRelationLogs);
-
- List<TaskDefinitionLog> taskDefinitionLogs = new ArrayList<>();
- for (int i = 0; i < 1; i++) {
- TaskDefinitionLog taskDefinitionLog = new TaskDefinitionLog();
- taskDefinitionLog.setFlag(YES);
- taskDefinitionLog.setDelayTime(0);
- taskDefinitionLog.setEnvironmentCode(-1);
- taskDefinitionLog.setFailRetryInterval(1);
- taskDefinitionLog.setFailRetryTimes(0);
- taskDefinitionLog.setTaskPriority(MEDIUM);
- taskDefinitionLog.setTimeout(0);
- taskDefinitionLog.setTimeoutFlag(TimeoutFlag.CLOSE);
- taskDefinitionLog.setTimeoutNotifyStrategy(null);
- taskDefinitionLog.setWorkerGroup("default");
- taskDefinitionLog.setTaskType("SUB_WORKFLOW");
- taskDefinitionLogs.add(taskDefinitionLog);
- }
- TaskDefinitionLog taskDefinitionLogFirst = taskDefinitionLogs.get(0);
- taskDefinitionLogFirst.setCode(taskCodes.get(0));
- taskDefinitionLogFirst.setName("subprocess node");
- taskDefinitionLogFirst.setDescription("Enter the demo_shell subnode");
- taskDefinitionLogFirst.setTaskParams(
-
"{\"localParams\":[],\"resourceList\":[],\"processDefinitionCode\":" +
subProcessCode + "}");
-
- String taskDefinitionJson = JSONUtils.toJsonString(taskDefinitionLogs);
-
- ProxyResult ProxyResult =
proxyWorkflowDefinitionController.createProcessDefinition(token, projectCode,
- processDefinitionLog.getName(),
- processDefinitionLog.getDescription(),
- processDefinitionLog.getGlobalParams(),
- processDefinitionLog.getLocations(),
- processDefinitionLog.getTimeout(),
- tenantCode,
- taskRelationJson,
- taskDefinitionJson,
- PARALLEL);
- return ProxyResult;
- }
-
-}
diff --git
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/resource/MigrateResourceService.java
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/resource/MigrateResourceService.java
index a6b2e995dc..2286ca76bc 100644
---
a/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/resource/MigrateResourceService.java
+++
b/dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/resource/MigrateResourceService.java
@@ -72,7 +72,6 @@ public class MigrateResourceService {
for (Map<String, Object> item : resources) {
String oriFullName = (String) item.get("full_name");
int type = (int) item.get("type");
- int id = (int) item.get("id");
try {
oriFullName = oriFullName.startsWith("/") ?
oriFullName.substring(1) : oriFullName;
if (ResourceType.FILE.getCode() == type) {
diff --git a/dolphinscheduler-tools/src/main/resources/application.yaml
b/dolphinscheduler-tools/src/main/resources/application.yaml
index 23680728dc..e192b04cc1 100644
--- a/dolphinscheduler-tools/src/main/resources/application.yaml
+++ b/dolphinscheduler-tools/src/main/resources/application.yaml
@@ -40,11 +40,6 @@ mybatis-plus:
id-type: auto
banner: false
-demo:
- tenant-code: default
- domain-name: localhost
- api-server-port: 5173
-
# Override by profile
---
diff --git a/dolphinscheduler-tools/src/test/resources/application-mysql.yaml
b/dolphinscheduler-tools/src/test/resources/application-mysql.yaml
index d33a68a7f8..729e2094eb 100644
--- a/dolphinscheduler-tools/src/test/resources/application-mysql.yaml
+++ b/dolphinscheduler-tools/src/test/resources/application-mysql.yaml
@@ -39,10 +39,4 @@ mybatis-plus:
id-type: auto
banner: false
-demo:
- tenant-code: default
- domain-name: localhost
- api-server-port: 5173
-
# Override by profile
-
diff --git
a/dolphinscheduler-tools/src/test/resources/application-postgresql.yaml
b/dolphinscheduler-tools/src/test/resources/application-postgresql.yaml
index a8be29014f..2cef501e40 100644
--- a/dolphinscheduler-tools/src/test/resources/application-postgresql.yaml
+++ b/dolphinscheduler-tools/src/test/resources/application-postgresql.yaml
@@ -39,10 +39,4 @@ mybatis-plus:
id-type: auto
banner: false
-demo:
- tenant-code: default
- domain-name: localhost
- api-server-port: 5173
-
# Override by profile
-