已关闭
630版本提交测试,测试提交pr的checkcode,单元测试问题 #254
AtomGit-Bot创建于 2023年6月12日关闭于 2023年6月12日
630版本提交测试,测试提交pr的checkcode,单元测试问题 #254
已关闭
共 334 个文件变更+17212-10381
| @@ -28,16 +28,14 @@ import lombok.extern.slf4j.Slf4j; | |||
| 28 | import org.apache.ibatis.reflection.MetaObject; | 28 | import org.apache.ibatis.reflection.MetaObject; |
| 29 | import org.opengauss.admin.common.core.domain.model.LoginUser; | 29 | import org.opengauss.admin.common.core.domain.model.LoginUser; |
| 30 | import org.opengauss.admin.common.utils.SecurityUtils; | 30 | import org.opengauss.admin.common.utils.SecurityUtils; |
| 31 | -import org.opengauss.admin.common.utils.ServletUtils; | ||
| 32 | -import org.opengauss.admin.framework.web.service.TokenService; | ||
| 33 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 34 | import org.springframework.stereotype.Component; | 31 | import org.springframework.stereotype.Component; |
| 35 | 32 | ||
| 36 | import java.util.Date; | 33 | import java.util.Date; |
| 37 | 34 | ||
| 38 | /** | 35 | /** |
| 36 | + * Autofill public attribute data | ||
| 37 | + * | ||
| 39 | * : AutoFillMetaObjectHandler | 38 | * : AutoFillMetaObjectHandler |
| 40 | - * : Autofill public attribute data | ||
| 41 | * : xielibo | 39 | * : xielibo |
| 42 | * : 2022-08-06 10:36 PM | 40 | * : 2022-08-06 10:36 PM |
| 43 | **/ | 41 | **/ |
| @@ -51,9 +49,8 @@ public class AutoFillMetaObjectHandler implements MetaObjectHandler { | |||
| 51 | try { | 49 | try { |
| 52 | loginUser = SecurityUtils.getLoginUser(); | 50 | loginUser = SecurityUtils.getLoginUser(); |
| 53 | } catch (Exception e) { | 51 | } catch (Exception e) { |
| 54 | - log.error("user information not obtained"); | 52 | + log.warn("No user information found, this is a new installation."); |
| 55 | } | 53 | } |
| 56 | - | ||
| 57 | if (loginUser != null) { | 54 | if (loginUser != null) { |
| 58 | this.setFieldValByName("createBy", loginUser.getUser().getUserName(), metaObject); | 55 | this.setFieldValByName("createBy", loginUser.getUser().getUserName(), metaObject); |
| 59 | this.setFieldValByName("updateBy", loginUser.getUser().getUserName(), metaObject); | 56 | this.setFieldValByName("updateBy", loginUser.getUser().getUserName(), metaObject); |
| @@ -628,7 +628,7 @@ | |||
| 628 | "5mjaax4r7mc0": "Username", | 628 | "5mjaax4r7mc0": "Username", |
| 629 | "5mjaax4r7qc0": "Please enter operator name", | 629 | "5mjaax4r7qc0": "Please enter operator name", |
| 630 | "5mjaax4r7to0": "Operation type", | 630 | "5mjaax4r7to0": "Operation type", |
| 631 | - "5mjaax4r7x80": "Operation status", | 631 | + "5mjaax4r7x80": "HTTP status", |
| 632 | "5mjaax4r80g0": "Success", | 632 | "5mjaax4r80g0": "Success", |
| 633 | "5mjaax4r83o0": "Fail", | 633 | "5mjaax4r83o0": "Fail", |
| 634 | "5mjaax4r89o0": "Search", | 634 | "5mjaax4r89o0": "Search", |
| @@ -644,7 +644,7 @@ | |||
| 644 | "5mjaax4r9hk0": "Method:", | 644 | "5mjaax4r9hk0": "Method:", |
| 645 | "5mjaax4r9m00": "Request parameter:", | 645 | "5mjaax4r9m00": "Request parameter:", |
| 646 | "5mjaax4r9ow0": "Response parameter:", | 646 | "5mjaax4r9ow0": "Response parameter:", |
| 647 | - "5mjaax4r9sw0": "Operation status:", | 647 | + "5mjaax4r9sw0": "HTTP status:", |
| 648 | "5mjaax4r9vo0": "Date:", | 648 | "5mjaax4r9vo0": "Date:", |
| 649 | "5mjaax4r9y00": "Error:", | 649 | "5mjaax4r9y00": "Error:", |
| 650 | "5mjaax4ra0g0": "Other", | 650 | "5mjaax4ra0g0": "Other", |
| @@ -628,7 +628,7 @@ | |||
| 628 | "5mjaax4r7mc0": "操作人员", | 628 | "5mjaax4r7mc0": "操作人员", |
| 629 | "5mjaax4r7qc0": "输入名称", | 629 | "5mjaax4r7qc0": "输入名称", |
| 630 | "5mjaax4r7to0": "操作类型", | 630 | "5mjaax4r7to0": "操作类型", |
| 631 | - "5mjaax4r7x80": "操作状态", | 631 | + "5mjaax4r7x80": "HTTP状态", |
| 632 | "5mjaax4r80g0": "成功", | 632 | "5mjaax4r80g0": "成功", |
| 633 | "5mjaax4r83o0": "失败", | 633 | "5mjaax4r83o0": "失败", |
| 634 | "5mjaax4r89o0": "查询", | 634 | "5mjaax4r89o0": "查询", |
| @@ -644,7 +644,7 @@ | |||
| 644 | "5mjaax4r9hk0": "操作方法:", | 644 | "5mjaax4r9hk0": "操作方法:", |
| 645 | "5mjaax4r9m00": "请求参数:", | 645 | "5mjaax4r9m00": "请求参数:", |
| 646 | "5mjaax4r9ow0": "返回参数:", | 646 | "5mjaax4r9ow0": "返回参数:", |
| 647 | - "5mjaax4r9sw0": "操作状态:", | 647 | + "5mjaax4r9sw0": "HTTP状态:", |
| 648 | "5mjaax4r9vo0": "操作时间:", | 648 | "5mjaax4r9vo0": "操作时间:", |
| 649 | "5mjaax4r9y00": "异常信息:", | 649 | "5mjaax4r9y00": "异常信息:", |
| 650 | "5mjaax4ra0g0": "其他", | 650 | "5mjaax4ra0g0": "其他", |
| @@ -1,7 +1,7 @@ | |||
| 1 | 1 | ||
| 2 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | 2 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| 3 | <modelVersion>4.0.0</modelVersion> | 3 | <modelVersion>4.0.0</modelVersion> |
| 4 | - <groupId>org.opengauss</groupId> | 4 | + <groupId>org.opengauss</groupId> |
| 5 | <version>5.0.0</version> | 5 | <version>5.0.0</version> |
| 6 | <artifactId>webds-plugin</artifactId> | 6 | <artifactId>webds-plugin</artifactId> |
| 7 | <packaging>jar</packaging> | 7 | <packaging>jar</packaging> |
| @@ -21,16 +21,9 @@ | |||
| 21 | <!-- dependency version --> | 21 | <!-- dependency version --> |
| 22 | <spring-boot.version>2.5.6</spring-boot.version> | 22 | <spring-boot.version>2.5.6</spring-boot.version> |
| 23 | <spring-brick.version>3.1.0</spring-brick.version> | 23 | <spring-brick.version>3.1.0</spring-brick.version> |
| 24 | - <junit.version>4.13</junit.version> | ||
| 25 | <fastjson.version>1.2.78</fastjson.version> | 24 | <fastjson.version>1.2.78</fastjson.version> |
| 26 | <lombok.version>1.18.24</lombok.version> | 25 | <lombok.version>1.18.24</lombok.version> |
| 27 | <hutool.version>5.0.3</hutool.version> | 26 | <hutool.version>5.0.3</hutool.version> |
| 28 | - | ||
| 29 | - <es-java-client.version>8.3.3</es-java-client.version> | ||
| 30 | - <es-java-client-jackson-databind.version>2.12.3</es-java-client-jackson-databind.version> | ||
| 31 | - <es-java-client-jakarta.version>2.0.1</es-java-client-jakarta.version> | ||
| 32 | - <jcraft-jsch.version>0.1.54</jcraft-jsch.version> | ||
| 33 | - <build.frontend.skip>false</build.frontend.skip> | ||
| 34 | </properties> | 27 | </properties> |
| 35 | <dependencies> | 28 | <dependencies> |
| 36 | <dependency> | 29 | <dependency> |
| @@ -39,19 +32,15 @@ | |||
| 39 | <version>3.39.3.0</version> | 32 | <version>3.39.3.0</version> |
| 40 | </dependency> | 33 | </dependency> |
| 41 | <dependency> | 34 | <dependency> |
| 42 | - <groupId>com.opengaussjdbc</groupId> | 35 | + <groupId>org.opengauss</groupId> |
| 43 | - <artifactId>opengaussjdbc</artifactId> | 36 | + <artifactId>opengauss-jdbc</artifactId> |
| 44 | - <version>1.0</version> | 37 | + <version>3.0.0</version> |
| 45 | - <scope>system</scope> | ||
| 46 | - <systemPath>${project.basedir}/src/main/resources/lib/opengaussjdbc.jar</systemPath> | ||
| 47 | </dependency> | 38 | </dependency> |
| 48 | <dependency> | 39 | <dependency> |
| 49 | <groupId>org.opengauss</groupId> | 40 | <groupId>org.opengauss</groupId> |
| 50 | <artifactId>visualtool-framework</artifactId> | 41 | <artifactId>visualtool-framework</artifactId> |
| 51 | <version>5.0.0</version> | 42 | <version>5.0.0</version> |
| 52 | -<!-- <scope>provided</scope>--> | ||
| 53 | <exclusions> | 43 | <exclusions> |
| 54 | - <!--druid-spring-boot-starter removed--> | ||
| 55 | <exclusion> | 44 | <exclusion> |
| 56 | <groupId>org.springframework.boot</groupId> | 45 | <groupId>org.springframework.boot</groupId> |
| 57 | <artifactId>spring-boot-starter-data-redis</artifactId> | 46 | <artifactId>spring-boot-starter-data-redis</artifactId> |
| @@ -73,8 +62,6 @@ | |||
| 73 | <version>${lombok.version}</version> | 62 | <version>${lombok.version}</version> |
| 74 | <scope>provided</scope> | 63 | <scope>provided</scope> |
| 75 | </dependency> | 64 | </dependency> |
| 76 | - | ||
| 77 | - <!-- common --> | ||
| 78 | <dependency> | 65 | <dependency> |
| 79 | <groupId>org.springframework.boot</groupId> | 66 | <groupId>org.springframework.boot</groupId> |
| 80 | <artifactId>spring-boot-starter-test</artifactId> | 67 | <artifactId>spring-boot-starter-test</artifactId> |
| @@ -96,9 +83,6 @@ | |||
| 96 | <artifactId>hutool-all</artifactId> | 83 | <artifactId>hutool-all</artifactId> |
| 97 | <version>${hutool.version}</version> | 84 | <version>${hutool.version}</version> |
| 98 | </dependency> | 85 | </dependency> |
| 99 | - <!-- common --> | ||
| 100 | - | ||
| 101 | - <!-- data --> | ||
| 102 | <dependency> | 86 | <dependency> |
| 103 | <groupId>com.alibaba</groupId> | 87 | <groupId>com.alibaba</groupId> |
| 104 | <artifactId>druid-spring-boot-starter</artifactId> | 88 | <artifactId>druid-spring-boot-starter</artifactId> |
| @@ -110,19 +94,9 @@ | |||
| 110 | <version>42.2.24</version> | 94 | <version>42.2.24</version> |
| 111 | </dependency> | 95 | </dependency> |
| 112 | <dependency> | 96 | <dependency> |
| 113 | - <groupId>com.fasterxml.jackson.core</groupId> | 97 | + <groupId>org.jsoup</groupId> |
| 114 | - <artifactId>jackson-databind</artifactId> | 98 | + <artifactId>jsoup</artifactId> |
| 115 | - <version>${es-java-client-jackson-databind.version}</version> | 99 | + <version>1.15.1</version> |
| 116 | - </dependency> | ||
| 117 | - <dependency> | ||
| 118 | - <groupId>jakarta.json</groupId> | ||
| 119 | - <artifactId>jakarta.json-api</artifactId> | ||
| 120 | - <version>${es-java-client-jakarta.version}</version> | ||
| 121 | - </dependency> | ||
| 122 | - <dependency> | ||
| 123 | - <groupId>com.jcraft</groupId> | ||
| 124 | - <artifactId>jsch</artifactId> | ||
| 125 | - <version>${jcraft-jsch.version}</version> | ||
| 126 | </dependency> | 100 | </dependency> |
| 127 | </dependencies> | 101 | </dependencies> |
| 128 | <dependencyManagement> | 102 | <dependencyManagement> |
| @@ -272,7 +246,7 @@ | |||
| 272 | <artifactId>exec-maven-plugin</artifactId> | 246 | <artifactId>exec-maven-plugin</artifactId> |
| 273 | <version>1.6.0</version> | 247 | <version>1.6.0</version> |
| 274 | <configuration> | 248 | <configuration> |
| 275 | - <skip>${build.frontend.skip}</skip> | 249 | + <skip>false</skip> |
| 276 | </configuration> | 250 | </configuration> |
| 277 | <executions> | 251 | <executions> |
| 278 | <execution> | 252 | <execution> |
| @@ -337,11 +311,5 @@ | |||
| 337 | </executions> | 311 | </executions> |
| 338 | </plugin> | 312 | </plugin> |
| 339 | </plugins> | 313 | </plugins> |
| 340 | - <resources> | ||
| 341 | - <resource> | ||
| 342 | - <directory>src/main/resources</directory> | ||
| 343 | - <filtering>true</filtering> | ||
| 344 | - </resource> | ||
| 345 | - </resources> | ||
| 346 | </build> | 314 | </build> |
| 347 | </project> | 315 | </project> |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio; | 5 | package com.nctigba.datastudio; |
| 2 | 6 | ||
| 3 | import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; | 7 | import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; |
| @@ -16,7 +20,6 @@ import org.springframework.scheduling.annotation.EnableAsync; | |||
| 16 | RedisRepositoriesAutoConfiguration.class | 20 | RedisRepositoriesAutoConfiguration.class |
| 17 | }) | 21 | }) |
| 18 | public class DataStudioPluginApplication extends SpringPluginBootstrap { | 22 | public class DataStudioPluginApplication extends SpringPluginBootstrap { |
| 19 | - | ||
| 20 | public static void main(String[] args) { | 23 | public static void main(String[] args) { |
| 21 | new DataStudioPluginApplication().run(args); | 24 | new DataStudioPluginApplication().run(args); |
| 22 | } | 25 | } |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio; | 5 | package com.nctigba.datastudio; |
| 2 | 6 | ||
| 3 | import com.gitee.starblues.bootstrap.EmptyMainApplicationContext; | 7 | import com.gitee.starblues.bootstrap.EmptyMainApplicationContext; |
| @@ -19,7 +23,6 @@ import org.springframework.scheduling.annotation.EnableAsync; | |||
| 19 | RedisRepositoriesAutoConfiguration.class}) | 23 | RedisRepositoriesAutoConfiguration.class}) |
| 20 | 24 | ||
| 21 | public class DataStudioPluginBootApplication { | 25 | public class DataStudioPluginBootApplication { |
| 22 | - | ||
| 23 | public static void main(String[] args) { | 26 | public static void main(String[] args) { |
| 24 | SpringApplication.run(DataStudioPluginBootApplication.class, args); | 27 | SpringApplication.run(DataStudioPluginBootApplication.class, args); |
| 25 | } | 28 | } |
| @@ -29,4 +32,5 @@ public class DataStudioPluginBootApplication { | |||
| 29 | public MainApplicationContext test() { | 32 | public MainApplicationContext test() { |
| 30 | return new EmptyMainApplicationContext(); | 33 | return new EmptyMainApplicationContext(); |
| 31 | } | 34 | } |
| 35 | + | ||
| 32 | } | 36 | } |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.base; | 5 | package com.nctigba.datastudio.base; |
| 2 | 6 | ||
| 3 | import com.gitee.starblues.bootstrap.annotation.AutowiredType; | 7 | import com.gitee.starblues.bootstrap.annotation.AutowiredType; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.base; | 5 | package com.nctigba.datastudio.base; |
| 2 | 6 | ||
| 3 | import org.springframework.beans.factory.DisposableBean; | 7 | import org.springframework.beans.factory.DisposableBean; |
| @@ -1,9 +1,13 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.base; | 5 | package com.nctigba.datastudio.base; |
| 2 | 6 | ||
| 3 | import cn.hutool.core.thread.ThreadUtil; | 7 | import cn.hutool.core.thread.ThreadUtil; |
| 4 | import cn.hutool.json.JSONUtil; | 8 | import cn.hutool.json.JSONUtil; |
| 5 | -import com.alibaba.fastjson.JSON; | ||
| 6 | import com.alibaba.fastjson.JSONObject; | 9 | import com.alibaba.fastjson.JSONObject; |
| 10 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 7 | import com.gitee.starblues.annotation.Extract; | 11 | import com.gitee.starblues.annotation.Extract; |
| 8 | import com.gitee.starblues.bootstrap.annotation.AutowiredType; | 12 | import com.gitee.starblues.bootstrap.annotation.AutowiredType; |
| 9 | import com.nctigba.datastudio.config.ConnectionConfig; | 13 | import com.nctigba.datastudio.config.ConnectionConfig; |
| @@ -14,6 +18,7 @@ import com.nctigba.datastudio.service.OperationInterface; | |||
| 14 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
| 15 | import org.apache.commons.lang3.StringUtils; | 19 | import org.apache.commons.lang3.StringUtils; |
| 16 | import org.apache.logging.log4j.util.Strings; | 20 | import org.apache.logging.log4j.util.Strings; |
| 21 | +import org.apache.poi.ss.formula.functions.T; | ||
| 17 | import org.opengauss.admin.system.plugin.extract.SocketExtract; | 22 | import org.opengauss.admin.system.plugin.extract.SocketExtract; |
| 18 | import org.opengauss.admin.system.plugin.facade.WsFacade; | 23 | import org.opengauss.admin.system.plugin.facade.WsFacade; |
| 19 | import org.springframework.beans.factory.annotation.Autowired; | 24 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -27,8 +32,6 @@ import java.sql.Statement; | |||
| 27 | import java.util.HashMap; | 32 | import java.util.HashMap; |
| 28 | import java.util.Map; | 33 | import java.util.Map; |
| 29 | 34 | ||
| 30 | -import static com.nctigba.datastudio.constants.CommonConstants.BEGIN; | ||
| 31 | -import static com.nctigba.datastudio.constants.CommonConstants.END; | ||
| 32 | import static com.nctigba.datastudio.constants.CommonConstants.FIVE_HUNDRED; | 35 | import static com.nctigba.datastudio.constants.CommonConstants.FIVE_HUNDRED; |
| 33 | import static com.nctigba.datastudio.constants.CommonConstants.START_RUN; | 36 | import static com.nctigba.datastudio.constants.CommonConstants.START_RUN; |
| 34 | import static com.nctigba.datastudio.constants.CommonConstants.STOP_DEBUG; | 37 | import static com.nctigba.datastudio.constants.CommonConstants.STOP_DEBUG; |
| @@ -41,18 +44,15 @@ import static com.nctigba.datastudio.enums.MessageEnum.window; | |||
| 41 | 44 | ||
| 42 | 45 | ||
| 43 | public class WebSocketServer implements SocketExtract { | 46 | public class WebSocketServer implements SocketExtract { |
| 47 | + private final Map<String, Map<String, Object>> paramMap = new HashMap<>(); | ||
| 48 | + private final Map<String, Connection> connectionMap = new HashMap<>(); | ||
| 49 | + private final Map<String, Statement> statementMap = new HashMap<>(); | ||
| 50 | + private final Map<String, OperateStatusDO> operationStatusMap = new HashMap<>(); | ||
| 51 | + | ||
| 52 | + ObjectMapper objectMapper; | ||
| 44 | 53 | ||
| 45 | 54 | ||
| 46 | private WsFacade wsFacade; | 55 | private WsFacade wsFacade; |
| 47 | - | ||
| 48 | - private final Map<String, Map<String, Object>> paramMap = new HashMap<>(); | ||
| 49 | - | ||
| 50 | - private final Map<String, Connection> connectionMap = new HashMap<>(); | ||
| 51 | - | ||
| 52 | - private final Map<String, Statement> statementMap = new HashMap<>(); | ||
| 53 | - | ||
| 54 | - private final Map<String, OperateStatusDO> operationStatusMap = new HashMap<>(); | ||
| 55 | - | ||
| 56 | private String language = Strings.EMPTY; | 56 | private String language = Strings.EMPTY; |
| 57 | 57 | ||
| 58 | 58 | ||
| @@ -76,7 +76,8 @@ public class WebSocketServer implements SocketExtract { | |||
| 76 | if (StringUtils.isEmpty(operation)) { | 76 | if (StringUtils.isEmpty(operation)) { |
| 77 | return; | 77 | return; |
| 78 | } | 78 | } |
| 79 | - var aa = SpringApplicationContext.getApplicationContext().getBean(operation, OperationInterface.class); | 79 | + OperationInterface<T> aa = SpringApplicationContext.getApplicationContext().getBean(operation, |
| 80 | + OperationInterface.class); | ||
| 80 | ThreadUtil.execAsync(() -> { | 81 | ThreadUtil.execAsync(() -> { |
| 81 | try { | 82 | try { |
| 82 | aa.operate(this, message); | 83 | aa.operate(this, message); |
| @@ -119,10 +120,11 @@ public class WebSocketServer implements SocketExtract { | |||
| 119 | * obj | 120 | * obj |
| 120 | * IOException | 121 | * IOException |
| 121 | */ | 122 | */ |
| 122 | - public synchronized void sendMessage(String sessionId, MessageEnum type, String code, String message, Object obj) throws IOException { | 123 | + public synchronized void sendMessage(String sessionId, MessageEnum type, String code, String message, |
| 124 | + Object obj) throws IOException { | ||
| 123 | WebDsResult result = WebDsResult.ok(type.toString(), message).addData(obj); | 125 | WebDsResult result = WebDsResult.ok(type.toString(), message).addData(obj); |
| 124 | result.setCode(code); | 126 | result.setCode(code); |
| 125 | - wsFacade.sendMessage(WEBDS_PLUGIN, sessionId, JSON.toJSONString(result)); | 127 | + wsFacade.sendMessage(WEBDS_PLUGIN, sessionId, objectMapper.writeValueAsString(result)); |
| 126 | } | 128 | } |
| 127 | 129 | ||
| 128 | public void sendMessage(String sessionId, MessageEnum type, String message, Object obj) throws IOException { | 130 | public void sendMessage(String sessionId, MessageEnum type, String message, Object obj) throws IOException { |
| @@ -151,11 +153,11 @@ public class WebSocketServer implements SocketExtract { | |||
| 151 | } | 153 | } |
| 152 | 154 | ||
| 153 | public OperateStatusDO getOperateStatus(String sessionId) { | 155 | public OperateStatusDO getOperateStatus(String sessionId) { |
| 154 | - OperateStatusDO operateStatusDO = this.operationStatusMap.get(sessionId); | 156 | + OperateStatusDO operateStatus = this.operationStatusMap.get(sessionId); |
| 155 | - if (operateStatusDO == null) { | 157 | + if (operateStatus == null) { |
| 156 | return new OperateStatusDO(); | 158 | return new OperateStatusDO(); |
| 157 | } | 159 | } |
| 158 | - return operateStatusDO; | 160 | + return operateStatus; |
| 159 | } | 161 | } |
| 160 | 162 | ||
| 161 | public void setOperateStatus(String sessionId, OperateStatusDO operateStatus) { | 163 | public void setOperateStatus(String sessionId, OperateStatusDO operateStatus) { |
| @@ -176,23 +178,11 @@ public class WebSocketServer implements SocketExtract { | |||
| 176 | this.paramMap.put(sessionId, map); | 178 | this.paramMap.put(sessionId, map); |
| 177 | } | 179 | } |
| 178 | 180 | ||
| 179 | - public void setLanguage(String language) { | ||
| 180 | - this.language = language; | ||
| 181 | - } | ||
| 182 | - | ||
| 183 | public String getLanguage() { | 181 | public String getLanguage() { |
| 184 | return language; | 182 | return language; |
| 185 | } | 183 | } |
| 186 | 184 | ||
| 187 | - /** | 185 | + public void setLanguage(String language) { |
| 188 | - * check line is in range | 186 | + this.language = language; |
| 189 | - * | ||
| 190 | - * line | ||
| 191 | - * | ||
| 192 | - */ | ||
| 193 | - public boolean checkLine(String sessionId, int line) { | ||
| 194 | - int begin = (int) getParamMap(sessionId).get(BEGIN); | ||
| 195 | - int end = (int) getParamMap(sessionId).get(END); | ||
| 196 | - return line > begin && line < end; | ||
| 197 | } | 187 | } |
| 198 | } | 188 | } |
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/DatabaseObjectSQLService.java+43-0
| @@ -0,0 +1,43 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.dto.CreateDatabaseDTO; | ||
| 8 | +import com.nctigba.datastudio.model.dto.DatabaseNameDTO; | ||
| 9 | +import com.nctigba.datastudio.model.dto.RenameDatabaseDTO; | ||
| 10 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 11 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 12 | + | ||
| 13 | +public interface DatabaseObjectSQLService { | ||
| 14 | + String type(); | ||
| 15 | + | ||
| 16 | + default String createDatabase(CreateDatabaseDTO database) throws Exception { | ||
| 17 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + default String connectionDatabaseTest() throws Exception { | ||
| 21 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + default String deleteDatabaseSQL(DatabaseNameDTO database) throws Exception { | ||
| 25 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + default String renameDatabaseSQL(RenameDatabaseDTO database) throws Exception { | ||
| 29 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + default String conRestrictionsSQL(RenameDatabaseDTO database) throws Exception { | ||
| 33 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + default String databaseAttributeSQL(DatabaseNameDTO database) throws Exception { | ||
| 37 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + default String databaseAttributeUpdateSQL(DatabaseNameDTO database) throws Exception { | ||
| 41 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 42 | + } | ||
| 43 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/FunctionSPObjectSQLService.java+17-0
| @@ -0,0 +1,17 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.dto.DatabaseFunctionSPDTO; | ||
| 8 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 9 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 10 | + | ||
| 11 | +public interface FunctionSPObjectSQLService { | ||
| 12 | + String type(); | ||
| 13 | + | ||
| 14 | + default String dropFunctionSP(DatabaseFunctionSPDTO request) throws Exception { | ||
| 15 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 16 | + } | ||
| 17 | +} | ||
| @@ -0,0 +1,66 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.query.DatabaseMetaarrayColumnQuery; | ||
| 8 | +import com.nctigba.datastudio.model.query.DatabaseMetaarrayQuery; | ||
| 9 | +import com.nctigba.datastudio.model.query.DatabaseMetaarraySchemaQuery; | ||
| 10 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 11 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 12 | + | ||
| 13 | +import java.util.List; | ||
| 14 | +import java.util.Map; | ||
| 15 | + | ||
| 16 | +public interface GainObjectSQLService { | ||
| 17 | + String type(); | ||
| 18 | + | ||
| 19 | + default String databaseList() throws Exception { | ||
| 20 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + default List<Map<String, String>> schemaList(DatabaseMetaarraySchemaQuery request) throws Exception { | ||
| 24 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + default List<String> objectList(DatabaseMetaarrayQuery request) throws Exception { | ||
| 28 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + default List<String> tableColumnList(DatabaseMetaarrayColumnQuery request) throws Exception { | ||
| 32 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + default String databaseVersion() throws Exception { | ||
| 36 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + default String tableSql(String schema) throws Exception { | ||
| 40 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + default String viewSql(String schema) throws Exception { | ||
| 44 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + default String fun_prosSql(String schema) throws Exception { | ||
| 48 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + default String sequenceSql(String schema) throws Exception { | ||
| 52 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + default String synonymSql(String schema) throws Exception { | ||
| 56 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + default String baseTypeListSQL() throws Exception { | ||
| 60 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + default String tablespaceListSQL() throws Exception { | ||
| 64 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 65 | + } | ||
| 66 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/SequenceObjectSQLService.java+27-0
| @@ -0,0 +1,27 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.dto.DatabaseCreateSequenceDTO; | ||
| 8 | +import com.nctigba.datastudio.model.dto.DatabaseDropSequenceDTO; | ||
| 9 | +import com.nctigba.datastudio.model.dto.DatabaseSequenceDdlDTO; | ||
| 10 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 11 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 12 | + | ||
| 13 | +public interface SequenceObjectSQLService { | ||
| 14 | + String type(); | ||
| 15 | + | ||
| 16 | + default String splicingSequenceDDL(DatabaseCreateSequenceDTO request) throws Exception { | ||
| 17 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + default String dropSequenceDDL(DatabaseDropSequenceDTO request) throws Exception { | ||
| 21 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + default String returnSequenceDDL(DatabaseSequenceDdlDTO request) throws Exception { | ||
| 25 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 26 | + } | ||
| 27 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/SynonymObjectSQLService.java+28-0
| @@ -0,0 +1,28 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.dto.DatabaseCreateSynonymDTO; | ||
| 8 | +import com.nctigba.datastudio.model.dto.DatabaseDropSynonymDTO; | ||
| 9 | +import com.nctigba.datastudio.model.dto.DatabaseSynonymAttributeDTO; | ||
| 10 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 11 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 12 | + | ||
| 13 | +public interface SynonymObjectSQLService { | ||
| 14 | + String type(); | ||
| 15 | + | ||
| 16 | + default String splicingSequenceDDL(DatabaseCreateSynonymDTO request) throws Exception { | ||
| 17 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + default String synonymAttributeSQL(DatabaseSynonymAttributeDTO request) throws Exception { | ||
| 22 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + default String dropSynonymSQL(DatabaseDropSynonymDTO request) throws Exception { | ||
| 26 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 27 | + } | ||
| 28 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/TableColumnSQLService.java+67-0
| @@ -0,0 +1,67 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.dto.DatabaseConstraintDTO; | ||
| 8 | +import com.nctigba.datastudio.model.dto.DatabaseConstraintPkDTO; | ||
| 9 | +import com.nctigba.datastudio.model.dto.DatabaseCreUpdColumnDTO; | ||
| 10 | +import com.nctigba.datastudio.model.dto.DatabaseCreateTableDTO; | ||
| 11 | +import com.nctigba.datastudio.model.dto.DatabaseIndexDTO; | ||
| 12 | +import com.nctigba.datastudio.model.query.SelectDataQuery; | ||
| 13 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 14 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 15 | + | ||
| 16 | +import java.util.List; | ||
| 17 | + | ||
| 18 | +public interface TableColumnSQLService { | ||
| 19 | + String type(); | ||
| 20 | + | ||
| 21 | + default String tableConstraintSQL(SelectDataQuery request) throws Exception { | ||
| 22 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + default String tablePKConstraintSQL(String schema, String tableName) throws Exception { | ||
| 26 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + default void editConstraint(DatabaseConstraintDTO request) throws Exception { | ||
| 30 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + default void editPkConstraint(DatabaseConstraintPkDTO request) throws Exception { | ||
| 34 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + default String tableIndexSQL(SelectDataQuery request) throws Exception { | ||
| 38 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + default String tableColumnSQL(String oid, String schema, String tableName) throws Exception { | ||
| 42 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + default List<String> tableColumnAddSQL(DatabaseCreUpdColumnDTO.CreUpdColumnDataDTO data, String schema, | ||
| 46 | + String tableName) throws Exception { | ||
| 47 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + default String tableColumnDropSQL(DatabaseCreUpdColumnDTO.CreUpdColumnDataDTO data, String schema, | ||
| 51 | + String tableName) throws Exception { | ||
| 52 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + default List<String> tableColumnUpdateSQL(DatabaseCreUpdColumnDTO.CreUpdColumnDataDTO data, String schema, | ||
| 56 | + String tableName, String uuid) throws Exception { | ||
| 57 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + default void editIndex(DatabaseIndexDTO request) throws Exception { | ||
| 61 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + default String createTable(DatabaseCreateTableDTO request) throws Exception { | ||
| 65 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 66 | + } | ||
| 67 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/TableCreateSQLService.java+31-0
| @@ -0,0 +1,31 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.query.SelectDataQuery; | ||
| 8 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 9 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 10 | + | ||
| 11 | +import java.util.Map; | ||
| 12 | + | ||
| 13 | +public interface TableCreateSQLService { | ||
| 14 | + String type(); | ||
| 15 | + | ||
| 16 | + default String tableDataSQL(String schema, String tableName) throws Exception { | ||
| 17 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + default Map<String, String> tableDdl(SelectDataQuery request) throws Exception { | ||
| 21 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + default String tableDataCountSQL(String schema, String tableName) throws Exception { | ||
| 25 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + default String tableAnalyseSQL(String schema, String tableName) throws Exception { | ||
| 29 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 30 | + } | ||
| 31 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/TableObjectSQLService.java+72-0
| @@ -0,0 +1,72 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.query.SelectDataQuery; | ||
| 8 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 9 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | +import java.util.Map; | ||
| 13 | + | ||
| 14 | +public interface TableObjectSQLService { | ||
| 15 | + String type(); | ||
| 16 | + | ||
| 17 | + default String tableDataSQL(String schema, String tableName) throws Exception { | ||
| 18 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + default Map<String, String> tableDdl(SelectDataQuery request) throws Exception { | ||
| 22 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + default String tableDataCountSQL(String schema, String tableName) throws Exception { | ||
| 26 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + default String tableAnalyseSQL(String schema, String tableName) throws Exception { | ||
| 30 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + default String tableTruncateSQL(String schema, String tableName) throws Exception { | ||
| 34 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + default String tableVacuumSQL(String schema, String tableName) throws Exception { | ||
| 38 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + default String tableReindexSQL(String schema, String tableName) throws Exception { | ||
| 42 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + default String tableRenameSQL(String schema, String tableName, String newName) throws Exception { | ||
| 46 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + default String tableCommentSQL(String schema, String tableName, String comment) throws Exception { | ||
| 50 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + default String tableAlterSchemaSQL(String schema, String tableName, String newSchema) throws Exception { | ||
| 54 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + default String tableDropSQL(String schema, String tableName) throws Exception { | ||
| 58 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + default String tableAlterTablespaceSQL(String schema, String tableName, String tablespace) throws Exception { | ||
| 62 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + default String tableSequenceSQL(String schema, String tableName) throws Exception { | ||
| 66 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + default List<Map<String, Object>> tableAttributeSQL(String uuid, String oid, String tableType) throws Exception { | ||
| 70 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 71 | + } | ||
| 72 | +} | ||
| @@ -0,0 +1,31 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.dto.DatabaseCreateViewDTO; | ||
| 8 | +import com.nctigba.datastudio.model.dto.DatabaseSelectViewDTO; | ||
| 9 | +import com.nctigba.datastudio.model.dto.DatabaseViewDdlDTO; | ||
| 10 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 11 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 12 | + | ||
| 13 | +public interface ViewObjectSQLService { | ||
| 14 | + String type(); | ||
| 15 | + | ||
| 16 | + default String splicingViewDDL(DatabaseCreateViewDTO request) throws Exception { | ||
| 17 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + default String returnDatabaseViewDDL(DatabaseViewDdlDTO request) throws Exception { | ||
| 21 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + default String returnDropViewSQL(DatabaseViewDdlDTO request) throws Exception { | ||
| 25 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + default String returnSelectViewSQL(DatabaseSelectViewDTO request) throws Exception { | ||
| 29 | + throw new CustomException(LocaleString.transLanguage("2016") + "" + LocaleString.transLanguage("2016")); | ||
| 30 | + } | ||
| 31 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/opengauss/DatabaseObjectSQLServiceImpl.java+102-0
| @@ -0,0 +1,102 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible.opengauss; | ||
| 6 | + | ||
| 7 | +import com.alibaba.druid.util.StringUtils; | ||
| 8 | +import com.nctigba.datastudio.compatible.DatabaseObjectSQLService; | ||
| 9 | +import com.nctigba.datastudio.model.dto.CreateDatabaseDTO; | ||
| 10 | +import com.nctigba.datastudio.model.dto.DatabaseNameDTO; | ||
| 11 | +import com.nctigba.datastudio.model.dto.RenameDatabaseDTO; | ||
| 12 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 13 | +import lombok.extern.slf4j.Slf4j; | ||
| 14 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 15 | +import org.springframework.stereotype.Service; | ||
| 16 | + | ||
| 17 | +import static com.nctigba.datastudio.constants.CommonConstants.OPENGAUSS; | ||
| 18 | +import static com.nctigba.datastudio.constants.SqlConstants.ALTER_SQL; | ||
| 19 | +import static com.nctigba.datastudio.constants.SqlConstants.CONNECTION_LIMIT_SQL; | ||
| 20 | +import static com.nctigba.datastudio.constants.SqlConstants.CREATE_SQL; | ||
| 21 | +import static com.nctigba.datastudio.constants.SqlConstants.DATABASE_ATTRIBUTE_SQL; | ||
| 22 | +import static com.nctigba.datastudio.constants.SqlConstants.DATABASE_SQL; | ||
| 23 | +import static com.nctigba.datastudio.constants.SqlConstants.DATABASE_UPDATA_ATTRIBUTE_SQL; | ||
| 24 | +import static com.nctigba.datastudio.constants.SqlConstants.DBCOMPATIBILITY_SQL; | ||
| 25 | +import static com.nctigba.datastudio.constants.SqlConstants.DROP_SQL; | ||
| 26 | +import static com.nctigba.datastudio.constants.SqlConstants.LC_COLLATE_SQL; | ||
| 27 | +import static com.nctigba.datastudio.constants.SqlConstants.LC_CTYPE_SQL; | ||
| 28 | +import static com.nctigba.datastudio.constants.SqlConstants.QUOTES; | ||
| 29 | +import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_SEMICOLON; | ||
| 30 | +import static com.nctigba.datastudio.constants.SqlConstants.RENAME_TO_SQL; | ||
| 31 | +import static com.nctigba.datastudio.constants.SqlConstants.SEMICOLON; | ||
| 32 | +import static com.nctigba.datastudio.constants.SqlConstants.WITH_ENCODING_SQL; | ||
| 33 | +import static com.nctigba.datastudio.constants.SqlConstants.WITH_KEYWORD_SQL; | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + | ||
| 37 | +public class DatabaseObjectSQLServiceImpl implements DatabaseObjectSQLService { | ||
| 38 | + | ||
| 39 | + public String type() { | ||
| 40 | + return OPENGAUSS; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + | ||
| 44 | + public String createDatabase(CreateDatabaseDTO request) throws Exception { | ||
| 45 | + log.info("createDatabaseDDL request is: " + request); | ||
| 46 | + String ddl = CREATE_SQL + DATABASE_SQL + request.getDatabaseName() + WITH_ENCODING_SQL + request.getDatabaseCode() + DBCOMPATIBILITY_SQL + request.getCompatibleType(); | ||
| 47 | + if (!StringUtils.isEmpty(request.getCollation())) { | ||
| 48 | + ddl = ddl + LC_COLLATE_SQL + request.getCollation(); | ||
| 49 | + } | ||
| 50 | + if (!StringUtils.isEmpty(request.getCharacterType())) { | ||
| 51 | + ddl = ddl + LC_CTYPE_SQL + request.getCharacterType(); | ||
| 52 | + } | ||
| 53 | + if (Integer.valueOf(request.getConRestrictions()) >= -1) { | ||
| 54 | + ddl = ddl + QUOTES + CONNECTION_LIMIT_SQL + request.getConRestrictions() + SEMICOLON; | ||
| 55 | + } else { | ||
| 56 | + throw new CustomException(LocaleString.transLanguage("2013")); | ||
| 57 | + } | ||
| 58 | + log.info("createDatabaseDDL is: " + ddl); | ||
| 59 | + return ddl; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + | ||
| 63 | + public String connectionDatabaseTest() throws Exception { | ||
| 64 | + String ddl = "SELECT 1"; | ||
| 65 | + return ddl; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + | ||
| 69 | + public String deleteDatabaseSQL(DatabaseNameDTO request) throws Exception { | ||
| 70 | + log.info("deleteDatabase request is: " + request); | ||
| 71 | + String ddl = DROP_SQL + DATABASE_SQL + request.getDatabaseName() + SEMICOLON; | ||
| 72 | + return ddl; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + | ||
| 76 | + public String renameDatabaseSQL(RenameDatabaseDTO request) throws Exception { | ||
| 77 | + log.info("renameDatabaseSQL request is: " + request); | ||
| 78 | + String ddl = ddl = ALTER_SQL + DATABASE_SQL + request.getOldDatabaseName() + RENAME_TO_SQL + request.getDatabaseName() + SEMICOLON; | ||
| 79 | + return ddl; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + | ||
| 83 | + public String conRestrictionsSQL(RenameDatabaseDTO request) throws Exception { | ||
| 84 | + log.info("conRestrictionsSQL request is: " + request); | ||
| 85 | + String ddl = ALTER_SQL + DATABASE_SQL + request.getDatabaseName() + WITH_KEYWORD_SQL + CONNECTION_LIMIT_SQL + request.getConRestrictions() + SEMICOLON; | ||
| 86 | + return ddl; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + | ||
| 90 | + public String databaseAttributeSQL(DatabaseNameDTO request) throws Exception { | ||
| 91 | + log.info("databaseAttributeSQL request is: " + request); | ||
| 92 | + String ddl = DATABASE_ATTRIBUTE_SQL + request.getDatabaseName() + QUOTES_SEMICOLON; | ||
| 93 | + return ddl; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + | ||
| 97 | + public String databaseAttributeUpdateSQL(DatabaseNameDTO request) throws Exception { | ||
| 98 | + log.info("databaseAttributeUpdateSQL request is: " + request); | ||
| 99 | + String ddl = DATABASE_UPDATA_ATTRIBUTE_SQL + request.getDatabaseName() + QUOTES_SEMICOLON; | ||
| 100 | + return ddl; | ||
| 101 | + } | ||
| 102 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/opengauss/FunctionSPObjectSQLServiceImpl.java+70-0
| @@ -0,0 +1,70 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible.opengauss; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.compatible.FunctionSPObjectSQLService; | ||
| 8 | +import com.nctigba.datastudio.config.ConnectionConfig; | ||
| 9 | +import com.nctigba.datastudio.model.dto.DatabaseFunctionSPDTO; | ||
| 10 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 11 | +import lombok.extern.slf4j.Slf4j; | ||
| 12 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 14 | +import org.springframework.stereotype.Service; | ||
| 15 | + | ||
| 16 | +import java.sql.Connection; | ||
| 17 | +import java.sql.ResultSet; | ||
| 18 | +import java.sql.Statement; | ||
| 19 | + | ||
| 20 | +import static com.nctigba.datastudio.constants.CommonConstants.OPENGAUSS; | ||
| 21 | +import static com.nctigba.datastudio.constants.CommonConstants.PRO_KIND; | ||
| 22 | +import static com.nctigba.datastudio.constants.SqlConstants.DROP_SQL; | ||
| 23 | +import static com.nctigba.datastudio.constants.SqlConstants.FUNCTION_KEYWORD_SQL; | ||
| 24 | +import static com.nctigba.datastudio.constants.SqlConstants.POINT; | ||
| 25 | +import static com.nctigba.datastudio.constants.SqlConstants.PROCEDURE_KEYWORD_SQL; | ||
| 26 | +import static com.nctigba.datastudio.constants.SqlConstants.PROC_SQL; | ||
| 27 | +import static com.nctigba.datastudio.constants.SqlConstants.SEMICOLON; | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ||
| 31 | +public class FunctionSPObjectSQLServiceImpl implements FunctionSPObjectSQLService { | ||
| 32 | + | ||
| 33 | + private ConnectionConfig connectionConfig; | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + public String type() { | ||
| 37 | + return OPENGAUSS; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + | ||
| 41 | + public String dropFunctionSP(DatabaseFunctionSPDTO request) { | ||
| 42 | + log.info("dropFunctionSP request is: " + request); | ||
| 43 | + try ( | ||
| 44 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 45 | + Statement statement = connection.createStatement() | ||
| 46 | + ) { | ||
| 47 | + try ( | ||
| 48 | + ResultSet funcResult = statement.executeQuery(String.format(PROC_SQL, request.getOid())) | ||
| 49 | + ) { | ||
| 50 | + String proKind = ""; | ||
| 51 | + if (funcResult.next()) { | ||
| 52 | + proKind = funcResult.getString(PRO_KIND); | ||
| 53 | + } else { | ||
| 54 | + throw new CustomException(LocaleString.transLanguage("2015")); | ||
| 55 | + } | ||
| 56 | + String sql = ""; | ||
| 57 | + if ("f".equals(proKind)) { | ||
| 58 | + sql = DROP_SQL + FUNCTION_KEYWORD_SQL + request.getSchema() + POINT + request.getFunctionSPName() + SEMICOLON; | ||
| 59 | + } else if ("p".equals(proKind)) { | ||
| 60 | + sql = DROP_SQL + PROCEDURE_KEYWORD_SQL + request.getSchema() + POINT + request.getFunctionSPName() + SEMICOLON; | ||
| 61 | + } | ||
| 62 | + log.info("dropFunctionSP sql is: " + sql); | ||
| 63 | + return sql; | ||
| 64 | + } | ||
| 65 | + } catch (Exception e) { | ||
| 66 | + log.info(e.getMessage()); | ||
| 67 | + throw new CustomException(e.getMessage(), e); | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/opengauss/GainObjectSQLServiceImpl.java+261-0
| @@ -0,0 +1,261 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible.opengauss; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.compatible.GainObjectSQLService; | ||
| 8 | +import com.nctigba.datastudio.config.ConnectionConfig; | ||
| 9 | +import com.nctigba.datastudio.model.query.DatabaseMetaarrayColumnQuery; | ||
| 10 | +import com.nctigba.datastudio.model.query.DatabaseMetaarrayQuery; | ||
| 11 | +import com.nctigba.datastudio.model.query.DatabaseMetaarraySchemaQuery; | ||
| 12 | +import lombok.extern.slf4j.Slf4j; | ||
| 13 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 15 | +import org.springframework.stereotype.Service; | ||
| 16 | + | ||
| 17 | +import java.sql.Connection; | ||
| 18 | +import java.sql.ResultSet; | ||
| 19 | +import java.sql.Statement; | ||
| 20 | +import java.util.ArrayList; | ||
| 21 | +import java.util.HashMap; | ||
| 22 | +import java.util.List; | ||
| 23 | +import java.util.Map; | ||
| 24 | + | ||
| 25 | +import static com.nctigba.datastudio.constants.CommonConstants.NAME; | ||
| 26 | +import static com.nctigba.datastudio.constants.CommonConstants.NSP_NAME; | ||
| 27 | +import static com.nctigba.datastudio.constants.CommonConstants.OID; | ||
| 28 | +import static com.nctigba.datastudio.constants.CommonConstants.OPENGAUSS; | ||
| 29 | +import static com.nctigba.datastudio.constants.SqlConstants.GET_DATABASE_SQL; | ||
| 30 | +import static com.nctigba.datastudio.constants.SqlConstants.GET_SCHEMA_NAME_SQL; | ||
| 31 | +import static com.nctigba.datastudio.constants.SqlConstants.LF; | ||
| 32 | +import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_PARENTHESES_SEMICOLON; | ||
| 33 | +import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_SEMICOLON; | ||
| 34 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_COLUMN_SQL; | ||
| 35 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_COLUMN_WHERE_SQL; | ||
| 36 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_FUNCTION_SQL; | ||
| 37 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_OBJECT_SQL; | ||
| 38 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_OBJECT_WHERE_IN_SQL; | ||
| 39 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_OBJECT_WHERE_SQL; | ||
| 40 | +import static com.nctigba.datastudio.constants.SqlConstants.SEMICOLON; | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + | ||
| 44 | +public class GainObjectSQLServiceImpl implements GainObjectSQLService { | ||
| 45 | + | ||
| 46 | + private ConnectionConfig connectionConfig; | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + public String type() { | ||
| 50 | + return OPENGAUSS; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + | ||
| 54 | + public String databaseList() throws Exception { | ||
| 55 | + String ddl; | ||
| 56 | + ddl = GET_DATABASE_SQL; | ||
| 57 | + log.info("databaseListDDL response is: " + ddl); | ||
| 58 | + return ddl; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + | ||
| 62 | + public List<Map<String, String>> schemaList(DatabaseMetaarraySchemaQuery request) throws Exception { | ||
| 63 | + log.info("schemaList request is: " + request); | ||
| 64 | + List<Map<String, String>> schemaList = new ArrayList<>(); | ||
| 65 | + try ( | ||
| 66 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 67 | + Statement statement = connection.createStatement(); | ||
| 68 | + ResultSet resultSet = statement.executeQuery(GET_SCHEMA_NAME_SQL) | ||
| 69 | + ) { | ||
| 70 | + while (resultSet.next()) { | ||
| 71 | + Map<String, String> map = new HashMap<>(); | ||
| 72 | + map.put(OID, resultSet.getString(OID)); | ||
| 73 | + map.put(NAME, resultSet.getString(NSP_NAME)); | ||
| 74 | + schemaList.add(map); | ||
| 75 | + } | ||
| 76 | + log.info("schemaList response is: " + schemaList); | ||
| 77 | + return schemaList; | ||
| 78 | + } catch (Exception e) { | ||
| 79 | + log.info(e.getMessage()); | ||
| 80 | + throw new CustomException(e.getMessage(), e); | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + | ||
| 85 | + public List<String> objectList(DatabaseMetaarrayQuery request) throws Exception { | ||
| 86 | + log.info("objectList request is: " + request); | ||
| 87 | + try ( | ||
| 88 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 89 | + Statement statement = connection.createStatement() | ||
| 90 | + ) { | ||
| 91 | + List<String> objectList = new ArrayList<>(); | ||
| 92 | + if (request.getObjectType().equals("ALL")) { | ||
| 93 | + try ( | ||
| 94 | + ResultSet resultSet = statement.executeQuery( | ||
| 95 | + SELECT_FUNCTION_SQL + request.getSchema() + QUOTES_PARENTHESES_SEMICOLON) | ||
| 96 | + ) { | ||
| 97 | + while (resultSet.next()) { | ||
| 98 | + objectList.add(resultSet.getString("proname")); | ||
| 99 | + } | ||
| 100 | + } | ||
| 101 | + try ( | ||
| 102 | + ResultSet resultSetView = statement.executeQuery( | ||
| 103 | + SELECT_OBJECT_SQL + request.getSchema() + SELECT_OBJECT_WHERE_IN_SQL + "v','m" + QUOTES_PARENTHESES_SEMICOLON) | ||
| 104 | + ) { | ||
| 105 | + while (resultSetView.next()) { | ||
| 106 | + objectList.add(resultSetView.getString("relname")); | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + try ( | ||
| 110 | + ResultSet resultSetTable = statement.executeQuery( | ||
| 111 | + SELECT_OBJECT_SQL + request.getSchema() + SELECT_OBJECT_WHERE_SQL + "r" + QUOTES_SEMICOLON) | ||
| 112 | + ) { | ||
| 113 | + while (resultSetTable.next()) { | ||
| 114 | + objectList.add(resultSetTable.getString("relname")); | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + return objectList; | ||
| 118 | + } else if (request.getObjectType().equals("FUN_PRO")) { | ||
| 119 | + try ( | ||
| 120 | + ResultSet resultSet = statement.executeQuery( | ||
| 121 | + SELECT_FUNCTION_SQL + request.getSchema() + QUOTES_PARENTHESES_SEMICOLON) | ||
| 122 | + ) { | ||
| 123 | + while (resultSet.next()) { | ||
| 124 | + objectList.add(resultSet.getString("proname")); | ||
| 125 | + } | ||
| 126 | + return objectList; | ||
| 127 | + } | ||
| 128 | + } else if (request.getObjectType().equals("VIEW")) { | ||
| 129 | + try ( | ||
| 130 | + ResultSet resultSet = statement.executeQuery( | ||
| 131 | + SELECT_OBJECT_SQL + request.getSchema() + SELECT_OBJECT_WHERE_IN_SQL + "v','m" + QUOTES_PARENTHESES_SEMICOLON) | ||
| 132 | + ) { | ||
| 133 | + while (resultSet.next()) { | ||
| 134 | + objectList.add(resultSet.getString("relname")); | ||
| 135 | + } | ||
| 136 | + return objectList; | ||
| 137 | + } | ||
| 138 | + } else { | ||
| 139 | + try ( | ||
| 140 | + ResultSet resultSet = statement.executeQuery( | ||
| 141 | + SELECT_OBJECT_SQL + request.getSchema() + SELECT_OBJECT_WHERE_SQL + request.getObjectType() + QUOTES_SEMICOLON) | ||
| 142 | + ) { | ||
| 143 | + while (resultSet.next()) { | ||
| 144 | + objectList.add(resultSet.getString("relname")); | ||
| 145 | + } | ||
| 146 | + log.info("objectList response is: " + objectList); | ||
| 147 | + return objectList; | ||
| 148 | + } | ||
| 149 | + } | ||
| 150 | + } catch (Exception e) { | ||
| 151 | + log.info(e.getMessage()); | ||
| 152 | + throw new CustomException(e.getMessage(), e); | ||
| 153 | + } | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + | ||
| 157 | + public List<String> tableColumnList(DatabaseMetaarrayColumnQuery request) throws Exception { | ||
| 158 | + log.info("tableColumnList request is: " + request); | ||
| 159 | + List<String> columnList = new ArrayList<>(); | ||
| 160 | + try ( | ||
| 161 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 162 | + Statement statement = connection.createStatement(); | ||
| 163 | + ResultSet resultSet = statement.executeQuery( | ||
| 164 | + SELECT_COLUMN_SQL + request.getSchema() + SELECT_COLUMN_WHERE_SQL + request.getObjectName() + QUOTES_SEMICOLON) | ||
| 165 | + ) { | ||
| 166 | + while (resultSet.next()) { | ||
| 167 | + columnList.add(resultSet.getString("column_name")); | ||
| 168 | + } | ||
| 169 | + log.info("tableColumnList response is: " + columnList); | ||
| 170 | + return columnList; | ||
| 171 | + } catch (Exception e) { | ||
| 172 | + log.info(e.getMessage()); | ||
| 173 | + throw new CustomException(e.getMessage(), e); | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + | ||
| 178 | + public String databaseVersion() throws Exception { | ||
| 179 | + String ddl; | ||
| 180 | + ddl = " select version();"; | ||
| 181 | + log.info("splicingSequenceDDL response is: " + ddl); | ||
| 182 | + return ddl; | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + | ||
| 186 | + public String tableSql(String schema) throws Exception { | ||
| 187 | + String ddl; | ||
| 188 | + ddl = "select x.oid,relname as tablename,parttype" + LF + | ||
| 189 | + " from (select tbl.oid as oid, tbl.relname relname,case when parttype='n' then 'n' else 'y' end as parttype " + LF + | ||
| 190 | + " from pg_class tbl" + LF + | ||
| 191 | + " inner join pg_namespace ns on tbl.relnamespace = ns.oid" + LF + | ||
| 192 | + " where tbl.relkind = 'r'" + LF + | ||
| 193 | + " and ns.nspname = '" + schema + "' ) x" + LF + | ||
| 194 | + " where has_table_privilege(x.oid, 'SELECT')" + | ||
| 195 | + " order by 1"; | ||
| 196 | + log.info("splicingSequenceDDL response is: " + ddl); | ||
| 197 | + return ddl; | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + | ||
| 201 | + public String viewSql(String schema) throws Exception { | ||
| 202 | + String ddl; | ||
| 203 | + ddl = "select c.oid,c.relname as viewname from pg_class c INNER JOIN pg_namespace n ON n.oid = c.relnamespace and n.nspname = '" + schema + SELECT_OBJECT_WHERE_IN_SQL + "v','m" + "') order by 1" + SEMICOLON; | ||
| 204 | + log.info("splicingSequenceDDL response is: " + ddl); | ||
| 205 | + return ddl; | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + | ||
| 209 | + public String fun_prosSql(String schema) throws Exception { | ||
| 210 | + String ddl; | ||
| 211 | + ddl = "SELECT oid,proname,proargtypes FROM pg_proc" + LF + | ||
| 212 | + "WHERE pronamespace = (SELECT pg_namespace.oid FROM pg_namespace WHERE nspname = '" + schema + "')" + LF + | ||
| 213 | + " order by 1" + LF; | ||
| 214 | + log.info("splicingSequenceDDL response is: " + ddl); | ||
| 215 | + return ddl; | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + | ||
| 219 | + public String sequenceSql(String schema) throws Exception { | ||
| 220 | + String ddl; | ||
| 221 | + ddl = "select c.oid,c.relname as relname from" + LF + | ||
| 222 | + "pg_class c INNER JOIN pg_namespace n ON n.oid = c.relnamespace " + LF + | ||
| 223 | + "and n.nspname = '" + schema + "' where c.relkind = 'S'" + LF + | ||
| 224 | + " order by 1"; | ||
| 225 | + log.info("splicingSequenceDDL response is: " + ddl); | ||
| 226 | + return ddl; | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + | ||
| 230 | + public String synonymSql(String schema) throws Exception { | ||
| 231 | + String ddl; | ||
| 232 | + ddl = "select pgs.oid,synname from PG_SYNONYM pgs, pg_namespace pgn" + LF + | ||
| 233 | + " where pgn.oid = pgs.synnamespace" + LF + | ||
| 234 | + " and pgn.nspname ='" + schema + "'" + LF + | ||
| 235 | + " order by 1"; | ||
| 236 | + log.info("splicingSequenceDDL response is: " + ddl); | ||
| 237 | + return ddl; | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + | ||
| 241 | + public String baseTypeListSQL() throws Exception { | ||
| 242 | + String ddl; | ||
| 243 | + ddl = "select pg_catalog.format_type(typ.oid,typ.typtypmod) as type" + LF + | ||
| 244 | + "from pg_type typ left join pg_description des on (typ.oid = des.objoid) " + LF + | ||
| 245 | + "where typ.typnamespace in (select oid from pg_namespace where nspname in " + LF + | ||
| 246 | + "('information_schema', 'pg_catalog'))" + LF + | ||
| 247 | + "and typtype = 'b'" + LF + | ||
| 248 | + "order by 1"; | ||
| 249 | + log.info("splicingSequenceDDL response is: " + ddl); | ||
| 250 | + return ddl; | ||
| 251 | + } | ||
| 252 | + | ||
| 253 | + | ||
| 254 | + public String tablespaceListSQL() throws Exception { | ||
| 255 | + String ddl; | ||
| 256 | + ddl = "select spcname from pg_tablespace " + LF + | ||
| 257 | + "order by 1"; | ||
| 258 | + log.info("splicingSequenceDDL response is: " + ddl); | ||
| 259 | + return ddl; | ||
| 260 | + } | ||
| 261 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/opengauss/SequenceObjectSQLServiceImpl.java+159-0
| @@ -0,0 +1,159 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible.opengauss; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.compatible.SequenceObjectSQLService; | ||
| 8 | +import com.nctigba.datastudio.config.ConnectionConfig; | ||
| 9 | +import com.nctigba.datastudio.model.dto.DatabaseCreateSequenceDTO; | ||
| 10 | +import com.nctigba.datastudio.model.dto.DatabaseDropSequenceDTO; | ||
| 11 | +import com.nctigba.datastudio.model.dto.DatabaseSequenceDdlDTO; | ||
| 12 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 13 | +import lombok.extern.slf4j.Slf4j; | ||
| 14 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 15 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 16 | +import org.springframework.stereotype.Service; | ||
| 17 | + | ||
| 18 | +import java.sql.Connection; | ||
| 19 | +import java.sql.ResultSet; | ||
| 20 | +import java.sql.Statement; | ||
| 21 | +import java.util.Objects; | ||
| 22 | + | ||
| 23 | +import static com.nctigba.datastudio.constants.CommonConstants.OPENGAUSS; | ||
| 24 | +import static com.nctigba.datastudio.constants.SqlConstants.CACHE_KEYWORD_SQL; | ||
| 25 | +import static com.nctigba.datastudio.constants.SqlConstants.COUNT_SQL; | ||
| 26 | +import static com.nctigba.datastudio.constants.SqlConstants.CREATE_SQL; | ||
| 27 | +import static com.nctigba.datastudio.constants.SqlConstants.CYCLE_KEYWORD_SQL; | ||
| 28 | +import static com.nctigba.datastudio.constants.SqlConstants.CYCLE_SQL; | ||
| 29 | +import static com.nctigba.datastudio.constants.SqlConstants.DROP_SQL; | ||
| 30 | +import static com.nctigba.datastudio.constants.SqlConstants.FROM_CLASS_SQL; | ||
| 31 | +import static com.nctigba.datastudio.constants.SqlConstants.FROM_CLASS_WHERE_SQL; | ||
| 32 | +import static com.nctigba.datastudio.constants.SqlConstants.INCREMENT_BY_SQL; | ||
| 33 | +import static com.nctigba.datastudio.constants.SqlConstants.INCREMENT_KEYWORD_SQL; | ||
| 34 | +import static com.nctigba.datastudio.constants.SqlConstants.LF; | ||
| 35 | +import static com.nctigba.datastudio.constants.SqlConstants.MAXVALUE_KEYWORD_SQL; | ||
| 36 | +import static com.nctigba.datastudio.constants.SqlConstants.MAXVALUE_SQL; | ||
| 37 | +import static com.nctigba.datastudio.constants.SqlConstants.MINVALUE_KEYWORD_SQL; | ||
| 38 | +import static com.nctigba.datastudio.constants.SqlConstants.MINVALUE_SQL; | ||
| 39 | +import static com.nctigba.datastudio.constants.SqlConstants.NO_MINVALUE_KEYWORD_SQL; | ||
| 40 | +import static com.nctigba.datastudio.constants.SqlConstants.NO_MINVALUE_SQL; | ||
| 41 | +import static com.nctigba.datastudio.constants.SqlConstants.OWNED_KEYWORD_SQL; | ||
| 42 | +import static com.nctigba.datastudio.constants.SqlConstants.POINT; | ||
| 43 | +import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_SEMICOLON; | ||
| 44 | +import static com.nctigba.datastudio.constants.SqlConstants.RELKIND_SQL; | ||
| 45 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_KEYWORD_SQL; | ||
| 46 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_SEQUENCE_DDL_SQL; | ||
| 47 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_SEQUENCE_DDL_WHERE_SQL; | ||
| 48 | +import static com.nctigba.datastudio.constants.SqlConstants.SEMICOLON; | ||
| 49 | +import static com.nctigba.datastudio.constants.SqlConstants.SEQUENCE_KEYWORD_SQL; | ||
| 50 | +import static com.nctigba.datastudio.constants.SqlConstants.SEQUENCE_SET_SQL; | ||
| 51 | +import static com.nctigba.datastudio.constants.SqlConstants.START_KEYWORD_SQL; | ||
| 52 | +import static com.nctigba.datastudio.constants.SqlConstants.START_WITH_SQL; | ||
| 53 | +import static org.apache.commons.lang3.StringUtils.isNumeric; | ||
| 54 | + | ||
| 55 | + | ||
| 56 | + | ||
| 57 | +public class SequenceObjectSQLServiceImpl implements SequenceObjectSQLService { | ||
| 58 | + | ||
| 59 | + private ConnectionConfig connectionConfig; | ||
| 60 | + | ||
| 61 | + | ||
| 62 | + public String type() { | ||
| 63 | + return OPENGAUSS; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + | ||
| 67 | + public String splicingSequenceDDL(DatabaseCreateSequenceDTO request) throws Exception { | ||
| 68 | + log.info("splicingSequenceDDL request is: " + request); | ||
| 69 | + String ddl = CREATE_SQL + SEQUENCE_KEYWORD_SQL + request.getSchema() + POINT + request.getSequenceName(); | ||
| 70 | + if (isNumeric(request.getStart())) { | ||
| 71 | + ddl = ddl + LF + START_KEYWORD_SQL + request.getStart(); | ||
| 72 | + } | ||
| 73 | + if (isNumeric(request.getIncrement())) { | ||
| 74 | + ddl = ddl + LF + INCREMENT_KEYWORD_SQL + request.getIncrement(); | ||
| 75 | + } | ||
| 76 | + if (isNumeric(request.getMinValue())) { | ||
| 77 | + ddl = ddl + LF + MINVALUE_KEYWORD_SQL + request.getMinValue(); | ||
| 78 | + } else { | ||
| 79 | + ddl = ddl + LF + NO_MINVALUE_KEYWORD_SQL; | ||
| 80 | + } | ||
| 81 | + if (isNumeric(request.getMaxValue())) { | ||
| 82 | + ddl = ddl + LF + MAXVALUE_KEYWORD_SQL + request.getMaxValue(); | ||
| 83 | + } | ||
| 84 | + if (isNumeric(request.getCache())) { | ||
| 85 | + ddl = ddl + LF + CACHE_KEYWORD_SQL + request.getCache(); | ||
| 86 | + } | ||
| 87 | + if (request.getCycle().equals("CYCLE")) { | ||
| 88 | + ddl = ddl + LF + CYCLE_KEYWORD_SQL; | ||
| 89 | + } | ||
| 90 | + if (!Objects.nonNull(request.getTableSchema())) { | ||
| 91 | + ddl = ddl + LF + OWNED_KEYWORD_SQL + request.getTableSchema() + POINT; | ||
| 92 | + } | ||
| 93 | + if (!Objects.nonNull(request.getTableName())) { | ||
| 94 | + ddl = ddl + request.getTableName() + POINT; | ||
| 95 | + } | ||
| 96 | + if (!Objects.nonNull(request.getTableColumn())) { | ||
| 97 | + ddl = ddl + request.getTableColumn(); | ||
| 98 | + } | ||
| 99 | + log.info("splicingSequenceDDL response is: " + ddl); | ||
| 100 | + return ddl; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + | ||
| 104 | + public String dropSequenceDDL(DatabaseDropSequenceDTO request) throws Exception { | ||
| 105 | + log.info("dropSequenceDDL request is: " + request); | ||
| 106 | + String sql = DROP_SQL + SEQUENCE_KEYWORD_SQL + request.getSchema() + POINT + request.getSequenceName(); | ||
| 107 | + return sql; | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + | ||
| 111 | + public String returnSequenceDDL(DatabaseSequenceDdlDTO request) throws Exception { | ||
| 112 | + log.info("returnSequenceDDL request is: " + request); | ||
| 113 | + try ( | ||
| 114 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 115 | + Statement statement = connection.createStatement() | ||
| 116 | + ) { | ||
| 117 | + String selectSql = SELECT_SEQUENCE_DDL_SQL + request.getSchema() + SELECT_SEQUENCE_DDL_WHERE_SQL + request.getSequenceName() + QUOTES_SEMICOLON; | ||
| 118 | + try ( | ||
| 119 | + ResultSet count = statement.executeQuery(SELECT_KEYWORD_SQL + COUNT_SQL + FROM_CLASS_SQL + | ||
| 120 | + request.getSchema() + FROM_CLASS_WHERE_SQL + request.getSequenceName() + RELKIND_SQL + "S" + QUOTES_SEMICOLON) | ||
| 121 | + ) { | ||
| 122 | + count.next(); | ||
| 123 | + int a = count.getInt("count"); | ||
| 124 | + if (a == 0) { | ||
| 125 | + throw new CustomException(LocaleString.transLanguage("2012")); | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + String ddl = ""; | ||
| 129 | + try ( | ||
| 130 | + ResultSet resultSet = statement.executeQuery(selectSql) | ||
| 131 | + ) { | ||
| 132 | + while (resultSet.next()) { | ||
| 133 | + ddl = SEQUENCE_SET_SQL + resultSet.getString("sequence_schema") + SEMICOLON + LF | ||
| 134 | + + CREATE_SQL + SEQUENCE_KEYWORD_SQL + resultSet.getString("sequence_name") + LF | ||
| 135 | + + START_WITH_SQL + resultSet.getString("start_value") + LF | ||
| 136 | + + INCREMENT_BY_SQL + resultSet.getString("increment") + LF; | ||
| 137 | + if (resultSet.getInt("minimum_value") == 1) { | ||
| 138 | + ddl = ddl + NO_MINVALUE_SQL + LF | ||
| 139 | + + MAXVALUE_SQL + resultSet.getString("maximum_value") + LF; | ||
| 140 | + | ||
| 141 | + } else { | ||
| 142 | + ddl = ddl + MINVALUE_SQL + resultSet.getString("minimum_value") + LF | ||
| 143 | + + MAXVALUE_SQL + resultSet.getString("maximum_value") + LF; | ||
| 144 | + | ||
| 145 | + } | ||
| 146 | + if (resultSet.getString("cycle_option").equals("YES")) { | ||
| 147 | + ddl = ddl + CYCLE_SQL + LF; | ||
| 148 | + } | ||
| 149 | + ddl = ddl + SEMICOLON; | ||
| 150 | + } | ||
| 151 | + log.info("returnSequenceDDL response is: " + ddl); | ||
| 152 | + } | ||
| 153 | + return ddl; | ||
| 154 | + } catch (Exception e) { | ||
| 155 | + log.info(e.getMessage()); | ||
| 156 | + throw new CustomException(e.getMessage(), e); | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/opengauss/SynonymObjectSQLServiceImpl.java+61-0
| @@ -0,0 +1,61 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible.opengauss; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.compatible.SynonymObjectSQLService; | ||
| 8 | +import com.nctigba.datastudio.model.dto.DatabaseCreateSynonymDTO; | ||
| 9 | +import com.nctigba.datastudio.model.dto.DatabaseDropSynonymDTO; | ||
| 10 | +import com.nctigba.datastudio.model.dto.DatabaseSynonymAttributeDTO; | ||
| 11 | +import lombok.extern.slf4j.Slf4j; | ||
| 12 | +import org.springframework.stereotype.Service; | ||
| 13 | + | ||
| 14 | +import static com.nctigba.datastudio.constants.CommonConstants.OPENGAUSS; | ||
| 15 | +import static com.nctigba.datastudio.constants.SqlConstants.CREATE_SQL; | ||
| 16 | +import static com.nctigba.datastudio.constants.SqlConstants.DROP_SQL; | ||
| 17 | +import static com.nctigba.datastudio.constants.SqlConstants.FOR_KEYWORD_SQL; | ||
| 18 | +import static com.nctigba.datastudio.constants.SqlConstants.LF; | ||
| 19 | +import static com.nctigba.datastudio.constants.SqlConstants.POINT; | ||
| 20 | +import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_SEMICOLON; | ||
| 21 | +import static com.nctigba.datastudio.constants.SqlConstants.REPLACE_KEYWORD_SQL; | ||
| 22 | +import static com.nctigba.datastudio.constants.SqlConstants.SYNONYM_ATTRIBUTE_SQL; | ||
| 23 | +import static com.nctigba.datastudio.constants.SqlConstants.SYNONYM_KEYWORD_SQL; | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +public class SynonymObjectSQLServiceImpl implements SynonymObjectSQLService { | ||
| 28 | + | ||
| 29 | + public String type() { | ||
| 30 | + return OPENGAUSS; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + public String splicingSequenceDDL(DatabaseCreateSynonymDTO request) throws Exception { | ||
| 35 | + log.info("splicingSequenceDDL request is: " + request); | ||
| 36 | + String ddl; | ||
| 37 | + if (request.isReplace()) { | ||
| 38 | + ddl = CREATE_SQL + REPLACE_KEYWORD_SQL + LF + SYNONYM_KEYWORD_SQL + request.getSchema() + POINT | ||
| 39 | + + request.getSynonymName() + LF + FOR_KEYWORD_SQL + LF + request.getSchema() | ||
| 40 | + + POINT + request.getObjectName(); | ||
| 41 | + } else { | ||
| 42 | + ddl = CREATE_SQL + LF + SYNONYM_KEYWORD_SQL + request.getSchema() + POINT | ||
| 43 | + + request.getSynonymName() + LF + FOR_KEYWORD_SQL + LF | ||
| 44 | + + request.getSchema() + POINT + request.getObjectName(); | ||
| 45 | + } | ||
| 46 | + log.info("splicingSequenceDDL response is: " + ddl); | ||
| 47 | + return ddl; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + | ||
| 51 | + public String synonymAttributeSQL(DatabaseSynonymAttributeDTO request) { | ||
| 52 | + log.info("synonymAttribute request is: " + request); | ||
| 53 | + return SYNONYM_ATTRIBUTE_SQL + request.getSynonymName() + QUOTES_SEMICOLON; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + | ||
| 57 | + public String dropSynonymSQL(DatabaseDropSynonymDTO request) { | ||
| 58 | + log.info("dropSynonym request is: " + request); | ||
| 59 | + return DROP_SQL + SYNONYM_KEYWORD_SQL + request.getSchema() + POINT + request.getSynonymName(); | ||
| 60 | + } | ||
| 61 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/opengauss/TableColumnSQLServiceImpl.java+608-0
| @@ -0,0 +1,608 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible.opengauss; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.compatible.TableColumnSQLService; | ||
| 8 | +import com.nctigba.datastudio.config.ConnectionConfig; | ||
| 9 | +import com.nctigba.datastudio.constants.CommonConstants; | ||
| 10 | +import com.nctigba.datastudio.constants.SqlConstants; | ||
| 11 | +import com.nctigba.datastudio.model.dto.ConstraintDTO; | ||
| 12 | +import com.nctigba.datastudio.model.dto.DatabaseConstraintDTO; | ||
| 13 | +import com.nctigba.datastudio.model.dto.DatabaseConstraintPkDTO; | ||
| 14 | +import com.nctigba.datastudio.model.dto.DatabaseCreUpdColumnDTO; | ||
| 15 | +import com.nctigba.datastudio.model.dto.DatabaseCreateTableDTO; | ||
| 16 | +import com.nctigba.datastudio.model.dto.DatabaseIndexDTO; | ||
| 17 | +import com.nctigba.datastudio.model.dto.IndexDTO; | ||
| 18 | +import com.nctigba.datastudio.model.query.SelectDataQuery; | ||
| 19 | +import com.nctigba.datastudio.model.query.TablePartitionInfoQuery; | ||
| 20 | +import com.nctigba.datastudio.model.query.TableUnderlyingInfoQuery; | ||
| 21 | +import lombok.extern.slf4j.Slf4j; | ||
| 22 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 23 | +import org.opengauss.admin.common.utils.StringUtils; | ||
| 24 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 25 | +import org.springframework.stereotype.Service; | ||
| 26 | + | ||
| 27 | +import java.sql.Connection; | ||
| 28 | +import java.sql.ResultSet; | ||
| 29 | +import java.sql.Statement; | ||
| 30 | +import java.util.ArrayList; | ||
| 31 | +import java.util.Arrays; | ||
| 32 | +import java.util.List; | ||
| 33 | + | ||
| 34 | +import static com.nctigba.datastudio.constants.CommonConstants.OPENGAUSS; | ||
| 35 | +import static com.nctigba.datastudio.constants.SqlConstants.ADD_KEYWORD_SQL; | ||
| 36 | +import static com.nctigba.datastudio.constants.SqlConstants.ALTER_DEFAULT_SQL; | ||
| 37 | +import static com.nctigba.datastudio.constants.SqlConstants.ALTER_SQL; | ||
| 38 | +import static com.nctigba.datastudio.constants.SqlConstants.ALTER_TABLE_SQL; | ||
| 39 | +import static com.nctigba.datastudio.constants.SqlConstants.CHECK_SQL; | ||
| 40 | +import static com.nctigba.datastudio.constants.SqlConstants.COLUMN_KEYWORD_SQL; | ||
| 41 | +import static com.nctigba.datastudio.constants.SqlConstants.COLUMN_SQL; | ||
| 42 | +import static com.nctigba.datastudio.constants.SqlConstants.COMMA; | ||
| 43 | +import static com.nctigba.datastudio.constants.SqlConstants.COMMENT_ON_COLUMN_SQL; | ||
| 44 | +import static com.nctigba.datastudio.constants.SqlConstants.COMMENT_TABLE_SQL; | ||
| 45 | +import static com.nctigba.datastudio.constants.SqlConstants.CONSTRAINT_COMMENT_SQL; | ||
| 46 | +import static com.nctigba.datastudio.constants.SqlConstants.CONSTRAINT_DROP_SQL; | ||
| 47 | +import static com.nctigba.datastudio.constants.SqlConstants.CONSTRAINT_TABLE_COLUMN_SQL; | ||
| 48 | +import static com.nctigba.datastudio.constants.SqlConstants.CONSTRAINT_UNIQUE_SQL; | ||
| 49 | +import static com.nctigba.datastudio.constants.SqlConstants.CREATE_TABLE_EXISTS_SQL; | ||
| 50 | +import static com.nctigba.datastudio.constants.SqlConstants.CREATE_TABLE_SQL; | ||
| 51 | +import static com.nctigba.datastudio.constants.SqlConstants.CREATE_UNLOGGED_TABLE_EXISTS_SQL; | ||
| 52 | +import static com.nctigba.datastudio.constants.SqlConstants.CREATE_UNLOGGED_TABLE_SQL; | ||
| 53 | +import static com.nctigba.datastudio.constants.SqlConstants.DEFAULT_KEYWORD_SQL; | ||
| 54 | +import static com.nctigba.datastudio.constants.SqlConstants.DROP_DEFAULT_SQL; | ||
| 55 | +import static com.nctigba.datastudio.constants.SqlConstants.DROP_SQL; | ||
| 56 | +import static com.nctigba.datastudio.constants.SqlConstants.FILLFACTOR_SQL; | ||
| 57 | +import static com.nctigba.datastudio.constants.SqlConstants.FOREIGN_KEY_SQL; | ||
| 58 | +import static com.nctigba.datastudio.constants.SqlConstants.GET_COLUMN_SQL; | ||
| 59 | +import static com.nctigba.datastudio.constants.SqlConstants.HASH_SQL; | ||
| 60 | +import static com.nctigba.datastudio.constants.SqlConstants.INTERVAL_SQL; | ||
| 61 | +import static com.nctigba.datastudio.constants.SqlConstants.IS_SQL; | ||
| 62 | +import static com.nctigba.datastudio.constants.SqlConstants.LEFT_BRACKET; | ||
| 63 | +import static com.nctigba.datastudio.constants.SqlConstants.LF; | ||
| 64 | +import static com.nctigba.datastudio.constants.SqlConstants.LIST_SQL; | ||
| 65 | +import static com.nctigba.datastudio.constants.SqlConstants.NOT_KEYWORD_SQL; | ||
| 66 | +import static com.nctigba.datastudio.constants.SqlConstants.NULL_KEYWORD_SQL; | ||
| 67 | +import static com.nctigba.datastudio.constants.SqlConstants.OIDS_SQL; | ||
| 68 | +import static com.nctigba.datastudio.constants.SqlConstants.PARTIAL_CLUSTER_KEY_SQL; | ||
| 69 | +import static com.nctigba.datastudio.constants.SqlConstants.PARTITION_BY_SQL; | ||
| 70 | +import static com.nctigba.datastudio.constants.SqlConstants.POINT; | ||
| 71 | +import static com.nctigba.datastudio.constants.SqlConstants.PRIMARY_KEY_SQL; | ||
| 72 | +import static com.nctigba.datastudio.constants.SqlConstants.QUOTES; | ||
| 73 | +import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_LF_COMMA; | ||
| 74 | +import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_SEMICOLON; | ||
| 75 | +import static com.nctigba.datastudio.constants.SqlConstants.RANGE_SQL; | ||
| 76 | +import static com.nctigba.datastudio.constants.SqlConstants.RENAME_KEYWORD_SQL; | ||
| 77 | +import static com.nctigba.datastudio.constants.SqlConstants.RIGHT_BRACKET; | ||
| 78 | +import static com.nctigba.datastudio.constants.SqlConstants.SEMICOLON; | ||
| 79 | +import static com.nctigba.datastudio.constants.SqlConstants.SET_KEYWORD_SQL; | ||
| 80 | +import static com.nctigba.datastudio.constants.SqlConstants.SPACE; | ||
| 81 | +import static com.nctigba.datastudio.constants.SqlConstants.TABLESPACE_SQL; | ||
| 82 | +import static com.nctigba.datastudio.constants.SqlConstants.TO_KEYWORD_SQL; | ||
| 83 | +import static com.nctigba.datastudio.constants.SqlConstants.TYPE_KEYWORD_SQL; | ||
| 84 | +import static com.nctigba.datastudio.constants.SqlConstants.UNIQUE_IMMEDIATE_SQL; | ||
| 85 | +import static com.nctigba.datastudio.constants.SqlConstants.UNIQUE_KEYWORD_SQL; | ||
| 86 | +import static com.nctigba.datastudio.constants.SqlConstants.UNIQUE_SQL; | ||
| 87 | +import static com.nctigba.datastudio.constants.SqlConstants.WITH_DOUBLE_SQL; | ||
| 88 | +import static com.nctigba.datastudio.constants.SqlConstants.WITH_SQL; | ||
| 89 | + | ||
| 90 | + | ||
| 91 | + | ||
| 92 | +public class TableColumnSQLServiceImpl implements TableColumnSQLService { | ||
| 93 | + | ||
| 94 | + private ConnectionConfig connectionConfig; | ||
| 95 | + | ||
| 96 | + private final String[] arrayRefVar = {"bigint", "smallint", "tinyint", "integer", "int16", "real", "double precision"}; | ||
| 97 | + | ||
| 98 | + | ||
| 99 | + public String type() { | ||
| 100 | + return OPENGAUSS; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + | ||
| 104 | + public String tableConstraintSQL(SelectDataQuery request) throws Exception { | ||
| 105 | + String ddl = String.format(SqlConstants.CONSTRAINT_TABLE_SQL, request.getSchema(), request.getTableName()); | ||
| 106 | + log.info("tableConstraintSQL response is: " + ddl); | ||
| 107 | + return ddl; | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + | ||
| 111 | + public String tablePKConstraintSQL(String schema, String tableName) throws Exception { | ||
| 112 | + String ddl = String.format(SqlConstants.UNIQUE_CONSTRAINT_TABLE_SQL, schema, tableName); | ||
| 113 | + log.info("tableConstraintSQL response is: " + ddl); | ||
| 114 | + return ddl; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + | ||
| 118 | + public void editConstraint(DatabaseConstraintDTO request) throws Exception { | ||
| 119 | + List<ConstraintDTO> list = request.getConstraints(); | ||
| 120 | + log.info("List<ConstraintDTO> request is: " + list.toString()); | ||
| 121 | + if (list != null) { | ||
| 122 | + Connection connection = null; | ||
| 123 | + Statement statement = null; | ||
| 124 | + try { | ||
| 125 | + connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 126 | + connection.setAutoCommit(false); | ||
| 127 | + statement = connection.createStatement(); | ||
| 128 | + for (ConstraintDTO obj : list) { | ||
| 129 | + if (obj.getType() == 1) { | ||
| 130 | + this.addConstraint(request, obj, statement); | ||
| 131 | + } else if (obj.getType() == 2) { | ||
| 132 | + statement.addBatch(String.format(SqlConstants.CONSTRAINT_DROP_SQL, request.getSchema(), | ||
| 133 | + request.getTableName(), obj.getConname())); | ||
| 134 | + } else if (obj.getType() == 3) { | ||
| 135 | + this.updateConstraint(request, obj, statement); | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + statement.executeBatch(); | ||
| 139 | + connection.commit(); | ||
| 140 | + } catch (Exception e) { | ||
| 141 | + connection.rollback(); | ||
| 142 | + log.info(e.getMessage()); | ||
| 143 | + throw new CustomException(e.getMessage(), e); | ||
| 144 | + } finally { | ||
| 145 | + if (statement != null) { | ||
| 146 | + statement.close(); | ||
| 147 | + } | ||
| 148 | + if (connection != null) { | ||
| 149 | + connection.close(); | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + | ||
| 156 | + public void editPkConstraint(DatabaseConstraintPkDTO request) throws Exception { | ||
| 157 | + log.info("DatabaseConstraintPkDTO request is: {}", request); | ||
| 158 | + String attname = request.getTableName() + "_PK"; | ||
| 159 | + try ( | ||
| 160 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 161 | + Statement statement = connection.createStatement() | ||
| 162 | + ) { | ||
| 163 | + log.info("sqlPK request is: {}", | ||
| 164 | + String.format(SqlConstants.CONSTRAINT_PRIMARY_SQL, request.getSchema(), request.getTableName(), | ||
| 165 | + attname, request.getColumn())); | ||
| 166 | + statement.execute( | ||
| 167 | + String.format(SqlConstants.CONSTRAINT_PRIMARY_SQL, request.getSchema(), request.getTableName(), | ||
| 168 | + attname, request.getColumn())); | ||
| 169 | + log.info("sqlPK1 request is: {}"); | ||
| 170 | + } | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + | ||
| 174 | + public String tableIndexSQL(SelectDataQuery request) throws Exception { | ||
| 175 | + String ddl = String.format(SqlConstants.INDEX_TABLE_SQL, request.getTableName(), request.getSchema()); | ||
| 176 | + log.info("tableIndexSQL response is: " + ddl); | ||
| 177 | + return ddl; | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + | ||
| 181 | + public void editIndex(DatabaseIndexDTO request) throws Exception { | ||
| 182 | + List<IndexDTO> list = request.getIndexs(); | ||
| 183 | + log.info("List<IndexDTO> request is: " + list.toString()); | ||
| 184 | + if (list != null) { | ||
| 185 | + Connection connection = null; | ||
| 186 | + Statement statement = null; | ||
| 187 | + try { | ||
| 188 | + connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 189 | + connection.setAutoCommit(false); | ||
| 190 | + statement = connection.createStatement(); | ||
| 191 | + for (IndexDTO obj : list) { | ||
| 192 | + if (obj.getType() == 1) { | ||
| 193 | + this.addIndex(request, obj, statement); | ||
| 194 | + } else if (obj.getType() == 2) { | ||
| 195 | + statement.addBatch( | ||
| 196 | + String.format(SqlConstants.INDEX_DROP_SQL, request.getSchema(), obj.getIndexName())); | ||
| 197 | + } else if (obj.getType() == 3) { | ||
| 198 | + this.updateIndex(request, obj, statement); | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + statement.executeBatch(); | ||
| 202 | + connection.commit(); | ||
| 203 | + } catch (Exception e) { | ||
| 204 | + connection.rollback(); | ||
| 205 | + log.info(e.getMessage()); | ||
| 206 | + throw new CustomException(e.getMessage(), e); | ||
| 207 | + } finally { | ||
| 208 | + if (statement != null) { | ||
| 209 | + statement.close(); | ||
| 210 | + } | ||
| 211 | + if (connection != null) { | ||
| 212 | + connection.close(); | ||
| 213 | + } | ||
| 214 | + } | ||
| 215 | + } | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + | ||
| 219 | + public String tableColumnSQL(String oid, String schema, String tableName) throws Exception { | ||
| 220 | + String ddl = String.format(GET_COLUMN_SQL, oid, oid, schema, tableName); | ||
| 221 | + log.info("tableColumnSQL response is: " + ddl); | ||
| 222 | + return ddl; | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + | ||
| 226 | + public List<String> tableColumnAddSQL(DatabaseCreUpdColumnDTO.CreUpdColumnDataDTO data, String schema, | ||
| 227 | + String tableName) throws Exception { | ||
| 228 | + List<String> list = new ArrayList<>(); | ||
| 229 | + StringBuilder ddl = new StringBuilder(ALTER_TABLE_SQL).append(schema).append(POINT) | ||
| 230 | + .append(tableName).append(ADD_KEYWORD_SQL).append(COLUMN_KEYWORD_SQL) | ||
| 231 | + .append(data.getNewColumnName()).append(SPACE); | ||
| 232 | + list.add(String.valueOf(ddl.append(columnAddSQL(data)).append(SEMICOLON))); | ||
| 233 | + list.add(commentAddSQL(data, schema, tableName)); | ||
| 234 | + log.info("tableColumnAddSQL response is: " + ddl); | ||
| 235 | + return list; | ||
| 236 | + | ||
| 237 | + } | ||
| 238 | + | ||
| 239 | + public String columnAddSQL(DatabaseCreUpdColumnDTO.CreUpdColumnDataDTO data) throws Exception { | ||
| 240 | + log.info("columnAddSQL response is: {}", data); | ||
| 241 | + StringBuilder ddl = new StringBuilder(); | ||
| 242 | + StringBuilder precision = new StringBuilder(); | ||
| 243 | + if (!StringUtils.isEmpty(data.getPrecision())) { | ||
| 244 | + precision.append(LEFT_BRACKET).append(data.getPrecision()); | ||
| 245 | + if (!StringUtils.isEmpty(data.getScope())) { | ||
| 246 | + precision.append(COMMA).append(data.getScope()); | ||
| 247 | + } | ||
| 248 | + precision.append(RIGHT_BRACKET); | ||
| 249 | + } | ||
| 250 | + if (data.getType().endsWith("[]")) { | ||
| 251 | + ddl.append(data.getType(), 0, data.getType().length() - 2); | ||
| 252 | + ddl.append(precision).append("[]"); | ||
| 253 | + } else { | ||
| 254 | + ddl.append(data.getType()); | ||
| 255 | + ddl.append(precision); | ||
| 256 | + } | ||
| 257 | + if (data.getEmpty() != null && data.getEmpty()) { | ||
| 258 | + ddl.append(NOT_KEYWORD_SQL).append(NULL_KEYWORD_SQL); | ||
| 259 | + } | ||
| 260 | + if (!StringUtils.isEmpty(data.getDefaultValue())) { | ||
| 261 | + if (Arrays.asList(arrayRefVar).contains(data.getType())) { | ||
| 262 | + ddl.append(DEFAULT_KEYWORD_SQL).append(data.getDefaultValue()); | ||
| 263 | + } else { | ||
| 264 | + ddl.append(DEFAULT_KEYWORD_SQL).append(QUOTES).append(data.getDefaultValue()).append(QUOTES); | ||
| 265 | + } | ||
| 266 | + } | ||
| 267 | + if (data.getOnly() != null && data.getOnly()) { | ||
| 268 | + ddl.append(UNIQUE_KEYWORD_SQL); | ||
| 269 | + } | ||
| 270 | + return ddl.toString(); | ||
| 271 | + } | ||
| 272 | + | ||
| 273 | + public String commentAddSQL(DatabaseCreUpdColumnDTO.CreUpdColumnDataDTO data, String schema, | ||
| 274 | + String tableName) throws Exception { | ||
| 275 | + if (StringUtils.isNotEmpty(data.getComment())) { | ||
| 276 | + String ddl = String.format(COMMENT_ON_COLUMN_SQL, schema, tableName, data.getNewColumnName(), | ||
| 277 | + data.getComment()); | ||
| 278 | + log.info("commentAddSQL response is: " + ddl); | ||
| 279 | + return ddl; | ||
| 280 | + } | ||
| 281 | + return ""; | ||
| 282 | + } | ||
| 283 | + | ||
| 284 | + | ||
| 285 | + | ||
| 286 | + public String tableColumnDropSQL(DatabaseCreUpdColumnDTO.CreUpdColumnDataDTO data, String schema, | ||
| 287 | + String tableName) throws Exception { | ||
| 288 | + StringBuilder ddl = new StringBuilder(ALTER_TABLE_SQL).append(schema).append(POINT) | ||
| 289 | + .append(tableName).append(SPACE).append(DROP_SQL).append(COLUMN_KEYWORD_SQL) | ||
| 290 | + .append(data.getColumnName()).append(SEMICOLON); | ||
| 291 | + log.info("tableColumnDropSQL response is: " + ddl); | ||
| 292 | + return ddl.toString(); | ||
| 293 | + } | ||
| 294 | + | ||
| 295 | + | ||
| 296 | + public List<String> tableColumnUpdateSQL(DatabaseCreUpdColumnDTO.CreUpdColumnDataDTO data, | ||
| 297 | + String schema, String tableName, String uuid) throws Exception { | ||
| 298 | + List<String> list = new ArrayList<>(); | ||
| 299 | + StringBuilder ddl = new StringBuilder(ALTER_TABLE_SQL).append(schema).append(POINT) | ||
| 300 | + .append(tableName); | ||
| 301 | + String column; | ||
| 302 | + if (!StringUtils.isEmpty(data.getNewColumnName()) && !data.getNewColumnName().equals(data.getColumnName())) { | ||
| 303 | + StringBuilder rename = new StringBuilder(ddl).append(RENAME_KEYWORD_SQL).append(COLUMN_KEYWORD_SQL) | ||
| 304 | + .append(data.getColumnName()).append(TO_KEYWORD_SQL) | ||
| 305 | + .append(data.getNewColumnName()).append(SEMICOLON); | ||
| 306 | + list.add(rename.toString()); | ||
| 307 | + column = data.getNewColumnName(); | ||
| 308 | + } else { | ||
| 309 | + column = data.getColumnName(); | ||
| 310 | + } | ||
| 311 | + ddl.append(SPACE).append(ALTER_SQL).append(COLUMN_KEYWORD_SQL).append(column).append(SPACE).append( | ||
| 312 | + TYPE_KEYWORD_SQL); | ||
| 313 | + if (!StringUtils.isEmpty(data.getType())) { | ||
| 314 | + StringBuilder alter = new StringBuilder(ddl); | ||
| 315 | + StringBuilder precision = new StringBuilder(); | ||
| 316 | + if (!StringUtils.isEmpty(data.getPrecision())) { | ||
| 317 | + precision.append(LEFT_BRACKET).append(data.getPrecision()); | ||
| 318 | + if (StringUtils.isNotEmpty(data.getScope())) { | ||
| 319 | + precision.append(COMMA).append(data.getScope()); | ||
| 320 | + } | ||
| 321 | + precision.append(RIGHT_BRACKET); | ||
| 322 | + } | ||
| 323 | + if (data.getType().endsWith("[]")) { | ||
| 324 | + alter.append(data.getType(), 0, data.getType().length() - 2); | ||
| 325 | + alter.append(precision).append("[]").append(SEMICOLON); | ||
| 326 | + } else { | ||
| 327 | + alter.append(data.getType()); | ||
| 328 | + alter.append(precision).append(SEMICOLON); | ||
| 329 | + } | ||
| 330 | + list.add(alter.toString()); | ||
| 331 | + } | ||
| 332 | + if (data.getEmpty() != null) { | ||
| 333 | + StringBuilder alter = new StringBuilder(ddl); | ||
| 334 | + if (data.getEmpty()) { | ||
| 335 | + alter.append(SET_KEYWORD_SQL).append(NOT_KEYWORD_SQL).append(NULL_KEYWORD_SQL).append(SEMICOLON); | ||
| 336 | + } else { | ||
| 337 | + alter.append(SPACE).append(DROP_SQL).append(NOT_KEYWORD_SQL).append(NULL_KEYWORD_SQL).append(SEMICOLON); | ||
| 338 | + } | ||
| 339 | + list.add(alter.toString()); | ||
| 340 | + } | ||
| 341 | + if (StringUtils.isNotEmpty(data.getDefaultValue()) && !data.getDefaultValue().equals("")) { | ||
| 342 | + String value; | ||
| 343 | + if (Arrays.asList(arrayRefVar).contains(data.getType())) { | ||
| 344 | + value = data.getDefaultValue(); | ||
| 345 | + } else { | ||
| 346 | + value = String.valueOf(new StringBuilder(QUOTES).append(data.getDefaultValue()).append(QUOTES)); | ||
| 347 | + } | ||
| 348 | + String alterDrop = String.format(ALTER_DEFAULT_SQL, schema, tableName, column, value); | ||
| 349 | + list.add(alterDrop); | ||
| 350 | + } else { | ||
| 351 | + String ddlDrop = String.format(DROP_DEFAULT_SQL, schema, tableName, column); | ||
| 352 | + list.add(ddlDrop); | ||
| 353 | + } | ||
| 354 | + if (data.getOnly() != null) { | ||
| 355 | + StringBuilder alter = new StringBuilder(ddl); | ||
| 356 | + if (data.getOnly()) { | ||
| 357 | + StringBuilder uniqueKey = new StringBuilder(tableName).append("_").append(column).append("_key"); | ||
| 358 | + String unique = String.format(CONSTRAINT_UNIQUE_SQL, schema, tableName, uniqueKey, column); | ||
| 359 | + list.add(unique); | ||
| 360 | + } else { | ||
| 361 | + String uniqueKey = getConname(String.format(CONSTRAINT_TABLE_COLUMN_SQL, schema, tableName, | ||
| 362 | + StringUtils.isEmpty(data.getNewColumnName()) ? data.getColumnName() : data.getNewColumnName()), | ||
| 363 | + uuid); | ||
| 364 | + String sql = String.format(CONSTRAINT_DROP_SQL, schema, tableName, uniqueKey); | ||
| 365 | + list.add(sql); | ||
| 366 | + } | ||
| 367 | + } | ||
| 368 | + if (!StringUtils.isEmpty(data.getComment())) { | ||
| 369 | + StringBuilder comment = new StringBuilder(COMMENT_ON_COLUMN_SQL).append(schema).append(POINT) | ||
| 370 | + .append(tableName).append(POINT).append(data.getNewColumnName()).append(IS_SQL) | ||
| 371 | + .append(data.getComment()).append(QUOTES_SEMICOLON); | ||
| 372 | + list.add(comment.toString()); | ||
| 373 | + } | ||
| 374 | + log.info("tableColumnUpdateSQL response is: " + list); | ||
| 375 | + return list; | ||
| 376 | + } | ||
| 377 | + | ||
| 378 | + | ||
| 379 | + private void addConstraint(DatabaseConstraintDTO request, ConstraintDTO obj, Statement statement) throws Exception { | ||
| 380 | + if ("u".equals(obj.getContype())) { | ||
| 381 | + if (obj.getCondeferrable() == null | ||
| 382 | + || !obj.getCondeferrable() || CommonConstants.F.equals(obj.getCondeferrable())) { | ||
| 383 | + //ALTER TABLE table_name ADD CONSTRAINT id_unique UNIQUE (id); | ||
| 384 | + statement.addBatch( | ||
| 385 | + String.format(SqlConstants.CONSTRAINT_UNIQUE_SQL, request.getSchema(), request.getTableName(), | ||
| 386 | + obj.getConname(), obj.getAttname())); | ||
| 387 | + } else { | ||
| 388 | + statement.addBatch(String.format(SqlConstants.CONSTRAINT_UNIQUE_IMMEDIATE_SQL, request.getSchema(), | ||
| 389 | + request.getTableName(), obj.getConname(), obj.getAttname())); | ||
| 390 | + } | ||
| 391 | + } else if ("p".equals(obj.getContype())) { | ||
| 392 | + if (obj.getCondeferrable() == null | ||
| 393 | + || !obj.getCondeferrable() || CommonConstants.F.equals(obj.getCondeferrable())) { | ||
| 394 | + statement.addBatch( | ||
| 395 | + String.format(SqlConstants.CONSTRAINT_PRIMARY_SQL, request.getSchema(), request.getTableName(), | ||
| 396 | + obj.getConname(), obj.getAttname())); | ||
| 397 | + } else { | ||
| 398 | + statement.addBatch(String.format(SqlConstants.CONSTRAINT_PRIMARY_IMMEDIATE_SQL, request.getSchema(), | ||
| 399 | + request.getTableName(), obj.getConname(), obj.getAttname())); | ||
| 400 | + } | ||
| 401 | + } else if ("c".equals(obj.getContype())) { | ||
| 402 | + if (org.apache.commons.lang3.StringUtils.isAnyEmpty(obj.getConstraintdef())) { | ||
| 403 | + throw new CustomException("Expression is empty"); | ||
| 404 | + } | ||
| 405 | + if (obj.getConstraintdef() != null && obj.getConstraintdef().toLowerCase().trim().startsWith("check")) { | ||
| 406 | + statement.addBatch( | ||
| 407 | + String.format(SqlConstants.CONSTRAINT_NO_CHECK_SQL, request.getSchema(), request.getTableName(), | ||
| 408 | + obj.getConname(), obj.getConstraintdef())); | ||
| 409 | + } else { | ||
| 410 | + statement.addBatch( | ||
| 411 | + String.format(SqlConstants.CONSTRAINT_CHECK_SQL, request.getSchema(), request.getTableName(), | ||
| 412 | + obj.getConname(), obj.getConstraintdef())); | ||
| 413 | + } | ||
| 414 | + } else if ("f".equals(obj.getContype())) { | ||
| 415 | + statement.addBatch( | ||
| 416 | + String.format(SqlConstants.CONSTRAINT_FOREIGN_KEY_SQL, request.getSchema(), request.getTableName() | ||
| 417 | + , obj.getConname(), obj.getAttname(), obj.getNspname(), obj.getTbname(), obj.getColname())); | ||
| 418 | + } else if ("s".equals(obj.getContype())) { | ||
| 419 | + statement.addBatch(String.format(SqlConstants.CONSTRAINT_PARTIAL_CLUSTER_KEY_SQL, request.getSchema(), | ||
| 420 | + request.getTableName(), obj.getConname(), obj.getAttname())); | ||
| 421 | + } | ||
| 422 | + if (!StringUtils.isEmpty(obj.getDescription())) { | ||
| 423 | + statement.addBatch(String.format(SqlConstants.CONSTRAINT_COMMENT_SQL, obj.getConname(), request.getSchema(), | ||
| 424 | + request.getTableName(), obj.getDescription())); | ||
| 425 | + } | ||
| 426 | + } | ||
| 427 | + | ||
| 428 | + private void updateConstraint(DatabaseConstraintDTO request, ConstraintDTO obj, | ||
| 429 | + Statement statement) throws Exception { | ||
| 430 | + statement.addBatch(String.format(SqlConstants.CONSTRAINT_DROP_SQL, request.getSchema(), request.getTableName(), | ||
| 431 | + obj.getOldConname())); | ||
| 432 | + this.addConstraint(request, obj, statement); | ||
| 433 | + } | ||
| 434 | + | ||
| 435 | + private void addIndex(DatabaseIndexDTO request, IndexDTO obj, Statement statement) throws Exception { | ||
| 436 | + statement.addBatch(this.addIndexSQL(request.getSchema(), request.getTableName(), obj)); | ||
| 437 | + if (!StringUtils.isEmpty(obj.getDescription())) { | ||
| 438 | + statement.addBatch(this.addIndexCommentSQL(request.getSchema(), obj)); | ||
| 439 | + } | ||
| 440 | + } | ||
| 441 | + | ||
| 442 | + private String addIndexSQL(String schema, String tableName, IndexDTO obj) throws Exception { | ||
| 443 | + String u = CommonConstants.SPACE; | ||
| 444 | + if (obj.getUnique() != null && obj.getUnique()) { | ||
| 445 | + u = " UNIQUE "; | ||
| 446 | + } | ||
| 447 | + String amname = CommonConstants.SPACE; | ||
| 448 | + if (!StringUtils.isEmpty(obj.getAmname())) { | ||
| 449 | + amname = " using " + obj.getAmname(); | ||
| 450 | + } | ||
| 451 | + String att = obj.getAttname(); | ||
| 452 | + if (StringUtils.isEmpty(att)) { | ||
| 453 | + att = obj.getExpression(); | ||
| 454 | + } | ||
| 455 | + return String.format(SqlConstants.INDEX_CREATE_SQL, u, obj.getIndexName(), schema, | ||
| 456 | + tableName, amname, att); | ||
| 457 | + } | ||
| 458 | + | ||
| 459 | + private String addIndexCommentSQL(String schema, IndexDTO obj) throws Exception { | ||
| 460 | + if (!StringUtils.isEmpty(obj.getDescription())) { | ||
| 461 | + return String.format(SqlConstants.INDEX_COMMENT_SQL, schema, obj.getIndexName(), obj.getDescription()); | ||
| 462 | + } | ||
| 463 | + return null; | ||
| 464 | + } | ||
| 465 | + | ||
| 466 | + private void updateIndex(DatabaseIndexDTO request, IndexDTO obj, Statement statement) throws Exception { | ||
| 467 | + statement.addBatch(String.format(SqlConstants.INDEX_DROP_SQL, request.getSchema(), obj.getOldIndexName())); | ||
| 468 | + this.addIndex(request, obj, statement); | ||
| 469 | + } | ||
| 470 | + | ||
| 471 | + private String getConname(String sql, String uuid) throws Exception { | ||
| 472 | + try ( | ||
| 473 | + Connection connection = connectionConfig.connectDatabase(uuid); | ||
| 474 | + Statement statement = connection.createStatement(); | ||
| 475 | + ResultSet resultSet = statement.executeQuery(sql) | ||
| 476 | + ) { | ||
| 477 | + String conname = null; | ||
| 478 | + while (resultSet.next()) { | ||
| 479 | + conname = resultSet.getString("conname"); | ||
| 480 | + } | ||
| 481 | + return conname; | ||
| 482 | + } | ||
| 483 | + } | ||
| 484 | + | ||
| 485 | + public String createTable(DatabaseCreateTableDTO request) throws Exception { | ||
| 486 | + log.info("createTable response is: {}", request); | ||
| 487 | + TableUnderlyingInfoQuery tableUnderlyingInfoQuery = request.getTableInfo(); | ||
| 488 | + String ddl = null; | ||
| 489 | + if (tableUnderlyingInfoQuery.getExists() && tableUnderlyingInfoQuery.getTableType().equals("UNLOGGED")) { | ||
| 490 | + ddl = String.format(CREATE_UNLOGGED_TABLE_EXISTS_SQL, request.getSchema(), | ||
| 491 | + tableUnderlyingInfoQuery.getTableName()); | ||
| 492 | + } else if (tableUnderlyingInfoQuery.getExists()) { | ||
| 493 | + ddl = String.format(CREATE_TABLE_EXISTS_SQL, request.getSchema(), tableUnderlyingInfoQuery.getTableName()); | ||
| 494 | + } else if (tableUnderlyingInfoQuery.getTableType().equals("UNLOGGED")) { | ||
| 495 | + ddl = String.format(CREATE_UNLOGGED_TABLE_SQL, request.getSchema(), | ||
| 496 | + tableUnderlyingInfoQuery.getTableName()); | ||
| 497 | + } else { | ||
| 498 | + ddl = String.format(CREATE_TABLE_SQL, request.getSchema(), tableUnderlyingInfoQuery.getTableName()); | ||
| 499 | + } | ||
| 500 | + log.info("createTableFormat response is: " + ddl); | ||
| 501 | + StringBuilder cteate = new StringBuilder(ddl); | ||
| 502 | + StringBuilder olumnComment = new StringBuilder(); | ||
| 503 | + for (int i = 0; i < request.getColumn().size(); i++) { | ||
| 504 | + DatabaseCreUpdColumnDTO.CreUpdColumnDataDTO col = request.getColumn().get(i); | ||
| 505 | + String columnSql = columnAddSQL(col); | ||
| 506 | + cteate.append(col.getNewColumnName()).append(SPACE).append(columnSql); | ||
| 507 | + log.info("cteate response is: {}", cteate); | ||
| 508 | + if (i < request.getColumn().size() - 1) { | ||
| 509 | + cteate.append(QUOTES_LF_COMMA); | ||
| 510 | + } else { | ||
| 511 | + cteate.append(LF); | ||
| 512 | + } | ||
| 513 | + olumnComment.append(commentAddSQL(col, request.getSchema(), tableUnderlyingInfoQuery.getTableName())); | ||
| 514 | + } | ||
| 515 | + StringBuilder constraintsComment = new StringBuilder(); | ||
| 516 | + for (int i = 0; i < request.getConstraints().size(); i++) { | ||
| 517 | + ConstraintDTO constraintDTO = request.getConstraints().get(i); | ||
| 518 | + String constraintsSql = getConstraintSQL(constraintDTO); | ||
| 519 | + cteate.append(constraintsSql); | ||
| 520 | + if (i < request.getConstraints().size() - 1) { | ||
| 521 | + cteate.append(QUOTES_LF_COMMA); | ||
| 522 | + } else { | ||
| 523 | + cteate.append(LF); | ||
| 524 | + } | ||
| 525 | + if (StringUtils.isEmpty(constraintDTO.getConname())) { | ||
| 526 | + constraintsComment.append( | ||
| 527 | + String.format(CONSTRAINT_COMMENT_SQL, constraintDTO.getConname(), request.getSchema(), | ||
| 528 | + tableUnderlyingInfoQuery.getTableName(), constraintDTO.getDescription())).append(LF); | ||
| 529 | + } | ||
| 530 | + } | ||
| 531 | + cteate.append(RIGHT_BRACKET); | ||
| 532 | + if (tableUnderlyingInfoQuery.getStorage().equals("COLUMN")) { | ||
| 533 | + cteate.append(COLUMN_SQL); | ||
| 534 | + } else if (tableUnderlyingInfoQuery.getOids() && tableUnderlyingInfoQuery.getFillingFactor() != 100) { | ||
| 535 | + cteate.append(String.format(WITH_DOUBLE_SQL, FILLFACTOR_SQL, tableUnderlyingInfoQuery.getFillingFactor(), | ||
| 536 | + OIDS_SQL)); | ||
| 537 | + } else if (tableUnderlyingInfoQuery.getOids()) { | ||
| 538 | + cteate.append(String.format(WITH_SQL, OIDS_SQL)); | ||
| 539 | + } else if (tableUnderlyingInfoQuery.getFillingFactor() != 100) { | ||
| 540 | + cteate.append(String.format(WITH_SQL, FILLFACTOR_SQL, tableUnderlyingInfoQuery.getFillingFactor())); | ||
| 541 | + } | ||
| 542 | + cteate.append(String.format(TABLESPACE_SQL, tableUnderlyingInfoQuery.getTableSpace())).append(SEMICOLON).append( | ||
| 543 | + getPartitionSQL(request.getPartitionInfo())).append(LF); | ||
| 544 | + StringBuilder indexComment = new StringBuilder(); | ||
| 545 | + for (var index : request.getIndexs()) { | ||
| 546 | + String indexSql = addIndexSQL(request.getSchema(), tableUnderlyingInfoQuery.getTableName(), index); | ||
| 547 | + cteate.append(indexSql).append(LF); | ||
| 548 | + indexComment.append(addIndexCommentSQL(request.getSchema(), index)).append(LF); | ||
| 549 | + } | ||
| 550 | + | ||
| 551 | + if (StringUtils.isEmpty(tableUnderlyingInfoQuery.getComment()) && !tableUnderlyingInfoQuery.getComment().equals( | ||
| 552 | + "")) { | ||
| 553 | + cteate.append(String.format(COMMENT_TABLE_SQL, request.getSchema(), tableUnderlyingInfoQuery.getTableName(), | ||
| 554 | + tableUnderlyingInfoQuery.getComment())); | ||
| 555 | + } | ||
| 556 | + cteate.append(indexComment).append(olumnComment).append(constraintsComment); | ||
| 557 | + log.info("createTable response is: " + cteate); | ||
| 558 | + return cteate.toString(); | ||
| 559 | + } | ||
| 560 | + | ||
| 561 | + private String getPartitionSQL(TablePartitionInfoQuery request) { | ||
| 562 | + if (request != null && StringUtils.isNotEmpty( | ||
| 563 | + request.getPaprtitionName()) && !request.getPaprtitionName().equals("")) { | ||
| 564 | + StringBuilder partition = new StringBuilder().append(PARTITION_BY_SQL); | ||
| 565 | + if (request.getType().equals("range")) { | ||
| 566 | + partition.append(String.format(RANGE_SQL, request.getPaprtitionColumn(), request.getPaprtitionName(), | ||
| 567 | + request.getPaprtitionValue(), request.getTableSpace())); | ||
| 568 | + } else if (request.getType().equals("interval")) { | ||
| 569 | + partition.append(String.format(INTERVAL_SQL, request.getPaprtitionColumn(), request.getValueInterval(), | ||
| 570 | + request.getPaprtitionName(), request.getPaprtitionValue(), request.getTableSpace())); | ||
| 571 | + } else if (request.getType().equals("list")) { | ||
| 572 | + partition.append(String.format(LIST_SQL, request.getPaprtitionColumn(), request.getPaprtitionName(), | ||
| 573 | + request.getPaprtitionValue(), request.getTableSpace())); | ||
| 574 | + } else if (request.getType().equals("hash")) { | ||
| 575 | + partition.append(String.format(HASH_SQL, request.getPaprtitionColumn(), request.getPaprtitionName(), | ||
| 576 | + request.getTableSpace())); | ||
| 577 | + } | ||
| 578 | + partition.append(SEMICOLON); | ||
| 579 | + return partition.toString(); | ||
| 580 | + } | ||
| 581 | + return ""; | ||
| 582 | + } | ||
| 583 | + | ||
| 584 | + private String getConstraintSQL(ConstraintDTO request) { | ||
| 585 | + StringBuilder partition = new StringBuilder(); | ||
| 586 | + if (StringUtils.isNotEmpty(request.getContype())) { | ||
| 587 | + if (request.getContype().equals("UNIQUE")) { | ||
| 588 | + if (request.getCondeferrable()) { | ||
| 589 | + partition.append(String.format(UNIQUE_IMMEDIATE_SQL, request.getConname(), request.getAttname())); | ||
| 590 | + } else { | ||
| 591 | + partition.append(String.format(UNIQUE_SQL, request.getConname(), request.getAttname())); | ||
| 592 | + } | ||
| 593 | + } else if (request.getContype().equals("PRIMARY KEY")) { | ||
| 594 | + partition.append(String.format(PRIMARY_KEY_SQL, request.getConname(), request.getAttname())); | ||
| 595 | + } else if (request.getContype().equals("CHECK")) { | ||
| 596 | + partition.append(String.format(CHECK_SQL, request.getConname(), request.getAttname())); | ||
| 597 | + } else if (request.getContype().equals("FOREIGN KEY")) { | ||
| 598 | + partition.append( | ||
| 599 | + String.format(FOREIGN_KEY_SQL, request.getConname(), request.getAttname(), request.getNspname(), | ||
| 600 | + request.getTbname(), request.getColname())); | ||
| 601 | + } else if (request.getContype().equals("PARTIAL CLUSTER KEY")) { | ||
| 602 | + partition.append(String.format(PARTIAL_CLUSTER_KEY_SQL, request.getConname(), request.getAttname())); | ||
| 603 | + } | ||
| 604 | + return partition.toString(); | ||
| 605 | + } | ||
| 606 | + return ""; | ||
| 607 | + } | ||
| 608 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/opengauss/TableObjectSQLServiceImpl.java+205-0
| @@ -0,0 +1,205 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible.opengauss; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.compatible.TableObjectSQLService; | ||
| 8 | +import com.nctigba.datastudio.config.ConnectionConfig; | ||
| 9 | +import com.nctigba.datastudio.model.query.SelectDataQuery; | ||
| 10 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 11 | +import lombok.extern.slf4j.Slf4j; | ||
| 12 | +import org.apache.commons.lang3.StringUtils; | ||
| 13 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 15 | +import org.springframework.stereotype.Service; | ||
| 16 | + | ||
| 17 | +import java.sql.Connection; | ||
| 18 | +import java.sql.ResultSet; | ||
| 19 | +import java.sql.SQLException; | ||
| 20 | +import java.sql.Statement; | ||
| 21 | +import java.util.ArrayList; | ||
| 22 | +import java.util.HashMap; | ||
| 23 | +import java.util.List; | ||
| 24 | +import java.util.Map; | ||
| 25 | + | ||
| 26 | +import static com.nctigba.datastudio.constants.CommonConstants.OPENGAUSS; | ||
| 27 | +import static com.nctigba.datastudio.constants.CommonConstants.PG_GET_TABLEDEF; | ||
| 28 | +import static com.nctigba.datastudio.constants.CommonConstants.RESULT; | ||
| 29 | +import static com.nctigba.datastudio.constants.SqlConstants.COMMENT_TABLE_SQL; | ||
| 30 | +import static com.nctigba.datastudio.constants.SqlConstants.DROP_TABLE_SQL; | ||
| 31 | +import static com.nctigba.datastudio.constants.SqlConstants.POINT; | ||
| 32 | +import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_PARENTHESES_SEMICOLON; | ||
| 33 | +import static com.nctigba.datastudio.constants.SqlConstants.REINDEX_TABLE_SQL; | ||
| 34 | +import static com.nctigba.datastudio.constants.SqlConstants.RENAME_TABLE_SQL; | ||
| 35 | +import static com.nctigba.datastudio.constants.SqlConstants.SCHEMA_TABLE_SQL; | ||
| 36 | +import static com.nctigba.datastudio.constants.SqlConstants.SEMICOLON; | ||
| 37 | +import static com.nctigba.datastudio.constants.SqlConstants.TABLESPACE_TABLE_SQL; | ||
| 38 | +import static com.nctigba.datastudio.constants.SqlConstants.TABLE_ANALYSE_SQL; | ||
| 39 | +import static com.nctigba.datastudio.constants.SqlConstants.TABLE_ATTRIBUTE_SQL; | ||
| 40 | +import static com.nctigba.datastudio.constants.SqlConstants.TABLE_DATA_COUNT_SQL; | ||
| 41 | +import static com.nctigba.datastudio.constants.SqlConstants.TABLE_DATA_SQL; | ||
| 42 | +import static com.nctigba.datastudio.constants.SqlConstants.TABLE_DEF_SQL; | ||
| 43 | +import static com.nctigba.datastudio.constants.SqlConstants.TABLE_PARTITIONG_ATTRIBUTE_SQL; | ||
| 44 | +import static com.nctigba.datastudio.constants.SqlConstants.TABLE_SEQUENCE_SQL; | ||
| 45 | +import static com.nctigba.datastudio.constants.SqlConstants.TABLE_TRUNCATE_SQL; | ||
| 46 | +import static com.nctigba.datastudio.constants.SqlConstants.VACUUM_SQL; | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + | ||
| 50 | +public class TableObjectSQLServiceImpl implements TableObjectSQLService { | ||
| 51 | + | ||
| 52 | + private ConnectionConfig connectionConfig; | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + public String type() { | ||
| 56 | + return OPENGAUSS; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + public String tableDataSQL(String schema, String tableName) { | ||
| 61 | + StringBuilder ddl = new StringBuilder(TABLE_DATA_SQL).append(schema).append(POINT) | ||
| 62 | + .append(tableName).append(SEMICOLON); | ||
| 63 | + log.info("tableDataSQL response is: " + ddl); | ||
| 64 | + return ddl.toString(); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + | ||
| 68 | + public String tableDataCountSQL(String schema, String tableName) { | ||
| 69 | + String ddl = String.format(TABLE_DATA_COUNT_SQL, schema, tableName); | ||
| 70 | + log.info("tableDataCountSQL response is: " + ddl); | ||
| 71 | + return ddl; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + | ||
| 75 | + public String tableAnalyseSQL(String schema, String tableName) { | ||
| 76 | + String ddl = String.format(TABLE_ANALYSE_SQL, schema, tableName); | ||
| 77 | + log.info("tableAnalyseSQL response is: " + ddl); | ||
| 78 | + return ddl; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + | ||
| 82 | + public Map<String, String> tableDdl(SelectDataQuery request) throws Exception { | ||
| 83 | + log.info("tableDdl request is: " + request); | ||
| 84 | + Map<String, String> resultMap = new HashMap<>(); | ||
| 85 | + try ( | ||
| 86 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 87 | + Statement statement = connection.createStatement() | ||
| 88 | + ) { | ||
| 89 | + String sql = TABLE_DEF_SQL + request.getSchema() | ||
| 90 | + + POINT + request.getTableName() + QUOTES_PARENTHESES_SEMICOLON; | ||
| 91 | + try ( | ||
| 92 | + ResultSet resultSet = statement.executeQuery(sql) | ||
| 93 | + ) { | ||
| 94 | + resultSet.next(); | ||
| 95 | + if (StringUtils.isBlank(String.valueOf(resultSet.getString("pg_get_tabledef")))) { | ||
| 96 | + throw new CustomException(LocaleString.transLanguage("2010")); | ||
| 97 | + } | ||
| 98 | + resultMap.put(RESULT, resultSet.getString(PG_GET_TABLEDEF)); | ||
| 99 | + } | ||
| 100 | + log.info("tableDdl map is: " + resultMap); | ||
| 101 | + return resultMap; | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + | ||
| 106 | + public String tableTruncateSQL(String schema, String tableName) { | ||
| 107 | + String ddl = String.format(TABLE_TRUNCATE_SQL, schema, tableName); | ||
| 108 | + log.info("tableAnalyseSQL response is: " + ddl); | ||
| 109 | + return ddl; | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + | ||
| 113 | + public String tableVacuumSQL(String schema, String tableName) { | ||
| 114 | + String ddl = String.format(VACUUM_SQL, schema, tableName); | ||
| 115 | + log.info("tableAnalyseSQL response is: " + ddl); | ||
| 116 | + return ddl; | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + | ||
| 120 | + public String tableReindexSQL(String schema, String tableName) { | ||
| 121 | + String ddl = String.format(REINDEX_TABLE_SQL, schema, tableName); | ||
| 122 | + log.info("tableAnalyseSQL response is: " + ddl); | ||
| 123 | + return ddl; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + | ||
| 127 | + public String tableRenameSQL(String schema, String tableName, String newName) { | ||
| 128 | + String ddl = String.format(RENAME_TABLE_SQL, schema, tableName, newName); | ||
| 129 | + log.info("tableAnalyseSQL response is: " + ddl); | ||
| 130 | + return ddl; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + | ||
| 134 | + public String tableCommentSQL(String schema, String tableName, String comment) { | ||
| 135 | + String ddl = String.format(COMMENT_TABLE_SQL, schema, tableName, comment); | ||
| 136 | + log.info("tableAnalyseSQL response is: " + ddl); | ||
| 137 | + return ddl; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + | ||
| 141 | + public String tableAlterSchemaSQL(String schema, String tableName, String newSchema) { | ||
| 142 | + String ddl = String.format(SCHEMA_TABLE_SQL, schema, tableName, newSchema); | ||
| 143 | + log.info("tableAnalyseSQL response is: " + ddl); | ||
| 144 | + return ddl; | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + | ||
| 148 | + public String tableDropSQL(String schema, String tableName) { | ||
| 149 | + String ddl = String.format(DROP_TABLE_SQL, schema, tableName); | ||
| 150 | + log.info("tableAnalyseSQL response is: " + ddl); | ||
| 151 | + return ddl; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + | ||
| 155 | + public String tableAlterTablespaceSQL(String schema, String tableName, String tablespace) { | ||
| 156 | + String ddl = String.format(TABLESPACE_TABLE_SQL, schema, tableName, tablespace); | ||
| 157 | + log.info("tableAnalyseSQL response is: " + ddl); | ||
| 158 | + return ddl; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + | ||
| 162 | + public String tableSequenceSQL(String schema, String tableName) { | ||
| 163 | + String ddl = String.format(TABLE_SEQUENCE_SQL, schema, tableName); | ||
| 164 | + log.info("tableAnalyseSQL response is: " + ddl); | ||
| 165 | + return ddl; | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + | ||
| 169 | + public List<Map<String, Object>> tableAttributeSQL(String uuid, String oid, String tableType) throws Exception { | ||
| 170 | + String ddl = null; | ||
| 171 | + if (tableType.equals("n")) { | ||
| 172 | + ddl = String.format(TABLE_ATTRIBUTE_SQL, oid); | ||
| 173 | + } else { | ||
| 174 | + ddl = String.format(TABLE_PARTITIONG_ATTRIBUTE_SQL, oid); | ||
| 175 | + } | ||
| 176 | + log.info("tableAttributeSQL response is: " + ddl); | ||
| 177 | + try ( | ||
| 178 | + Connection connection = connectionConfig.connectDatabase(uuid); | ||
| 179 | + Statement statement = connection.createStatement() | ||
| 180 | + ) { | ||
| 181 | + try (ResultSet resultSet = statement.executeQuery(ddl)) { | ||
| 182 | + List list; | ||
| 183 | + if (tableType.equals("y")) { | ||
| 184 | + list = tableAttributeResultSet(resultSet, 15); | ||
| 185 | + } else { | ||
| 186 | + list = tableAttributeResultSet(resultSet, 14); | ||
| 187 | + } | ||
| 188 | + log.info("tableColumn list is: " + list); | ||
| 189 | + return list; | ||
| 190 | + } | ||
| 191 | + } | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + public static List<Map<String, Object>> tableAttributeResultSet(ResultSet resultSet, int num) throws SQLException { | ||
| 195 | + List list = new ArrayList<>(); | ||
| 196 | + resultSet.next(); | ||
| 197 | + for (int i = 1; i <= num; i++) { | ||
| 198 | + Map<String, Object> map = new HashMap<>(); | ||
| 199 | + map.put(LocaleString.transLanguage(String.valueOf(i)), resultSet.getObject(i)); | ||
| 200 | + list.add(map); | ||
| 201 | + } | ||
| 202 | + log.info("tableAttributeResultSet List {}", list); | ||
| 203 | + return list; | ||
| 204 | + } | ||
| 205 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/compatible/opengauss/ViewObjectSQLServiceImpl.java+187-0
| @@ -0,0 +1,187 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.compatible.opengauss; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.compatible.ViewObjectSQLService; | ||
| 8 | +import com.nctigba.datastudio.config.ConnectionConfig; | ||
| 9 | +import com.nctigba.datastudio.model.dto.DatabaseCreateViewDTO; | ||
| 10 | +import com.nctigba.datastudio.model.dto.DatabaseSelectViewDTO; | ||
| 11 | +import com.nctigba.datastudio.model.dto.DatabaseViewDdlDTO; | ||
| 12 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 13 | +import lombok.extern.slf4j.Slf4j; | ||
| 14 | +import org.apache.commons.lang3.StringUtils; | ||
| 15 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 16 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 17 | +import org.springframework.stereotype.Service; | ||
| 18 | + | ||
| 19 | +import java.sql.Connection; | ||
| 20 | +import java.sql.ResultSet; | ||
| 21 | +import java.sql.ResultSetMetaData; | ||
| 22 | +import java.sql.Statement; | ||
| 23 | +import java.util.HashMap; | ||
| 24 | +import java.util.Map; | ||
| 25 | + | ||
| 26 | +import static com.nctigba.datastudio.constants.CommonConstants.OPENGAUSS; | ||
| 27 | +import static com.nctigba.datastudio.constants.SqlConstants.COMMON_VIEW_SQL; | ||
| 28 | +import static com.nctigba.datastudio.constants.SqlConstants.CONNECTIVES_SQL; | ||
| 29 | +import static com.nctigba.datastudio.constants.SqlConstants.CREATE_SQL; | ||
| 30 | +import static com.nctigba.datastudio.constants.SqlConstants.DROP_SQL; | ||
| 31 | +import static com.nctigba.datastudio.constants.SqlConstants.IF_EXISTS_SQL; | ||
| 32 | +import static com.nctigba.datastudio.constants.SqlConstants.LF; | ||
| 33 | +import static com.nctigba.datastudio.constants.SqlConstants.LIMIT_SQL; | ||
| 34 | +import static com.nctigba.datastudio.constants.SqlConstants.MATERIALIZED_VIEW_SQL; | ||
| 35 | +import static com.nctigba.datastudio.constants.SqlConstants.POINT; | ||
| 36 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_VIEWNAME_DDL_WHERE_SQL; | ||
| 37 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_VIEW_DDL_SQL; | ||
| 38 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_VIEW_DDL_WHERE_SQL; | ||
| 39 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_VIEW_TYPE_SQL; | ||
| 40 | +import static com.nctigba.datastudio.constants.SqlConstants.TABLE_DATA_SQL; | ||
| 41 | +import static com.nctigba.datastudio.constants.SqlConstants.VIEW_KEYWORD_SQL; | ||
| 42 | + | ||
| 43 | + | ||
| 44 | + | ||
| 45 | +public class ViewObjectSQLServiceImpl implements ViewObjectSQLService { | ||
| 46 | + | ||
| 47 | + private ConnectionConfig connectionConfig; | ||
| 48 | + | ||
| 49 | + | ||
| 50 | + public String type() { | ||
| 51 | + return OPENGAUSS; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + public String splicingViewDDL(DatabaseCreateViewDTO request) throws Exception { | ||
| 56 | + log.info("splicingViewDDL request is: " + request); | ||
| 57 | + String viewType; | ||
| 58 | + if (request.getViewType().equals("MATERIALIZED")) { | ||
| 59 | + viewType = MATERIALIZED_VIEW_SQL; | ||
| 60 | + } else { | ||
| 61 | + viewType = COMMON_VIEW_SQL; | ||
| 62 | + } | ||
| 63 | + String ddl = | ||
| 64 | + CREATE_SQL + viewType + VIEW_KEYWORD_SQL + request.getSchema() + POINT + request.getViewName() + LF + CONNECTIVES_SQL + LF + request.getSql(); | ||
| 65 | + log.info("splicingViewDDL response is: " + ddl); | ||
| 66 | + return ddl; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public Map<String, Object> returnViewDDLData(DatabaseViewDdlDTO request) throws Exception { | ||
| 70 | + log.info("returnViewDDLData request is: " + request); | ||
| 71 | + try ( | ||
| 72 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 73 | + Statement statement = connection.createStatement() | ||
| 74 | + ) { | ||
| 75 | + String selectSql = SELECT_VIEW_DDL_SQL + request.getSchema() + SELECT_VIEWNAME_DDL_WHERE_SQL + request.getViewName() + SELECT_VIEW_DDL_WHERE_SQL; | ||
| 76 | + try ( | ||
| 77 | + ResultSet count = statement.executeQuery(selectSql) | ||
| 78 | + ) { | ||
| 79 | + count.next(); | ||
| 80 | + if (StringUtils.isBlank(String.valueOf(count.getString("relkind")))) { | ||
| 81 | + throw new CustomException(LocaleString.transLanguage("2010")); | ||
| 82 | + } | ||
| 83 | + } catch (Exception e) { | ||
| 84 | + log.info(e.getMessage()); | ||
| 85 | + throw new CustomException(e.getMessage(), e); | ||
| 86 | + } | ||
| 87 | + try ( | ||
| 88 | + ResultSet resultSet = statement.executeQuery(selectSql) | ||
| 89 | + ) { | ||
| 90 | + log.info("returnViewDDLData sql is: " + selectSql); | ||
| 91 | + log.info("returnViewDDLData response is: " + resultSet); | ||
| 92 | + Map<String, Object> resultMap = new HashMap<>(); | ||
| 93 | + ResultSetMetaData metaData = resultSet.getMetaData(); | ||
| 94 | + String column; | ||
| 95 | + while (resultSet.next()) { | ||
| 96 | + for (int i = 0; i < metaData.getColumnCount(); i++) { | ||
| 97 | + column = metaData.getColumnName(i + 1); | ||
| 98 | + resultMap.put(column, resultSet.getString(column)); | ||
| 99 | + } | ||
| 100 | + } | ||
| 101 | + return resultMap; | ||
| 102 | + } catch (Exception e) { | ||
| 103 | + log.info(e.getMessage()); | ||
| 104 | + throw new CustomException(e.getMessage(), e); | ||
| 105 | + } | ||
| 106 | + } catch (Exception e) { | ||
| 107 | + log.info(e.getMessage()); | ||
| 108 | + throw new CustomException(e.getMessage(), e); | ||
| 109 | + } | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + | ||
| 113 | + public String returnDatabaseViewDDL(DatabaseViewDdlDTO request) throws Exception { | ||
| 114 | + log.info("returnViewDDL request is: " + request); | ||
| 115 | + try { | ||
| 116 | + Map<String, Object> resultMap = returnViewDDLData(request); | ||
| 117 | + String viewType; | ||
| 118 | + String ddl = null; | ||
| 119 | + if (resultMap.get("relkind").equals("m")) { | ||
| 120 | + viewType = MATERIALIZED_VIEW_SQL; | ||
| 121 | + } else { | ||
| 122 | + viewType = COMMON_VIEW_SQL; | ||
| 123 | + } | ||
| 124 | + ddl = CREATE_SQL + viewType + VIEW_KEYWORD_SQL + resultMap.get("schemaname") + POINT + resultMap.get( | ||
| 125 | + "matviewname") + LF + CONNECTIVES_SQL + LF + resultMap.get("definition"); | ||
| 126 | + | ||
| 127 | + log.info("returnViewDDL response is: " + ddl); | ||
| 128 | + return ddl; | ||
| 129 | + } catch (Exception e) { | ||
| 130 | + log.info(e.getMessage()); | ||
| 131 | + throw new CustomException(e.getMessage(), e); | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + public String viewTypeData(DatabaseViewDdlDTO request) throws Exception { | ||
| 136 | + log.info("viewAttributeData request is: " + request); | ||
| 137 | + try ( | ||
| 138 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 139 | + Statement statement = connection.createStatement() | ||
| 140 | + ) { | ||
| 141 | + String selectsql = SELECT_VIEW_TYPE_SQL + request.getSchema() + SELECT_VIEWNAME_DDL_WHERE_SQL + request.getViewName() + SELECT_VIEW_DDL_WHERE_SQL; | ||
| 142 | + try ( | ||
| 143 | + ResultSet resultSet = statement.executeQuery(selectsql) | ||
| 144 | + ) { | ||
| 145 | + log.info("count sql is: " + resultSet); | ||
| 146 | + log.info("viewAttributeData sql is: " + selectsql); | ||
| 147 | + String type; | ||
| 148 | + if (resultSet.next()) { | ||
| 149 | + type = resultSet.getString("relkind"); | ||
| 150 | + } else { | ||
| 151 | + throw new CustomException(LocaleString.transLanguage("2010")); | ||
| 152 | + } | ||
| 153 | + log.info("resultMap response is: " + type); | ||
| 154 | + return type; | ||
| 155 | + } catch (Exception e) { | ||
| 156 | + log.info(e.getMessage()); | ||
| 157 | + throw new CustomException(e.getMessage(), e); | ||
| 158 | + } | ||
| 159 | + } catch (Exception e) { | ||
| 160 | + log.info(e.getMessage()); | ||
| 161 | + throw new CustomException(e.getMessage(), e); | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + | ||
| 166 | + public String returnDropViewSQL(DatabaseViewDdlDTO request) throws Exception { | ||
| 167 | + log.info("dropView request is: " + request); | ||
| 168 | + String type = viewTypeData(request); | ||
| 169 | + if (type.equals("m")) { | ||
| 170 | + String materializedSql = DROP_SQL + MATERIALIZED_VIEW_SQL + VIEW_KEYWORD_SQL + IF_EXISTS_SQL + request.getSchema() + POINT + request.getViewName(); | ||
| 171 | + log.info("dropView sql is: " + materializedSql); | ||
| 172 | + return materializedSql; | ||
| 173 | + } else { | ||
| 174 | + String sql = DROP_SQL + VIEW_KEYWORD_SQL + request.getSchema() + POINT + request.getViewName(); | ||
| 175 | + log.info("dropView sql is: " + sql); | ||
| 176 | + return sql; | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + | ||
| 181 | + public String returnSelectViewSQL(DatabaseSelectViewDTO request) { | ||
| 182 | + log.info("selectView request is: " + request); | ||
| 183 | + String ddl = TABLE_DATA_SQL + request.getSchema() + POINT + request.getViewName() + LIMIT_SQL; | ||
| 184 | + log.info("selectViewddl is: " + ddl); | ||
| 185 | + return ddl; | ||
| 186 | + } | ||
| 187 | +} | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.config; | 5 | package com.nctigba.datastudio.config; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.dao.ConnectionMapDAO; | 7 | import com.nctigba.datastudio.dao.ConnectionMapDAO; |
| @@ -19,7 +23,7 @@ public class ConnectionConfig { | |||
| 19 | private DbConnectionServiceImpl dbConnectionServiceImpl; | 23 | private DbConnectionServiceImpl dbConnectionServiceImpl; |
| 20 | 24 | ||
| 21 | public Connection connectDatabase(String uuid) throws Exception { | 25 | public Connection connectDatabase(String uuid) throws Exception { |
| 22 | - if(!conMap.containsKey(uuid)){ | 26 | + if (!conMap.containsKey(uuid)) { |
| 23 | throw new CustomException(LocaleString.transLanguage("1004")); | 27 | throw new CustomException(LocaleString.transLanguage("1004")); |
| 24 | } | 28 | } |
| 25 | ConnectionDTO connectionDTO = conMap.get(uuid); | 29 | ConnectionDTO connectionDTO = conMap.get(uuid); |
| @@ -33,7 +37,7 @@ public class ConnectionConfig { | |||
| 33 | } | 37 | } |
| 34 | 38 | ||
| 35 | public Connection connectDatabaseMap(String uuid, String winName) throws Exception { | 39 | public Connection connectDatabaseMap(String uuid, String winName) throws Exception { |
| 36 | - if(!conMap.containsKey(uuid)){ | 40 | + if (!conMap.containsKey(uuid)) { |
| 37 | throw new CustomException(LocaleString.transLanguage("1004")); | 41 | throw new CustomException(LocaleString.transLanguage("1004")); |
| 38 | } | 42 | } |
| 39 | ConnectionDTO connectionDTO = conMap.get(uuid); | 43 | ConnectionDTO connectionDTO = conMap.get(uuid); |
| @@ -0,0 +1,49 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.config; | ||
| 6 | + | ||
| 7 | +import com.fasterxml.jackson.core.JsonGenerator; | ||
| 8 | +import com.fasterxml.jackson.databind.JsonSerializer; | ||
| 9 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 10 | +import com.fasterxml.jackson.databind.SerializerProvider; | ||
| 11 | +import com.fasterxml.jackson.databind.module.SimpleModule; | ||
| 12 | +import org.opengauss.jdbc.PgArray; | ||
| 13 | +import org.opengauss.util.PGobject; | ||
| 14 | +import org.springframework.context.annotation.Bean; | ||
| 15 | +import org.springframework.context.annotation.Configuration; | ||
| 16 | + | ||
| 17 | +import java.io.IOException; | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +public class FastjsonConfig { | ||
| 21 | + | ||
| 22 | + public ObjectMapper fastJsonHttpMessageConverters() { | ||
| 23 | + var objectMapper = new ObjectMapper(); | ||
| 24 | + var module = new SimpleModule(); | ||
| 25 | + module.addSerializer(PgArray.class, new JsonSerializer<PgArray>() { | ||
| 26 | + | ||
| 27 | + public void serialize(PgArray value, JsonGenerator gen, SerializerProvider serializers) throws IOException { | ||
| 28 | + if (value == null) { | ||
| 29 | + gen.writeString((String) null); | ||
| 30 | + return; | ||
| 31 | + } | ||
| 32 | + gen.writeString(value.toString()); | ||
| 33 | + } | ||
| 34 | + }); | ||
| 35 | + module.addSerializer(PGobject.class, new JsonSerializer<PGobject>() { | ||
| 36 | + | ||
| 37 | + public void serialize(PGobject value, JsonGenerator gen, | ||
| 38 | + SerializerProvider serializers) throws IOException { | ||
| 39 | + if (value == null) { | ||
| 40 | + gen.writeString((String) null); | ||
| 41 | + return; | ||
| 42 | + } | ||
| 43 | + gen.writeString(value.toString()); | ||
| 44 | + } | ||
| 45 | + }); | ||
| 46 | + objectMapper.registerModule(module); | ||
| 47 | + return objectMapper; | ||
| 48 | + } | ||
| 49 | +} | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.config; | 5 | package com.nctigba.datastudio.config; |
| 2 | 6 | ||
| 3 | import com.gitee.starblues.core.PluginExtensionInfo; | 7 | import com.gitee.starblues.core.PluginExtensionInfo; |
| @@ -12,7 +16,8 @@ public class PluginExtensionInfoConfig implements PluginExtensionInfo { | |||
| 12 | 16 | ||
| 13 | public Map<String, Object> extensionInfo() { | 17 | public Map<String, Object> extensionInfo() { |
| 14 | Map<String, Object> map = new HashMap<>(); | 18 | Map<String, Object> map = new HashMap<>(); |
| 15 | - map.put("logo", "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItc2VhcmNoIj48Y2lyY2xlIGN4PSIxMSIgY3k9IjExIiByPSI4Ij48L2NpcmNsZT48bGluZSB4MT0iMjEiIHkxPSIyMSIgeDI9IjE2LjY1IiB5Mj0iMTYuNjUiPjwvbGluZT48L3N2Zz4="); | 19 | + map.put("logo", |
| 20 | + "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItc2VhcmNoIj48Y2lyY2xlIGN4PSIxMSIgY3k9IjExIiByPSI4Ij48L2NpcmNsZT48bGluZSB4MT0iMjEiIHkxPSIyMSIgeDI9IjE2LjY1IiB5Mj0iMTYuNjUiPjwvbGluZT48L3N2Zz4="); | ||
| 16 | map.put("theme", "white"); | 21 | map.put("theme", "white"); |
| 17 | map.put("pluginType", 1); | 22 | map.put("pluginType", 1); |
| 18 | map.put("isNeedConfigured", 0); | 23 | map.put("isNeedConfigured", 0); |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.config; | 5 | package com.nctigba.datastudio.config; |
| 2 | 6 | ||
| 3 | import org.springframework.context.annotation.Bean; | 7 | import org.springframework.context.annotation.Bean; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.constants; | 5 | package com.nctigba.datastudio.constants; |
| 2 | 6 | ||
| 3 | public class CommonConstants { | 7 | public class CommonConstants { |
| @@ -7,12 +11,20 @@ public class CommonConstants { | |||
| 7 | 11 | ||
| 8 | public static final String SPACE = " "; | 12 | public static final String SPACE = " "; |
| 9 | 13 | ||
| 10 | - public static final String LINE_FEED = "\n"; | ||
| 11 | - | ||
| 12 | public static final String UNDERLINE = "_"; | 14 | public static final String UNDERLINE = "_"; |
| 13 | 15 | ||
| 16 | + public static final String N_SLASH = System.getProperty("line.separator"); | ||
| 17 | + | ||
| 14 | public static final String SUCCESS = "success"; | 18 | public static final String SUCCESS = "success"; |
| 15 | 19 | ||
| 20 | + public static final String FUNCTION_DOLLAR = "$function$"; | ||
| 21 | + | ||
| 22 | + public static final String DOLLAR = "$$"; | ||
| 23 | + | ||
| 24 | + public static final String SLASH = "/"; | ||
| 25 | + | ||
| 26 | + public static final String DEFINITION = "definition"; | ||
| 27 | + | ||
| 16 | public static final String CONNECTION = "connection"; | 28 | public static final String CONNECTION = "connection"; |
| 17 | 29 | ||
| 18 | public static final String STATEMENT = "statement"; | 30 | public static final String STATEMENT = "statement"; |
| @@ -23,13 +35,19 @@ public class CommonConstants { | |||
| 23 | 35 | ||
| 24 | public static final String OID = "oid"; | 36 | public static final String OID = "oid"; |
| 25 | 37 | ||
| 38 | + public static final String OPENGAUSS = "openGauss"; | ||
| 39 | + | ||
| 26 | public static final String PORT = "port"; | 40 | public static final String PORT = "port"; |
| 27 | 41 | ||
| 42 | + public static final String NAME = "name"; | ||
| 43 | + | ||
| 44 | + public static final String PARTTYPE = "parttype"; | ||
| 45 | + | ||
| 28 | public static final String NODE_NAME = "nodename"; | 46 | public static final String NODE_NAME = "nodename"; |
| 29 | 47 | ||
| 30 | public static final String BEGIN = "begin"; | 48 | public static final String BEGIN = "begin"; |
| 31 | 49 | ||
| 32 | - public static final String END = "end"; | 50 | + public static final String END = "end;"; |
| 33 | 51 | ||
| 34 | public static final String DIFFER = "differ"; | 52 | public static final String DIFFER = "differ"; |
| 35 | 53 | ||
| @@ -39,50 +57,60 @@ public class CommonConstants { | |||
| 39 | 57 | ||
| 40 | public static final String PRO_NAME = "proname"; | 58 | public static final String PRO_NAME = "proname"; |
| 41 | 59 | ||
| 42 | - public static final String LAN_NAME = "lanname"; | 60 | + public static final String NSP_NAME = "nspname"; |
| 61 | + | ||
| 62 | + public static final String ROL_NAME = "rolname"; | ||
| 63 | + | ||
| 64 | + public static final String DESCRIPTION = "description"; | ||
| 65 | + | ||
| 66 | + public static final String SCHEMA_NAME = "schemaName"; | ||
| 67 | + | ||
| 68 | + public static final String OWNER = "owner"; | ||
| 43 | 69 | ||
| 44 | public static final String TYP_NAME = "typname"; | 70 | public static final String TYP_NAME = "typname"; |
| 45 | 71 | ||
| 46 | - public static final String PRO_ARG_TYPES = "proargtypes"; | 72 | + public static final String PRON_ARGS = "pronargs"; |
| 47 | 73 | ||
| 48 | - public static final String PRO_ALL_ARG_TYPES = "proallargtypes"; | 74 | + public static final String PRO_ARG_TYPES = "proargtypes"; |
| 49 | 75 | ||
| 50 | public static final String PRO_ARG_MODES = "proargmodes"; | 76 | public static final String PRO_ARG_MODES = "proargmodes"; |
| 51 | 77 | ||
| 52 | public static final String PRO_ARG_NAMES = "proargnames"; | 78 | public static final String PRO_ARG_NAMES = "proargnames"; |
| 53 | 79 | ||
| 54 | - public static final String PRO_SRC = "prosrc"; | ||
| 55 | - | ||
| 56 | - public static final String PRO_BIN = "probin"; | ||
| 57 | - | ||
| 58 | - public static final String PRO_ARG_SRC = "proargsrc"; | ||
| 59 | - | ||
| 60 | public static final String PRO_KIND = "prokind"; | 80 | public static final String PRO_KIND = "prokind"; |
| 61 | 81 | ||
| 62 | - public static final String PRO_VOLATILE = "provolatile"; | ||
| 63 | - | ||
| 64 | - public static final String FEN_CED_MODE = "fencedmode"; | ||
| 65 | - | ||
| 66 | - public static final String PRO_SHIPPABLE = "proshippable"; | ||
| 67 | - | ||
| 68 | - public static final String PRO_IS_STRICT = "proisstrict"; | ||
| 69 | - | ||
| 70 | - public static final String PRO_RET_SET = "proretset"; | ||
| 71 | - | ||
| 72 | - public static final String PRO_COST = "procost"; | ||
| 73 | - | ||
| 74 | - public static final String PRO_ROWS = "prorows"; | ||
| 75 | - | ||
| 76 | public static final String PG_GET_TABLEDEF = "pg_get_tabledef"; | 82 | public static final String PG_GET_TABLEDEF = "pg_get_tabledef"; |
| 77 | 83 | ||
| 78 | public static final String FUNC_OID = "funcoid"; | 84 | public static final String FUNC_OID = "funcoid"; |
| 79 | public static final String LINE_NO = "lineno"; | 85 | public static final String LINE_NO = "lineno"; |
| 86 | + public static final String CAN_BREAK = "canbreak"; | ||
| 80 | 87 | ||
| 81 | public static final String START_RUN = "startRun"; | 88 | public static final String START_RUN = "startRun"; |
| 82 | public static final String STOP_RUN = "stopRun"; | 89 | public static final String STOP_RUN = "stopRun"; |
| 83 | public static final String STOP_DEBUG = "stopDebug"; | 90 | public static final String STOP_DEBUG = "stopDebug"; |
| 84 | - public static final String FUNCTION = "function"; | ||
| 85 | - public static final String PROCEDURE = "procedure"; | ||
| 86 | public static final String TYPE = "type"; | 91 | public static final String TYPE = "type"; |
| 87 | 92 | ||
| 93 | + public static final String IN = "IN"; | ||
| 94 | + public static final String OUT = "OUT"; | ||
| 95 | + public static final String INOUT = "INOUT"; | ||
| 96 | + public static final String VARIADIC = "VARIADIC"; | ||
| 97 | + public static final String T = "t"; | ||
| 98 | + public static final String F = "f"; | ||
| 99 | + public static final String CID = "cid"; | ||
| 100 | + public static final String COVERAGE_LINES = "coveragelines"; | ||
| 101 | + public static final String REMARK_LINES = "remarklines"; | ||
| 102 | + public static final String END_TIME = "endtime"; | ||
| 103 | + public static final String SOURCECODE = "sourcecode"; | ||
| 104 | + public static final String PARAMS = "params"; | ||
| 105 | + public static final String CAN_BREAK_LINE = "canbreakline"; | ||
| 106 | + public static final String TABLE = "table"; | ||
| 107 | + public static final String FUNCTION = "function"; | ||
| 108 | + public static final String VIEW = "view"; | ||
| 109 | + public static final String SEQUENCE = "sequence"; | ||
| 110 | + public static final String SCHEMA = "schema"; | ||
| 111 | + public static final String MAX_VALUE = "max_value"; | ||
| 112 | + public static final String MIN_VALUE = "min_value"; | ||
| 113 | + public static final String NEXT_VALUE = "nextval"; | ||
| 114 | + public static final String IS_CALLED = "is_called"; | ||
| 115 | + | ||
| 88 | } | 116 | } |
| @@ -1,11 +1,17 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.constants; | 5 | package com.nctigba.datastudio.constants; |
| 2 | 6 | ||
| 3 | public class SqlConstants { | 7 | public class SqlConstants { |
| 4 | public static final String POINT = "."; | 8 | public static final String POINT = "."; |
| 9 | + public static final String LF = System.getProperty("line.separator"); | ||
| 10 | + public static final String SPACE = " "; | ||
| 5 | 11 | ||
| 6 | - public static final String PARENTHESES_LEFT = "("; | 12 | + public static final String LEFT_BRACKET = "("; |
| 7 | 13 | ||
| 8 | - public static final String PARENTHESES_RIGHT = ")"; | 14 | + public static final String RIGHT_BRACKET = ")"; |
| 9 | 15 | ||
| 10 | public static final String SEMICOLON = ";"; | 16 | public static final String SEMICOLON = ";"; |
| 11 | 17 | ||
| @@ -19,16 +25,29 @@ public class SqlConstants { | |||
| 19 | 25 | ||
| 20 | public static final String QUOTES_COMMA = "',"; | 26 | public static final String QUOTES_COMMA = "',"; |
| 21 | 27 | ||
| 28 | + public static final String QUOTES_LF_COMMA = "," + LF; | ||
| 29 | + | ||
| 22 | public static final String COMMA = ","; | 30 | public static final String COMMA = ","; |
| 23 | 31 | ||
| 24 | public static final String COMMA_SPACE = ", "; | 32 | public static final String COMMA_SPACE = ", "; |
| 33 | + | ||
| 34 | + public static final String COMMENT_ON_COLUMN_SQL = "COMMENT ON COLUMN %s.%s.%s IS '%s';" + LF; | ||
| 25 | public static final String CONFIGURE_TIME = "?connectTimeout=30&socketTimeout=0"; | 35 | public static final String CONFIGURE_TIME = "?connectTimeout=30&socketTimeout=0"; |
| 26 | 36 | ||
| 27 | - public static final String TURN_ON_SQL = "select * from dbe_pldebugger.turn_on("; | 37 | + public static final String PROC_SQL = "select pn.nspname, pp.proname, pp.pronargs, pp.proargtypes, " + |
| 38 | + "pp.proallargtypes, pp.proargnames, pp.proargmodes, pp.prokind " + | ||
| 39 | + "from pg_proc pp left join pg_namespace pn on pp.pronamespace = pn.oid where pp.oid =%s;"; | ||
| 28 | 40 | ||
| 29 | - public static final String ATTACH_SQL = "select * from dbe_pldebugger.attach('"; | 41 | + public static final String QUERY_DEF_SQL = "select definition from PG_GET_FUNCTIONDEF(%s);"; |
| 30 | 42 | ||
| 31 | - public static final String ADD_BREAKPOINT_SQL = "select * from dbe_pldebugger.add_breakpoint("; | 43 | + public static final String QUERY_OID_SQL = "select pp.oid from pg_proc pp " + |
| 44 | + "left join pg_namespace pn on pp.pronamespace = pn.oid where pp.proname = '%s' and pn.nspname = '%s';"; | ||
| 45 | + | ||
| 46 | + public static final String TURN_ON_SQL = "select * from dbe_pldebugger.turn_on(%s);"; | ||
| 47 | + | ||
| 48 | + public static final String ATTACH_SQL = "select * from dbe_pldebugger.attach('%s',%s);"; | ||
| 49 | + | ||
| 50 | + public static final String ADD_BREAKPOINT_SQL = "select * from dbe_pldebugger.add_breakpoint(%s,%s);"; | ||
| 32 | 51 | ||
| 33 | public static final String INFO_BREAKPOINT_PRE = "select funcoid, lineno + "; | 52 | public static final String INFO_BREAKPOINT_PRE = "select funcoid, lineno + "; |
| 34 | 53 | ||
| @@ -36,17 +55,17 @@ public class SqlConstants { | |||
| 36 | 55 | ||
| 37 | public static final String CONTINUE_SQL = "select * from dbe_pldebugger.continue();"; | 56 | public static final String CONTINUE_SQL = "select * from dbe_pldebugger.continue();"; |
| 38 | 57 | ||
| 39 | - public static final String BACKTRACE_SQL_PRE = "select frameno, funcname, lineno + "; | 58 | + public static final String BACKTRACE_SQL_PRE = "select funcoid, frameno, funcname, lineno + "; |
| 40 | 59 | ||
| 41 | public static final String BACKTRACE_SQL = " as lineno from dbe_pldebugger.backtrace();"; | 60 | public static final String BACKTRACE_SQL = " as lineno from dbe_pldebugger.backtrace();"; |
| 42 | 61 | ||
| 43 | public static final String INFO_LOCALS_SQL = "select varname, value, vartype, isconst from dbe_pldebugger.info_locals();"; | 62 | public static final String INFO_LOCALS_SQL = "select varname, value, vartype, isconst from dbe_pldebugger.info_locals();"; |
| 44 | 63 | ||
| 45 | - public static final String DELETE_BREAKPOINT_SQL = "select * from dbe_pldebugger.delete_breakpoint("; | 64 | + public static final String DELETE_BREAKPOINT_SQL = "select * from dbe_pldebugger.delete_breakpoint(%s);"; |
| 46 | 65 | ||
| 47 | - public static final String DISABLE_BREAKPOINT_SQL = "select * from dbe_pldebugger.disable_breakpoint("; | 66 | + public static final String DISABLE_BREAKPOINT_SQL = "select * from dbe_pldebugger.disable_breakpoint(%s);"; |
| 48 | 67 | ||
| 49 | - public static final String ENABLE_BREAKPOINT_SQL = "select * from dbe_pldebugger.enable_breakpoint("; | 68 | + public static final String ENABLE_BREAKPOINT_SQL = "select * from dbe_pldebugger.enable_breakpoint(%s);"; |
| 50 | 69 | ||
| 51 | public static final String STEP_SQL = "select * from dbe_pldebugger.step();"; | 70 | public static final String STEP_SQL = "select * from dbe_pldebugger.step();"; |
| 52 | 71 | ||
| @@ -56,76 +75,138 @@ public class SqlConstants { | |||
| 56 | 75 | ||
| 57 | public static final String FINISH_SQL = "select * from dbe_pldebugger.finish();"; | 76 | public static final String FINISH_SQL = "select * from dbe_pldebugger.finish();"; |
| 58 | 77 | ||
| 59 | - public static final String INFO_CODE_SQL = "select * from dbe_pldebugger.info_code("; | 78 | + public static final String TURN_OFF_SQL = "select * from dbe_pldebugger.turn_off(%s);"; |
| 60 | - | ||
| 61 | - public static final String TURN_OFF_SQL = "select * from dbe_pldebugger.turn_off("; | ||
| 62 | 79 | ||
| 63 | public static final String ABORT_SQL = "select * from dbe_pldebugger.abort();"; | 80 | public static final String ABORT_SQL = "select * from dbe_pldebugger.abort();"; |
| 64 | 81 | ||
| 65 | - public static final String DEBUG_INFO_SQL = "select * from dbe_pldebugger.local_debug_server_info()"; | 82 | + public static final String INFO_CODE_SQL = "SELECT * FROM DBE_PLDEBUGGER.info_code(%s);"; |
| 66 | 83 | ||
| 67 | - public static final String GET_TYPE_OID_SQL = "select oid from pg_type where typname = '"; | 84 | + public static final String GET_OID_NAME_SQL = "select typname from pg_type pt where pt.oid in (%s);"; |
| 68 | - | ||
| 69 | - public static final String GET_OID_NAME_SQL = "select typname from pg_type pt where pt.oid = "; | ||
| 70 | - | ||
| 71 | - public static final String GET_PROC_SQL = "select pg.oid, pg.proname, pg.proallargtypes, pg.proargmodes, pg.proargtypes, pg.proargnames, pg.procost, pg.prorows," + | ||
| 72 | - "pg.proretset, pg.prosrc, pg.probin, pg.prokind, pg.proargsrc, pg.proisstrict, pg.provolatile, pg.fencedmode, pg.proshippable, pl.lanname, pt.typname \n" + | ||
| 73 | - "from pg_proc pg\n" + | ||
| 74 | - "left join pg_language pl on pl.oid = pg.prolang\n" + | ||
| 75 | - "left join pg_type pt on pt.oid = pg.prorettype\n" + | ||
| 76 | - "left join pg_namespace pn on pn.oid = pg.pronamespace\n" + | ||
| 77 | - "where pg.proname = '"; | ||
| 78 | - | ||
| 79 | - public static final String GET_PROC_TYPE_SQL = "' and pg.proargtypes = '"; | ||
| 80 | - public static final String GET_PROC_NAME_SQL = "' and pn.nspname = '"; | ||
| 81 | public static final String GET_URL_JDBC = "jdbc:opengauss://"; | 85 | public static final String GET_URL_JDBC = "jdbc:opengauss://"; |
| 82 | public static final String GET_TYPENAME_SQL = "select a.oid,a.typname from pg_type a where a.oid<9999"; | 86 | public static final String GET_TYPENAME_SQL = "select a.oid,a.typname from pg_type a where a.oid<9999"; |
| 83 | public static final String GET_DATABASE_SQL = "select datname from pg_database;"; | 87 | public static final String GET_DATABASE_SQL = "select datname from pg_database;"; |
| 84 | - public static final String GET_SCHEMA_NAME_SQL = "SELECT nspname as schema_name FROM pg_namespace where nspname not in ('blockchain','snapshot','dbe_perf','pkg_service','cstore','pg_toast');"; | 88 | + public static final String GET_SCHEMA_NAME_SQL = "SELECT oid, nspname FROM pg_namespace where nspname not in ('blockchain','snapshot','dbe_perf','pkg_service','cstore','pg_toast');"; |
| 85 | public static final String GET_DATA_Connection_SQL = "select id, type , name , driver , ip, port ,dataname , username, userpassword ,webuser,edition from DATABASELINK WHERE"; | 89 | public static final String GET_DATA_Connection_SQL = "select id, type , name , driver , ip, port ,dataname , username, userpassword ,webuser,edition from DATABASELINK WHERE"; |
| 86 | - public static final String GET_DATA_Connection_NOT_PASSWORD_SQL = "select id, type , name , driver , ip, port ,dataname , username, '' as userpassword ,webuser,edition from DATABASELINK WHERE"; | 90 | + public static final String GET_DATA_Connection_NOT_P_SQL = "select id, type , name , driver , ip, port ,dataname , username, '' as userpassword ,webuser,edition from DATABASELINK WHERE"; |
| 87 | public static final String GET_DATABASELINK_COUNT_SQL = "select count(1) as count from DATABASELINK where"; | 91 | public static final String GET_DATABASELINK_COUNT_SQL = "select count(1) as count from DATABASELINK where"; |
| 88 | 92 | ||
| 89 | public static final String TABLE_DEF_SQL = "select pg_get_tabledef('"; | 93 | public static final String TABLE_DEF_SQL = "select pg_get_tabledef('"; |
| 94 | + public static final String TABLE_DDL_SQL = "select pg_get_tabledef('%s.%s');"; | ||
| 90 | 95 | ||
| 91 | public static final String TABLE_DATA_SQL = "select * from "; | 96 | public static final String TABLE_DATA_SQL = "select * from "; |
| 92 | 97 | ||
| 93 | - public static final String GET_CONSTRAINT_SQL = "select con.conname, string_agg(att.attname, ',' order by att.attname) as attname,\n" + | 98 | + public static final String TABLE_ANALYSE_SQL = "ANALYSE %s.%s "; |
| 94 | - " con.contype, pg_get_constraintdef(con.oid), con.condeferrable, ns.nspname, 'pg_default' as tablespace\n" + | ||
| 95 | - "from pg_class cla\n" + | ||
| 96 | - "inner join pg_attribute att on cla.oid = att.attrelid and att.attnum > 0 \n" + | ||
| 97 | - "inner join (select oid, condeferrable, unnest(conkey) as conkey, conrelid, contype, conname from pg_constraint) con \n" + | ||
| 98 | - " on att.attnum = con.conkey and con.conrelid = cla.oid\n" + | ||
| 99 | - "inner join pg_namespace ns on cla.relnamespace = ns.oid and ns.nspname = '"; | ||
| 100 | 99 | ||
| 101 | - public static final String RELNAME_CONDITION = "'where cla.relname = '"; | 100 | + public static final String TABLE_TRUNCATE_SQL = "TRUNCATE TABLE ONLY %s.%s "; |
| 102 | 101 | ||
| 103 | - public static final String CONSTRAINT_GROUP_BY_SQL = "' group by con.conname, con.contype, pg_get_constraintdef(con.oid), con.condeferrable, ns.nspname"; | 102 | + public static final String VACUUM_SQL = "VACUUM %s.%s "; |
| 104 | 103 | ||
| 105 | - public static final String GET_INDEX_SQL = "select pc.relname,string_agg(att.attname, ',' order by att.attname),\n" + | 104 | + public static final String REINDEX_TABLE_SQL = "REINDEX TABLE %s.%s "; |
| 106 | - " pi.indisunique, '' as expression, 'pg_default' as tablespace\n" + | ||
| 107 | - "from PG_INDEX pi \n" + | ||
| 108 | - "inner join PG_CLASS pc on pi.indexrelid = pc.oid and pc.relkind = 'i'\n" + | ||
| 109 | - "inner join PG_ATTRIBUTE att on pc.oid = att.attrelid\n" + | ||
| 110 | - "inner join (select pc.oid from PG_CLASS pc\n" + | ||
| 111 | - "\t\tinner join pg_namespace pn on pn.oid = pc.relnamespace\n" + | ||
| 112 | - "\t\twhere pc.relname = '"; | ||
| 113 | 105 | ||
| 114 | - public static final String NSPNAME_CONDITION = "' and pn.nspname = '"; | 106 | + public static final String RENAME_TABLE_SQL = "ALTER TABLE %s.%s RENAME TO %s "; |
| 115 | 107 | ||
| 116 | - public static final String INDEX_GROUP_BY_SQL = "') tt\n" + "\t\ton pi.indrelid = tt.oid\n" + | 108 | + public static final String SCHEMA_TABLE_SQL = "ALTER TABLE ONLY %s.%s SET SCHEMA %s "; |
| 117 | - "group by pc.relname, pi.indisunique"; | ||
| 118 | 109 | ||
| 119 | - public static final String GET_CLASS_OID_SQL = "select cla.oid from PG_CLASS cla left join pg_namespace pn on pn.oid = cla.relnamespace\n" + | 110 | + public static final String TABLESPACE_TABLE_SQL = "ALTER TABLE %s.%s SET TABLESPACE %s;"; |
| 120 | - "where cla.relname = '"; | ||
| 121 | 111 | ||
| 122 | - public static final String GET_COLUMN_SQL = "select pa.attname, pt.typname, pa.attnotnull, pd.description\n" + | 112 | + public static final String DROP_TABLE_SQL = "DROP TABLE %s.%s ;"; |
| 123 | - "from PG_ATTRIBUTE pa\n" + | ||
| 124 | - "left join pg_type pt on pt.oid = pa.atttypid\n" + | ||
| 125 | - "left join PG_DESCRIPTION pd on pd.objsubid = pa.attnum and pd.objoid = "; | ||
| 126 | 113 | ||
| 127 | - public static final String ATTRELID_CONDITION_SQL = "\nwhere pa.attnum > 0 and pa.attrelid = "; | 114 | + public static final String TABLE_SEQUENCE_SQL = "select t.tableuser, t.tableName, t.columnName, decode(seq.sequence_name, t.relname, seq.sequence_name, '[No_Privilege]') as sequenceName, decode(seq.sequence_name, t.relname, seq.sequence_schema, '[No_Privilege]') as sequenceuser, decode(seq.sequence_name, t.relname, seq.minimum_value, '[No_Privilege]') as minValue, decode(seq.sequence_name, t.relname, seq.maximum_value, '[No_Privilege]') as maxValue, decode(seq.sequence_name, t.relname, seq.increment, '[No_Privilege]') as increment" + LF + |
| 115 | + " from (SELECT tu.rolname as tableuser, tb.relname as tableName, tc.attname as columnName, scl.relname, sch.nspname" + LF + | ||
| 116 | + " FROM pg_class scl, pg_depend sdp, pg_attrdef sc, pg_attribute tc, pg_class tb, pg_roles tu, pg_namespace sch" + LF + | ||
| 117 | + " WHERE sch.nspname = '%s'" + LF + | ||
| 118 | + " and tb.relname = '%s'" + LF + | ||
| 119 | + " AND scl.relnamespace = sch.oid" + LF + | ||
| 120 | + " AND scl.relkind = 'S'" + LF + | ||
| 121 | + " AND sdp.refobjid = scl.oid" + LF + | ||
| 122 | + " AND sc.oid = sdp.objid" + LF + | ||
| 123 | + " AND tc.attrelid = sc.adrelid" + LF + | ||
| 124 | + " AND tc.attnum = sc.adnum" + LF + | ||
| 125 | + " AND tb.oid = tc.attrelid" + LF + | ||
| 126 | + " AND tu.oid = tb.relowner ) t" + LF + | ||
| 127 | + " LEFT OUTER join information_schema.sequences seq on (t.nspname = seq.sequence_schema AND t.relname = seq.sequence_name);"; | ||
| 128 | + | ||
| 129 | + public static final String TABLE_DATA_COUNT_SQL = "select reltuples from pg_class cla" + LF + | ||
| 130 | + "inner join pg_namespace ns on cla.relnamespace = ns.oid and ns.nspname = '%s'" + LF + | ||
| 131 | + "where relname = '%s'"; | ||
| 132 | + | ||
| 133 | + public static final String GET_COLUMN_SQL = "select col.column_name,col.data_type,case when col.is_nullable = 'YES' then TRUE else FALSE end as is_null," + LF + | ||
| 134 | + "substr(col.column_default,1,instr(col.column_default,'::')-1) as column_default, case when con.conname is null then FALSE ELSE TRUE end as is_only," + LF + | ||
| 135 | + "case when col.CHARACTER_MAXIMUM_LENGTH is not null then col.CHARACTER_MAXIMUM_LENGTH" + LF + | ||
| 136 | + "when col.numeric_precision is not null then col.numeric_precision end as precision, col.NUMERIC_SCALE, pd.description" + LF + | ||
| 137 | + "from information_schema.columns col" + LF + | ||
| 138 | + "inner join pg_class pc on pc.relname = col.table_name and pc.oid = %s" + LF + | ||
| 139 | + "left join (select oid, unnest(conkey) as conkey, conrelid, contype, conname from pg_constraint) con " + LF + | ||
| 140 | + "on con.conrelid = pc.oid and col.ordinal_position = con.conkey and con.contype = 'u'" + LF + | ||
| 141 | + "left join PG_DESCRIPTION pd on pd.objsubid = con.conkey and objoid = %s" + LF + | ||
| 142 | + "where col.table_schema = '%s' and col.table_name = '%s'"; | ||
| 143 | + public static final String ALTER_TABLE_SQL = "ALTER TABLE "; | ||
| 144 | + public static final String TABLE_PARTITIONG_ATTRIBUTE_SQL = "SELECT tbl.oid," + LF + | ||
| 145 | + " tbl.relname," + LF + | ||
| 146 | + " case when tbl.reltablespace = 0 then 'pg_default' else tblsp.spcname end," + LF + | ||
| 147 | + " case when tbl.relpersistence = 'g' then true else false end as relpersistence," + LF + | ||
| 148 | + " case when tbl.relpersistence = 'u' then 'UNLOGGED' else '正常' end as table_type," + LF + | ||
| 149 | + " auth.rolname as owner," + LF + | ||
| 150 | + " tbl.relpages pages," + LF + | ||
| 151 | + " tbl.reltuples as rows_count," + LF + | ||
| 152 | + " tbl.relhasindex as has_index," + LF + | ||
| 153 | + " tbl.relisshared as is_shared,split_part(split_part(array_to_string(tbl.reloptions, ','),',', 1),'=',2) orientation ," + LF + | ||
| 154 | + " split_part(split_part(array_to_string(tbl.reloptions, ','),',', 2),'=',2) compression ," + LF + | ||
| 155 | + " tbl.relhasoids as hashoid," + LF + | ||
| 156 | + " d.description as tbl_desc," + LF + | ||
| 157 | + " 'Y' as partition" + | ||
| 158 | + " FROM pg_class tbl" + LF + | ||
| 159 | + " LEFT JOIN pg_roles auth on (tbl.relowner = auth.oid)" + LF + | ||
| 160 | + " left join pg_description d on (tbl.oid = d.objoid)" + LF + | ||
| 161 | + " LEFT JOIN pg_tablespace tblsp ON (tbl.reltablespace = tblsp.oid)" + LF + | ||
| 162 | + " WHERE tbl.oid = %s"; | ||
| 163 | + public static final String TABLE_ATTRIBUTE_SQL = "SELECT tbl.oid," + LF + | ||
| 164 | + " tbl.relname," + LF + | ||
| 165 | + " case when tbl.reltablespace = 0 then 'pg_default' else tblsp.spcname end," + LF + | ||
| 166 | + " case when tbl.relpersistence = 'g' then true else false end as relpersistence," + LF + | ||
| 167 | + " case when tbl.relpersistence = 'u' then 'UNLOGGED' else '正常' end as table_type," + LF + | ||
| 168 | + " auth.rolname as owner," + LF + | ||
| 169 | + " tbl.relpages pages," + LF + | ||
| 170 | + " tbl.reltuples as rows_count," + LF + | ||
| 171 | + " tbl.relhasindex as has_index," + LF + | ||
| 172 | + " tbl.relisshared as is_shared,split_part(split_part(array_to_string(tbl.reloptions, ','),',', 1),'=',2) orientation ," + LF + | ||
| 173 | + " split_part(split_part(array_to_string(tbl.reloptions, ','),',', 2),'=',2) compression ," + LF + | ||
| 174 | + " tbl.relhasoids as hashoid," + LF + | ||
| 175 | + " d.description as tbl_desc" + LF + | ||
| 176 | + " FROM pg_class tbl" + LF + | ||
| 177 | + " LEFT JOIN pg_roles auth on (tbl.relowner = auth.oid)" + LF + | ||
| 178 | + " left join pg_description d on (tbl.oid = d.objoid)" + LF + | ||
| 179 | + " LEFT JOIN pg_tablespace tblsp ON (tbl.reltablespace = tblsp.oid)" + LF + | ||
| 180 | + " WHERE tbl.oid = %s"; | ||
| 128 | public static final String CREATE_SQL = "CREATE "; | 181 | public static final String CREATE_SQL = "CREATE "; |
| 182 | + public static final String CREATE_TABLE_SQL = "CREATE TABLE %s.%s(" + LF; | ||
| 183 | + public static final String CREATE_TABLE_EXISTS_SQL = "CREATE TABLE IF NOT EXISTS %s.%s(" + LF; | ||
| 184 | + public static final String CREATE_UNLOGGED_TABLE_SQL = "CREATE UNLOGGED TABLE %s.%s(" + LF; | ||
| 185 | + public static final String CREATE_UNLOGGED_TABLE_EXISTS_SQL = "CREATE UNLOGGED TABLE IF NOT EXISTS %s.%s(" + LF; | ||
| 186 | + public static final String PARTITION_BY_SQL = "PARTITION BY "; | ||
| 187 | + public static final String RANGE_SQL = "RANGE(%s)(" + LF + | ||
| 188 | + "partition %s values less than (%s) tablespace %s)" + LF; | ||
| 189 | + public static final String INTERVAL_SQL = "RANGE(%s)\n INTERVAL(%s)(" + LF + | ||
| 190 | + "partition %s values less than (%s) tablespace %s)" + LF; | ||
| 191 | + public static final String LIST_SQL = "LIST(%s)(" + LF + | ||
| 192 | + "partition %s values (%s) tablespace &s"; | ||
| 193 | + public static final String HASH_SQL = "HASH(%s)(" + LF + | ||
| 194 | + "partition %s tablespace %s"; | ||
| 195 | + | ||
| 196 | + public static final String UNIQUE_SQL = "CONSTRAINT %s UNIQUE (%s)"; | ||
| 197 | + | ||
| 198 | + public static final String UNIQUE_IMMEDIATE_SQL = "CONSTRAINT %s UNIQUE (%s) DEFERRABLE INITIALLY IMMEDIATE "; | ||
| 199 | + public static final String PRIMARY_KEY_SQL = "CONSTRAINT %s PRIMARY KEY (%s)"; | ||
| 200 | + public static final String CHECK_SQL = "CONSTRAINT %s CHECK (%s)"; | ||
| 201 | + public static final String FOREIGN_KEY_SQL = "CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s.%s (%s)"; | ||
| 202 | + public static final String PARTIAL_CLUSTER_KEY_SQL = "CONSTRAINT %s PARTIAL CLUSTER KEY (%s)"; | ||
| 203 | + public static final String WITH_DOUBLE_SQL = "WITH (%s,%s)" + LF; | ||
| 204 | + public static final String WITH_SQL = "WITH (%s)" + LF; | ||
| 205 | + public static final String OIDS_SQL = "OIDS=TRUE" + LF; | ||
| 206 | + public static final String FILLFACTOR_SQL = "FILLFACTOR=%s" + LF; | ||
| 207 | + public static final String COLUMN_SQL = "WITH (orientation = column)" + LF; | ||
| 208 | + public static final String TABLESPACE_SQL = "TABLESPACE %s" + LF; | ||
| 209 | + public static final String COMMENT_TABLE_SQL = "COMMENT ON TABLE %s.%s IS '%s'" + LF; | ||
| 129 | public static final String SEQUENCE_SET_SQL = "SET search_path = "; | 210 | public static final String SEQUENCE_SET_SQL = "SET search_path = "; |
| 130 | public static final String NO_MINVALUE_SQL = "NO MINVALUE"; | 211 | public static final String NO_MINVALUE_SQL = "NO MINVALUE"; |
| 131 | public static final String START_WITH_SQL = "START WITH "; | 212 | public static final String START_WITH_SQL = "START WITH "; |
| @@ -136,12 +217,25 @@ public class SqlConstants { | |||
| 136 | public static final String MATERIALIZED_VIEW_SQL = "MATERIALIZED "; | 217 | public static final String MATERIALIZED_VIEW_SQL = "MATERIALIZED "; |
| 137 | public static final String COMMON_VIEW_SQL = "OR REPLACE "; | 218 | public static final String COMMON_VIEW_SQL = "OR REPLACE "; |
| 138 | public static final String VIEW_KEYWORD_SQL = "VIEW "; | 219 | public static final String VIEW_KEYWORD_SQL = "VIEW "; |
| 220 | + public static final String RENAME_KEYWORD_SQL = " RENAME "; | ||
| 221 | + public static final String TO_KEYWORD_SQL = " TO "; | ||
| 222 | + public static final String ADD_KEYWORD_SQL = " ADD "; | ||
| 223 | + public static final String COLUMN_KEYWORD_SQL = "COLUMN "; | ||
| 224 | + public static final String TYPE_KEYWORD_SQL = " TYPE "; | ||
| 225 | + public static final String NULL_KEYWORD_SQL = " NULL"; | ||
| 226 | + public static final String UNIQUE_KEYWORD_SQL = " UNIQUE"; | ||
| 227 | + public static final String NOT_KEYWORD_SQL = " NOT"; | ||
| 228 | + public static final String SET_KEYWORD_SQL = " SET "; | ||
| 229 | + public static final String DROP_DEFAULT_SQL = " ALTER TABLE %s.%s ALTER COLUMN %s DROP DEFAULT;"; | ||
| 230 | + public static final String ALTER_DEFAULT_SQL = " ALTER TABLE %s.%s ALTER COLUMN %s SET DEFAULT %s;"; | ||
| 231 | + public static final String DEFAULT_KEYWORD_SQL = " DEFAULT "; | ||
| 139 | public static final String SELECT_KEYWORD_SQL = "SELECT "; | 232 | public static final String SELECT_KEYWORD_SQL = "SELECT "; |
| 140 | - public static final String COUNT_SQL = " count(1) as count " ; | 233 | + public static final String FROM_KEYWORD_SQL = " FROM "; |
| 141 | - public static final String FROM_CLASS_SQL = " from PG_CLASS c INNER JOIN pg_namespace n ON n.oid = c.relnamespace\n" + | 234 | + public static final String COUNT_SQL = " count(1) as count "; |
| 142 | - "and n.nspname = '" ; | 235 | + public static final String FROM_CLASS_SQL = " from PG_CLASS c INNER JOIN pg_namespace n ON n.oid = c.relnamespace" + LF + |
| 143 | - public static final String FROM_CLASS_WHERE_SQL = "' where relname = '" ; | 236 | + "and n.nspname = '"; |
| 144 | - public static final String RELKIND_SQL = "' and relkind = '" ; | 237 | + public static final String FROM_CLASS_WHERE_SQL = "' where relname = '"; |
| 238 | + public static final String RELKIND_SQL = "' and relkind = '"; | ||
| 145 | public static final String SEQUENCE_KEYWORD_SQL = "SEQUENCE "; | 239 | public static final String SEQUENCE_KEYWORD_SQL = "SEQUENCE "; |
| 146 | public static final String SYNONYM_KEYWORD_SQL = "SYNONYM "; | 240 | public static final String SYNONYM_KEYWORD_SQL = "SYNONYM "; |
| 147 | public static final String WITH_KEYWORD_SQL = " WITH "; | 241 | public static final String WITH_KEYWORD_SQL = " WITH "; |
| @@ -168,11 +262,64 @@ public class SqlConstants { | |||
| 168 | public static final String DROP_SQL = "DROP "; | 262 | public static final String DROP_SQL = "DROP "; |
| 169 | public static final String ALTER_SQL = "ALTER "; | 263 | public static final String ALTER_SQL = "ALTER "; |
| 170 | public static final String RENAME_TO_SQL = " RENAME TO "; | 264 | public static final String RENAME_TO_SQL = " RENAME TO "; |
| 171 | - public static final String LIMIT_SQL = " LIMIT 500"; | 265 | + public static final String LIMIT_SQL = " LIMIT 300"; |
| 172 | - public static final String SELECT_SEQUENCE_DDL_SQL = " SELECT sequence_schema,sequence_name,start_value,increment,minimum_value,maximum_value,cycle_option\n" + | 266 | + |
| 267 | + public static final String CONSTRAINT_DROP_SQL = " ALTER TABLE %s.%s DROP CONSTRAINT %s"; | ||
| 268 | + public static final String CONSTRAINT_UNIQUE_SQL = " ALTER TABLE %s.%s ADD CONSTRAINT %s UNIQUE (%s) "; | ||
| 269 | + public static final String CONSTRAINT_UNIQUE_IMMEDIATE_SQL = " ALTER TABLE %s.%s ADD CONSTRAINT %s UNIQUE (%s) DEFERRABLE INITIALLY IMMEDIATE "; | ||
| 270 | + public static final String CONSTRAINT_PRIMARY_SQL = " ALTER TABLE %s.%s ADD CONSTRAINT %s PRIMARY KEY (%s) "; | ||
| 271 | + public static final String CONSTRAINT_PRIMARY_IMMEDIATE_SQL = " ALTER TABLE %s.%s ADD CONSTRAINT %s PRIMARY KEY (%s) DEFERRABLE INITIALLY IMMEDIATE "; | ||
| 272 | + public static final String CONSTRAINT_CHECK_SQL = " ALTER TABLE %s.%s ADD CONSTRAINT %s CHECK (%s) "; | ||
| 273 | + public static final String CONSTRAINT_PARTIAL_CLUSTER_KEY_SQL = " ALTER TABLE %s.%s ADD CONSTRAINT %s PARTIAL CLUSTER KEY (%s) "; | ||
| 274 | + public static final String CONSTRAINT_NO_CHECK_SQL = " ALTER TABLE %s.%s ADD CONSTRAINT %s %s "; | ||
| 275 | + | ||
| 276 | + public static final String CONSTRAINT_FOREIGN_KEY_SQL = " ALTER TABLE %s.%s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s.%s (%s) "; | ||
| 277 | + public static final String CONSTRAINT_TABLE_SQL = "select con.conname, string_agg(DISTINCT att.attname, ',' order by att.attname) as attname, con.contype, pg_get_constraintdef(con.oid) constraintdef," + | ||
| 278 | + " con.condeferrable, d.description,f.nspname AS ref_nspname , f.relname AS ref_tbname , string_agg(DISTINCT f.attname, ', ') AS ref_columns " + | ||
| 279 | + " from pg_class cla inner join pg_attribute att on cla.oid = att.attrelid and att.attnum > 0 inner join (select oid, condeferrable, " + | ||
| 280 | + " unnest(conkey) as conkey, conrelid, contype, conname,confrelid ,confkey from pg_constraint) con on att.attnum = con.conkey and con.conrelid " + | ||
| 281 | + " = cla.oid left JOIN (SELECT pg_attribute.attnum,pg_attribute.attrelid,pg_attribute.attname,relname, nspname FROM pg_class INNER JOIN pg_namespace " + | ||
| 282 | + " ON pg_namespace.oid = pg_class.relnamespace INNER JOIN pg_attribute ON pg_class.oid = pg_attribute.attrelid) f ON f.attrelid = con.confrelid " + | ||
| 283 | + " AND f.attnum = ANY ( con.confkey) inner join pg_namespace ns on cla.relnamespace = ns.oid and ns.nspname = '%s' LEFT JOIN pg_description d " + | ||
| 284 | + " ON con.oid = d.objoid where cla.relname = '%s' group by con.conname,con.contype, pg_get_constraintdef(con.oid), con.condeferrable, ns.nspname " + | ||
| 285 | + " ,d.description,ref_nspname,ref_tbname"; | ||
| 286 | + public static final String UNIQUE_CONSTRAINT_TABLE_SQL = "select con.contype from pg_class cla inner join pg_attribute att on cla.oid = att.attrelid and att.attnum > 0" + LF + | ||
| 287 | + "inner join (select oid, condeferrable, unnest(conkey) as conkey, conrelid, contype, conname,confrelid ,confkey from pg_constraint) con " + LF + | ||
| 288 | + "on att.attnum = con.conkey and con.conrelid = cla.oid inner join pg_namespace ns on cla.relnamespace = ns.oid and ns.nspname = '%s' " + LF + | ||
| 289 | + "LEFT JOIN pg_description d ON con.oid = d.objoid where cla.relname = '%s' and con.contype ='p' "; | ||
| 290 | + public static final String CONSTRAINT_COMMENT_SQL = " COMMENT ON CONSTRAINT %s ON %s.%s is '%s' "; | ||
| 291 | + | ||
| 292 | + public static final String CONSTRAINT_TABLE_COLUMN_SQL = "select con.conname" + LF + | ||
| 293 | + " from pg_class cla" + LF + | ||
| 294 | + " inner join pg_attribute att on cla.oid = att.attrelid" + LF + | ||
| 295 | + " and att.attnum > 0" + LF + | ||
| 296 | + " inner join (select oid, condeferrable, unnest(conkey) as conkey, conrelid, contype, conname" + LF + | ||
| 297 | + " from pg_constraint ) con on att.attnum = con.conkey" + LF + | ||
| 298 | + " and con.conrelid = cla.oid" + LF + | ||
| 299 | + " inner join pg_namespace ns on cla.relnamespace = ns.oid" + LF + | ||
| 300 | + " and ns.nspname = '%s'" + LF + | ||
| 301 | + " LEFT JOIN pg_description d ON con.oid = d.objoid" + LF + | ||
| 302 | + " where cla.relname = '%s'" + LF + | ||
| 303 | + " and con.contype = 'u'" + LF + | ||
| 304 | + " and att.attname = '%s'" + LF + | ||
| 305 | + " group by con.conname"; | ||
| 306 | + | ||
| 307 | + | ||
| 308 | + public static final String INDEX_DROP_SQL = " DROP INDEX %s.%s ;"; | ||
| 309 | + public static final String INDEX_CREATE_SQL = " CREATE %s INDEX %s ON %s.%s %s (%s); "; | ||
| 310 | + public static final String INDEX_COMMENT_SQL = " COMMENT ON INDEX %s.%s is '%s' ;"; | ||
| 311 | + public static final String INDEX_TABLE_SQL = "select pc.relname,pi.indisunique, am.amname, CASE WHEN pg_catalog.pg_get_expr(pi.indexprs, pi.indrelid, true) is null THEN string_agg(att.attname, ',' order by att.attname) ELSE null END attname, " + | ||
| 312 | + " pg_catalog.pg_get_expr(pi.indexprs, pi.indrelid, true) expression, pg_description.description " + | ||
| 313 | + "from PG_INDEX pi inner join PG_CLASS pc on pi.indexrelid = pc.oid and pc.relkind = 'i' inner join PG_ATTRIBUTE att on pc.oid = att.attrelid " + | ||
| 314 | + "LEFT JOIN pg_description ON pi.indexrelid = pg_description.objoid JOIN pg_am am ON pc.relam = am.oid " + | ||
| 315 | + "inner join (select pc.oid from PG_CLASS pc inner join pg_namespace pn on pn.oid = pc.relnamespace " + | ||
| 316 | + "where pc.relname = '%s' and pn.nspname = '%s' ) tt on pi.indrelid = tt.oid " + | ||
| 317 | + "group by pc.relname, pi.indisunique, pi.indexprs, pi.indrelid, am.amname, pg_description.description;"; | ||
| 318 | + | ||
| 319 | + public static final String SELECT_SEQUENCE_DDL_SQL = " SELECT sequence_schema,sequence_name,start_value,increment,minimum_value,maximum_value,cycle_option" + LF + | ||
| 173 | " FROM information_schema.sequences where sequence_schema = '"; | 320 | " FROM information_schema.sequences where sequence_schema = '"; |
| 174 | public static final String SELECT_SEQUENCE_DDL_WHERE_SQL = "'and sequence_name ='"; | 321 | public static final String SELECT_SEQUENCE_DDL_WHERE_SQL = "'and sequence_name ='"; |
| 175 | - public static final String SELECT_VIEW_DDL_SQL = " SELECT c.relkind as relkind, n.nspname AS schemaname, c.relname AS matviewname, pg_get_userbyid(c.relowner) AS matviewowner, c.relhasindex AS hasindexes, pg_get_viewdef(c.oid) AS definition FROM pg_class c \n" + | 322 | + public static final String SELECT_VIEW_DDL_SQL = " SELECT c.relkind as relkind, n.nspname AS schemaname, c.relname AS matviewname, pg_get_userbyid(c.relowner) AS matviewowner, c.relhasindex AS hasindexes, pg_get_viewdef(c.oid) AS definition FROM pg_class c " + LF + |
| 176 | "LEFT JOIN pg_namespace n ON n.oid = c.relnamespace and n.nspname = '"; | 323 | "LEFT JOIN pg_namespace n ON n.oid = c.relnamespace and n.nspname = '"; |
| 177 | public static final String SELECT_VIEW_TYPE_SQL = " SELECT c.relkind as relkind FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace and n.nspname = '"; | 324 | public static final String SELECT_VIEW_TYPE_SQL = " SELECT c.relkind as relkind FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace and n.nspname = '"; |
| 178 | public static final String SELECT_VIEWNAME_DDL_WHERE_SQL = "' where c.relname = '"; | 325 | public static final String SELECT_VIEWNAME_DDL_WHERE_SQL = "' where c.relname = '"; |
| @@ -183,14 +330,36 @@ public class SqlConstants { | |||
| 183 | public static final String SELECT_COLUMN_SQL = "select column_name from information_schema.columns where table_schema ='"; | 330 | public static final String SELECT_COLUMN_SQL = "select column_name from information_schema.columns where table_schema ='"; |
| 184 | public static final String SELECT_COLUMN_WHERE_SQL = "' and table_name = '"; | 331 | public static final String SELECT_COLUMN_WHERE_SQL = "' and table_name = '"; |
| 185 | public static final String SELECT_SYNONYM_SQL = "select synname from PG_SYNONYM where synobjschema ='"; | 332 | public static final String SELECT_SYNONYM_SQL = "select synname from PG_SYNONYM where synobjschema ='"; |
| 186 | - public static final String SELECT_FUNCTION_SQL = "SELECT proname,proargtypes FROM pg_proc\n" + | 333 | + public static final String SELECT_FUNCTION_SQL = "SELECT proname,proargtypes FROM pg_proc" + LF + |
| 187 | "WHERE pronamespace = (SELECT pg_namespace.oid FROM pg_namespace WHERE nspname = '"; | 334 | "WHERE pronamespace = (SELECT pg_namespace.oid FROM pg_namespace WHERE nspname = '"; |
| 188 | public static final String SYNONYM_ATTRIBUTE_SQL = "select synname,synobjschema,rolname,synobjname from PG_SYNONYM a inner join pg_authid b on a.synowner = b.oid where synname = '"; | 335 | public static final String SYNONYM_ATTRIBUTE_SQL = "select synname,synobjschema,rolname,synobjname from PG_SYNONYM a inner join pg_authid b on a.synowner = b.oid where synname = '"; |
| 189 | public static final String SYNONYM_COUNT_SQL = "select count(1) count from PG_SYNONYM where synname = '"; | 336 | public static final String SYNONYM_COUNT_SQL = "select count(1) count from PG_SYNONYM where synname = '"; |
| 190 | - public static final String DATABASE_ATTRIBUTE_SQL = "select ds.oid,ds.datname,pg_encoding_to_char(ds.encoding) as encoding,ds.datallowconn,\n" + | 337 | + public static final String DATABASE_ATTRIBUTE_SQL = "select ds.oid,ds.datname,pg_encoding_to_char(ds.encoding) as encoding,ds.datallowconn," + LF + |
| 191 | - " case when ds.datconnlimit = -1 \n" + | 338 | + " case when ds.datconnlimit = -1 " + LF + |
| 192 | - " then '-1(不限制)'\n" + | 339 | + " then '-1(不限制)'" + LF + |
| 193 | - " else to_char(ds.datconnlimit)\n" + | 340 | + " else to_char(ds.datconnlimit)" + LF + |
| 194 | " end as datconnlimit,ts.spcname,ds.datcollate,ds.datctype from pg_database ds left join pg_tablespace ts on ts.oid = ds.dattablespace where ds.datname = '"; | 341 | " end as datconnlimit,ts.spcname,ds.datcollate,ds.datctype from pg_database ds left join pg_tablespace ts on ts.oid = ds.dattablespace where ds.datname = '"; |
| 195 | public static final String DATABASE_UPDATA_ATTRIBUTE_SQL = "select datname as databaseName,pg_encoding_to_char(encoding) as databaseCode,datcompatibility as compatibleType,datcollate as collation,datctype as characterType,datconnlimit as conRestrictions from pg_database where datname = '"; | 342 | public static final String DATABASE_UPDATA_ATTRIBUTE_SQL = "select datname as databaseName,pg_encoding_to_char(encoding) as databaseCode,datcompatibility as compatibleType,datcollate as collation,datctype as characterType,datconnlimit as conRestrictions from pg_database where datname = '"; |
| 343 | + | ||
| 344 | + public static final String QUERY_USERS_SQL = "select rolname from pg_roles;"; | ||
| 345 | + public static final String QUERY_SCHEMA_SQL = "select pn.oid, pn.nspname, pr.rolname, pd.description from pg_namespace pn " + | ||
| 346 | + "left join pg_description pd on pn.oid = pd.objoid left join pg_roles pr on pr.oid = pn.nspowner where pn.oid = "; | ||
| 347 | + public static final String CREATE_SCHEMA_SQL = "create schema "; | ||
| 348 | + public static final String USER_CONDITION = " authorization "; | ||
| 349 | + public static final String UPDATE_SCHEMA_SQL = "alter schema "; | ||
| 350 | + public static final String UPDATE_DESCRIPTION_SQL = "comment on schema "; | ||
| 351 | + public static final String IS_SQL = " IS '"; | ||
| 352 | + public static final String RENAME_CONDITION = " rename to "; | ||
| 353 | + public static final String OWNER_CONDITION = " owner to "; | ||
| 354 | + public static final String DROP_SCHEMA_SQL = "drop schema "; | ||
| 355 | + public static final String HIS_COVERAGE_OID_SQL = "select ph.*, pp.proname from public.his_coverage ph " + | ||
| 356 | + "left join pg_proc pp on pp.oid = ph.oid where ph.oid =%s order by cid desc;"; | ||
| 357 | + public static final String DELETE_BY_ID_SQL = "delete public.his_coverage where cid in ("; | ||
| 358 | + public static final String CREATE_COVERAGE_SQL = "CREATE TABLE IF NOT EXISTS public.his_coverage( " + LF + | ||
| 359 | + "oid BIGINT, cid BIGINT, coverageLines VARCHAR, remarkLines VARCHAR, " + LF + | ||
| 360 | + "endTime BIGINT, sourceCode VARCHAR, params VARCHAR, canBreakLine VARCHAR);"; | ||
| 361 | + public static final String INSERT_COVERAGE_SQL = "insert into public.his_coverage VALUES(?,?,?,?,?,?,?,?);"; | ||
| 362 | + public static final String SEQUENCE_SQL = "SELECT start_value, increment_by, max_value, min_value, is_called FROM %s;"; | ||
| 363 | + public static final String SET_VALUE_SQL = "SELECT pg_catalog.setVal('%s',%d,%b);"; | ||
| 364 | + public static final String NEXT_VALUE_SQL = "SELECT pg_catalog.nextval('%s');"; | ||
| 196 | } | 365 | } |
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/controller/CoverageRateController.java+42-0
| @@ -0,0 +1,42 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.controller; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.entity.CoverageRateDO; | ||
| 8 | +import com.nctigba.datastudio.model.query.CoverageRateRequest; | ||
| 9 | +import com.nctigba.datastudio.service.CoverageRateService; | ||
| 10 | +import io.swagger.annotations.Api; | ||
| 11 | +import org.springframework.http.MediaType; | ||
| 12 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 13 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 14 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 15 | +import org.springframework.web.bind.annotation.RestController; | ||
| 16 | + | ||
| 17 | +import javax.annotation.Resource; | ||
| 18 | +import javax.servlet.http.HttpServletResponse; | ||
| 19 | +import java.util.List; | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +public class CoverageRateController { | ||
| 25 | + | ||
| 26 | + private CoverageRateService coverageRateService; | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + public List<CoverageRateDO> queryByOid( CoverageRateRequest request) throws Exception { | ||
| 30 | + return coverageRateService.queryCoverageRate(request); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + public void delete( CoverageRateRequest request) throws Exception { | ||
| 35 | + coverageRateService.delete(request); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + | ||
| 39 | + public void export( CoverageRateRequest request, HttpServletResponse response) throws Exception { | ||
| 40 | + coverageRateService.export(request, response); | ||
| 41 | + } | ||
| 42 | +} | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/controller/CreateDatabaseController.java+11-1
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.controller; | 5 | package com.nctigba.datastudio.controller; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.dto.CreateDatabaseDTO; | 7 | import com.nctigba.datastudio.model.dto.CreateDatabaseDTO; |
| @@ -7,7 +11,12 @@ import com.nctigba.datastudio.model.entity.DatabaseConnectionDO; | |||
| 7 | import com.nctigba.datastudio.service.CreateDatabaseService; | 11 | import com.nctigba.datastudio.service.CreateDatabaseService; |
| 8 | import io.swagger.annotations.Api; | 12 | import io.swagger.annotations.Api; |
| 9 | import org.springframework.http.MediaType; | 13 | import org.springframework.http.MediaType; |
| 10 | -import org.springframework.web.bind.annotation.*; | 14 | +import org.springframework.web.bind.annotation.DeleteMapping; |
| 15 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 16 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 17 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 18 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 19 | +import org.springframework.web.bind.annotation.RestController; | ||
| 11 | 20 | ||
| 12 | import javax.annotation.Resource; | 21 | import javax.annotation.Resource; |
| 13 | import java.util.Map; | 22 | import java.util.Map; |
| @@ -45,6 +54,7 @@ public class CreateDatabaseController { | |||
| 45 | public Map<String, Object> databaseAttribute(DatabaseNameDTO request) throws Exception { | 54 | public Map<String, Object> databaseAttribute(DatabaseNameDTO request) throws Exception { |
| 46 | return creaeteDatabaseService.databaseAttribute(request); | 55 | return creaeteDatabaseService.databaseAttribute(request); |
| 47 | } | 56 | } |
| 57 | + | ||
| 48 | 58 | ||
| 49 | public Map<String, Object> databaseAttributeUpdate(DatabaseNameDTO request) throws Exception { | 59 | public Map<String, Object> databaseAttributeUpdate(DatabaseNameDTO request) throws Exception { |
| 50 | return creaeteDatabaseService.databaseAttributeUpdate(request); | 60 | return creaeteDatabaseService.databaseAttributeUpdate(request); |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/controller/DatabaseFunctionSPController.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.controller; | 5 | package com.nctigba.datastudio.controller; |
| 2 | 6 | ||
| 3 | 7 | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/controller/DatabaseSequenceController.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.controller; | 5 | package com.nctigba.datastudio.controller; |
| 2 | 6 | ||
| 3 | 7 | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/controller/DatabaseSynonymController.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.controller; | 5 | package com.nctigba.datastudio.controller; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.dto.DatabaseCreateSynonymDTO; | 7 | import com.nctigba.datastudio.model.dto.DatabaseCreateSynonymDTO; |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/controller/DatabaseTableController.java+132-1
| @@ -1,17 +1,40 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.controller; | 5 | package com.nctigba.datastudio.controller; |
| 2 | 6 | ||
| 7 | +import com.nctigba.datastudio.model.dto.DatabaseConstraintDTO; | ||
| 8 | +import com.nctigba.datastudio.model.dto.DatabaseConstraintPkDTO; | ||
| 9 | +import com.nctigba.datastudio.model.dto.DatabaseCreUpdColumnDTO; | ||
| 10 | +import com.nctigba.datastudio.model.dto.DatabaseCreateTableDTO; | ||
| 11 | +import com.nctigba.datastudio.model.dto.DatabaseIndexDTO; | ||
| 12 | +import com.nctigba.datastudio.model.dto.TableAlterDTO; | ||
| 13 | +import com.nctigba.datastudio.model.dto.TableAttributeDTO; | ||
| 14 | +import com.nctigba.datastudio.model.dto.TableDataDTO; | ||
| 15 | +import com.nctigba.datastudio.model.dto.TableNameDTO; | ||
| 3 | import com.nctigba.datastudio.model.query.SelectDataQuery; | 16 | import com.nctigba.datastudio.model.query.SelectDataQuery; |
| 17 | +import com.nctigba.datastudio.model.query.TableDataEditQuery; | ||
| 18 | +import com.nctigba.datastudio.model.query.TableDataQuery; | ||
| 19 | +import com.nctigba.datastudio.model.query.TablePKDataQuery; | ||
| 4 | import com.nctigba.datastudio.service.TableDataService; | 20 | import com.nctigba.datastudio.service.TableDataService; |
| 5 | import io.swagger.annotations.Api; | 21 | import io.swagger.annotations.Api; |
| 6 | import io.swagger.annotations.ApiOperation; | 22 | import io.swagger.annotations.ApiOperation; |
| 23 | +import lombok.extern.slf4j.Slf4j; | ||
| 7 | import org.springframework.http.MediaType; | 24 | import org.springframework.http.MediaType; |
| 25 | +import org.springframework.web.bind.annotation.DeleteMapping; | ||
| 8 | import org.springframework.web.bind.annotation.GetMapping; | 26 | import org.springframework.web.bind.annotation.GetMapping; |
| 27 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 28 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 29 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 9 | import org.springframework.web.bind.annotation.RequestMapping; | 30 | import org.springframework.web.bind.annotation.RequestMapping; |
| 10 | import org.springframework.web.bind.annotation.RestController; | 31 | import org.springframework.web.bind.annotation.RestController; |
| 11 | 32 | ||
| 12 | import javax.annotation.Resource; | 33 | import javax.annotation.Resource; |
| 34 | +import java.util.List; | ||
| 13 | import java.util.Map; | 35 | import java.util.Map; |
| 14 | 36 | ||
| 37 | + | ||
| 15 | 38 | ||
| 16 | 39 | ||
| 17 | 40 | ||
| @@ -23,10 +46,23 @@ public class DatabaseTableController { | |||
| 23 | 46 | ||
| 24 | 47 | ||
| 25 | 48 | ||
| 26 | - public Map<String, Object> tableData(SelectDataQuery request) throws Exception { | 49 | + public TableDataDTO tableData(TableDataQuery request) throws Exception { |
| 50 | + log.info("22111 request is: {}", request); | ||
| 27 | return tableDataService.tableData(request); | 51 | return tableDataService.tableData(request); |
| 28 | } | 52 | } |
| 29 | 53 | ||
| 54 | + | ||
| 55 | + | ||
| 56 | + public TablePKDataQuery tableDataEdit( TableDataEditQuery request) throws Exception { | ||
| 57 | + log.info("tableDataEdit111 request is: {}", request); | ||
| 58 | + return tableDataService.tableDataEdit(request); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + | ||
| 62 | + | ||
| 63 | + public void tableDataClose( String winId) throws Exception { | ||
| 64 | + tableDataService.tableDataClose(winId); | ||
| 65 | + } | ||
| 30 | 66 | ||
| 31 | 67 | ||
| 32 | 68 | ||
| @@ -34,6 +70,11 @@ public class DatabaseTableController { | |||
| 34 | return tableDataService.tableColumn(request); | 70 | return tableDataService.tableColumn(request); |
| 35 | } | 71 | } |
| 36 | 72 | ||
| 73 | + | ||
| 74 | + | ||
| 75 | + public Map<String, Object> editTableColumn( DatabaseCreUpdColumnDTO request) throws Exception { | ||
| 76 | + return tableDataService.tableColumnEdit(request); | ||
| 77 | + } | ||
| 37 | 78 | ||
| 38 | 79 | ||
| 39 | 80 | ||
| @@ -41,6 +82,12 @@ public class DatabaseTableController { | |||
| 41 | return tableDataService.tableIndex(request); | 82 | return tableDataService.tableIndex(request); |
| 42 | } | 83 | } |
| 43 | 84 | ||
| 85 | + | ||
| 86 | + | ||
| 87 | + public void editIndex( DatabaseIndexDTO request) throws Exception { | ||
| 88 | + tableDataService.tableEditIndex(request); | ||
| 89 | + } | ||
| 90 | + | ||
| 44 | 91 | ||
| 45 | 92 | ||
| 46 | 93 | ||
| @@ -48,10 +95,94 @@ public class DatabaseTableController { | |||
| 48 | return tableDataService.tableConstraint(request); | 95 | return tableDataService.tableConstraint(request); |
| 49 | } | 96 | } |
| 50 | 97 | ||
| 98 | + | ||
| 99 | + | ||
| 100 | + public void editConstraint( DatabaseConstraintDTO request) throws Exception { | ||
| 101 | + tableDataService.tableEditConstraint(request); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + | ||
| 105 | + | ||
| 106 | + public void editPkConstraint( DatabaseConstraintPkDTO request) throws Exception { | ||
| 107 | + tableDataService.tableEditPkConstraint(request); | ||
| 108 | + } | ||
| 51 | 109 | ||
| 52 | 110 | ||
| 53 | 111 | ||
| 54 | public Map<String, String> tableDdl(SelectDataQuery request) throws Exception { | 112 | public Map<String, String> tableDdl(SelectDataQuery request) throws Exception { |
| 55 | return tableDataService.tableDdl(request); | 113 | return tableDataService.tableDdl(request); |
| 56 | } | 114 | } |
| 115 | + | ||
| 116 | + | ||
| 117 | + | ||
| 118 | + public void tableCreate( DatabaseCreateTableDTO request) throws Exception { | ||
| 119 | + tableDataService.tableCreate(request); | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + | ||
| 123 | + | ||
| 124 | + public String tableCreateDDL( DatabaseCreateTableDTO request) throws Exception { | ||
| 125 | + return tableDataService.returnTableCreate(request); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + | ||
| 129 | + | ||
| 130 | + public void tableTruncate( TableNameDTO request) throws Exception { | ||
| 131 | + tableDataService.tableTruncate(request); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + | ||
| 135 | + | ||
| 136 | + public void tableVacuum( TableNameDTO request) throws Exception { | ||
| 137 | + tableDataService.tableVacuum(request); | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + | ||
| 141 | + | ||
| 142 | + public void tableReindex( TableNameDTO request) throws Exception { | ||
| 143 | + tableDataService.tableReindex(request); | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + | ||
| 147 | + | ||
| 148 | + public void tableRename( TableAlterDTO request) throws Exception { | ||
| 149 | + tableDataService.tableRename(request); | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + | ||
| 153 | + | ||
| 154 | + public void tableComment( TableAlterDTO request) throws Exception { | ||
| 155 | + tableDataService.tableComment(request); | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + | ||
| 159 | + | ||
| 160 | + public void tableAlterSchema( TableAlterDTO request) throws Exception { | ||
| 161 | + tableDataService.tableAlterSchema(request); | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + | ||
| 165 | + | ||
| 166 | + public void tableDrop( TableNameDTO request) throws Exception { | ||
| 167 | + tableDataService.tableDrop(request); | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + | ||
| 171 | + | ||
| 172 | + public void tableAlterTablespace( TableAlterDTO request) throws Exception { | ||
| 173 | + tableDataService.tableAlterTablespace(request); | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + | ||
| 177 | + | ||
| 178 | + public Map<String, Object> tableSequence( TableNameDTO request) throws Exception { | ||
| 179 | + return tableDataService.tableSequence(request); | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + | ||
| 183 | + | ||
| 184 | + public List<Map<String, Object>> tableAttribute( TableAttributeDTO request) throws Exception { | ||
| 185 | + return tableDataService.tableAttribute(request); | ||
| 186 | + } | ||
| 187 | + | ||
| 57 | } | 188 | } |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/controller/DatabaseViewController.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.controller; | 5 | package com.nctigba.datastudio.controller; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.dto.DatabaseCreateViewDTO; | 7 | import com.nctigba.datastudio.model.dto.DatabaseCreateViewDTO; |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/controller/DbConnectionController.java+13-1
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.controller; | 5 | package com.nctigba.datastudio.controller; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.base.ClusterManager; | 7 | import com.nctigba.datastudio.base.ClusterManager; |
| @@ -11,7 +15,15 @@ import lombok.extern.slf4j.Slf4j; | |||
| 11 | import org.opengauss.admin.common.core.domain.model.ops.OpsClusterVO; | 15 | import org.opengauss.admin.common.core.domain.model.ops.OpsClusterVO; |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.http.MediaType; | 17 | import org.springframework.http.MediaType; |
| 14 | -import org.springframework.web.bind.annotation.*; | 18 | +import org.springframework.web.bind.annotation.DeleteMapping; |
| 19 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 20 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 21 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 22 | +import org.springframework.web.bind.annotation.PutMapping; | ||
| 23 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 24 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 25 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 26 | +import org.springframework.web.bind.annotation.RestController; | ||
| 15 | 27 | ||
| 16 | import javax.annotation.Resource; | 28 | import javax.annotation.Resource; |
| 17 | import java.util.List; | 29 | import java.util.List; |
| @@ -0,0 +1,55 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.controller; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.query.ExportRequest; | ||
| 8 | +import com.nctigba.datastudio.service.ExportService; | ||
| 9 | +import io.swagger.annotations.Api; | ||
| 10 | +import org.springframework.http.MediaType; | ||
| 11 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 12 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 13 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 14 | +import org.springframework.web.bind.annotation.RestController; | ||
| 15 | + | ||
| 16 | +import javax.annotation.Resource; | ||
| 17 | +import javax.servlet.http.HttpServletResponse; | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | +public class ExportController { | ||
| 23 | + | ||
| 24 | + private ExportService exportService; | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + public void exportTableDdl( ExportRequest request, HttpServletResponse response) throws Exception { | ||
| 28 | + exportService.exportTableDdl(request, response); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + public void exportTableData( ExportRequest request, HttpServletResponse response) throws Exception { | ||
| 33 | + exportService.exportTableData(request, response); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + public void exportFunctionDdl( ExportRequest request, HttpServletResponse response) throws Exception { | ||
| 38 | + exportService.exportFunctionDdl(request, response); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + | ||
| 42 | + public void exportViewDdl( ExportRequest request, HttpServletResponse response) throws Exception { | ||
| 43 | + exportService.exportViewDdl(request, response); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + | ||
| 47 | + public void exportSequenceDdl( ExportRequest request, HttpServletResponse response) throws Exception { | ||
| 48 | + exportService.exportSequenceDdl(request, response); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + | ||
| 52 | + public void exportSchemaDdl( ExportRequest request, HttpServletResponse response) throws Exception { | ||
| 53 | + exportService.exportSchemaDdl(request, response); | ||
| 54 | + } | ||
| 55 | +} | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/controller/FunctionalityConrroller.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.controller; | 5 | package com.nctigba.datastudio.controller; |
| 2 | 6 | ||
| 3 | import org.springframework.http.MediaType; | 7 | import org.springframework.http.MediaType; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.controller; | 5 | package com.nctigba.datastudio.controller; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.dto.DataListDTO; | 7 | import com.nctigba.datastudio.model.dto.DataListDTO; |
| @@ -17,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController; | |||
| 17 | 21 | ||
| 18 | import javax.annotation.Resource; | 22 | import javax.annotation.Resource; |
| 19 | import java.util.List; | 23 | import java.util.List; |
| 24 | +import java.util.Map; | ||
| 20 | 25 | ||
| 21 | 26 | ||
| 22 | 27 | ||
| @@ -28,13 +33,6 @@ public class MetaDataController { | |||
| 28 | 33 | ||
| 29 | private QueryMetaArrayService queryMetaArrayService; | 34 | private QueryMetaArrayService queryMetaArrayService; |
| 30 | 35 | ||
| 31 | - | ||
| 32 | - | ||
| 33 | - | ||
| 34 | - public List<DataListDTO> dataList( String id) throws Exception { | ||
| 35 | - return dbConnectionService.dataList(id); | ||
| 36 | - } | ||
| 37 | - | ||
| 38 | 36 | ||
| 39 | 37 | ||
| 40 | public List<String> databaseList( String uuid) throws Exception { | 38 | public List<String> databaseList( String uuid) throws Exception { |
| @@ -49,7 +47,7 @@ public class MetaDataController { | |||
| 49 | 47 | ||
| 50 | 48 | ||
| 51 | 49 | ||
| 52 | - public List<String> schemaList(DatabaseMetaarraySchemaQuery request) throws Exception { | 50 | + public List<Map<String, String>> schemaList(DatabaseMetaarraySchemaQuery request) throws Exception { |
| 53 | return queryMetaArrayService.schemaList(request); | 51 | return queryMetaArrayService.schemaList(request); |
| 54 | } | 52 | } |
| 55 | 53 | ||
| @@ -66,4 +64,17 @@ public class MetaDataController { | |||
| 66 | public List<String> tableColumnList(DatabaseMetaarrayColumnQuery request) throws Exception { | 64 | public List<String> tableColumnList(DatabaseMetaarrayColumnQuery request) throws Exception { |
| 67 | return queryMetaArrayService.tableColumnList(request); | 65 | return queryMetaArrayService.tableColumnList(request); |
| 68 | } | 66 | } |
| 67 | + | ||
| 68 | + | ||
| 69 | + | ||
| 70 | + | ||
| 71 | + public List<String> typeList( String uuid) throws Exception { | ||
| 72 | + return queryMetaArrayService.baseTypeList(uuid); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + | ||
| 76 | + | ||
| 77 | + public List<String> tablespaceList( String uuid) throws Exception { | ||
| 78 | + return queryMetaArrayService.tablespaceList(uuid); | ||
| 79 | + } | ||
| 69 | } | 80 | } |
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/controller/SchemaManagerController.java+51-0
| @@ -0,0 +1,51 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.controller; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.query.SchemaManagerRequest; | ||
| 8 | +import com.nctigba.datastudio.service.SchemaManagerService; | ||
| 9 | +import io.swagger.annotations.Api; | ||
| 10 | +import org.springframework.http.MediaType; | ||
| 11 | +import org.springframework.web.bind.annotation.PostMapping; | ||
| 12 | +import org.springframework.web.bind.annotation.RequestBody; | ||
| 13 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 14 | +import org.springframework.web.bind.annotation.RestController; | ||
| 15 | + | ||
| 16 | +import javax.annotation.Resource; | ||
| 17 | +import java.util.List; | ||
| 18 | +import java.util.Map; | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +public class SchemaManagerController { | ||
| 24 | + | ||
| 25 | + private SchemaManagerService schemaManagerService; | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + public List<String> queryAllUsers( SchemaManagerRequest request) throws Exception { | ||
| 29 | + return schemaManagerService.queryAllUsers(request); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + public Map<String, String> querySchema( SchemaManagerRequest request) throws Exception { | ||
| 34 | + return schemaManagerService.querySchema(request); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + public void createSchema( SchemaManagerRequest request) throws Exception { | ||
| 39 | + schemaManagerService.createSchema(request); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + public void updateSchema( SchemaManagerRequest request) throws Exception { | ||
| 44 | + schemaManagerService.updateSchema(request); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + public void deleteSchema( SchemaManagerRequest request) throws Exception { | ||
| 49 | + schemaManagerService.deleteSchema(request); | ||
| 50 | + } | ||
| 51 | +} | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.dao; | 5 | package com.nctigba.datastudio.dao; |
| 2 | 6 | ||
| 3 | 7 | ||
| @@ -13,16 +17,20 @@ import org.springframework.stereotype.Repository; | |||
| 13 | 17 | ||
| 14 | import java.sql.Connection; | 18 | import java.sql.Connection; |
| 15 | import java.sql.Statement; | 19 | import java.sql.Statement; |
| 16 | -import java.util.*; | 20 | +import java.util.Date; |
| 21 | +import java.util.HashMap; | ||
| 22 | +import java.util.HashSet; | ||
| 23 | +import java.util.Iterator; | ||
| 24 | +import java.util.Map; | ||
| 17 | 25 | ||
| 18 | import static java.util.concurrent.TimeUnit.HOURS; | 26 | import static java.util.concurrent.TimeUnit.HOURS; |
| 19 | -import static java.util.concurrent.TimeUnit.MINUTES; | ||
| 20 | 27 | ||
| 21 | 28 | ||
| 22 | 29 | ||
| 23 | 30 | ||
| 24 | public class ConnectionMapDAO { | 31 | public class ConnectionMapDAO { |
| 25 | public static Map<String, ConnectionDTO> conMap = new HashMap<>(1); | 32 | public static Map<String, ConnectionDTO> conMap = new HashMap<>(1); |
| 33 | + | ||
| 26 | public static void setConMap(String uuiD, ConnectionDTO con) throws Exception { | 34 | public static void setConMap(String uuiD, ConnectionDTO con) throws Exception { |
| 27 | if (conMap.size() <= 100) { | 35 | if (conMap.size() <= 100) { |
| 28 | conMap.put(uuiD, con); | 36 | conMap.put(uuiD, con); |
| @@ -33,37 +41,43 @@ public class ConnectionMapDAO { | |||
| 33 | 41 | ||
| 34 | } | 42 | } |
| 35 | 43 | ||
| 36 | - @Scheduled(fixedRate=2 ,timeUnit = HOURS) | 44 | + @Scheduled(fixedRate = 2, timeUnit = HOURS) |
| 37 | public void overtime() { | 45 | public void overtime() { |
| 46 | + log.info("Start scheduled cleanup of connections. Connection number is: " + conMap.size()); | ||
| 38 | Date nowData = new Date(); | 47 | Date nowData = new Date(); |
| 48 | + log.info("conMap is: {}", conMap); | ||
| 39 | for (String key : conMap.keySet()) { | 49 | for (String key : conMap.keySet()) { |
| 40 | ConnectionDTO connectionDTO = conMap.get(key); | 50 | ConnectionDTO connectionDTO = conMap.get(key); |
| 51 | + log.info("connectionDTO is: " + connectionDTO); | ||
| 41 | Date lastDate = connectionDTO.getLastDate(); | 52 | Date lastDate = connectionDTO.getLastDate(); |
| 42 | long diff = nowData.getTime() - lastDate.getTime(); | 53 | long diff = nowData.getTime() - lastDate.getTime(); |
| 43 | log.info("diff is: " + diff); | 54 | log.info("diff is: " + diff); |
| 44 | if (diff > 2 * 60 * 60 * 1000) { | 55 | if (diff > 2 * 60 * 60 * 1000) { |
| 56 | + | ||
| 45 | try { | 57 | try { |
| 58 | + log.info("connectionDTO.getSocketSet() is: " + connectionDTO.getSocketSet()); | ||
| 46 | overtimeCloseSocket(connectionDTO.getSocketSet()); | 59 | overtimeCloseSocket(connectionDTO.getSocketSet()); |
| 47 | conMap.remove(key); | 60 | conMap.remove(key); |
| 48 | } catch (Exception e) { | 61 | } catch (Exception e) { |
| 49 | throw new RuntimeException(e); | 62 | throw new RuntimeException(e); |
| 50 | } | 63 | } |
| 51 | } | 64 | } |
| 65 | + log.info("End scheduled cleanup of connections. Connection number is: " + conMap.size()); | ||
| 52 | } | 66 | } |
| 53 | } | 67 | } |
| 54 | 68 | ||
| 55 | public void deleteConnection(String uuid) { | 69 | public void deleteConnection(String uuid) { |
| 56 | - if(conMap.containsKey(uuid)){ | 70 | + if (conMap.containsKey(uuid)) { |
| 57 | try { | 71 | try { |
| 58 | - ConnectionDTO connectionDTO= conMap.get(uuid); | 72 | + ConnectionDTO connectionDTO = conMap.get(uuid); |
| 59 | log.info("connectionDTO is: " + connectionDTO); | 73 | log.info("connectionDTO is: " + connectionDTO); |
| 60 | overtimeCloseSocket(connectionDTO.getSocketSet()); | 74 | overtimeCloseSocket(connectionDTO.getSocketSet()); |
| 61 | log.info("old conMap is: " + conMap); | 75 | log.info("old conMap is: " + conMap); |
| 62 | conMap.remove(uuid); | 76 | conMap.remove(uuid); |
| 63 | log.info("new conMap is: " + conMap); | 77 | log.info("new conMap is: " + conMap); |
| 64 | } catch (Exception e) { | 78 | } catch (Exception e) { |
| 65 | - e.printStackTrace(); | 79 | + log.info(e.getMessage()); |
| 66 | - throw new CustomException(e.getMessage(),e); | 80 | + throw new CustomException(e.getMessage(), e); |
| 67 | } | 81 | } |
| 68 | } | 82 | } |
| 69 | } | 83 | } |
| @@ -76,12 +90,12 @@ public class ConnectionMapDAO { | |||
| 76 | Iterator<String> iterator = socketSet.iterator(); | 90 | Iterator<String> iterator = socketSet.iterator(); |
| 77 | log.info("iterator is: " + iterator); | 91 | log.info("iterator is: " + iterator); |
| 78 | while (iterator.hasNext()) { | 92 | while (iterator.hasNext()) { |
| 79 | - String winNmae = iterator.next(); | 93 | + String winName = iterator.next(); |
| 80 | - Statement statement = webSocketServer.getStatement(winNmae); | 94 | + Statement statement = webSocketServer.getStatement(winName); |
| 81 | - Connection connection = webSocketServer.getConnection(winNmae); | 95 | + Connection connection = webSocketServer.getConnection(winName); |
| 82 | if (statement != null) { | 96 | if (statement != null) { |
| 83 | - statement.close(); | ||
| 84 | statement.cancel(); | 97 | statement.cancel(); |
| 98 | + statement.close(); | ||
| 85 | } | 99 | } |
| 86 | if (connection != null) { | 100 | if (connection != null) { |
| 87 | connection.close(); | 101 | connection.close(); |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.dao; | 5 | package com.nctigba.datastudio.dao; |
| 2 | 6 | ||
| 3 | 7 | ||
| @@ -17,7 +21,7 @@ import java.util.Map; | |||
| 17 | 21 | ||
| 18 | import static com.nctigba.datastudio.constants.SqlConstants.CONFIGURE_TIME; | 22 | import static com.nctigba.datastudio.constants.SqlConstants.CONFIGURE_TIME; |
| 19 | import static com.nctigba.datastudio.constants.SqlConstants.GET_DATABASELINK_COUNT_SQL; | 23 | import static com.nctigba.datastudio.constants.SqlConstants.GET_DATABASELINK_COUNT_SQL; |
| 20 | -import static com.nctigba.datastudio.constants.SqlConstants.GET_DATA_Connection_NOT_PASSWORD_SQL; | 24 | +import static com.nctigba.datastudio.constants.SqlConstants.GET_DATA_Connection_NOT_P_SQL; |
| 21 | import static com.nctigba.datastudio.constants.SqlConstants.GET_DATA_Connection_SQL; | 25 | import static com.nctigba.datastudio.constants.SqlConstants.GET_DATA_Connection_SQL; |
| 22 | import static com.nctigba.datastudio.constants.SqlConstants.GET_URL_JDBC; | 26 | import static com.nctigba.datastudio.constants.SqlConstants.GET_URL_JDBC; |
| 23 | 27 | ||
| @@ -28,35 +32,41 @@ public class DatabaseConnectionDAO implements ApplicationRunner { | |||
| 28 | private JdbcTemplate jdbcTemplate; | 32 | private JdbcTemplate jdbcTemplate; |
| 29 | 33 | ||
| 30 | public void insertTable(DatabaseConnectionDO databaseConnectionDO) { | 34 | public void insertTable(DatabaseConnectionDO databaseConnectionDO) { |
| 31 | - jdbcTemplate.execute("insert into DATABASELINK(type,name,driver,ip,port,dataname,username,userpassword,webuser,edition) values('" + databaseConnectionDO.getType() + "','" + databaseConnectionDO.getName() + "','" + databaseConnectionDO.getDriver() + "','" + databaseConnectionDO.getIp() + "','" + databaseConnectionDO.getPort() + "','" + databaseConnectionDO.getDataName() + "','" + databaseConnectionDO.getUserName() + "','" + databaseConnectionDO.getPassword() + "','" + databaseConnectionDO.getWebUser() +"','" + databaseConnectionDO.getEdition() + "');"); | 35 | + jdbcTemplate.execute( |
| 36 | + "insert into DATABASELINK(type,name,driver,ip,port,dataname,username,userpassword,webuser,edition) values('" + databaseConnectionDO.getType() + "','" + databaseConnectionDO.getName() + "','" + databaseConnectionDO.getDriver() + "','" + databaseConnectionDO.getIp() + "','" + databaseConnectionDO.getPort() + "','" + databaseConnectionDO.getDataName() + "','" + databaseConnectionDO.getUserName() + "','" + databaseConnectionDO.getPassword() + "','" + databaseConnectionDO.getWebUser() + "','" + databaseConnectionDO.getEdition() + "');"); | ||
| 32 | } | 37 | } |
| 33 | 38 | ||
| 34 | public void updateTable(DatabaseConnectionDO databaseConnectionDO) { | 39 | public void updateTable(DatabaseConnectionDO databaseConnectionDO) { |
| 35 | - jdbcTemplate.execute("UPDATE DATABASELINK SET type= '" + databaseConnectionDO.getType() + "' ,driver = '" + databaseConnectionDO.getDriver() + "',ip= '" + databaseConnectionDO.getIp() + "' ,port = '" + databaseConnectionDO.getPort() + "',dataName = '" + databaseConnectionDO.getDataName() + "',username ='" + databaseConnectionDO.getUserName() + "' ,userpassword ='" + databaseConnectionDO.getPassword() + "' ,edition ='" + databaseConnectionDO.getEdition()+ "' WHERE name = '" + databaseConnectionDO.getName() + "' and webuser = '" + databaseConnectionDO.getWebUser() + "';"); | 40 | + jdbcTemplate.execute( |
| 41 | + "UPDATE DATABASELINK SET type= '" + databaseConnectionDO.getType() + "' ,driver = '" + databaseConnectionDO.getDriver() + "',ip= '" + databaseConnectionDO.getIp() + "' ,port = '" + databaseConnectionDO.getPort() + "',dataName = '" + databaseConnectionDO.getDataName() + "',username ='" + databaseConnectionDO.getUserName() + "' ,userpassword ='" + databaseConnectionDO.getPassword() + "' ,edition ='" + databaseConnectionDO.getEdition() + "' WHERE name = '" + databaseConnectionDO.getName() + "' and webuser = '" + databaseConnectionDO.getWebUser() + "';"); | ||
| 36 | } | 42 | } |
| 37 | 43 | ||
| 38 | public List<DatabaseConnectionDO> selectTable(String webUser) { | 44 | public List<DatabaseConnectionDO> selectTable(String webUser) { |
| 39 | List list = new ArrayList<>(); | 45 | List list = new ArrayList<>(); |
| 40 | - Map<String, Object> count = jdbcTemplate.queryForMap(GET_DATABASELINK_COUNT_SQL + " webuser = '" + webUser + "';"); | 46 | + Map<String, Object> count = jdbcTemplate.queryForMap( |
| 47 | + GET_DATABASELINK_COUNT_SQL + " webuser = '" + webUser + "';"); | ||
| 41 | if ((int) count.get("count") == 0) { | 48 | if ((int) count.get("count") == 0) { |
| 42 | return null; | 49 | return null; |
| 43 | } else { | 50 | } else { |
| 44 | - list = jdbcTemplate.query(GET_DATA_Connection_NOT_PASSWORD_SQL + " webuser = '" + webUser + "';", new BeanPropertyRowMapper<DatabaseConnectionDO>(DatabaseConnectionDO.class)); | 51 | + list = jdbcTemplate.query(GET_DATA_Connection_NOT_P_SQL + " webuser = '" + webUser + "';", |
| 52 | + new BeanPropertyRowMapper<DatabaseConnectionDO>(DatabaseConnectionDO.class)); | ||
| 45 | } | 53 | } |
| 46 | return list; | 54 | return list; |
| 47 | } | 55 | } |
| 48 | 56 | ||
| 49 | public DatabaseConnectionUrlDO getByName(String name, String webUser) { | 57 | public DatabaseConnectionUrlDO getByName(String name, String webUser) { |
| 50 | DatabaseConnectionUrlDO databaseConnectionUrlDO = new DatabaseConnectionUrlDO(); | 58 | DatabaseConnectionUrlDO databaseConnectionUrlDO = new DatabaseConnectionUrlDO(); |
| 51 | - Map<String, Object> data = jdbcTemplate.queryForMap(GET_DATA_Connection_SQL + " name = '" + name + "' and webUser = '" + webUser + "';"); | 59 | + Map<String, Object> data = jdbcTemplate.queryForMap( |
| 60 | + GET_DATA_Connection_SQL + " name = '" + name + "' and webUser = '" + webUser + "';"); | ||
| 52 | if (StringUtils.isBlank(String.valueOf(data.get("id")))) { | 61 | if (StringUtils.isBlank(String.valueOf(data.get("id")))) { |
| 53 | return null; | 62 | return null; |
| 54 | - } else { | 63 | + } else { |
| 55 | databaseConnectionUrlDO.setId((Integer) data.get("id")); | 64 | databaseConnectionUrlDO.setId((Integer) data.get("id")); |
| 56 | databaseConnectionUrlDO.setType((String) data.get("type")); | 65 | databaseConnectionUrlDO.setType((String) data.get("type")); |
| 57 | databaseConnectionUrlDO.setName((String) data.get("name")); | 66 | databaseConnectionUrlDO.setName((String) data.get("name")); |
| 58 | databaseConnectionUrlDO.setDriver((String) data.get("driver")); | 67 | databaseConnectionUrlDO.setDriver((String) data.get("driver")); |
| 59 | - databaseConnectionUrlDO.setUrl(GET_URL_JDBC + data.get("ip") + ":" + data.get("port") + "/" + data.get("dataName") + CONFIGURE_TIME); | 68 | + databaseConnectionUrlDO.setUrl(GET_URL_JDBC + data.get("ip") + ":" + data.get("port") + "/" + data.get( |
| 69 | + "dataName") + CONFIGURE_TIME); | ||
| 60 | databaseConnectionUrlDO.setUserName((String) data.get("username")); | 70 | databaseConnectionUrlDO.setUserName((String) data.get("username")); |
| 61 | databaseConnectionUrlDO.setPassword((String) data.get("userpassword")); | 71 | databaseConnectionUrlDO.setPassword((String) data.get("userpassword")); |
| 62 | databaseConnectionUrlDO.setWebUser((String) data.get("webuser")); | 72 | databaseConnectionUrlDO.setWebUser((String) data.get("webuser")); |
| @@ -66,7 +76,8 @@ public class DatabaseConnectionDAO implements ApplicationRunner { | |||
| 66 | } | 76 | } |
| 67 | 77 | ||
| 68 | public Integer getJudgeName(String name, String webUser) { | 78 | public Integer getJudgeName(String name, String webUser) { |
| 69 | - Map<String, Object> count = jdbcTemplate.queryForMap(GET_DATABASELINK_COUNT_SQL + " name ='" + name + "' and webUser = '" + webUser + "'"); | 79 | + Map<String, Object> count = jdbcTemplate.queryForMap( |
| 80 | + GET_DATABASELINK_COUNT_SQL + " name ='" + name + "' and webUser = '" + webUser + "'"); | ||
| 70 | Integer a = (int) count.get("count"); | 81 | Integer a = (int) count.get("count"); |
| 71 | return a; | 82 | return a; |
| 72 | } | 83 | } |
| @@ -78,10 +89,11 @@ public class DatabaseConnectionDAO implements ApplicationRunner { | |||
| 78 | 89 | ||
| 79 | public DatabaseConnectionDO getByIdDatabase(Integer id, String webUser) { | 90 | public DatabaseConnectionDO getByIdDatabase(Integer id, String webUser) { |
| 80 | DatabaseConnectionDO databaseConnectionDO = new DatabaseConnectionDO(); | 91 | DatabaseConnectionDO databaseConnectionDO = new DatabaseConnectionDO(); |
| 81 | - Map<String, Object> data = jdbcTemplate.queryForMap(GET_DATA_Connection_SQL + " id =" + id + " and webUser = '" + webUser + "';"); | 92 | + Map<String, Object> data = jdbcTemplate.queryForMap( |
| 93 | + GET_DATA_Connection_SQL + " id =" + id + " and webUser = '" + webUser + "';"); | ||
| 82 | if (StringUtils.isBlank(String.valueOf(data.get("id")))) { | 94 | if (StringUtils.isBlank(String.valueOf(data.get("id")))) { |
| 83 | return null; | 95 | return null; |
| 84 | - } else { | 96 | + } else { |
| 85 | databaseConnectionDO.setId(String.valueOf(data.get("id"))); | 97 | databaseConnectionDO.setId(String.valueOf(data.get("id"))); |
| 86 | databaseConnectionDO.setType((String) data.get("type")); | 98 | databaseConnectionDO.setType((String) data.get("type")); |
| 87 | databaseConnectionDO.setName((String) data.get("name")); | 99 | databaseConnectionDO.setName((String) data.get("name")); |
| @@ -99,10 +111,11 @@ public class DatabaseConnectionDAO implements ApplicationRunner { | |||
| 99 | 111 | ||
| 100 | public DatabaseConnectionDO getAttributeById(String id, String webUser) { | 112 | public DatabaseConnectionDO getAttributeById(String id, String webUser) { |
| 101 | DatabaseConnectionDO databaseConnectionDO = new DatabaseConnectionDO(); | 113 | DatabaseConnectionDO databaseConnectionDO = new DatabaseConnectionDO(); |
| 102 | - Map<String, Object> data = jdbcTemplate.queryForMap(GET_DATA_Connection_SQL + " id =" + id + " and webUser = '" + webUser + "';"); | 114 | + Map<String, Object> data = jdbcTemplate.queryForMap( |
| 115 | + GET_DATA_Connection_SQL + " id =" + id + " and webUser = '" + webUser + "';"); | ||
| 103 | if (StringUtils.isBlank(String.valueOf(data.get("id")))) { | 116 | if (StringUtils.isBlank(String.valueOf(data.get("id")))) { |
| 104 | return null; | 117 | return null; |
| 105 | - } else { | 118 | + } else { |
| 106 | databaseConnectionDO.setId(String.valueOf(data.get("id"))); | 119 | databaseConnectionDO.setId(String.valueOf(data.get("id"))); |
| 107 | databaseConnectionDO.setType((String) data.get("type")); | 120 | databaseConnectionDO.setType((String) data.get("type")); |
| 108 | databaseConnectionDO.setName((String) data.get("name")); | 121 | databaseConnectionDO.setName((String) data.get("name")); |
| @@ -119,7 +132,8 @@ public class DatabaseConnectionDAO implements ApplicationRunner { | |||
| 119 | 132 | ||
| 120 | public DatabaseConnectionDO getAttributeByName(String name, String webUser) { | 133 | public DatabaseConnectionDO getAttributeByName(String name, String webUser) { |
| 121 | DatabaseConnectionDO databaseConnectionDO = new DatabaseConnectionDO(); | 134 | DatabaseConnectionDO databaseConnectionDO = new DatabaseConnectionDO(); |
| 122 | - Map<String, Object> data = jdbcTemplate.queryForMap(GET_DATA_Connection_SQL + " name ='" + name + "' and webUser = '" + webUser + "';"); | 135 | + Map<String, Object> data = jdbcTemplate.queryForMap( |
| 136 | + GET_DATA_Connection_SQL + " name ='" + name + "' and webUser = '" + webUser + "';"); | ||
| 123 | if (StringUtils.isBlank(String.valueOf(data.get("id")))) { | 137 | if (StringUtils.isBlank(String.valueOf(data.get("id")))) { |
| 124 | return null; | 138 | return null; |
| 125 | } else { | 139 | } else { |
| @@ -140,7 +154,8 @@ public class DatabaseConnectionDAO implements ApplicationRunner { | |||
| 140 | 154 | ||
| 141 | 155 | ||
| 142 | public void run(ApplicationArguments args) throws Exception { | 156 | public void run(ApplicationArguments args) throws Exception { |
| 143 | - jdbcTemplate.execute("create table if not exists DATABASELINK(id INTEGER PRIMARY KEY,type varchar(20),name text,driver varchar(100),ip varchar(30),port varchar(10),dataName varchar(40),username varchar(40),userpassword varchar(40) ," + | 157 | + jdbcTemplate.execute( |
| 144 | - "webuser varchar(40),edition varchar(300), UNIQUE(name));"); | 158 | + "create table if not exists DATABASELINK(id INTEGER PRIMARY KEY,type varchar(20),name text,driver varchar(100),ip varchar(30),port varchar(10),dataName varchar(40),username varchar(40),userpassword varchar(40) ," + |
| 159 | + "webuser varchar(40),edition varchar(300), UNIQUE(name));"); | ||
| 145 | } | 160 | } |
| 146 | } | 161 | } |
| @@ -0,0 +1,76 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.dao; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.dto.WinInfoDTO; | ||
| 8 | +import com.nctigba.datastudio.service.impl.sql.TableDataServiceImpl; | ||
| 9 | +import lombok.extern.slf4j.Slf4j; | ||
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | +import org.springframework.scheduling.annotation.EnableScheduling; | ||
| 12 | +import org.springframework.scheduling.annotation.Scheduled; | ||
| 13 | +import org.springframework.stereotype.Repository; | ||
| 14 | + | ||
| 15 | +import java.sql.Connection; | ||
| 16 | +import java.sql.ResultSet; | ||
| 17 | +import java.sql.Statement; | ||
| 18 | +import java.util.Date; | ||
| 19 | +import java.util.HashMap; | ||
| 20 | +import java.util.Map; | ||
| 21 | +import java.util.Set; | ||
| 22 | + | ||
| 23 | +import static java.util.concurrent.TimeUnit.MINUTES; | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + | ||
| 28 | +public class ResultSetMapDAO { | ||
| 29 | + public static Map<String, WinInfoDTO> winMap = new HashMap<>(); | ||
| 30 | + | ||
| 31 | + public static void setWinMap(String winid, WinInfoDTO winInfoDTO) { | ||
| 32 | + winMap.put(winid, winInfoDTO); | ||
| 33 | + log.info("winMap is: " + winMap); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + public void overtime() { | ||
| 38 | + Date nowData = new Date(); | ||
| 39 | + Set<String> set = winMap.keySet(); | ||
| 40 | + Date date; | ||
| 41 | + for (String key : set) { | ||
| 42 | + log.info("WinId is: " + key); | ||
| 43 | + date = winMap.get(key).getLastDate(); | ||
| 44 | + long diff = nowData.getTime() - date.getTime(); | ||
| 45 | + log.info("diff is: " + diff); | ||
| 46 | + if (diff > 10 * 60 * 1000) { | ||
| 47 | + try { | ||
| 48 | + overtimeCloseWin(key); | ||
| 49 | + winMap.remove(key); | ||
| 50 | + } catch (Exception e) { | ||
| 51 | + throw new RuntimeException(e); | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + | ||
| 58 | + TableDataServiceImpl tableDataServiceImpl; | ||
| 59 | + | ||
| 60 | + public void overtimeCloseWin(String winID) throws Exception { | ||
| 61 | + log.info("socketSet is: " + winID); | ||
| 62 | + Connection connection = tableDataServiceImpl.getConnectionMap(winID); | ||
| 63 | + Statement statement = tableDataServiceImpl.getSatementMap(winID); | ||
| 64 | + ResultSet resultSet = tableDataServiceImpl.getResultSetMap(winID); | ||
| 65 | + if (resultSet != null) { | ||
| 66 | + resultSet.close(); | ||
| 67 | + } | ||
| 68 | + if (statement != null) { | ||
| 69 | + statement.cancel(); | ||
| 70 | + statement.close(); | ||
| 71 | + } | ||
| 72 | + if (connection != null) { | ||
| 73 | + connection.close(); | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | +} | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.enums; | 5 | package com.nctigba.datastudio.enums; |
| 2 | 6 | ||
| 3 | public enum MessageEnum { | 7 | public enum MessageEnum { |
| @@ -5,6 +9,7 @@ public enum MessageEnum { | |||
| 5 | button, | 9 | button, |
| 6 | table, | 10 | table, |
| 7 | window, | 11 | window, |
| 12 | + confirm, | ||
| 8 | ignoreWindow, | 13 | ignoreWindow, |
| 9 | stack, | 14 | stack, |
| 10 | breakPoint, | 15 | breakPoint, |
| @@ -12,8 +17,11 @@ public enum MessageEnum { | |||
| 12 | operateStatus, | 17 | operateStatus, |
| 13 | paramWindow, | 18 | paramWindow, |
| 14 | view, | 19 | view, |
| 15 | - refresh, | 20 | + newFile, |
| 16 | newWindow, | 21 | newWindow, |
| 17 | closeWindow, | 22 | closeWindow, |
| 23 | + switchWindow, | ||
| 24 | + message, | ||
| 25 | + createCoverageRate, | ||
| 18 | other | 26 | other |
| 19 | } | 27 | } |
| @@ -1,741 +1,14 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.enums; | 5 | package com.nctigba.datastudio.enums; |
| 2 | 6 | ||
| 3 | public enum ParamTypeEnum { | 7 | public enum ParamTypeEnum { |
| 4 | - bool("boolean"), | ||
| 5 | - bytea("bytea"), | ||
| 6 | - //char("char"), | ||
| 7 | - name("name"), | ||
| 8 | int8("bigint"), | 8 | int8("bigint"), |
| 9 | - int2("smallint"), | ||
| 10 | - int1("tinyint"), | ||
| 11 | - int2vector("int2vector"), | ||
| 12 | int4("integer"), | 9 | int4("integer"), |
| 13 | - regproc("regproc"), | 10 | + int2("smallint"), |
| 14 | - text("text"), | 11 | + int1("tinyint"); |
| 15 | - oid("oid"), | ||
| 16 | - tid("tid"), | ||
| 17 | - xid("xid"), | ||
| 18 | - xid32("xid32"), | ||
| 19 | - cid("cid"), | ||
| 20 | - oidvector("oidvector"), | ||
| 21 | - oidvector_extend("oidvector_extend"), | ||
| 22 | - int2vector_extend("int2vector_extend"), | ||
| 23 | - int16("int16"), | ||
| 24 | - raw("raw"), | ||
| 25 | - _raw("_raw"), | ||
| 26 | - blob("blob"), | ||
| 27 | - _blob("_blob"), | ||
| 28 | - clob("clob"), | ||
| 29 | - _clob("_clob"), | ||
| 30 | - pg_type("pg_type"), | ||
| 31 | - pg_attribute("pg_attribute"), | ||
| 32 | - pg_proc("pg_proc"), | ||
| 33 | - pg_class("pg_class"), | ||
| 34 | - gs_package("gs_package"), | ||
| 35 | - json("json"), | ||
| 36 | - xml("xml"), | ||
| 37 | - _xml("_xml"), | ||
| 38 | - _json("_json"), | ||
| 39 | - pg_node_tree("pg_node_tree"), | ||
| 40 | - smgr("smgr"), | ||
| 41 | - point("point"), | ||
| 42 | - lseg("lseg"), | ||
| 43 | - path("path"), | ||
| 44 | - box("box"), | ||
| 45 | - polygon("polygon"), | ||
| 46 | - line("line"), | ||
| 47 | - _line("_line"), | ||
| 48 | - float4("float4"), | ||
| 49 | - float8("float8"), | ||
| 50 | - abstime("abstime"), | ||
| 51 | - reltime("reltime"), | ||
| 52 | - tinterval("tinterval"), | ||
| 53 | - unknown("unknown"), | ||
| 54 | - circle("circle"), | ||
| 55 | - _circle("_circle"), | ||
| 56 | - money("money"), | ||
| 57 | - _money("_money"), | ||
| 58 | - macaddr("macaddr"), | ||
| 59 | - inet("inet"), | ||
| 60 | - cidr("cidr"), | ||
| 61 | - _bool("_bool"), | ||
| 62 | - _bytea("_bytea"), | ||
| 63 | - _char("_char"), | ||
| 64 | - _name("_name"), | ||
| 65 | - _int2vector_extend("_int2vector_extend"), | ||
| 66 | - _int2("_int2"), | ||
| 67 | - _int1("_int1"), | ||
| 68 | - _int2vector("_int2vector"), | ||
| 69 | - _int4("_int4"), | ||
| 70 | - _regproc("_regproc"), | ||
| 71 | - _text("_text"), | ||
| 72 | - _oid("_oid"), | ||
| 73 | - _tid("_tid"), | ||
| 74 | - _xid("_xid"), | ||
| 75 | - _xid32("_xid32"), | ||
| 76 | - _cid("_cid"), | ||
| 77 | - _oidvector("_oidvector"), | ||
| 78 | - _bpchar("_bpchar"), | ||
| 79 | - _varchar("_varchar"), | ||
| 80 | - _int8("_int8"), | ||
| 81 | - _point("_point"), | ||
| 82 | - _lseg("_lseg"), | ||
| 83 | - _path("_path"), | ||
| 84 | - _box("_box"), | ||
| 85 | - _float4("_float4"), | ||
| 86 | - _float8("_float8"), | ||
| 87 | - _abstime("_abstime"), | ||
| 88 | - _reltime("_reltime"), | ||
| 89 | - _tinterval("_tinterval"), | ||
| 90 | - _polygon("_polygon"), | ||
| 91 | - aclitem("aclitem"), | ||
| 92 | - _aclitem("_aclitem"), | ||
| 93 | - _macaddr("_macaddr"), | ||
| 94 | - _inet("_inet"), | ||
| 95 | - _cidr("_cidr"), | ||
| 96 | - _cstring("_cstring"), | ||
| 97 | - bpchar("bpchar"), | ||
| 98 | - varchar("varchar"), | ||
| 99 | - nvarchar2("nvarchar2"), | ||
| 100 | - _nvarchar2("_nvarchar2"), | ||
| 101 | - date("date"), | ||
| 102 | - time("time without time zone"), | ||
| 103 | - timestamp("timestamp without time zone"), | ||
| 104 | - _timestamp("_timestamp"), | ||
| 105 | - _date("_date"), | ||
| 106 | - _time("_time"), | ||
| 107 | - timestamptz("timestamptz"), | ||
| 108 | - _timestamptz("_timestamptz"), | ||
| 109 | - interval("interval"), | ||
| 110 | - _interval("_interval"), | ||
| 111 | - _numeric("_numeric"), | ||
| 112 | - _int16("_int16"), | ||
| 113 | - timetz("timetz"), | ||
| 114 | - _timetz("_timetz"), | ||
| 115 | - bit("bit"), | ||
| 116 | - _bit("_bit"), | ||
| 117 | - varbit("varbit"), | ||
| 118 | - _varbit("_varbit"), | ||
| 119 | - numeric("numeric"), | ||
| 120 | - refcursor("refcursor"), | ||
| 121 | - _refcursor("_refcursor"), | ||
| 122 | - regprocedure("regprocedure"), | ||
| 123 | - regoper("regoper"), | ||
| 124 | - regoperator("regoperator"), | ||
| 125 | - regclass("regclass"), | ||
| 126 | - regtype("regtype"), | ||
| 127 | - _regprocedure("_regprocedure"), | ||
| 128 | - _regoper("_regoper"), | ||
| 129 | - _regoperator("_regoperator"), | ||
| 130 | - _regclass("_regclass"), | ||
| 131 | - _regtype("_regtype"), | ||
| 132 | - uuid("uuid"), | ||
| 133 | - _uuid("_uuid"), | ||
| 134 | - tsvector("tsvector"), | ||
| 135 | - gtsvector("gtsvector"), | ||
| 136 | - tsquery("tsquery"), | ||
| 137 | - regconfig("regconfig"), | ||
| 138 | - regdictionary("regdictionary"), | ||
| 139 | - _tsvector("_tsvector"), | ||
| 140 | - _gtsvector("_gtsvector"), | ||
| 141 | - _tsquery("_tsquery"), | ||
| 142 | - _regconfig("_regconfig"), | ||
| 143 | - _regdictionary("_regdictionary"), | ||
| 144 | - jsonb("jsonb"), | ||
| 145 | - _jsonb("_jsonb"), | ||
| 146 | - txid_snapshot("txid_snapshot"), | ||
| 147 | - _txid_snapshot("_txid_snapshot"), | ||
| 148 | - int4range("int4range"), | ||
| 149 | - _int4range("_int4range"), | ||
| 150 | - numrange("numrange"), | ||
| 151 | - _numrange("_numrange"), | ||
| 152 | - tsrange("tsrange"), | ||
| 153 | - _tsrange("_tsrange"), | ||
| 154 | - tstzrange("tstzrange"), | ||
| 155 | - _tstzrange("_tstzrange"), | ||
| 156 | - daterange("daterange"), | ||
| 157 | - _daterange("_daterange"), | ||
| 158 | - int8range("int8range"), | ||
| 159 | - _int8range("_int8range"), | ||
| 160 | - record("record"), | ||
| 161 | - _record("_record"), | ||
| 162 | - cstring("cstring"), | ||
| 163 | - any("any"), | ||
| 164 | - anyarray("anyarray"), | ||
| 165 | - //void("void"), | ||
| 166 | - trigger("trigger"), | ||
| 167 | - language_handler("language_handler"), | ||
| 168 | - internal("internal"), | ||
| 169 | - opaque("opaque"), | ||
| 170 | - anyelement("anyelement"), | ||
| 171 | - anynonarray("anynonarray"), | ||
| 172 | - anyenum("anyenum"), | ||
| 173 | - fdw_handler("fdw_handler"), | ||
| 174 | - anyrange("anyrange"), | ||
| 175 | - smalldatetime("smalldatetime"), | ||
| 176 | - _smalldatetime("_smalldatetime"), | ||
| 177 | - hll("hll"), | ||
| 178 | - _hll("_hll"), | ||
| 179 | - hll_hashval("hll_hashval"), | ||
| 180 | - _hll_hashval("_hll_hashval"), | ||
| 181 | - hll_trans_type("hll_trans_type"), | ||
| 182 | - _hll_trans_type("_hll_trans_type"), | ||
| 183 | - byteawithoutorderwithequalcol("byteawithoutorderwithequalcol"), | ||
| 184 | - hash16("hash16"), | ||
| 185 | - hash32("hash32"), | ||
| 186 | - _hash16("_hash16"), | ||
| 187 | - _hash32("_hash32"), | ||
| 188 | - byteawithoutordercol("byteawithoutordercol"), | ||
| 189 | - _byteawithoutorderwithequalcol("_byteawithoutorderwithequalcol"), | ||
| 190 | - _byteawithoutordercol("_byteawithoutordercol"), | ||
| 191 | - tdigestdata("tdigestdata"), | ||
| 192 | - _tdigestdata("_tdigestdata"), | ||
| 193 | - anyset("anyset"), | ||
| 194 | - pg_partition("pg_partition"), | ||
| 195 | - pg_attrdef("pg_attrdef"), | ||
| 196 | - pg_constraint("pg_constraint"), | ||
| 197 | - pg_inherits("pg_inherits"), | ||
| 198 | - pg_index("pg_index"), | ||
| 199 | - pg_operator("pg_operator"), | ||
| 200 | - pg_opfamily("pg_opfamily"), | ||
| 201 | - pg_opclass("pg_opclass"), | ||
| 202 | - pg_am("pg_am"), | ||
| 203 | - pg_amop("pg_amop"), | ||
| 204 | - pg_amproc("pg_amproc"), | ||
| 205 | - pg_language("pg_language"), | ||
| 206 | - pg_largeobject_metadata("pg_largeobject_metadata"), | ||
| 207 | - pg_largeobject("pg_largeobject"), | ||
| 208 | - pg_aggregate("pg_aggregate"), | ||
| 209 | - pg_statistic("pg_statistic"), | ||
| 210 | - pg_rewrite("pg_rewrite"), | ||
| 211 | - pg_trigger("pg_trigger"), | ||
| 212 | - pg_description("pg_description"), | ||
| 213 | - pg_cast("pg_cast"), | ||
| 214 | - pg_enum("pg_enum"), | ||
| 215 | - pg_set("pg_set"), | ||
| 216 | - pg_namespace("pg_namespace"), | ||
| 217 | - pg_conversion("pg_conversion"), | ||
| 218 | - pg_depend("pg_depend"), | ||
| 219 | - pg_database("pg_database"), | ||
| 220 | - pg_db_role_setting("pg_db_role_setting"), | ||
| 221 | - pg_tablespace("pg_tablespace"), | ||
| 222 | - pg_pltemplate("pg_pltemplate"), | ||
| 223 | - pg_authid("pg_authid"), | ||
| 224 | - pg_auth_members("pg_auth_members"), | ||
| 225 | - pg_shdepend("pg_shdepend"), | ||
| 226 | - pg_shdescription("pg_shdescription"), | ||
| 227 | - pg_ts_config("pg_ts_config"), | ||
| 228 | - pg_ts_config_map("pg_ts_config_map"), | ||
| 229 | - pg_ts_dict("pg_ts_dict"), | ||
| 230 | - pg_ts_parser("pg_ts_parser"), | ||
| 231 | - pg_ts_template("pg_ts_template"), | ||
| 232 | - pg_auth_history("pg_auth_history"), | ||
| 233 | - pg_user_status("pg_user_status"), | ||
| 234 | - pg_extension("pg_extension"), | ||
| 235 | - pg_obsscaninfo("pg_obsscaninfo"), | ||
| 236 | - pg_foreign_data_wrapper("pg_foreign_data_wrapper"), | ||
| 237 | - pg_foreign_server("pg_foreign_server"), | ||
| 238 | - pg_user_mapping("pg_user_mapping"), | ||
| 239 | - pgxc_class("pgxc_class"), | ||
| 240 | - pgxc_node("pgxc_node"), | ||
| 241 | - pgxc_group("pgxc_group"), | ||
| 242 | - pg_resource_pool("pg_resource_pool"), | ||
| 243 | - pg_workload_group("pg_workload_group"), | ||
| 244 | - pg_app_workloadgroup_mapping("pg_app_workloadgroup_mapping"), | ||
| 245 | - pg_foreign_table("pg_foreign_table"), | ||
| 246 | - pg_rlspolicy("pg_rlspolicy"), | ||
| 247 | - pg_default_acl("pg_default_acl"), | ||
| 248 | - pg_seclabel("pg_seclabel"), | ||
| 249 | - pg_shseclabel("pg_shseclabel"), | ||
| 250 | - pg_collation("pg_collation"), | ||
| 251 | - pg_range("pg_range"), | ||
| 252 | - gs_policy_label("gs_policy_label"), | ||
| 253 | - gs_auditing_policy("gs_auditing_policy"), | ||
| 254 | - gs_auditing_policy_access("gs_auditing_policy_access"), | ||
| 255 | - gs_auditing_policy_privileges("gs_auditing_policy_privileges"), | ||
| 256 | - gs_auditing_policy_filters("gs_auditing_policy_filters"), | ||
| 257 | - gs_masking_policy("gs_masking_policy"), | ||
| 258 | - gs_masking_policy_actions("gs_masking_policy_actions"), | ||
| 259 | - gs_masking_policy_filters("gs_masking_policy_filters"), | ||
| 260 | - gs_encrypted_columns("gs_encrypted_columns"), | ||
| 261 | - gs_column_keys("gs_column_keys"), | ||
| 262 | - gs_column_keys_args("gs_column_keys_args"), | ||
| 263 | - gs_client_global_keys("gs_client_global_keys"), | ||
| 264 | - gs_client_global_keys_args("gs_client_global_keys_args"), | ||
| 265 | - gs_encrypted_proc("gs_encrypted_proc"), | ||
| 266 | - pg_job("pg_job"), | ||
| 267 | - gs_asp("gs_asp"), | ||
| 268 | - pg_job_proc("pg_job_proc"), | ||
| 269 | - pg_extension_data_source("pg_extension_data_source"), | ||
| 270 | - pg_statistic_ext("pg_statistic_ext"), | ||
| 271 | - pg_object("pg_object"), | ||
| 272 | - pg_synonym("pg_synonym"), | ||
| 273 | - gs_obsscaninfo("gs_obsscaninfo"), | ||
| 274 | - pg_directory("pg_directory"), | ||
| 275 | - pg_hashbucket("pg_hashbucket"), | ||
| 276 | - gs_global_chain("gs_global_chain"), | ||
| 277 | - gs_global_config("gs_global_config"), | ||
| 278 | - streaming_stream("streaming_stream"), | ||
| 279 | - streaming_cont_query("streaming_cont_query"), | ||
| 280 | - streaming_reaper_status("streaming_reaper_status"), | ||
| 281 | - gs_matview("gs_matview"), | ||
| 282 | - gs_matview_dependency("gs_matview_dependency"), | ||
| 283 | - pgxc_slice("pgxc_slice"), | ||
| 284 | - gs_opt_model("gs_opt_model"), | ||
| 285 | - gs_model_warehouse("gs_model_warehouse"), | ||
| 286 | - gs_recyclebin("gs_recyclebin"), | ||
| 287 | - gs_txn_snapshot("gs_txn_snapshot"), | ||
| 288 | - gs_job_argument("gs_job_argument"), | ||
| 289 | - gs_job_attribute("gs_job_attribute"), | ||
| 290 | - gs_uid("gs_uid"), | ||
| 291 | - gs_db_privilege("gs_db_privilege"), | ||
| 292 | - pg_replication_origin("pg_replication_origin"), | ||
| 293 | - pg_publication("pg_publication"), | ||
| 294 | - pg_publication_rel("pg_publication_rel"), | ||
| 295 | - pg_subscription("pg_subscription"), | ||
| 296 | - gs_sql_patch("gs_sql_patch"), | ||
| 297 | - pg_subscription_rel("pg_subscription_rel"), | ||
| 298 | - pg_toast_2604("pg_toast_2604"), | ||
| 299 | - pg_toast_2606("pg_toast_2606"), | ||
| 300 | - pg_toast_2609("pg_toast_2609"), | ||
| 301 | - pg_toast_1255("pg_toast_1255"), | ||
| 302 | - pg_toast_2618("pg_toast_2618"), | ||
| 303 | - pg_toast_3254("pg_toast_3254"), | ||
| 304 | - pg_toast_3596("pg_toast_3596"), | ||
| 305 | - pg_toast_2619("pg_toast_2619"), | ||
| 306 | - pg_toast_3220("pg_toast_3220"), | ||
| 307 | - pg_toast_2620("pg_toast_2620"), | ||
| 308 | - pg_toast_9016("pg_toast_9016"), | ||
| 309 | - pg_toast_9001("pg_toast_9001"), | ||
| 310 | - pg_toast_9027("pg_toast_9027"), | ||
| 311 | - pg_toast_7815("pg_toast_7815"), | ||
| 312 | - pg_toast_5818("pg_toast_5818"), | ||
| 313 | - pg_toast_3991("pg_toast_3991"), | ||
| 314 | - pg_toast_2396("pg_toast_2396"), | ||
| 315 | - pg_toast_2964("pg_toast_2964"), | ||
| 316 | - pg_toast_9014("pg_toast_9014"), | ||
| 317 | - pgxc_prepared_xacts("pgxc_prepared_xacts"), | ||
| 318 | - pg_roles("pg_roles"), | ||
| 319 | - pg_shadow("pg_shadow"), | ||
| 320 | - pg_group("pg_group"), | ||
| 321 | - pg_user("pg_user"), | ||
| 322 | - pg_rules("pg_rules"), | ||
| 323 | - gs_labels("gs_labels"), | ||
| 324 | - gs_auditing_access("gs_auditing_access"), | ||
| 325 | - gs_auditing_privilege("gs_auditing_privilege"), | ||
| 326 | - gs_auditing("gs_auditing"), | ||
| 327 | - gs_masking("gs_masking"), | ||
| 328 | - pg_rlspolicies("pg_rlspolicies"), | ||
| 329 | - pg_views("pg_views"), | ||
| 330 | - pg_tables("pg_tables"), | ||
| 331 | - gs_matviews("gs_matviews"), | ||
| 332 | - pg_indexes("pg_indexes"), | ||
| 333 | - pg_gtt_relstats("pg_gtt_relstats"), | ||
| 334 | - pg_gtt_attached_pids("pg_gtt_attached_pids"), | ||
| 335 | - pg_gtt_stats("pg_gtt_stats"), | ||
| 336 | - pg_stats("pg_stats"), | ||
| 337 | - pg_ext_stats("pg_ext_stats"), | ||
| 338 | - pg_locks("pg_locks"), | ||
| 339 | - pg_cursors("pg_cursors"), | ||
| 340 | - pg_available_extensions("pg_available_extensions"), | ||
| 341 | - pg_available_extension_versions("pg_available_extension_versions"), | ||
| 342 | - pg_prepared_xacts("pg_prepared_xacts"), | ||
| 343 | - pg_prepared_statements("pg_prepared_statements"), | ||
| 344 | - pg_seclabels("pg_seclabels"), | ||
| 345 | - pg_settings("pg_settings"), | ||
| 346 | - pg_timezone_abbrevs("pg_timezone_abbrevs"), | ||
| 347 | - pg_timezone_names("pg_timezone_names"), | ||
| 348 | - pg_control_group_config("pg_control_group_config"), | ||
| 349 | - pg_stat_all_tables("pg_stat_all_tables"), | ||
| 350 | - pg_stat_xact_all_tables("pg_stat_xact_all_tables"), | ||
| 351 | - pg_stat_sys_tables("pg_stat_sys_tables"), | ||
| 352 | - pg_stat_xact_sys_tables("pg_stat_xact_sys_tables"), | ||
| 353 | - pg_stat_user_tables("pg_stat_user_tables"), | ||
| 354 | - pg_stat_xact_user_tables("pg_stat_xact_user_tables"), | ||
| 355 | - pg_statio_all_tables("pg_statio_all_tables"), | ||
| 356 | - pg_statio_sys_tables("pg_statio_sys_tables"), | ||
| 357 | - pg_statio_user_tables("pg_statio_user_tables"), | ||
| 358 | - pg_stat_all_indexes("pg_stat_all_indexes"), | ||
| 359 | - pg_stat_sys_indexes("pg_stat_sys_indexes"), | ||
| 360 | - pg_stat_user_indexes("pg_stat_user_indexes"), | ||
| 361 | - pg_statio_all_indexes("pg_statio_all_indexes"), | ||
| 362 | - pg_statio_sys_indexes("pg_statio_sys_indexes"), | ||
| 363 | - pg_statio_user_indexes("pg_statio_user_indexes"), | ||
| 364 | - pg_statio_all_sequences("pg_statio_all_sequences"), | ||
| 365 | - pg_statio_sys_sequences("pg_statio_sys_sequences"), | ||
| 366 | - pg_statio_user_sequences("pg_statio_user_sequences"), | ||
| 367 | - pg_stat_activity("pg_stat_activity"), | ||
| 368 | - pg_stat_activity_ng("pg_stat_activity_ng"), | ||
| 369 | - pg_session_wlmstat("pg_session_wlmstat"), | ||
| 370 | - pg_wlm_statistics("pg_wlm_statistics"), | ||
| 371 | - gs_session_memory_statistics("gs_session_memory_statistics"), | ||
| 372 | - pg_session_iostat("pg_session_iostat"), | ||
| 373 | - gs_cluster_resource_info("gs_cluster_resource_info"), | ||
| 374 | - gs_session_cpu_statistics("gs_session_cpu_statistics"), | ||
| 375 | - gs_wlm_session_statistics("gs_wlm_session_statistics"), | ||
| 376 | - pg_total_user_resource_info_oid("pg_total_user_resource_info_oid"), | ||
| 377 | - pg_total_user_resource_info("pg_total_user_resource_info"), | ||
| 378 | - gs_wlm_user_resource_history("gs_wlm_user_resource_history"), | ||
| 379 | - pg_toast_12290("pg_toast_12290"), | ||
| 380 | - gs_wlm_instance_history("gs_wlm_instance_history"), | ||
| 381 | - pg_toast_12297("pg_toast_12297"), | ||
| 382 | - gs_wlm_session_query_info_all("gs_wlm_session_query_info_all"), | ||
| 383 | - pg_toast_12303("pg_toast_12303"), | ||
| 384 | - gs_wlm_session_info_all("gs_wlm_session_info_all"), | ||
| 385 | - gs_wlm_session_info("gs_wlm_session_info"), | ||
| 386 | - gs_wlm_session_history("gs_wlm_session_history"), | ||
| 387 | - gs_wlm_cgroup_info("gs_wlm_cgroup_info"), | ||
| 388 | - gs_wlm_user_info("gs_wlm_user_info"), | ||
| 389 | - gs_wlm_resource_pool("gs_wlm_resource_pool"), | ||
| 390 | - gs_wlm_rebuild_user_resource_pool("gs_wlm_rebuild_user_resource_pool"), | ||
| 391 | - gs_wlm_workload_records("gs_wlm_workload_records"), | ||
| 392 | - gs_os_run_info("gs_os_run_info"), | ||
| 393 | - gs_session_memory_context("gs_session_memory_context"), | ||
| 394 | - gs_thread_memory_context("gs_thread_memory_context"), | ||
| 395 | - gs_shared_memory_detail("gs_shared_memory_detail"), | ||
| 396 | - gs_instance_time("gs_instance_time"), | ||
| 397 | - gs_session_time("gs_session_time"), | ||
| 398 | - gs_session_memory("gs_session_memory"), | ||
| 399 | - gs_total_memory_detail("gs_total_memory_detail"), | ||
| 400 | - pg_total_memory_detail("pg_total_memory_detail"), | ||
| 401 | - gs_redo_stat("gs_redo_stat"), | ||
| 402 | - gs_session_stat("gs_session_stat"), | ||
| 403 | - gs_file_stat("gs_file_stat"), | ||
| 404 | - gs_session_memory_detail("gs_session_memory_detail"), | ||
| 405 | - pg_stat_replication("pg_stat_replication"), | ||
| 406 | - pg_replication_slots("pg_replication_slots"), | ||
| 407 | - pg_stat_database("pg_stat_database"), | ||
| 408 | - pg_stat_database_conflicts("pg_stat_database_conflicts"), | ||
| 409 | - pg_stat_user_functions("pg_stat_user_functions"), | ||
| 410 | - pg_stat_xact_user_functions("pg_stat_xact_user_functions"), | ||
| 411 | - pg_stat_bgwriter("pg_stat_bgwriter"), | ||
| 412 | - pg_user_mappings("pg_user_mappings"), | ||
| 413 | - exception("exception"), | ||
| 414 | - pg_thread_wait_status("pg_thread_wait_status"), | ||
| 415 | - pgxc_thread_wait_status("pgxc_thread_wait_status"), | ||
| 416 | - gs_sql_count("gs_sql_count"), | ||
| 417 | - pg_os_threads("pg_os_threads"), | ||
| 418 | - pg_node_env("pg_node_env"), | ||
| 419 | - pg_comm_status("pg_comm_status"), | ||
| 420 | - pg_comm_recv_stream("pg_comm_recv_stream"), | ||
| 421 | - pg_comm_send_stream("pg_comm_send_stream"), | ||
| 422 | - pg_running_xacts("pg_running_xacts"), | ||
| 423 | - pg_variable_info("pg_variable_info"), | ||
| 424 | - pg_get_invalid_backends("pg_get_invalid_backends"), | ||
| 425 | - pg_get_senders_catchup_time("pg_get_senders_catchup_time"), | ||
| 426 | - gs_stat_session_cu("gs_stat_session_cu"), | ||
| 427 | - pg_comm_delay("pg_comm_delay"), | ||
| 428 | - gs_comm_proxy_thread_status("gs_comm_proxy_thread_status"), | ||
| 429 | - gs_all_control_group_info("gs_all_control_group_info"), | ||
| 430 | - mpp_tables("mpp_tables"), | ||
| 431 | - gs_wlm_operator_info("gs_wlm_operator_info"), | ||
| 432 | - pg_toast_12592("pg_toast_12592"), | ||
| 433 | - gs_wlm_operator_statistics("gs_wlm_operator_statistics"), | ||
| 434 | - gs_wlm_operator_history("gs_wlm_operator_history"), | ||
| 435 | - gs_wlm_plan_operator_info("gs_wlm_plan_operator_info"), | ||
| 436 | - pg_toast_12606("pg_toast_12606"), | ||
| 437 | - gs_wlm_plan_operator_history("gs_wlm_plan_operator_history"), | ||
| 438 | - gs_wlm_plan_encoding_table("gs_wlm_plan_encoding_table"), | ||
| 439 | - pg_toast_12616("pg_toast_12616"), | ||
| 440 | - gs_total_nodegroup_memory_detail("gs_total_nodegroup_memory_detail"), | ||
| 441 | - gs_get_control_group_info("gs_get_control_group_info"), | ||
| 442 | - gs_wlm_ec_operator_statistics("gs_wlm_ec_operator_statistics"), | ||
| 443 | - gs_wlm_ec_operator_history("gs_wlm_ec_operator_history"), | ||
| 444 | - gs_wlm_ec_operator_info("gs_wlm_ec_operator_info"), | ||
| 445 | - pg_toast_12639("pg_toast_12639"), | ||
| 446 | - pg_tde_info("pg_tde_info"), | ||
| 447 | - pg_stat_bad_block("pg_stat_bad_block"), | ||
| 448 | - plan_table_data("plan_table_data"), | ||
| 449 | - pg_toast_12654("pg_toast_12654"), | ||
| 450 | - plan_table("plan_table"), | ||
| 451 | - get_global_prepared_xacts("get_global_prepared_xacts"), | ||
| 452 | - statement_history("statement_history"), | ||
| 453 | - pg_toast_12669("pg_toast_12669"), | ||
| 454 | - gs_source("gs_source"), | ||
| 455 | - pg_toast_12675("pg_toast_12675"), | ||
| 456 | - gs_errors("gs_errors"), | ||
| 457 | - pg_toast_12682("pg_toast_12682"), | ||
| 458 | - sys_dummy("sys_dummy"), | ||
| 459 | - bulk_exception("bulk_exception"), | ||
| 460 | - _bulk_exception("_bulk_exception"), | ||
| 461 | - gs_db_privileges("gs_db_privileges"), | ||
| 462 | - gs_gsc_memory_detail("gs_gsc_memory_detail"), | ||
| 463 | - gs_lsc_memory_detail("gs_lsc_memory_detail"), | ||
| 464 | - pg_publication_tables("pg_publication_tables"), | ||
| 465 | - pg_stat_subscription("pg_stat_subscription"), | ||
| 466 | - pg_replication_origin_status("pg_replication_origin_status"), | ||
| 467 | - os_runtime("os_runtime"), | ||
| 468 | - node_name("node_name"), | ||
| 469 | - global_os_runtime("global_os_runtime"), | ||
| 470 | - os_threads("os_threads"), | ||
| 471 | - global_os_threads("global_os_threads"), | ||
| 472 | - instance_time("instance_time"), | ||
| 473 | - global_instance_time("global_instance_time"), | ||
| 474 | - workload_sql_count("workload_sql_count"), | ||
| 475 | - workload_sql_elapse_time("workload_sql_elapse_time"), | ||
| 476 | - summary_workload_sql_count("summary_workload_sql_count"), | ||
| 477 | - summary_workload_sql_elapse_time("summary_workload_sql_elapse_time"), | ||
| 478 | - user_transaction("user_transaction"), | ||
| 479 | - global_user_transaction("global_user_transaction"), | ||
| 480 | - workload_transaction("workload_transaction"), | ||
| 481 | - global_workload_transaction("global_workload_transaction"), | ||
| 482 | - summary_workload_transaction("summary_workload_transaction"), | ||
| 483 | - session_stat("session_stat"), | ||
| 484 | - global_session_stat("global_session_stat"), | ||
| 485 | - session_time("session_time"), | ||
| 486 | - global_session_time("global_session_time"), | ||
| 487 | - session_memory("session_memory"), | ||
| 488 | - global_session_memory("global_session_memory"), | ||
| 489 | - session_memory_detail("session_memory_detail"), | ||
| 490 | - global_session_memory_detail("global_session_memory_detail"), | ||
| 491 | - session_cpu_runtime("session_cpu_runtime"), | ||
| 492 | - session_memory_runtime("session_memory_runtime"), | ||
| 493 | - session_stat_activity("session_stat_activity"), | ||
| 494 | - global_session_stat_activity("global_session_stat_activity"), | ||
| 495 | - thread_wait_status("thread_wait_status"), | ||
| 496 | - global_thread_wait_status("global_thread_wait_status"), | ||
| 497 | - wlm_user_resource_runtime("wlm_user_resource_runtime"), | ||
| 498 | - wlm_user_resource_config("wlm_user_resource_config"), | ||
| 499 | - operator_history_table("operator_history_table"), | ||
| 500 | - global_operator_history_table("global_operator_history_table"), | ||
| 501 | - operator_history("operator_history"), | ||
| 502 | - global_operator_history("global_operator_history"), | ||
| 503 | - operator_runtime("operator_runtime"), | ||
| 504 | - global_operator_runtime("global_operator_runtime"), | ||
| 505 | - statement_complex_history("statement_complex_history"), | ||
| 506 | - global_statement_complex_history("global_statement_complex_history"), | ||
| 507 | - statement_complex_history_table("statement_complex_history_table"), | ||
| 508 | - global_statement_complex_history_table("global_statement_complex_history_table"), | ||
| 509 | - statement_complex_runtime("statement_complex_runtime"), | ||
| 510 | - global_statement_complex_runtime("global_statement_complex_runtime"), | ||
| 511 | - statement_iostat_complex_runtime("statement_iostat_complex_runtime"), | ||
| 512 | - statement_wlmstat_complex_runtime("statement_wlmstat_complex_runtime"), | ||
| 513 | - memory_node_detail("memory_node_detail"), | ||
| 514 | - global_memory_node_detail("global_memory_node_detail"), | ||
| 515 | - shared_memory_detail("shared_memory_detail"), | ||
| 516 | - global_shared_memory_detail("global_shared_memory_detail"), | ||
| 517 | - statio_all_indexes("statio_all_indexes"), | ||
| 518 | - global_statio_all_indexes("global_statio_all_indexes"), | ||
| 519 | - summary_statio_all_indexes("summary_statio_all_indexes"), | ||
| 520 | - statio_all_sequences("statio_all_sequences"), | ||
| 521 | - global_statio_all_sequences("global_statio_all_sequences"), | ||
| 522 | - summary_statio_all_sequences("summary_statio_all_sequences"), | ||
| 523 | - statio_all_tables("statio_all_tables"), | ||
| 524 | - global_statio_all_tables("global_statio_all_tables"), | ||
| 525 | - summary_statio_all_tables("summary_statio_all_tables"), | ||
| 526 | - statio_sys_indexes("statio_sys_indexes"), | ||
| 527 | - global_statio_sys_indexes("global_statio_sys_indexes"), | ||
| 528 | - summary_statio_sys_indexes("summary_statio_sys_indexes"), | ||
| 529 | - statio_sys_sequences("statio_sys_sequences"), | ||
| 530 | - global_statio_sys_sequences("global_statio_sys_sequences"), | ||
| 531 | - summary_statio_sys_sequences("summary_statio_sys_sequences"), | ||
| 532 | - statio_sys_tables("statio_sys_tables"), | ||
| 533 | - global_statio_sys_tables("global_statio_sys_tables"), | ||
| 534 | - summary_statio_sys_tables("summary_statio_sys_tables"), | ||
| 535 | - statio_user_indexes("statio_user_indexes"), | ||
| 536 | - global_statio_user_indexes("global_statio_user_indexes"), | ||
| 537 | - summary_statio_user_indexes("summary_statio_user_indexes"), | ||
| 538 | - statio_user_sequences("statio_user_sequences"), | ||
| 539 | - global_statio_user_sequences("global_statio_user_sequences"), | ||
| 540 | - summary_statio_user_sequences("summary_statio_user_sequences"), | ||
| 541 | - statio_user_tables("statio_user_tables"), | ||
| 542 | - global_statio_user_tables("global_statio_user_tables"), | ||
| 543 | - summary_statio_user_tables("summary_statio_user_tables"), | ||
| 544 | - global_stat_db_cu("global_stat_db_cu"), | ||
| 545 | - global_stat_session_cu("global_stat_session_cu"), | ||
| 546 | - stat_all_tables("stat_all_tables"), | ||
| 547 | - global_stat_all_tables("global_stat_all_tables"), | ||
| 548 | - summary_stat_all_tables("summary_stat_all_tables"), | ||
| 549 | - stat_all_indexes("stat_all_indexes"), | ||
| 550 | - global_stat_all_indexes("global_stat_all_indexes"), | ||
| 551 | - summary_stat_all_indexes("summary_stat_all_indexes"), | ||
| 552 | - stat_sys_tables("stat_sys_tables"), | ||
| 553 | - global_stat_sys_tables("global_stat_sys_tables"), | ||
| 554 | - summary_stat_sys_tables("summary_stat_sys_tables"), | ||
| 555 | - stat_sys_indexes("stat_sys_indexes"), | ||
| 556 | - global_stat_sys_indexes("global_stat_sys_indexes"), | ||
| 557 | - summary_stat_sys_indexes("summary_stat_sys_indexes"), | ||
| 558 | - stat_user_tables("stat_user_tables"), | ||
| 559 | - global_stat_user_tables("global_stat_user_tables"), | ||
| 560 | - summary_stat_user_tables("summary_stat_user_tables"), | ||
| 561 | - stat_user_indexes("stat_user_indexes"), | ||
| 562 | - global_stat_user_indexes("global_stat_user_indexes"), | ||
| 563 | - summary_stat_user_indexes("summary_stat_user_indexes"), | ||
| 564 | - stat_database("stat_database"), | ||
| 565 | - global_stat_database("global_stat_database"), | ||
| 566 | - summary_stat_database("summary_stat_database"), | ||
| 567 | - stat_database_conflicts("stat_database_conflicts"), | ||
| 568 | - global_stat_database_conflicts("global_stat_database_conflicts"), | ||
| 569 | - summary_stat_database_conflicts("summary_stat_database_conflicts"), | ||
| 570 | - stat_xact_all_tables("stat_xact_all_tables"), | ||
| 571 | - global_stat_xact_all_tables("global_stat_xact_all_tables"), | ||
| 572 | - summary_stat_xact_all_tables("summary_stat_xact_all_tables"), | ||
| 573 | - stat_xact_sys_tables("stat_xact_sys_tables"), | ||
| 574 | - global_stat_xact_sys_tables("global_stat_xact_sys_tables"), | ||
| 575 | - summary_stat_xact_sys_tables("summary_stat_xact_sys_tables"), | ||
| 576 | - stat_xact_user_tables("stat_xact_user_tables"), | ||
| 577 | - global_stat_xact_user_tables("global_stat_xact_user_tables"), | ||
| 578 | - summary_stat_xact_user_tables("summary_stat_xact_user_tables"), | ||
| 579 | - stat_user_functions("stat_user_functions"), | ||
| 580 | - global_stat_user_functions("global_stat_user_functions"), | ||
| 581 | - summary_stat_user_functions("summary_stat_user_functions"), | ||
| 582 | - stat_xact_user_functions("stat_xact_user_functions"), | ||
| 583 | - global_stat_xact_user_functions("global_stat_xact_user_functions"), | ||
| 584 | - summary_stat_xact_user_functions("summary_stat_xact_user_functions"), | ||
| 585 | - stat_bad_block("stat_bad_block"), | ||
| 586 | - global_stat_bad_block("global_stat_bad_block"), | ||
| 587 | - summary_stat_bad_block("summary_stat_bad_block"), | ||
| 588 | - file_redo_iostat("file_redo_iostat"), | ||
| 589 | - global_file_redo_iostat("global_file_redo_iostat"), | ||
| 590 | - summary_file_redo_iostat("summary_file_redo_iostat"), | ||
| 591 | - local_rel_iostat("local_rel_iostat"), | ||
| 592 | - global_rel_iostat("global_rel_iostat"), | ||
| 593 | - summary_rel_iostat("summary_rel_iostat"), | ||
| 594 | - file_iostat("file_iostat"), | ||
| 595 | - global_file_iostat("global_file_iostat"), | ||
| 596 | - summary_file_iostat("summary_file_iostat"), | ||
| 597 | - locks("locks"), | ||
| 598 | - global_locks("global_locks"), | ||
| 599 | - replication_slots("replication_slots"), | ||
| 600 | - global_replication_slots("global_replication_slots"), | ||
| 601 | - bgwriter_stat("bgwriter_stat"), | ||
| 602 | - global_bgwriter_stat("global_bgwriter_stat"), | ||
| 603 | - replication_stat("replication_stat"), | ||
| 604 | - global_replication_stat("global_replication_stat"), | ||
| 605 | - transactions_running_xacts("transactions_running_xacts"), | ||
| 606 | - global_transactions_running_xacts("global_transactions_running_xacts"), | ||
| 607 | - summary_transactions_running_xacts("summary_transactions_running_xacts"), | ||
| 608 | - transactions_prepared_xacts("transactions_prepared_xacts"), | ||
| 609 | - global_transactions_prepared_xacts("global_transactions_prepared_xacts"), | ||
| 610 | - summary_transactions_prepared_xacts("summary_transactions_prepared_xacts"), | ||
| 611 | - statement("statement"), | ||
| 612 | - summary_statement("summary_statement"), | ||
| 613 | - statement_count("statement_count"), | ||
| 614 | - global_statement_count("global_statement_count"), | ||
| 615 | - summary_statement_count("summary_statement_count"), | ||
| 616 | - config_settings("config_settings"), | ||
| 617 | - global_config_settings("global_config_settings"), | ||
| 618 | - wait_events("wait_events"), | ||
| 619 | - global_wait_events("global_wait_events"), | ||
| 620 | - statement_responsetime_percentile("statement_responsetime_percentile"), | ||
| 621 | - user_login("user_login"), | ||
| 622 | - summary_user_login("summary_user_login"), | ||
| 623 | - class_vital_info("class_vital_info"), | ||
| 624 | - global_candidate_status("global_candidate_status"), | ||
| 625 | - global_ckpt_status("global_ckpt_status"), | ||
| 626 | - global_double_write_status("global_double_write_status"), | ||
| 627 | - global_single_flush_dw_status("global_single_flush_dw_status"), | ||
| 628 | - global_pagewriter_status("global_pagewriter_status"), | ||
| 629 | - global_record_reset_time("global_record_reset_time"), | ||
| 630 | - global_redo_status("global_redo_status"), | ||
| 631 | - global_rto_status("global_rto_status"), | ||
| 632 | - global_streaming_hadr_rto_and_rpo_stat("global_streaming_hadr_rto_and_rpo_stat"), | ||
| 633 | - global_recovery_status("global_recovery_status"), | ||
| 634 | - local_threadpool_status("local_threadpool_status"), | ||
| 635 | - global_threadpool_status("global_threadpool_status"), | ||
| 636 | - gs_slow_query_info("gs_slow_query_info"), | ||
| 637 | - gs_slow_query_history("gs_slow_query_history"), | ||
| 638 | - global_slow_query_history("global_slow_query_history"), | ||
| 639 | - global_slow_query_info("global_slow_query_info"), | ||
| 640 | - global_plancache_status("global_plancache_status"), | ||
| 641 | - global_plancache_clean("global_plancache_clean"), | ||
| 642 | - local_active_session("local_active_session"), | ||
| 643 | - cardinal_number("cardinal_number"), | ||
| 644 | - character_data("character_data"), | ||
| 645 | - sql_identifier("sql_identifier"), | ||
| 646 | - information_schema_catalog_name("information_schema_catalog_name"), | ||
| 647 | - time_stamp("time_stamp"), | ||
| 648 | - yes_or_no("yes_or_no"), | ||
| 649 | - applicable_roles("applicable_roles"), | ||
| 650 | - administrable_role_authorizations("administrable_role_authorizations"), | ||
| 651 | - attributes("attributes"), | ||
| 652 | - character_sets("character_sets"), | ||
| 653 | - check_constraint_routine_usage("check_constraint_routine_usage"), | ||
| 654 | - check_constraints("check_constraints"), | ||
| 655 | - collations("collations"), | ||
| 656 | - collation_character_set_applicability("collation_character_set_applicability"), | ||
| 657 | - column_domain_usage("column_domain_usage"), | ||
| 658 | - column_privileges("column_privileges"), | ||
| 659 | - column_udt_usage("column_udt_usage"), | ||
| 660 | - columns("columns"), | ||
| 661 | - constraint_column_usage("constraint_column_usage"), | ||
| 662 | - constraint_table_usage("constraint_table_usage"), | ||
| 663 | - domain_constraints("domain_constraints"), | ||
| 664 | - domain_udt_usage("domain_udt_usage"), | ||
| 665 | - domains("domains"), | ||
| 666 | - enabled_roles("enabled_roles"), | ||
| 667 | - key_column_usage("key_column_usage"), | ||
| 668 | - parameters("parameters"), | ||
| 669 | - referential_constraints("referential_constraints"), | ||
| 670 | - role_column_grants("role_column_grants"), | ||
| 671 | - routine_privileges("routine_privileges"), | ||
| 672 | - role_routine_grants("role_routine_grants"), | ||
| 673 | - routines("routines"), | ||
| 674 | - schemata("schemata"), | ||
| 675 | - sequences("sequences"), | ||
| 676 | - sql_features("sql_features"), | ||
| 677 | - pg_toast_14838("pg_toast_14838"), | ||
| 678 | - sql_implementation_info("sql_implementation_info"), | ||
| 679 | - pg_toast_14843("pg_toast_14843"), | ||
| 680 | - sql_languages("sql_languages"), | ||
| 681 | - pg_toast_14848("pg_toast_14848"), | ||
| 682 | - sql_packages("sql_packages"), | ||
| 683 | - pg_toast_14853("pg_toast_14853"), | ||
| 684 | - sql_parts("sql_parts"), | ||
| 685 | - pg_toast_14858("pg_toast_14858"), | ||
| 686 | - sql_sizing("sql_sizing"), | ||
| 687 | - pg_toast_14863("pg_toast_14863"), | ||
| 688 | - sql_sizing_profiles("sql_sizing_profiles"), | ||
| 689 | - pg_toast_14868("pg_toast_14868"), | ||
| 690 | - table_constraints("table_constraints"), | ||
| 691 | - table_privileges("table_privileges"), | ||
| 692 | - role_table_grants("role_table_grants"), | ||
| 693 | - tables("tables"), | ||
| 694 | - triggered_update_columns("triggered_update_columns"), | ||
| 695 | - triggers("triggers"), | ||
| 696 | - udt_privileges("udt_privileges"), | ||
| 697 | - role_udt_grants("role_udt_grants"), | ||
| 698 | - usage_privileges("usage_privileges"), | ||
| 699 | - role_usage_grants("role_usage_grants"), | ||
| 700 | - user_defined_types("user_defined_types"), | ||
| 701 | - view_column_usage("view_column_usage"), | ||
| 702 | - view_routine_usage("view_routine_usage"), | ||
| 703 | - view_table_usage("view_table_usage"), | ||
| 704 | - views("views"), | ||
| 705 | - data_type_privileges("data_type_privileges"), | ||
| 706 | - element_types("element_types"), | ||
| 707 | - _pg_foreign_table_columns("_pg_foreign_table_columns"), | ||
| 708 | - column_options("column_options"), | ||
| 709 | - _pg_foreign_data_wrappers("_pg_foreign_data_wrappers"), | ||
| 710 | - foreign_data_wrapper_options("foreign_data_wrapper_options"), | ||
| 711 | - foreign_data_wrappers("foreign_data_wrappers"), | ||
| 712 | - _pg_foreign_servers("_pg_foreign_servers"), | ||
| 713 | - foreign_server_options("foreign_server_options"), | ||
| 714 | - foreign_servers("foreign_servers"), | ||
| 715 | - _pg_foreign_tables("_pg_foreign_tables"), | ||
| 716 | - foreign_table_options("foreign_table_options"), | ||
| 717 | - foreign_tables("foreign_tables"), | ||
| 718 | - _pg_user_mappings("_pg_user_mappings"), | ||
| 719 | - user_mapping_options("user_mapping_options"), | ||
| 720 | - user_mappings("user_mappings"), | ||
| 721 | - hstore("hstore"), | ||
| 722 | - _hstore("_hstore"), | ||
| 723 | - snapshot_name("snapshot_name"), | ||
| 724 | - snapshot_sequence("snapshot_sequence"), | ||
| 725 | - snapshot("snapshot"), | ||
| 726 | - pg_toast_15057("pg_toast_15057"), | ||
| 727 | - breakpoint("breakpoint"), | ||
| 728 | - _breakpoint("_breakpoint"), | ||
| 729 | - frame("frame"), | ||
| 730 | - _frame("_frame"), | ||
| 731 | - var("var"), | ||
| 732 | - _var("_var"), | ||
| 733 | - proxyinfo("proxyinfo"), | ||
| 734 | - _proxyinfo("_proxyinfo"), | ||
| 735 | - targetinfo("targetinfo"), | ||
| 736 | - _targetinfo("_targetinfo"), | ||
| 737 | - | ||
| 738 | - ; | ||
| 739 | 12 | ||
| 740 | private String type; | 13 | private String type; |
| 741 | 14 | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.listener; | 5 | package com.nctigba.datastudio.listener; |
| 2 | 6 | ||
| 3 | import com.gitee.starblues.spring.MainApplicationContext; | 7 | import com.gitee.starblues.spring.MainApplicationContext; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model; | 5 | package com.nctigba.datastudio.model; |
| 2 | 6 | ||
| 3 | 7 | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model; | 5 | package com.nctigba.datastudio.model; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -36,15 +40,15 @@ public class PublicParamReq { | |||
| 36 | // function/procedure schema | 40 | // function/procedure schema |
| 37 | private String schema; | 41 | private String schema; |
| 38 | 42 | ||
| 39 | - // is debug | ||
| 40 | - private boolean isDebug; | ||
| 41 | - | ||
| 42 | // window name | 43 | // window name |
| 43 | private String windowName; | 44 | private String windowName; |
| 44 | 45 | ||
| 45 | // old window name | 46 | // old window name |
| 46 | private String oldWindowName; | 47 | private String oldWindowName; |
| 47 | 48 | ||
| 49 | + // root window name | ||
| 50 | + private String rootWindowName; | ||
| 51 | + | ||
| 48 | // is close window | 52 | // is close window |
| 49 | private boolean isCloseWindow; | 53 | private boolean isCloseWindow; |
| 50 | 54 | ||
| @@ -54,6 +58,13 @@ public class PublicParamReq { | |||
| 54 | // language | 58 | // language |
| 55 | private String language; | 59 | private String language; |
| 56 | 60 | ||
| 61 | + // oid | ||
| 62 | + private String oid; | ||
| 63 | + | ||
| 64 | + private boolean isContinue; | ||
| 65 | + | ||
| 66 | + private boolean isCoverage; | ||
| 67 | + | ||
| 57 | 68 | ||
| 58 | public String toString() { | 69 | public String toString() { |
| 59 | return "PublicParamReq{" + | 70 | return "PublicParamReq{" + |
| @@ -65,12 +76,15 @@ public class PublicParamReq { | |||
| 65 | ", line=" + line + | 76 | ", line=" + line + |
| 66 | ", fullName='" + fullName + '\'' + | 77 | ", fullName='" + fullName + '\'' + |
| 67 | ", schema='" + schema + '\'' + | 78 | ", schema='" + schema + '\'' + |
| 68 | - ", isDebug=" + isDebug + | ||
| 69 | ", windowName='" + windowName + '\'' + | 79 | ", windowName='" + windowName + '\'' + |
| 70 | ", oldWindowName='" + oldWindowName + '\'' + | 80 | ", oldWindowName='" + oldWindowName + '\'' + |
| 81 | + ", rootWindowName='" + rootWindowName + '\'' + | ||
| 71 | ", isCloseWindow='" + isCloseWindow + '\'' + | 82 | ", isCloseWindow='" + isCloseWindow + '\'' + |
| 72 | ", uuid='" + uuid + '\'' + | 83 | ", uuid='" + uuid + '\'' + |
| 73 | ", language='" + language + '\'' + | 84 | ", language='" + language + '\'' + |
| 85 | + ", oid='" + oid + '\'' + | ||
| 86 | + ", isContinue='" + isContinue + '\'' + | ||
| 87 | + ", isCoverage='" + isCoverage + '\'' + | ||
| 74 | '}'; | 88 | '}'; |
| 75 | } | 89 | } |
| 76 | } | 90 | } |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.entity.DatabaseConnectionDO; | 7 | import com.nctigba.datastudio.model.entity.DatabaseConnectionDO; |
| @@ -19,6 +23,7 @@ public class ConnectionDTO { | |||
| 19 | private String url; | 23 | private String url; |
| 20 | private String dbUser; | 24 | private String dbUser; |
| 21 | private String dbPassword; | 25 | private String dbPassword; |
| 26 | + private String type; | ||
| 22 | 27 | ||
| 23 | 28 | ||
| 24 | public void setConnectionDTO(DatabaseConnectionUrlDO databaseConnectionUrlDO) { | 29 | public void setConnectionDTO(DatabaseConnectionUrlDO databaseConnectionUrlDO) { |
| @@ -27,6 +32,7 @@ public class ConnectionDTO { | |||
| 27 | this.url = databaseConnectionUrlDO.getUrl(); | 32 | this.url = databaseConnectionUrlDO.getUrl(); |
| 28 | this.dbUser = databaseConnectionUrlDO.getUserName(); | 33 | this.dbUser = databaseConnectionUrlDO.getUserName(); |
| 29 | this.dbPassword = databaseConnectionUrlDO.getPassword(); | 34 | this.dbPassword = databaseConnectionUrlDO.getPassword(); |
| 35 | + this.type = databaseConnectionUrlDO.getType(); | ||
| 30 | } | 36 | } |
| 31 | 37 | ||
| 32 | public void setIpConnectionDTO(DatabaseConnectionDO databaseConnectionDO) { | 38 | public void setIpConnectionDTO(DatabaseConnectionDO databaseConnectionDO) { |
| @@ -35,6 +41,7 @@ public class ConnectionDTO { | |||
| 35 | this.url = GET_URL_JDBC + databaseConnectionDO.getIp() + ":" + databaseConnectionDO.getPort() + "/" + databaseConnectionDO.getDataName() + CONFIGURE_TIME; | 41 | this.url = GET_URL_JDBC + databaseConnectionDO.getIp() + ":" + databaseConnectionDO.getPort() + "/" + databaseConnectionDO.getDataName() + CONFIGURE_TIME; |
| 36 | this.dbUser = databaseConnectionDO.getUserName(); | 42 | this.dbUser = databaseConnectionDO.getUserName(); |
| 37 | this.dbPassword = databaseConnectionDO.getPassword(); | 43 | this.dbPassword = databaseConnectionDO.getPassword(); |
| 44 | + this.type = databaseConnectionDO.getType(); | ||
| 38 | } | 45 | } |
| 39 | 46 | ||
| 40 | public void updataConnectionDTO(ConnectionDTO aon, String socketSet) { | 47 | public void updataConnectionDTO(ConnectionDTO aon, String socketSet) { |
| @@ -44,6 +51,7 @@ public class ConnectionDTO { | |||
| 44 | this.url = aon.getUrl(); | 51 | this.url = aon.getUrl(); |
| 45 | this.dbUser = aon.getDbUser(); | 52 | this.dbUser = aon.getDbUser(); |
| 46 | this.dbPassword = aon.getDbPassword(); | 53 | this.dbPassword = aon.getDbPassword(); |
| 54 | + this.type = aon.getType(); | ||
| 47 | } | 55 | } |
| 48 | 56 | ||
| 49 | public void updataConnectionDTO(ConnectionDTO aon) { | 57 | public void updataConnectionDTO(ConnectionDTO aon) { |
| @@ -52,6 +60,7 @@ public class ConnectionDTO { | |||
| 52 | this.url = aon.getUrl(); | 60 | this.url = aon.getUrl(); |
| 53 | this.dbUser = aon.getDbUser(); | 61 | this.dbUser = aon.getDbUser(); |
| 54 | this.dbPassword = aon.getDbPassword(); | 62 | this.dbPassword = aon.getDbPassword(); |
| 63 | + this.type = aon.getType(); | ||
| 55 | } | 64 | } |
| 56 | 65 | ||
| 57 | public void reduceConnectionDTO(ConnectionDTO aon, String socketSet) { | 66 | public void reduceConnectionDTO(ConnectionDTO aon, String socketSet) { |
| @@ -61,5 +70,6 @@ public class ConnectionDTO { | |||
| 61 | this.url = aon.getUrl(); | 70 | this.url = aon.getUrl(); |
| 62 | this.dbUser = aon.getDbUser(); | 71 | this.dbUser = aon.getDbUser(); |
| 63 | this.dbPassword = aon.getDbPassword(); | 72 | this.dbPassword = aon.getDbPassword(); |
| 73 | + this.type = aon.getType(); | ||
| 64 | } | 74 | } |
| 65 | } | 75 | } |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -0,0 +1,24 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.dto; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.NoArgsConstructor; | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + | ||
| 12 | +public class ConstraintDTO { | ||
| 13 | + private String attname; //attribute name | ||
| 14 | + private String conname; //Constraint name | ||
| 15 | + private String oldConname; //old Constraint name | ||
| 16 | + private String contype; //Constraint type | ||
| 17 | + private String constraintdef; | ||
| 18 | + private Boolean condeferrable; //DEFERRED | ||
| 19 | + private String nspname; //Foreign name space name | ||
| 20 | + private String tbname; //Foreign table name | ||
| 21 | + private String colname; //Foreign primary column | ||
| 22 | + private String description; | ||
| 23 | + private int type; //1=add 2=delete 3=update | ||
| 24 | +} | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import io.swagger.annotations.ApiModel; | 7 | import io.swagger.annotations.ApiModel; |
| @@ -6,6 +10,7 @@ import lombok.Data; | |||
| 6 | import lombok.NoArgsConstructor; | 10 | import lombok.NoArgsConstructor; |
| 7 | 11 | ||
| 8 | import java.util.List; | 12 | import java.util.List; |
| 13 | +import java.util.Map; | ||
| 9 | 14 | ||
| 10 | 15 | ||
| 11 | 16 | ||
| @@ -15,18 +20,18 @@ public class DataListDTO { | |||
| 15 | private String schema_name; | 20 | private String schema_name; |
| 16 | 21 | ||
| 17 | 22 | ||
| 18 | - private List<String> table; | 23 | + private List<Map<String, String>> table; |
| 19 | 24 | ||
| 20 | 25 | ||
| 21 | - private List<String> view; | 26 | + private List<Map<String, String>> view; |
| 22 | 27 | ||
| 23 | 28 | ||
| 24 | - private List<String> fun_pro; | 29 | + private List<Map<String, String>> fun_pro; |
| 25 | 30 | ||
| 26 | 31 | ||
| 27 | - private List<String> synonym; | 32 | + private List<Map<String, String>> synonym; |
| 28 | 33 | ||
| 29 | 34 | ||
| 30 | - private List<String> sequence; | 35 | + private List<Map<String, String>> sequence; |
| 31 | 36 | ||
| 32 | } | 37 | } |
| @@ -0,0 +1,24 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.dto; | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +import lombok.Data; | ||
| 9 | +import lombok.NoArgsConstructor; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +public class DatabaseConstraintDTO { | ||
| 16 | + private String uuid; | ||
| 17 | + private String webUser; | ||
| 18 | + private String connectionName; | ||
| 19 | + private String schema; | ||
| 20 | + private String sequenceName; | ||
| 21 | + private String tableName; | ||
| 22 | + private List<ConstraintDTO> constraints; | ||
| 23 | +} | ||
| 24 | + | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/model/dto/DatabaseConstraintPkDTO.java+19-0
| @@ -0,0 +1,19 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.dto; | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +import lombok.Data; | ||
| 9 | +import lombok.NoArgsConstructor; | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + | ||
| 13 | +public class DatabaseConstraintPkDTO { | ||
| 14 | + private String uuid; | ||
| 15 | + private String schema; | ||
| 16 | + private String tableName; | ||
| 17 | + private String column; | ||
| 18 | +} | ||
| 19 | + | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/model/dto/DatabaseCreUpdColumnDTO.java+34-0
| @@ -0,0 +1,34 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.dto; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.NoArgsConstructor; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +public class DatabaseCreUpdColumnDTO { | ||
| 15 | + private String uuid; | ||
| 16 | + private List<CreUpdColumnDataDTO> data; | ||
| 17 | + private String oid; | ||
| 18 | + private String schema; | ||
| 19 | + private String tableName; | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + public static class CreUpdColumnDataDTO { | ||
| 23 | + private String columnName; | ||
| 24 | + private String newColumnName; | ||
| 25 | + private String type; | ||
| 26 | + private Boolean empty; | ||
| 27 | + private String defaultValue; | ||
| 28 | + private Boolean only; | ||
| 29 | + private String precision; | ||
| 30 | + private String scope; | ||
| 31 | + private String comment; | ||
| 32 | + private Integer operationType; | ||
| 33 | + } | ||
| 34 | +} | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/model/dto/DatabaseCreateSequenceDTO.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/model/dto/DatabaseCreateSynonymDTO.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/model/dto/DatabaseCreateTableDTO.java+24-0
| @@ -0,0 +1,24 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.dto; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.query.TablePartitionInfoQuery; | ||
| 8 | +import com.nctigba.datastudio.model.query.TableUnderlyingInfoQuery; | ||
| 9 | +import lombok.Data; | ||
| 10 | +import lombok.NoArgsConstructor; | ||
| 11 | + | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + | ||
| 16 | +public class DatabaseCreateTableDTO { | ||
| 17 | + private String uuid; | ||
| 18 | + private String schema; | ||
| 19 | + private TableUnderlyingInfoQuery tableInfo; | ||
| 20 | + private List<DatabaseCreUpdColumnDTO.CreUpdColumnDataDTO> column; | ||
| 21 | + private List<ConstraintDTO> constraints; | ||
| 22 | + private List<IndexDTO> indexs; | ||
| 23 | + private TablePartitionInfoQuery partitionInfo; | ||
| 24 | +} | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/model/dto/DatabaseDropSequenceDTO.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -11,4 +15,5 @@ public class DatabaseFunctionSPDTO { | |||
| 11 | private String connectionName; | 15 | private String connectionName; |
| 12 | private String schema; | 16 | private String schema; |
| 13 | private String functionSPName; | 17 | private String functionSPName; |
| 18 | + private String oid; | ||
| 14 | } | 19 | } |
| @@ -0,0 +1,24 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.dto; | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +import lombok.Data; | ||
| 9 | +import lombok.NoArgsConstructor; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +public class DatabaseIndexDTO { | ||
| 16 | + private String uuid; | ||
| 17 | + private String webUser; | ||
| 18 | + private String connectionName; | ||
| 19 | + private String schema; | ||
| 20 | + private String sequenceName; | ||
| 21 | + private String tableName; | ||
| 22 | + private List<IndexDTO> indexs; | ||
| 23 | +} | ||
| 24 | + | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/model/dto/DatabaseSynonymAttributeDTO.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | 7 | ||
| @@ -0,0 +1,21 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.dto; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.NoArgsConstructor; | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + | ||
| 12 | +public class IndexDTO { | ||
| 13 | + private String attname; | ||
| 14 | + private String indexName; | ||
| 15 | + private String oldIndexName; | ||
| 16 | + private String amname; | ||
| 17 | + private String description; | ||
| 18 | + private String expression; | ||
| 19 | + private Boolean unique; | ||
| 20 | + private int type; | ||
| 21 | +} | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.dto; | 5 | package com.nctigba.datastudio.model.dto; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -0,0 +1,17 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.dto; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.NoArgsConstructor; | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + | ||
| 12 | +public class TableAlterDTO { | ||
| 13 | + private String uuid; | ||
| 14 | + private String schema; | ||
| 15 | + private String tableName; | ||
| 16 | + private String generalPurpose; | ||
| 17 | +} | ||
| @@ -0,0 +1,18 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.dto; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.NoArgsConstructor; | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + | ||
| 12 | +public class TableAttributeDTO { | ||
| 13 | + private String uuid; | ||
| 14 | + private String oid; | ||
| 15 | + private String schema; | ||
| 16 | + private String tableName; | ||
| 17 | + private String tableType; | ||
| 18 | +} | ||
| @@ -0,0 +1,26 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.dto; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.query.TableDataQuery; | ||
| 8 | +import lombok.Data; | ||
| 9 | + | ||
| 10 | +import java.util.Map; | ||
| 11 | + | ||
| 12 | + | ||
| 13 | +public class TableDataDTO { | ||
| 14 | + private String winId; | ||
| 15 | + private Map<String, Object> data; | ||
| 16 | + private Integer dataSize; | ||
| 17 | + private Integer pageTotal; | ||
| 18 | + private Integer pageNum; | ||
| 19 | + private Integer pageSize; | ||
| 20 | + | ||
| 21 | + public void setTableDataDTO(TableDataQuery request) { | ||
| 22 | + this.winId = request.getWinId(); | ||
| 23 | + this.pageSize = request.getPageSize(); | ||
| 24 | + this.pageNum = request.getPageNum(); | ||
| 25 | + } | ||
| 26 | +} | ||
| @@ -0,0 +1,17 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.dto; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.NoArgsConstructor; | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + | ||
| 12 | +public class TableNameDTO { | ||
| 13 | + private String uuid; | ||
| 14 | + private String oid; | ||
| 15 | + private String schema; | ||
| 16 | + private String tableName; | ||
| 17 | +} | ||
| @@ -0,0 +1,27 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.dto; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.NoArgsConstructor; | ||
| 9 | + | ||
| 10 | +import java.util.Date; | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +public class WinInfoDTO { | ||
| 15 | + private Date lastDate; | ||
| 16 | + private String uuid; | ||
| 17 | + private String schema; | ||
| 18 | + private String tableName; | ||
| 19 | + | ||
| 20 | + public void setWinInfoDTO(String uuid, String schema, String tableName) { | ||
| 21 | + Date date = new Date(); | ||
| 22 | + this.lastDate = date; | ||
| 23 | + this.uuid = uuid; | ||
| 24 | + this.schema = schema; | ||
| 25 | + this.tableName = tableName; | ||
| 26 | + } | ||
| 27 | +} | ||
| @@ -0,0 +1,38 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.entity; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.NoArgsConstructor; | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + | ||
| 12 | +public class CoverageRateDO { | ||
| 13 | + private String name; | ||
| 14 | + | ||
| 15 | + private Long oid; | ||
| 16 | + | ||
| 17 | + private Long cid; | ||
| 18 | + | ||
| 19 | + private Integer serialNumber; | ||
| 20 | + | ||
| 21 | + private Integer totalRows; | ||
| 22 | + | ||
| 23 | + private Integer executionRows; | ||
| 24 | + | ||
| 25 | + private String totalCoverage; | ||
| 26 | + | ||
| 27 | + private String allLineNumber; | ||
| 28 | + | ||
| 29 | + private String executionLineNumber; | ||
| 30 | + | ||
| 31 | + private String executionCoverage; | ||
| 32 | + | ||
| 33 | + private String inputParams; | ||
| 34 | + | ||
| 35 | + private String updateTime; | ||
| 36 | + | ||
| 37 | + private String sourcecode; | ||
| 38 | +} | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/model/entity/DatabaseConnectionDO.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.entity; | 5 | package com.nctigba.datastudio.model.entity; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/model/entity/DatabaseConnectionUrlDO.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.entity; | 5 | package com.nctigba.datastudio.model.entity; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.entity; | 5 | package com.nctigba.datastudio.model.entity; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -5,6 +9,7 @@ import lombok.Data; | |||
| 5 | 9 | ||
| 6 | public class OperateStatusDO { | 10 | public class OperateStatusDO { |
| 7 | private boolean isDebug; | 11 | private boolean isDebug; |
| 12 | + private boolean compile; | ||
| 8 | 13 | ||
| 9 | private boolean execute; | 14 | private boolean execute; |
| 10 | 15 | ||
| @@ -12,7 +17,7 @@ public class OperateStatusDO { | |||
| 12 | 17 | ||
| 13 | private boolean stopDebug; | 18 | private boolean stopDebug; |
| 14 | 19 | ||
| 15 | - private boolean breakPointStep; | 20 | + private boolean continueStep; |
| 16 | 21 | ||
| 17 | private boolean singleStep; | 22 | private boolean singleStep; |
| 18 | 23 | ||
| @@ -24,21 +29,24 @@ public class OperateStatusDO { | |||
| 24 | 29 | ||
| 25 | private boolean stepOut; | 30 | private boolean stepOut; |
| 26 | 31 | ||
| 32 | + private boolean coverageRate; | ||
| 33 | + | ||
| 27 | public OperateStatusDO() { | 34 | public OperateStatusDO() { |
| 28 | - this.isDebug = true; | ||
| 29 | init(); | 35 | init(); |
| 30 | } | 36 | } |
| 31 | 37 | ||
| 32 | public void init() { | 38 | public void init() { |
| 33 | - this.execute = true; | 39 | + this.compile = true; |
| 40 | + this.execute = false; | ||
| 34 | this.startDebug = false; | 41 | this.startDebug = false; |
| 35 | this.stopDebug = false; | 42 | this.stopDebug = false; |
| 36 | - this.breakPointStep = false; | 43 | + this.continueStep = false; |
| 37 | this.singleStep = false; | 44 | this.singleStep = false; |
| 38 | this.startRun = false; | 45 | this.startRun = false; |
| 39 | this.stopRun = false; | 46 | this.stopRun = false; |
| 40 | this.stepIn = false; | 47 | this.stepIn = false; |
| 41 | this.stepOut = false; | 48 | this.stepOut = false; |
| 49 | + this.coverageRate = false; | ||
| 42 | } | 50 | } |
| 43 | 51 | ||
| 44 | public void enableStopRun() { | 52 | public void enableStopRun() { |
| @@ -47,30 +55,40 @@ public class OperateStatusDO { | |||
| 47 | } | 55 | } |
| 48 | 56 | ||
| 49 | public void enableStartDebug() { | 57 | public void enableStartDebug() { |
| 58 | + this.compile = true; | ||
| 50 | this.execute = true; | 59 | this.execute = true; |
| 51 | this.startDebug = true; | 60 | this.startDebug = true; |
| 52 | this.stopDebug = false; | 61 | this.stopDebug = false; |
| 53 | - this.breakPointStep = false; | 62 | + this.continueStep = false; |
| 54 | this.singleStep = false; | 63 | this.singleStep = false; |
| 55 | this.stepIn = false; | 64 | this.stepIn = false; |
| 56 | this.stepOut = false; | 65 | this.stepOut = false; |
| 66 | + this.coverageRate = true; | ||
| 57 | } | 67 | } |
| 58 | 68 | ||
| 59 | public void enableStopDebug() { | 69 | public void enableStopDebug() { |
| 70 | + this.compile = false; | ||
| 60 | this.execute = false; | 71 | this.execute = false; |
| 61 | this.startDebug = false; | 72 | this.startDebug = false; |
| 62 | this.stopDebug = true; | 73 | this.stopDebug = true; |
| 63 | - this.breakPointStep = true; | 74 | + this.continueStep = true; |
| 75 | + this.singleStep = true; | ||
| 76 | + this.stepIn = true; | ||
| 77 | + this.stepOut = true; | ||
| 78 | + this.coverageRate = false; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public void subAllTrue() { | ||
| 82 | + this.continueStep = true; | ||
| 64 | this.singleStep = true; | 83 | this.singleStep = true; |
| 65 | this.stepIn = true; | 84 | this.stepIn = true; |
| 66 | this.stepOut = true; | 85 | this.stepOut = true; |
| 67 | } | 86 | } |
| 68 | 87 | ||
| 69 | - public void allStatusFalse() { | 88 | + public void subAllFalse() { |
| 70 | - this.execute = false; | 89 | + this.continueStep = false; |
| 71 | - this.startDebug = false; | ||
| 72 | - this.stopDebug = false; | ||
| 73 | - this.breakPointStep = false; | ||
| 74 | this.singleStep = false; | 90 | this.singleStep = false; |
| 91 | + this.stepIn = false; | ||
| 92 | + this.stepOut = false; | ||
| 75 | } | 93 | } |
| 76 | } | 94 | } |
| @@ -0,0 +1,20 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.query; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.NoArgsConstructor; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +public class CoverageRateRequest { | ||
| 15 | + private String uuid; | ||
| 16 | + | ||
| 17 | + private Long oid; | ||
| 18 | + | ||
| 19 | + private List<Long> cidList; | ||
| 20 | +} | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/model/query/DatabaseMetaarrayColumnQuery.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.query; | 5 | package com.nctigba.datastudio.model.query; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/model/query/DatabaseMetaarrayIdSchemaQuery.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.query; | 5 | package com.nctigba.datastudio.model.query; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/model/query/DatabaseMetaarrayQuery.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.query; | 5 | package com.nctigba.datastudio.model.query; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/model/query/DatabaseMetaarraySchemaQuery.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.query; | 5 | package com.nctigba.datastudio.model.query; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
Rplugins/data-studio/src/main/java/com/nctigba/datastudio/model/entity/DatabaseSelectViewQuery.java→plugins/data-studio/src/main/java/com/nctigba/datastudio/model/query/DatabaseSelectViewQuery.java+5-1
| @@ -1,4 +1,8 @@ | |||
| 1 | -package com.nctigba.datastudio.model.entity; | 1 | +/* |
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.query; | ||
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| 4 | import lombok.NoArgsConstructor; | 8 | import lombok.NoArgsConstructor; |
| @@ -0,0 +1,48 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.query; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.NoArgsConstructor; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +public class ExportRequest { | ||
| 15 | + private String uuid; | ||
| 16 | + | ||
| 17 | + private String schema; | ||
| 18 | + | ||
| 19 | + private boolean dataFlag; | ||
| 20 | + | ||
| 21 | + private List<String> tableList; | ||
| 22 | + | ||
| 23 | + private String tableName; | ||
| 24 | + | ||
| 25 | + private List<String> columnList; | ||
| 26 | + | ||
| 27 | + private String fileType; | ||
| 28 | + | ||
| 29 | + private boolean titleFlag; | ||
| 30 | + | ||
| 31 | + private String quote; | ||
| 32 | + | ||
| 33 | + private String escape; | ||
| 34 | + | ||
| 35 | + private String replaceNull; | ||
| 36 | + | ||
| 37 | + private String delimiter; | ||
| 38 | + | ||
| 39 | + private String encoding; | ||
| 40 | + | ||
| 41 | + private List<Integer> functionMap; | ||
| 42 | + | ||
| 43 | + private List<String> viewList; | ||
| 44 | + | ||
| 45 | + private List<String> sequenceList; | ||
| 46 | + | ||
| 47 | + private List<String> schemaList; | ||
| 48 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/model/query/SchemaManagerRequest.java+20-0
| @@ -0,0 +1,20 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.query; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +public class SchemaManagerRequest { | ||
| 11 | + private String uuid; | ||
| 12 | + | ||
| 13 | + private String oid; | ||
| 14 | + | ||
| 15 | + private String schemaName; | ||
| 16 | + | ||
| 17 | + private String owner; | ||
| 18 | + | ||
| 19 | + private String description; | ||
| 20 | +} | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.model.query; | 5 | package com.nctigba.datastudio.model.query; |
| 2 | 6 | ||
| 3 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -5,11 +9,7 @@ import lombok.Data; | |||
| 5 | 9 | ||
| 6 | public class SelectDataQuery { | 10 | public class SelectDataQuery { |
| 7 | private String uuid; | 11 | private String uuid; |
| 8 | - private String webUser; | 12 | + private String oid; |
| 9 | - | ||
| 10 | - private String connName; | ||
| 11 | - | ||
| 12 | private String schema; | 13 | private String schema; |
| 13 | - | ||
| 14 | private String tableName; | 14 | private String tableName; |
| 15 | } | 15 | } |
| @@ -0,0 +1,64 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.query; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.NoArgsConstructor; | ||
| 9 | +import lombok.extern.slf4j.Slf4j; | ||
| 10 | + | ||
| 11 | +import java.sql.ResultSet; | ||
| 12 | +import java.sql.SQLException; | ||
| 13 | +import java.util.Iterator; | ||
| 14 | +import java.util.List; | ||
| 15 | +import java.util.Map; | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +public class TableDataEditQuery { | ||
| 21 | + private String winId; | ||
| 22 | + private List<TableDataDTO> data; | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + public static class TableDataDTO { | ||
| 26 | + private Map<String, Object> columnData; | ||
| 27 | + private Integer rowNum; | ||
| 28 | + private type type; | ||
| 29 | + | ||
| 30 | + public enum type { | ||
| 31 | + Insert { | ||
| 32 | + public void rs(ResultSet resultSet, TableDataDTO requst) throws SQLException { | ||
| 33 | + log.info("TableDataDTO request is: {}" + requst); | ||
| 34 | + resultSet.moveToInsertRow(); | ||
| 35 | + Iterator iterator = requst.columnData.entrySet().iterator(); | ||
| 36 | + while (iterator.hasNext()) { | ||
| 37 | + Map.Entry map = (Map.Entry) iterator.next(); | ||
| 38 | + resultSet.updateObject((String) map.getKey(), map.getValue()); | ||
| 39 | + } | ||
| 40 | + resultSet.insertRow(); | ||
| 41 | + } | ||
| 42 | + }, Delete { | ||
| 43 | + public void rs(ResultSet resultSet, TableDataDTO requst) throws SQLException { | ||
| 44 | + log.info("TableDataDTO request is: {}" + requst); | ||
| 45 | + resultSet.absolute(requst.getRowNum()); | ||
| 46 | + resultSet.deleteRow(); | ||
| 47 | + } | ||
| 48 | + }, Update { | ||
| 49 | + public void rs(ResultSet resultSet, TableDataDTO requst) throws SQLException { | ||
| 50 | + log.info("TableDataDTO request is: {}" + requst); | ||
| 51 | + resultSet.absolute(requst.getRowNum()); | ||
| 52 | + Iterator iterator = requst.columnData.entrySet().iterator(); | ||
| 53 | + while (iterator.hasNext()) { | ||
| 54 | + Map.Entry map = (Map.Entry) iterator.next(); | ||
| 55 | + resultSet.updateObject((String) map.getKey(), map.getValue()); | ||
| 56 | + } | ||
| 57 | + resultSet.updateRow(); | ||
| 58 | + } | ||
| 59 | + }; | ||
| 60 | + | ||
| 61 | + public abstract void rs(ResultSet resultSet, TableDataDTO requst) throws SQLException; | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | +} | ||
| @@ -0,0 +1,17 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.query; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +public class TableDataQuery { | ||
| 11 | + private String winId; | ||
| 12 | + private String uuid; | ||
| 13 | + private String schema; | ||
| 14 | + private String tableName; | ||
| 15 | + private Integer pageNum; | ||
| 16 | + private Integer pageSize; | ||
| 17 | +} | ||
| @@ -0,0 +1,13 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.query; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +public class TablePKDataQuery { | ||
| 11 | + private String msg; | ||
| 12 | + private Boolean PKCreate; | ||
| 13 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/model/query/TablePartitionInfoQuery.java+17-0
| @@ -0,0 +1,17 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.query; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +public class TablePartitionInfoQuery { | ||
| 11 | + private String type; | ||
| 12 | + private String valueInterval; | ||
| 13 | + private String paprtitionColumn; | ||
| 14 | + private String paprtitionName; | ||
| 15 | + private String paprtitionValue; | ||
| 16 | + private String tableSpace; | ||
| 17 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/model/query/TableUnderlyingInfoQuery.java+19-0
| @@ -0,0 +1,19 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.model.query; | ||
| 6 | + | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +public class TableUnderlyingInfoQuery { | ||
| 11 | + private String tableName; | ||
| 12 | + private Boolean exists; | ||
| 13 | + private String tableType; | ||
| 14 | + private Boolean oids; | ||
| 15 | + private String tableSpace; | ||
| 16 | + private Integer fillingFactor; | ||
| 17 | + private String storage; | ||
| 18 | + private String comment; | ||
| 19 | +} | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.result; | 5 | package com.nctigba.datastudio.result; |
| 2 | 6 | ||
| 3 | import static com.nctigba.datastudio.constants.CommonConstants.FIVE_HUNDRED; | 7 | import static com.nctigba.datastudio.constants.CommonConstants.FIVE_HUNDRED; |
| @@ -0,0 +1,19 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.service; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.entity.CoverageRateDO; | ||
| 8 | +import com.nctigba.datastudio.model.query.CoverageRateRequest; | ||
| 9 | + | ||
| 10 | +import javax.servlet.http.HttpServletResponse; | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +public interface CoverageRateService { | ||
| 14 | + List<CoverageRateDO> queryCoverageRate(CoverageRateRequest request) throws Exception; | ||
| 15 | + | ||
| 16 | + void delete(CoverageRateRequest request) throws Exception; | ||
| 17 | + | ||
| 18 | + void export(CoverageRateRequest request, HttpServletResponse response) throws Exception; | ||
| 19 | +} | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service; | 5 | package com.nctigba.datastudio.service; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.dto.CreateDatabaseDTO; | 7 | import com.nctigba.datastudio.model.dto.CreateDatabaseDTO; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service; | 5 | package com.nctigba.datastudio.service; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.dto.DataListDTO; | 7 | import com.nctigba.datastudio.model.dto.DataListDTO; |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/DatabaseFunctionSPService.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service; | 5 | package com.nctigba.datastudio.service; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.dto.DatabaseFunctionSPDTO; | 7 | import com.nctigba.datastudio.model.dto.DatabaseFunctionSPDTO; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service; | 5 | package com.nctigba.datastudio.service; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.dto.DatabaseCreateSequenceDTO; | 7 | import com.nctigba.datastudio.model.dto.DatabaseCreateSequenceDTO; |
| @@ -5,8 +9,6 @@ import com.nctigba.datastudio.model.dto.DatabaseDropSequenceDTO; | |||
| 5 | import com.nctigba.datastudio.model.dto.DatabaseSequenceDdlDTO; | 9 | import com.nctigba.datastudio.model.dto.DatabaseSequenceDdlDTO; |
| 6 | 10 | ||
| 7 | public interface DatabaseSequenceService { | 11 | public interface DatabaseSequenceService { |
| 8 | - String splicingSequenceDDL(DatabaseCreateSequenceDTO request) throws Exception; | ||
| 9 | - | ||
| 10 | String createSequenceDDL(DatabaseCreateSequenceDTO request) throws Exception; | 12 | String createSequenceDDL(DatabaseCreateSequenceDTO request) throws Exception; |
| 11 | 13 | ||
| 12 | void createSequence(DatabaseCreateSequenceDTO request) throws Exception; | 14 | void createSequence(DatabaseCreateSequenceDTO request) throws Exception; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service; | 5 | package com.nctigba.datastudio.service; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.dto.DatabaseCreateSynonymDTO; | 7 | import com.nctigba.datastudio.model.dto.DatabaseCreateSynonymDTO; |
| @@ -7,8 +11,6 @@ import com.nctigba.datastudio.model.dto.DatabaseSynonymAttributeDTO; | |||
| 7 | import java.util.Map; | 11 | import java.util.Map; |
| 8 | 12 | ||
| 9 | public interface DatabaseSynonymService { | 13 | public interface DatabaseSynonymService { |
| 10 | - String splicingSequenceDDL(DatabaseCreateSynonymDTO request) throws Exception; | ||
| 11 | - | ||
| 12 | String createSynonymDDL(DatabaseCreateSynonymDTO request) throws Exception; | 14 | String createSynonymDDL(DatabaseCreateSynonymDTO request) throws Exception; |
| 13 | 15 | ||
| 14 | void createSynonym(DatabaseCreateSynonymDTO request) throws Exception; | 16 | void createSynonym(DatabaseCreateSynonymDTO request) throws Exception; |
| @@ -1,21 +1,20 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service; | 5 | package com.nctigba.datastudio.service; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.dto.DatabaseCreateViewDTO; | 7 | import com.nctigba.datastudio.model.dto.DatabaseCreateViewDTO; |
| 4 | import com.nctigba.datastudio.model.dto.DatabaseSelectViewDTO; | 8 | import com.nctigba.datastudio.model.dto.DatabaseSelectViewDTO; |
| 5 | import com.nctigba.datastudio.model.dto.DatabaseViewDdlDTO; | 9 | import com.nctigba.datastudio.model.dto.DatabaseViewDdlDTO; |
| 6 | 10 | ||
| 7 | -import java.sql.ResultSet; | ||
| 8 | import java.util.Map; | 11 | import java.util.Map; |
| 9 | 12 | ||
| 10 | public interface DatabaseViewService { | 13 | public interface DatabaseViewService { |
| 11 | - String splicingViewDDL(DatabaseCreateViewDTO request) throws Exception; | ||
| 12 | - | ||
| 13 | String createViewDDL(DatabaseCreateViewDTO request) throws Exception; | 14 | String createViewDDL(DatabaseCreateViewDTO request) throws Exception; |
| 14 | 15 | ||
| 15 | String returnViewDDL(DatabaseViewDdlDTO request) throws Exception; | 16 | String returnViewDDL(DatabaseViewDdlDTO request) throws Exception; |
| 16 | 17 | ||
| 17 | - Map<String, Object> returnViewDDLData(DatabaseViewDdlDTO request) throws Exception; | ||
| 18 | - | ||
| 19 | void createView(DatabaseCreateViewDTO request) throws Exception; | 18 | void createView(DatabaseCreateViewDTO request) throws Exception; |
| 20 | 19 | ||
| 21 | void dropView(DatabaseViewDdlDTO request) throws Exception; | 20 | void dropView(DatabaseViewDdlDTO request) throws Exception; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service; | 5 | package com.nctigba.datastudio.service; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.dto.DataListDTO; | 7 | import com.nctigba.datastudio.model.dto.DataListDTO; |
| @@ -19,7 +23,7 @@ public interface DbConnectionService { | |||
| 19 | 23 | ||
| 20 | DatabaseConnectionDO updateDatabaseConnection(DbConnectionCreateDTO request) throws Exception; | 24 | DatabaseConnectionDO updateDatabaseConnection(DbConnectionCreateDTO request) throws Exception; |
| 21 | 25 | ||
| 22 | - List<DataListDTO> dataList(String id); | 26 | +// List<DataListDTO> dataList(String id); |
| 23 | 27 | ||
| 24 | List<DataListDTO> schemaObjectList(DatabaseMetaarrayIdSchemaQuery schema); | 28 | List<DataListDTO> schemaObjectList(DatabaseMetaarrayIdSchemaQuery schema); |
| 25 | 29 | ||
| @@ -0,0 +1,23 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.service; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.query.ExportRequest; | ||
| 8 | + | ||
| 9 | +import javax.servlet.http.HttpServletResponse; | ||
| 10 | + | ||
| 11 | +public interface ExportService { | ||
| 12 | + void exportTableDdl(ExportRequest request, HttpServletResponse response) throws Exception; | ||
| 13 | + | ||
| 14 | + void exportTableData(ExportRequest request, HttpServletResponse response) throws Exception; | ||
| 15 | + | ||
| 16 | + void exportFunctionDdl(ExportRequest request, HttpServletResponse response) throws Exception; | ||
| 17 | + | ||
| 18 | + void exportViewDdl(ExportRequest request, HttpServletResponse response) throws Exception; | ||
| 19 | + | ||
| 20 | + void exportSequenceDdl(ExportRequest request, HttpServletResponse response) throws Exception; | ||
| 21 | + | ||
| 22 | + void exportSchemaDdl(ExportRequest request, HttpServletResponse response) throws Exception; | ||
| 23 | +} | ||
| @@ -1,6 +1,11 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service; | 5 | package com.nctigba.datastudio.service; |
| 2 | 6 | ||
| 3 | public interface MetaDataByJdbcService { | 7 | public interface MetaDataByJdbcService { |
| 4 | void testQuerySQL(String jdbcUrl, String userName, String password, String sql) throws Exception; | 8 | void testQuerySQL(String jdbcUrl, String userName, String password, String sql) throws Exception; |
| 9 | + | ||
| 5 | String versionSQL(String jdbcUrl, String userName, String password, String sql) throws Exception; | 10 | String versionSQL(String jdbcUrl, String userName, String password, String sql) throws Exception; |
| 6 | } | 11 | } |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service; | 5 | package com.nctigba.datastudio.service; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service; | 5 | package com.nctigba.datastudio.service; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.query.DatabaseMetaarrayColumnQuery; | 7 | import com.nctigba.datastudio.model.query.DatabaseMetaarrayColumnQuery; |
| @@ -5,6 +9,7 @@ import com.nctigba.datastudio.model.query.DatabaseMetaarrayQuery; | |||
| 5 | import com.nctigba.datastudio.model.query.DatabaseMetaarraySchemaQuery; | 9 | import com.nctigba.datastudio.model.query.DatabaseMetaarraySchemaQuery; |
| 6 | 10 | ||
| 7 | import java.util.List; | 11 | import java.util.List; |
| 12 | +import java.util.Map; | ||
| 8 | 13 | ||
| 9 | public interface QueryMetaArrayService { | 14 | public interface QueryMetaArrayService { |
| 10 | List<String> databaseList(String uuid) throws Exception; | 15 | List<String> databaseList(String uuid) throws Exception; |
| @@ -13,6 +18,10 @@ public interface QueryMetaArrayService { | |||
| 13 | 18 | ||
| 14 | List<String> tableColumnList(DatabaseMetaarrayColumnQuery request) throws Exception; | 19 | List<String> tableColumnList(DatabaseMetaarrayColumnQuery request) throws Exception; |
| 15 | 20 | ||
| 16 | - List<String> schemaList(DatabaseMetaarraySchemaQuery request) throws Exception; | 21 | + List<Map<String, String>> schemaList(DatabaseMetaarraySchemaQuery request) throws Exception; |
| 22 | + | ||
| 23 | + List<String> baseTypeList(String uuid) throws Exception; | ||
| 24 | + | ||
| 25 | + List<String> tablespaceList(String uuid) throws Exception; | ||
| 17 | 26 | ||
| 18 | } | 27 | } |
| @@ -0,0 +1,22 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.service; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.model.query.SchemaManagerRequest; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | +import java.util.Map; | ||
| 11 | + | ||
| 12 | +public interface SchemaManagerService { | ||
| 13 | + List<String> queryAllUsers(SchemaManagerRequest request) throws Exception; | ||
| 14 | + | ||
| 15 | + Map<String, String> querySchema(SchemaManagerRequest request) throws Exception; | ||
| 16 | + | ||
| 17 | + void createSchema(SchemaManagerRequest request) throws Exception; | ||
| 18 | + | ||
| 19 | + void updateSchema(SchemaManagerRequest request) throws Exception; | ||
| 20 | + | ||
| 21 | + void deleteSchema(SchemaManagerRequest request) throws Exception; | ||
| 22 | +} | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service; | 5 | package com.nctigba.datastudio.service; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.dto.DataListDTO; | 7 | import com.nctigba.datastudio.model.dto.DataListDTO; |
| @@ -1,11 +1,29 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service; | 5 | package com.nctigba.datastudio.service; |
| 2 | 6 | ||
| 3 | -import com.nctigba.datastudio.model.query.SelectDataQuery; | ||
| 4 | 7 | ||
| 8 | +import com.nctigba.datastudio.model.dto.DatabaseConstraintDTO; | ||
| 9 | +import com.nctigba.datastudio.model.dto.DatabaseConstraintPkDTO; | ||
| 10 | +import com.nctigba.datastudio.model.dto.DatabaseCreUpdColumnDTO; | ||
| 11 | +import com.nctigba.datastudio.model.dto.DatabaseCreateTableDTO; | ||
| 12 | +import com.nctigba.datastudio.model.dto.DatabaseIndexDTO; | ||
| 13 | +import com.nctigba.datastudio.model.dto.TableAlterDTO; | ||
| 14 | +import com.nctigba.datastudio.model.dto.TableAttributeDTO; | ||
| 15 | +import com.nctigba.datastudio.model.dto.TableDataDTO; | ||
| 16 | +import com.nctigba.datastudio.model.dto.TableNameDTO; | ||
| 17 | +import com.nctigba.datastudio.model.query.SelectDataQuery; | ||
| 18 | +import com.nctigba.datastudio.model.query.TableDataEditQuery; | ||
| 19 | +import com.nctigba.datastudio.model.query.TableDataQuery; | ||
| 20 | +import com.nctigba.datastudio.model.query.TablePKDataQuery; | ||
| 21 | + | ||
| 22 | +import java.util.List; | ||
| 5 | import java.util.Map; | 23 | import java.util.Map; |
| 6 | 24 | ||
| 7 | public interface TableDataService { | 25 | public interface TableDataService { |
| 8 | - Map<String, Object> tableData(SelectDataQuery request) throws Exception; | 26 | + TableDataDTO tableData(TableDataQuery request) throws Exception; |
| 9 | 27 | ||
| 10 | Map<String, Object> tableColumn(SelectDataQuery request) throws Exception; | 28 | Map<String, Object> tableColumn(SelectDataQuery request) throws Exception; |
| 11 | 29 | ||
| @@ -14,4 +32,41 @@ public interface TableDataService { | |||
| 14 | Map<String, Object> tableConstraint(SelectDataQuery request) throws Exception; | 32 | Map<String, Object> tableConstraint(SelectDataQuery request) throws Exception; |
| 15 | 33 | ||
| 16 | Map<String, String> tableDdl(SelectDataQuery request) throws Exception; | 34 | Map<String, String> tableDdl(SelectDataQuery request) throws Exception; |
| 35 | + | ||
| 36 | + | ||
| 37 | + Map<String, Object> tableColumnEdit(DatabaseCreUpdColumnDTO request) throws Exception; | ||
| 38 | + | ||
| 39 | + void tableDataClose(String winId) throws Exception; | ||
| 40 | + | ||
| 41 | + TablePKDataQuery tableDataEdit(TableDataEditQuery request) throws Exception; | ||
| 42 | + | ||
| 43 | + void tableEditConstraint(DatabaseConstraintDTO request) throws Exception; | ||
| 44 | + | ||
| 45 | + void tableEditPkConstraint(DatabaseConstraintPkDTO request) throws Exception; | ||
| 46 | + | ||
| 47 | + void tableEditIndex(DatabaseIndexDTO request) throws Exception; | ||
| 48 | + | ||
| 49 | + void tableCreate(DatabaseCreateTableDTO request) throws Exception; | ||
| 50 | + | ||
| 51 | + String returnTableCreate(DatabaseCreateTableDTO request) throws Exception; | ||
| 52 | + | ||
| 53 | + void tableTruncate(TableNameDTO request) throws Exception; | ||
| 54 | + | ||
| 55 | + void tableVacuum(TableNameDTO request) throws Exception; | ||
| 56 | + | ||
| 57 | + void tableReindex(TableNameDTO request) throws Exception; | ||
| 58 | + | ||
| 59 | + void tableRename(TableAlterDTO request) throws Exception; | ||
| 60 | + | ||
| 61 | + void tableComment(TableAlterDTO request) throws Exception; | ||
| 62 | + | ||
| 63 | + void tableAlterSchema(TableAlterDTO request) throws Exception; | ||
| 64 | + | ||
| 65 | + void tableDrop(TableNameDTO request) throws Exception; | ||
| 66 | + | ||
| 67 | + void tableAlterTablespace(TableAlterDTO request) throws Exception; | ||
| 68 | + | ||
| 69 | + Map<String, Object> tableSequence(TableNameDTO request) throws Exception; | ||
| 70 | + | ||
| 71 | + List<Map<String, Object>> tableAttribute(TableAttributeDTO request) throws Exception; | ||
| 17 | } | 72 | } |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/AddBreakPointImpl.java+31-23
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| @@ -6,26 +10,26 @@ import com.nctigba.datastudio.model.PublicParamReq; | |||
| 6 | import com.nctigba.datastudio.service.OperationInterface; | 10 | import com.nctigba.datastudio.service.OperationInterface; |
| 7 | import com.nctigba.datastudio.util.DebugUtils; | 11 | import com.nctigba.datastudio.util.DebugUtils; |
| 8 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 9 | -import org.apache.commons.lang3.StringUtils; | 13 | +import org.opengauss.admin.common.exception.CustomException; |
| 10 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
| 11 | import org.springframework.util.CollectionUtils; | 15 | import org.springframework.util.CollectionUtils; |
| 12 | 16 | ||
| 13 | import java.sql.ResultSet; | 17 | import java.sql.ResultSet; |
| 14 | import java.sql.Statement; | 18 | import java.sql.Statement; |
| 15 | import java.util.HashMap; | 19 | import java.util.HashMap; |
| 20 | +import java.util.List; | ||
| 16 | import java.util.Map; | 21 | import java.util.Map; |
| 17 | 22 | ||
| 18 | import static com.nctigba.datastudio.constants.CommonConstants.BREAK_POINT; | 23 | import static com.nctigba.datastudio.constants.CommonConstants.BREAK_POINT; |
| 19 | import static com.nctigba.datastudio.constants.CommonConstants.BREAK_POINT_NO; | 24 | import static com.nctigba.datastudio.constants.CommonConstants.BREAK_POINT_NO; |
| 25 | +import static com.nctigba.datastudio.constants.CommonConstants.CAN_BREAK; | ||
| 20 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; | 26 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; |
| 21 | import static com.nctigba.datastudio.constants.CommonConstants.OID; | 27 | import static com.nctigba.datastudio.constants.CommonConstants.OID; |
| 22 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; | 28 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; |
| 23 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | 29 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; |
| 24 | import static com.nctigba.datastudio.constants.SqlConstants.ADD_BREAKPOINT_SQL; | 30 | import static com.nctigba.datastudio.constants.SqlConstants.ADD_BREAKPOINT_SQL; |
| 25 | -import static com.nctigba.datastudio.constants.SqlConstants.COMMA; | ||
| 26 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_PRE; | 31 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_PRE; |
| 27 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_SQL; | 32 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_SQL; |
| 28 | -import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_SEMICOLON; | ||
| 29 | import static com.nctigba.datastudio.enums.MessageEnum.breakPoint; | 33 | import static com.nctigba.datastudio.enums.MessageEnum.breakPoint; |
| 30 | 34 | ||
| 31 | /** | 35 | /** |
| @@ -36,41 +40,45 @@ import static com.nctigba.datastudio.enums.MessageEnum.breakPoint; | |||
| 36 | public class AddBreakPointImpl implements OperationInterface { | 40 | public class AddBreakPointImpl implements OperationInterface { |
| 37 | 41 | ||
| 38 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 42 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 39 | - log.info("AddBreakPointImpl obj is: " + obj); | ||
| 40 | PublicParamReq paramReq = (PublicParamReq) obj; | 43 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 41 | - String windowName = paramReq.getWindowName(); | 44 | + log.info("AddBreakPointImpl paramReq: " + paramReq); |
| 42 | - int line = paramReq.getLine(); | ||
| 43 | - int differ = (int) webSocketServer.getParamMap(windowName).get(DIFFER); | ||
| 44 | - String oid = (String) webSocketServer.getParamMap(windowName).get(OID); | ||
| 45 | 45 | ||
| 46 | - Map<Integer, String> breakPointMap = (Map<Integer, String>) webSocketServer.getParamMap(windowName).get(BREAK_POINT); | 46 | + String windowName = paramReq.getWindowName(); |
| 47 | + Map<Integer, String> breakPointMap = (Map<Integer, String>) webSocketServer.getParamMap(windowName).get( | ||
| 48 | + BREAK_POINT); | ||
| 47 | if (CollectionUtils.isEmpty(breakPointMap)) { | 49 | if (CollectionUtils.isEmpty(breakPointMap)) { |
| 48 | breakPointMap = new HashMap<>(); | 50 | breakPointMap = new HashMap<>(); |
| 49 | } | 51 | } |
| 50 | - log.info("AddBreakPointImpl old breakPointMap is: " + breakPointMap); | 52 | + log.info("AddBreakPointImpl old breakPointMap: " + breakPointMap); |
| 51 | 53 | ||
| 52 | - String name = paramReq.getOldWindowName(); | 54 | + String rootWindowName = paramReq.getRootWindowName(); |
| 53 | - if (StringUtils.isEmpty(name)) { | 55 | + Statement stat = (Statement) webSocketServer.getParamMap(rootWindowName).get(STATEMENT); |
| 54 | - name = windowName; | ||
| 55 | - } | ||
| 56 | - Statement stat = (Statement) webSocketServer.getParamMap(name).get(STATEMENT); | ||
| 57 | if (stat == null) { | 56 | if (stat == null) { |
| 58 | return; | 57 | return; |
| 59 | } | 58 | } |
| 60 | 59 | ||
| 61 | - if (webSocketServer.checkLine(windowName, line)) { | 60 | + int line = paramReq.getLine(); |
| 62 | - ResultSet resultSet = stat.executeQuery( | 61 | + int differ = (int) webSocketServer.getParamMap(windowName).get(DIFFER); |
| 63 | - ADD_BREAKPOINT_SQL + oid + COMMA + (line - differ) + PARENTHESES_SEMICOLON); | 62 | + String oid = (String) webSocketServer.getParamMap(windowName).get(OID); |
| 64 | - while (resultSet.next()) { | 63 | + List<Integer> list = (List<Integer>) webSocketServer.getParamMap(windowName).get(CAN_BREAK); |
| 65 | - String no = resultSet.getString(BREAK_POINT_NO); | 64 | + if (list.contains(line - differ)) { |
| 66 | - breakPointMap.put(line, no); | 65 | + try ( |
| 66 | + ResultSet resultSet = stat.executeQuery(String.format(ADD_BREAKPOINT_SQL, oid, (line - differ))) | ||
| 67 | + ) { | ||
| 68 | + while (resultSet.next()) { | ||
| 69 | + String no = resultSet.getString(BREAK_POINT_NO); | ||
| 70 | + breakPointMap.put(line, no); | ||
| 71 | + } | ||
| 72 | + } catch (Exception e) { | ||
| 73 | + log.info(e.getMessage()); | ||
| 74 | + throw new CustomException(e.getMessage(), e); | ||
| 67 | } | 75 | } |
| 68 | } | 76 | } |
| 69 | webSocketServer.setParamMap(windowName, BREAK_POINT, breakPointMap); | 77 | webSocketServer.setParamMap(windowName, BREAK_POINT, breakPointMap); |
| 70 | - log.info("AddBreakPointImpl new breakPointMap is: " + breakPointMap); | 78 | + log.info("AddBreakPointImpl new breakPointMap: " + breakPointMap); |
| 71 | 79 | ||
| 72 | ResultSet bpResult = stat.executeQuery(INFO_BREAKPOINT_PRE + differ + INFO_BREAKPOINT_SQL); | 80 | ResultSet bpResult = stat.executeQuery(INFO_BREAKPOINT_PRE + differ + INFO_BREAKPOINT_SQL); |
| 73 | - webSocketServer.sendMessage(windowName, breakPoint, SUCCESS, DebugUtils.parseBeakPoint(bpResult, oid)); | 81 | + webSocketServer.sendMessage(windowName, breakPoint, SUCCESS, DebugUtils.parseBreakPoint(bpResult, oid)); |
| 74 | } | 82 | } |
| 75 | 83 | ||
| 76 | 84 | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.base.WebSocketServer; | 7 | import com.nctigba.datastudio.base.WebSocketServer; |
| @@ -24,8 +28,8 @@ import static com.nctigba.datastudio.constants.CommonConstants.OID; | |||
| 24 | import static com.nctigba.datastudio.constants.CommonConstants.RESULT; | 28 | import static com.nctigba.datastudio.constants.CommonConstants.RESULT; |
| 25 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; | 29 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; |
| 26 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | 30 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; |
| 27 | -import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_SEMICOLON; | ||
| 28 | import static com.nctigba.datastudio.constants.SqlConstants.TURN_OFF_SQL; | 31 | import static com.nctigba.datastudio.constants.SqlConstants.TURN_OFF_SQL; |
| 32 | +import static com.nctigba.datastudio.enums.MessageEnum.createCoverageRate; | ||
| 29 | import static com.nctigba.datastudio.enums.MessageEnum.operateStatus; | 33 | import static com.nctigba.datastudio.enums.MessageEnum.operateStatus; |
| 30 | import static com.nctigba.datastudio.enums.MessageEnum.table; | 34 | import static com.nctigba.datastudio.enums.MessageEnum.table; |
| 31 | import static com.nctigba.datastudio.enums.MessageEnum.text; | 35 | import static com.nctigba.datastudio.enums.MessageEnum.text; |
| @@ -36,20 +40,42 @@ import static com.nctigba.datastudio.enums.MessageEnum.window; | |||
| 36 | public class AsyncHelper { | 40 | public class AsyncHelper { |
| 37 | 41 | ||
| 38 | public void task(WebSocketServer webSocketServer, PublicParamReq paramReq) throws SQLException, IOException { | 42 | public void task(WebSocketServer webSocketServer, PublicParamReq paramReq) throws SQLException, IOException { |
| 39 | - log.info("AsyncHelper paramReq is: " + paramReq); | 43 | + log.info("AsyncHelper paramReq: " + paramReq); |
| 40 | String windowName = paramReq.getWindowName(); | 44 | String windowName = paramReq.getWindowName(); |
| 41 | Statement statement = webSocketServer.getStatement(windowName); | 45 | Statement statement = webSocketServer.getStatement(windowName); |
| 42 | - try { | 46 | + try ( |
| 43 | - ResultSet resultSet = statement.executeQuery(DebugUtils.prepareSql(paramReq)); | 47 | + ResultSet resultSet = statement.executeQuery(DebugUtils.prepareSql(paramReq)) |
| 48 | + ) { | ||
| 49 | + if (!paramReq.isCoverage()) { | ||
| 50 | + Connection conn = (Connection) webSocketServer.getParamMap(windowName).get(CONNECTION); | ||
| 51 | + Statement stat = (Statement) webSocketServer.getParamMap(windowName).get(STATEMENT); | ||
| 52 | + if (stat != null) { | ||
| 53 | + stat.close(); | ||
| 54 | + stat.cancel(); | ||
| 55 | + webSocketServer.setParamMap(windowName, STATEMENT, null); | ||
| 56 | + } | ||
| 57 | + if (conn != null) { | ||
| 58 | + conn.close(); | ||
| 59 | + webSocketServer.setParamMap(windowName, CONNECTION, null); | ||
| 60 | + } | ||
| 61 | + statement.close(); | ||
| 62 | + webSocketServer.setStatement(windowName, null); | ||
| 63 | + | ||
| 64 | + Map<String, String> map = new HashMap<>(); | ||
| 65 | + map.put(RESULT, LocaleString.transLanguageWs("1010", webSocketServer)); | ||
| 66 | + webSocketServer.sendMessage(windowName, createCoverageRate, SUCCESS, map); | ||
| 67 | + return; | ||
| 68 | + } | ||
| 69 | + | ||
| 44 | Map<String, Object> map = DebugUtils.parseResultSet(resultSet); | 70 | Map<String, Object> map = DebugUtils.parseResultSet(resultSet); |
| 45 | - log.info("AsyncHelper map is: " + map); | 71 | + log.info("AsyncHelper result map: " + map); |
| 46 | List<List<Object>> list = (List<List<Object>>) map.get(RESULT); | 72 | List<List<Object>> list = (List<List<Object>>) map.get(RESULT); |
| 47 | if (list.size() == 1) { | 73 | if (list.size() == 1) { |
| 48 | if (list.get(0).size() == 1) { | 74 | if (list.get(0).size() == 1) { |
| 49 | webSocketServer.sendMessage(windowName, text, SUCCESS, map); | 75 | webSocketServer.sendMessage(windowName, text, SUCCESS, map); |
| 50 | } else { | 76 | } else { |
| 51 | Map<String, String> messageMap = new HashMap<>(); | 77 | Map<String, String> messageMap = new HashMap<>(); |
| 52 | - messageMap.put(RESULT, LocaleString.transLanguageWs("1007", webSocketServer)); | 78 | + messageMap.put(RESULT, LocaleString.transLanguageWs("1008", webSocketServer)); |
| 53 | webSocketServer.sendMessage(windowName, text, SUCCESS, messageMap); | 79 | webSocketServer.sendMessage(windowName, text, SUCCESS, messageMap); |
| 54 | webSocketServer.sendMessage(windowName, table, SUCCESS, map); | 80 | webSocketServer.sendMessage(windowName, table, SUCCESS, map); |
| 55 | } | 81 | } |
| @@ -63,14 +89,13 @@ public class AsyncHelper { | |||
| 63 | OperateStatusDO operateStatusDO = webSocketServer.getOperateStatus(windowName); | 89 | OperateStatusDO operateStatusDO = webSocketServer.getOperateStatus(windowName); |
| 64 | operateStatusDO.enableStartDebug(); | 90 | operateStatusDO.enableStartDebug(); |
| 65 | webSocketServer.setOperateStatus(windowName, operateStatusDO); | 91 | webSocketServer.setOperateStatus(windowName, operateStatusDO); |
| 66 | - | ||
| 67 | Map<String, Object> operateStatusMap = new HashMap<>(); | 92 | Map<String, Object> operateStatusMap = new HashMap<>(); |
| 68 | operateStatusMap.put(RESULT, operateStatusDO); | 93 | operateStatusMap.put(RESULT, operateStatusDO); |
| 69 | webSocketServer.sendMessage(windowName, operateStatus, SUCCESS, operateStatusMap); | 94 | webSocketServer.sendMessage(windowName, operateStatus, SUCCESS, operateStatusMap); |
| 70 | 95 | ||
| 71 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); | 96 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); |
| 72 | - statement.execute(TURN_OFF_SQL + oid + PARENTHESES_SEMICOLON); | 97 | + statement.execute(String.format(TURN_OFF_SQL, oid)); |
| 73 | - log.info("AsyncHelper oid is: " + oid); | 98 | + log.info("AsyncHelper oid: " + oid); |
| 74 | 99 | ||
| 75 | Connection conn = (Connection) webSocketServer.getParamMap(windowName).get(CONNECTION); | 100 | Connection conn = (Connection) webSocketServer.getParamMap(windowName).get(CONNECTION); |
| 76 | Statement stat = (Statement) webSocketServer.getParamMap(windowName).get(STATEMENT); | 101 | Statement stat = (Statement) webSocketServer.getParamMap(windowName).get(STATEMENT); |
| @@ -85,8 +110,5 @@ public class AsyncHelper { | |||
| 85 | } | 110 | } |
| 86 | statement.close(); | 111 | statement.close(); |
| 87 | webSocketServer.setStatement(windowName, null); | 112 | webSocketServer.setStatement(windowName, null); |
| 88 | - Connection connection = webSocketServer.getConnection(windowName); | ||
| 89 | - connection.close(); | ||
| 90 | - webSocketServer.setConnection(windowName, null); | ||
| 91 | } | 113 | } |
| 92 | } | 114 | } |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/ChangeLanguageImpl.java+4-8
| @@ -1,23 +1,19 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| 4 | import com.nctigba.datastudio.base.WebSocketServer; | 8 | import com.nctigba.datastudio.base.WebSocketServer; |
| 5 | import com.nctigba.datastudio.model.PublicParamReq; | 9 | import com.nctigba.datastudio.model.PublicParamReq; |
| 6 | import com.nctigba.datastudio.service.OperationInterface; | 10 | import com.nctigba.datastudio.service.OperationInterface; |
| 7 | -import com.nctigba.datastudio.util.LocaleString; | ||
| 8 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
| 9 | -import org.opengauss.admin.common.exception.CustomException; | ||
| 10 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
| 11 | 13 | ||
| 12 | -import java.sql.Connection; | ||
| 13 | - | ||
| 14 | -import static com.nctigba.datastudio.dao.ConnectionMapDAO.conMap; | ||
| 15 | -import static com.nctigba.datastudio.enums.MessageEnum.other; | ||
| 16 | - | ||
| 17 | 14 | ||
| 18 | 15 | ||
| 19 | public class ChangeLanguageImpl implements OperationInterface { | 16 | public class ChangeLanguageImpl implements OperationInterface { |
| 20 | - | ||
| 21 | 17 | ||
| 22 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 18 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 23 | PublicParamReq paramReq = (PublicParamReq) obj; | 19 | PublicParamReq paramReq = (PublicParamReq) obj; |
| @@ -0,0 +1,109 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.service.impl.debug; | ||
| 6 | + | ||
| 7 | +import com.alibaba.fastjson.JSON; | ||
| 8 | +import com.nctigba.datastudio.base.WebSocketServer; | ||
| 9 | +import com.nctigba.datastudio.model.PublicParamReq; | ||
| 10 | +import com.nctigba.datastudio.service.OperationInterface; | ||
| 11 | +import com.nctigba.datastudio.util.DebugUtils; | ||
| 12 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 13 | +import lombok.extern.slf4j.Slf4j; | ||
| 14 | +import org.apache.commons.lang3.StringUtils; | ||
| 15 | +import org.apache.logging.log4j.util.Strings; | ||
| 16 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 17 | +import org.springframework.stereotype.Service; | ||
| 18 | + | ||
| 19 | +import java.sql.ResultSet; | ||
| 20 | +import java.sql.Statement; | ||
| 21 | +import java.util.ArrayList; | ||
| 22 | +import java.util.HashMap; | ||
| 23 | +import java.util.List; | ||
| 24 | +import java.util.Map; | ||
| 25 | + | ||
| 26 | +import static com.nctigba.datastudio.constants.CommonConstants.OID; | ||
| 27 | +import static com.nctigba.datastudio.constants.CommonConstants.RESULT; | ||
| 28 | +import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | ||
| 29 | +import static com.nctigba.datastudio.constants.SqlConstants.QUERY_OID_SQL; | ||
| 30 | +import static com.nctigba.datastudio.enums.MessageEnum.message; | ||
| 31 | +import static com.nctigba.datastudio.enums.MessageEnum.newFile; | ||
| 32 | +import static com.nctigba.datastudio.enums.MessageEnum.text; | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + | ||
| 36 | +public class CompileImpl implements OperationInterface { | ||
| 37 | + | ||
| 38 | + public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | ||
| 39 | + PublicParamReq paramReq = (PublicParamReq) obj; | ||
| 40 | + log.info("compile paramReq: " + paramReq); | ||
| 41 | + | ||
| 42 | + String rootWindowName = paramReq.getRootWindowName(); | ||
| 43 | + Statement statement = webSocketServer.getStatement(rootWindowName); | ||
| 44 | + if (statement == null) { | ||
| 45 | + statement = webSocketServer.getConnection(rootWindowName).createStatement(); | ||
| 46 | + webSocketServer.setStatement(rootWindowName, statement); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + String sql = paramReq.getSql(); | ||
| 50 | + String schema = DebugUtils.getSchemaBySql(sql); | ||
| 51 | + String name = DebugUtils.getNameBySql(sql); | ||
| 52 | + if (StringUtils.isEmpty(schema)) { | ||
| 53 | + schema = paramReq.getSchema(); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + List<String> oldOidList = new ArrayList<>(); | ||
| 57 | + try ( | ||
| 58 | + ResultSet resultSetOld = statement.executeQuery(String.format(QUERY_OID_SQL, name, schema)) | ||
| 59 | + ) { | ||
| 60 | + while (resultSetOld.next()) { | ||
| 61 | + oldOidList.add(resultSetOld.getString(OID)); | ||
| 62 | + } | ||
| 63 | + } catch (Exception e) { | ||
| 64 | + log.info(e.getMessage()); | ||
| 65 | + throw new CustomException(e.getMessage(), e); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + log.info("compile oldOidList: " + oldOidList); | ||
| 69 | + statement.execute(sql); | ||
| 70 | + List<String> newOidList = new ArrayList<>(); | ||
| 71 | + | ||
| 72 | + try ( | ||
| 73 | + ResultSet resultSetNew = statement.executeQuery(String.format(QUERY_OID_SQL, name, schema)) | ||
| 74 | + ) { | ||
| 75 | + while (resultSetNew.next()) { | ||
| 76 | + newOidList.add(resultSetNew.getString(OID)); | ||
| 77 | + } | ||
| 78 | + } catch (Exception e) { | ||
| 79 | + log.info(e.getMessage()); | ||
| 80 | + throw new CustomException(e.getMessage(), e); | ||
| 81 | + } | ||
| 82 | + log.info("compile newOidList: " + newOidList); | ||
| 83 | + | ||
| 84 | + String newOid = Strings.EMPTY; | ||
| 85 | + for (String id : newOidList) { | ||
| 86 | + if (!oldOidList.contains(id)) { | ||
| 87 | + newOid = id; | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + log.info("compile newOid: " + newOid); | ||
| 91 | + String windowName = paramReq.getRootWindowName(); | ||
| 92 | + if (StringUtils.isEmpty(newOid)) { | ||
| 93 | + webSocketServer.sendMessage(windowName, text, LocaleString.transLanguageWs("1002", webSocketServer), null); | ||
| 94 | + return; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + Map<String, String> messageMap = new HashMap<>(); | ||
| 98 | + messageMap.put(RESULT, LocaleString.transLanguageWs("1005", webSocketServer)); | ||
| 99 | + webSocketServer.sendMessage(windowName, message, SUCCESS, messageMap); | ||
| 100 | + paramReq.setOid(newOid); | ||
| 101 | + Map<String, Map<String, String>> map = DebugUtils.getResultMap(webSocketServer, paramReq); | ||
| 102 | + webSocketServer.sendMessage(windowName, newFile, SUCCESS, map); | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + | ||
| 106 | + public Object formatJson(String str) { | ||
| 107 | + return JSON.parseObject(str, PublicParamReq.class); | ||
| 108 | + } | ||
| 109 | +} | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/ConnectionImpl.java+5-2
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| @@ -17,13 +21,12 @@ import static com.nctigba.datastudio.enums.MessageEnum.other; | |||
| 17 | 21 | ||
| 18 | 22 | ||
| 19 | public class ConnectionImpl implements OperationInterface { | 23 | public class ConnectionImpl implements OperationInterface { |
| 20 | - | ||
| 21 | 24 | ||
| 22 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 25 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 23 | PublicParamReq paramReq = (PublicParamReq) obj; | 26 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 24 | String windowName = paramReq.getWindowName(); | 27 | String windowName = paramReq.getWindowName(); |
| 25 | log.info("connection paramReq is: " + paramReq); | 28 | log.info("connection paramReq is: " + paramReq); |
| 26 | - if(!conMap.containsKey(paramReq.getUuid())){ | 29 | + if (!conMap.containsKey(paramReq.getUuid())) { |
| 27 | throw new CustomException(LocaleString.transLanguageWs("1004", webSocketServer)); | 30 | throw new CustomException(LocaleString.transLanguageWs("1004", webSocketServer)); |
| 28 | } | 31 | } |
| 29 | Connection connection = webSocketServer.createConnection(paramReq.getUuid(), windowName); | 32 | Connection connection = webSocketServer.createConnection(paramReq.getUuid(), windowName); |
Rplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/BreakPointStepImpl.java→plugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/ContinueStepImpl.java+41-18
| @@ -1,31 +1,41 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| 4 | import com.nctigba.datastudio.base.WebSocketServer; | 8 | import com.nctigba.datastudio.base.WebSocketServer; |
| 5 | import com.nctigba.datastudio.model.PublicParamReq; | 9 | import com.nctigba.datastudio.model.PublicParamReq; |
| 6 | import com.nctigba.datastudio.service.OperationInterface; | 10 | import com.nctigba.datastudio.service.OperationInterface; |
| 11 | +import com.nctigba.datastudio.util.DebugUtils; | ||
| 7 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 8 | -import org.apache.commons.lang3.StringUtils; | ||
| 9 | import org.apache.logging.log4j.util.Strings; | 13 | import org.apache.logging.log4j.util.Strings; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.stereotype.Service; | 15 | import org.springframework.stereotype.Service; |
| 16 | +import org.springframework.util.CollectionUtils; | ||
| 12 | 17 | ||
| 13 | import java.sql.ResultSet; | 18 | import java.sql.ResultSet; |
| 14 | import java.sql.Statement; | 19 | import java.sql.Statement; |
| 20 | +import java.util.HashMap; | ||
| 21 | +import java.util.List; | ||
| 22 | +import java.util.Map; | ||
| 15 | 23 | ||
| 16 | import static com.nctigba.datastudio.constants.CommonConstants.FUNC_OID; | 24 | import static com.nctigba.datastudio.constants.CommonConstants.FUNC_OID; |
| 17 | import static com.nctigba.datastudio.constants.CommonConstants.OID; | 25 | import static com.nctigba.datastudio.constants.CommonConstants.OID; |
| 26 | +import static com.nctigba.datastudio.constants.CommonConstants.RESULT; | ||
| 18 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; | 27 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; |
| 19 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | 28 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; |
| 20 | import static com.nctigba.datastudio.constants.SqlConstants.CONTINUE_SQL; | 29 | import static com.nctigba.datastudio.constants.SqlConstants.CONTINUE_SQL; |
| 21 | import static com.nctigba.datastudio.enums.MessageEnum.closeWindow; | 30 | import static com.nctigba.datastudio.enums.MessageEnum.closeWindow; |
| 31 | +import static com.nctigba.datastudio.enums.MessageEnum.switchWindow; | ||
| 22 | 32 | ||
| 23 | /** | 33 | /** |
| 24 | * break point step | 34 | * break point step |
| 25 | */ | 35 | */ |
| 26 | 36 | ||
| 27 | -@Service("breakPointStep") | 37 | +@Service("continueStep") |
| 28 | -public class BreakPointStepImpl implements OperationInterface { | 38 | +public class ContinueStepImpl implements OperationInterface { |
| 29 | 39 | ||
| 30 | private SingleStepImpl singleStep; | 40 | private SingleStepImpl singleStep; |
| 31 | 41 | ||
| @@ -34,36 +44,49 @@ public class BreakPointStepImpl implements OperationInterface { | |||
| 34 | 44 | ||
| 35 | 45 | ||
| 36 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 46 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 37 | - log.info("breakPointStep obj is: " + obj); | ||
| 38 | PublicParamReq paramReq = (PublicParamReq) obj; | 47 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 39 | - String name = paramReq.getOldWindowName(); | 48 | + log.info("continueStep paramReq: " + paramReq); |
| 49 | + String rootWindowName = paramReq.getRootWindowName(); | ||
| 50 | + String oldWindowName = paramReq.getOldWindowName(); | ||
| 40 | String windowName = paramReq.getWindowName(); | 51 | String windowName = paramReq.getWindowName(); |
| 41 | - if (StringUtils.isEmpty(name)) { | ||
| 42 | - name = windowName; | ||
| 43 | - } | ||
| 44 | 52 | ||
| 45 | try { | 53 | try { |
| 46 | - Statement stat = (Statement) webSocketServer.getParamMap(name).get(STATEMENT); | 54 | + Statement stat = (Statement) webSocketServer.getParamMap(rootWindowName).get(STATEMENT); |
| 47 | if (stat == null) { | 55 | if (stat == null) { |
| 48 | return; | 56 | return; |
| 49 | } | 57 | } |
| 50 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); | 58 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); |
| 51 | - log.info("breakPointStep oid is: " + oid); | 59 | + log.info("continueStep windowName oid: " + oid); |
| 52 | - ResultSet resultSet = stat.executeQuery(CONTINUE_SQL); | ||
| 53 | String newOid = Strings.EMPTY; | 60 | String newOid = Strings.EMPTY; |
| 54 | - while (resultSet.next()) { | 61 | + ResultSet resultSet = stat.executeQuery(CONTINUE_SQL); |
| 62 | + if (resultSet.next()) { | ||
| 55 | newOid = resultSet.getString(FUNC_OID); | 63 | newOid = resultSet.getString(FUNC_OID); |
| 56 | - log.info("breakPointStep newOid is: " + newOid); | ||
| 57 | } | 64 | } |
| 58 | 65 | ||
| 59 | - if (!oid.equals(newOid)) { | 66 | + List<String> oidList = DebugUtils.getOidList(webSocketServer, rootWindowName); |
| 60 | - stepOut.deleteBreakPoint(webSocketServer, paramReq); | 67 | + if (!CollectionUtils.isEmpty(oidList)) { |
| 61 | - webSocketServer.sendMessage(windowName, closeWindow, SUCCESS, null); | 68 | + if (oidList.contains(oid) && !oidList.get(0).equals(oid)) { |
| 62 | - paramReq.setCloseWindow(true); | 69 | + Map<String, String> map = new HashMap<>(); |
| 70 | + map.put(RESULT, oidList.get(0)); | ||
| 71 | + webSocketServer.sendMessage(windowName, switchWindow, SUCCESS, map); | ||
| 72 | + String name = DebugUtils.getOldWindowName(webSocketServer, rootWindowName, newOid); | ||
| 73 | + DebugUtils.disableButton(webSocketServer, windowName); | ||
| 74 | + DebugUtils.enableButton(webSocketServer, name); | ||
| 75 | + paramReq.setCloseWindow(true); | ||
| 76 | + paramReq.setOldWindowName(name); | ||
| 77 | + } | ||
| 78 | + if (!oidList.contains(oid)) { | ||
| 79 | + stepOut.deleteBreakPoint(webSocketServer, paramReq); | ||
| 80 | + webSocketServer.sendMessage(windowName, closeWindow, SUCCESS, null); | ||
| 81 | + DebugUtils.enableButton(webSocketServer, oldWindowName); | ||
| 82 | + paramReq.setCloseWindow(true); | ||
| 83 | + Map<String, Object> paramMap = webSocketServer.getParamMap(rootWindowName); | ||
| 84 | + paramMap.keySet().removeIf(oid::equals); | ||
| 85 | + } | ||
| 63 | } | 86 | } |
| 64 | singleStep.showDebugInfo(webSocketServer, paramReq); | 87 | singleStep.showDebugInfo(webSocketServer, paramReq); |
| 65 | } catch (Exception e) { | 88 | } catch (Exception e) { |
| 66 | - e.printStackTrace(); | 89 | + log.info(e.getMessage()); |
| 67 | } | 90 | } |
| 68 | } | 91 | } |
| 69 | 92 | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/CoverageRateServiceImpl.java+339-0
| @@ -0,0 +1,339 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.service.impl.debug; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.config.ConnectionConfig; | ||
| 8 | +import com.nctigba.datastudio.model.entity.CoverageRateDO; | ||
| 9 | +import com.nctigba.datastudio.model.query.CoverageRateRequest; | ||
| 10 | +import com.nctigba.datastudio.service.CoverageRateService; | ||
| 11 | +import com.nctigba.datastudio.util.DebugUtils; | ||
| 12 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 13 | +import lombok.extern.slf4j.Slf4j; | ||
| 14 | +import org.jsoup.Jsoup; | ||
| 15 | +import org.jsoup.nodes.Document; | ||
| 16 | +import org.jsoup.nodes.Element; | ||
| 17 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 18 | +import org.springframework.stereotype.Service; | ||
| 19 | + | ||
| 20 | +import javax.servlet.http.HttpServletResponse; | ||
| 21 | +import java.lang.reflect.Field; | ||
| 22 | +import java.math.BigDecimal; | ||
| 23 | +import java.math.RoundingMode; | ||
| 24 | +import java.sql.Connection; | ||
| 25 | +import java.sql.ResultSet; | ||
| 26 | +import java.sql.SQLException; | ||
| 27 | +import java.sql.Statement; | ||
| 28 | +import java.text.DateFormat; | ||
| 29 | +import java.text.SimpleDateFormat; | ||
| 30 | +import java.util.ArrayList; | ||
| 31 | +import java.util.Arrays; | ||
| 32 | +import java.util.HashMap; | ||
| 33 | +import java.util.List; | ||
| 34 | +import java.util.Map; | ||
| 35 | + | ||
| 36 | +import static com.nctigba.datastudio.constants.CommonConstants.BEGIN; | ||
| 37 | +import static com.nctigba.datastudio.constants.CommonConstants.CAN_BREAK_LINE; | ||
| 38 | +import static com.nctigba.datastudio.constants.CommonConstants.CID; | ||
| 39 | +import static com.nctigba.datastudio.constants.CommonConstants.COVERAGE_LINES; | ||
| 40 | +import static com.nctigba.datastudio.constants.CommonConstants.END; | ||
| 41 | +import static com.nctigba.datastudio.constants.CommonConstants.END_TIME; | ||
| 42 | +import static com.nctigba.datastudio.constants.CommonConstants.OID; | ||
| 43 | +import static com.nctigba.datastudio.constants.CommonConstants.PARAMS; | ||
| 44 | +import static com.nctigba.datastudio.constants.CommonConstants.PRO_NAME; | ||
| 45 | +import static com.nctigba.datastudio.constants.CommonConstants.REMARK_LINES; | ||
| 46 | +import static com.nctigba.datastudio.constants.CommonConstants.SOURCECODE; | ||
| 47 | +import static com.nctigba.datastudio.constants.CommonConstants.UNDERLINE; | ||
| 48 | +import static com.nctigba.datastudio.constants.SqlConstants.COMMA; | ||
| 49 | +import static com.nctigba.datastudio.constants.SqlConstants.DELETE_BY_ID_SQL; | ||
| 50 | +import static com.nctigba.datastudio.constants.SqlConstants.HIS_COVERAGE_OID_SQL; | ||
| 51 | +import static com.nctigba.datastudio.constants.SqlConstants.LF; | ||
| 52 | +import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_SEMICOLON; | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + | ||
| 56 | +public class CoverageRateServiceImpl implements CoverageRateService { | ||
| 57 | + public static final String EXPORT_HTML = "<!DOCTYPE html>" + LF + | ||
| 58 | + "<html>" + LF + | ||
| 59 | + "<body>" + LF + | ||
| 60 | + " <table style=\"height:50px\">" + LF + | ||
| 61 | + " <thead>" + LF + | ||
| 62 | + " <tr>" + LF + | ||
| 63 | + " <th colspan=\"4\" id=\"EXECUTE_STATEMENT\"></th>" + LF + | ||
| 64 | + " </tr>" + LF + | ||
| 65 | + " </thead>" + LF + | ||
| 66 | + " <tbody id=\"executeSql\">" + LF + | ||
| 67 | + " </tbody>" + LF + | ||
| 68 | + " </table>" + LF + | ||
| 69 | + " <table>" + LF + | ||
| 70 | + " <thead>" + LF + | ||
| 71 | + " <tr>" + LF + | ||
| 72 | + " <th id=\"SERIAL_NUMBER\"></th>" + LF + | ||
| 73 | + " <th id=\"TOTAL_ROWS\"></th>" + LF + | ||
| 74 | + " <th id=\"EXECUTION_ROWS\"></th>" + LF + | ||
| 75 | + " <th id=\"TOTAL_COVERAGE\"></th>" + LF + | ||
| 76 | + " <th id=\"ALL_LINE_NUMBER\"></th>" + LF + | ||
| 77 | + " <th id=\"EXECUTION_LINE_NUMBER\"></th>" + LF + | ||
| 78 | + " <th id=\"EXECUTION_COVERAGE\"></th>" + LF + | ||
| 79 | + " <th id=\"INPUT_PARAMS\"></th>" + LF + | ||
| 80 | + " <th id=\"UPDATE_TIME\"></th>" + LF + | ||
| 81 | + " </tr>" + LF + | ||
| 82 | + " </thead>" + LF + | ||
| 83 | + " <tbody id =\"data\">" + LF + | ||
| 84 | + " </tbody>" + LF + | ||
| 85 | + " </table>" + LF + | ||
| 86 | + "</body>" + LF + | ||
| 87 | + "<style>" + LF + | ||
| 88 | + " .bac_nor {" + LF + | ||
| 89 | + " border-top: none;" + LF + | ||
| 90 | + " border-bottom: none;" + LF + | ||
| 91 | + " }" + LF + | ||
| 92 | + " .bac_remark {" + LF + | ||
| 93 | + " background-color: rgb(167, 169, 169);" + LF + | ||
| 94 | + " }" + LF + | ||
| 95 | + " .bac_fail {" + LF + | ||
| 96 | + " width: 10px;" + LF + | ||
| 97 | + " height: 10px;" + LF + | ||
| 98 | + " background-color: #ff0000;" + LF + | ||
| 99 | + " border-radius: 50%;" + LF + | ||
| 100 | + " float: right;" + LF + | ||
| 101 | + " }" + LF + | ||
| 102 | + " .bac_pass {" + LF + | ||
| 103 | + " width: 10px;" + LF + | ||
| 104 | + " height: 10px;" + LF + | ||
| 105 | + " background-color: #008000;" + LF + | ||
| 106 | + " border-radius: 50%;" + LF + | ||
| 107 | + " float: right;" + LF + | ||
| 108 | + " }" + LF + | ||
| 109 | + "" + LF + | ||
| 110 | + " table {" + LF + | ||
| 111 | + " width: 100%;" + LF + | ||
| 112 | + " height: 200px;" + LF + | ||
| 113 | + " border-collapse: collapse;" + LF + | ||
| 114 | + " border: 1px solid black;" + LF + | ||
| 115 | + " }" + LF + | ||
| 116 | + "" + LF + | ||
| 117 | + " td {" + LF + | ||
| 118 | + " border: 1px solid black;" + LF + | ||
| 119 | + " text-align: center;" + LF + | ||
| 120 | + " }" + LF + | ||
| 121 | + "" + LF + | ||
| 122 | + " thead {" + LF + | ||
| 123 | + " background-color: rgb(220, 157, 157);" + LF + | ||
| 124 | + " }" + LF + | ||
| 125 | + "</style>" + LF + | ||
| 126 | + "</html>"; | ||
| 127 | + | ||
| 128 | + private ConnectionConfig connectionConfig; | ||
| 129 | + | ||
| 130 | + | ||
| 131 | + public List<CoverageRateDO> queryCoverageRate(CoverageRateRequest request) throws Exception { | ||
| 132 | + log.info("CoverageRateServiceImpl queryCoverageRate request: " + request); | ||
| 133 | + try ( | ||
| 134 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 135 | + Statement statement = connection.createStatement(); | ||
| 136 | + ResultSet resultSet = statement.executeQuery(String.format(HIS_COVERAGE_OID_SQL, request.getOid())) | ||
| 137 | + ) { | ||
| 138 | + List<CoverageRateDO> list = getCoverageList(resultSet); | ||
| 139 | + log.info("CoverageRateServiceImpl queryCoverageRate list: " + list); | ||
| 140 | + return list; | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + | ||
| 145 | + public void delete(CoverageRateRequest request) throws Exception { | ||
| 146 | + log.info("CoverageRateServiceImpl delete request: " + request); | ||
| 147 | + try ( | ||
| 148 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 149 | + Statement statement = connection.createStatement() | ||
| 150 | + ) { | ||
| 151 | + StringBuilder sb = new StringBuilder(); | ||
| 152 | + List<Long> cidList = request.getCidList(); | ||
| 153 | + for (int i = 0; i < cidList.size(); i++) { | ||
| 154 | + sb.append(cidList.get(i)); | ||
| 155 | + if (i != cidList.size() - 1) { | ||
| 156 | + sb.append(","); | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | + statement.execute(DELETE_BY_ID_SQL + sb + PARENTHESES_SEMICOLON); | ||
| 160 | + log.info("CoverageRateServiceImpl delete end "); | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + | ||
| 165 | + public void export(CoverageRateRequest request, HttpServletResponse response) throws Exception { | ||
| 166 | + log.info("CoverageRateServiceImpl export request: " + request); | ||
| 167 | + List<CoverageRateDO> list; | ||
| 168 | + try ( | ||
| 169 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 170 | + Statement statement = connection.createStatement(); | ||
| 171 | + ResultSet resultSet = statement.executeQuery(String.format(HIS_COVERAGE_OID_SQL, request.getOid())) | ||
| 172 | + ) { | ||
| 173 | + list = getCoverageList(resultSet); | ||
| 174 | + log.info("CoverageRateServiceImpl export list: " + list); | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + String html = parseHtml(list, request.getCidList()); | ||
| 178 | + log.info("CoverageRateServiceImpl export html: " + html); | ||
| 179 | + | ||
| 180 | + String fileName = "函数覆盖率报告_" + request.getOid() + UNDERLINE + list.get(0).getName() | ||
| 181 | + + UNDERLINE + System.currentTimeMillis() + ".html"; | ||
| 182 | + log.info("CoverageRateServiceImpl export fileName: " + fileName); | ||
| 183 | + DebugUtils.exportFile(fileName, html, response); | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + private List<CoverageRateDO> getCoverageList(ResultSet resultSet) throws SQLException { | ||
| 187 | + List<CoverageRateDO> list = new ArrayList<>(); | ||
| 188 | + int index = 1; | ||
| 189 | + while (resultSet.next()) { | ||
| 190 | + CoverageRateDO coverageRateDO = new CoverageRateDO(); | ||
| 191 | + String proName = resultSet.getString(PRO_NAME); | ||
| 192 | + Long oid = resultSet.getLong(OID); | ||
| 193 | + Long cid = resultSet.getLong(CID); | ||
| 194 | + String coverageLines = resultSet.getString(COVERAGE_LINES); | ||
| 195 | + String remarkLines = resultSet.getString(REMARK_LINES); | ||
| 196 | + Long endTime = resultSet.getLong(END_TIME); | ||
| 197 | + String sourcecode = resultSet.getString(SOURCECODE); | ||
| 198 | + String params = resultSet.getString(PARAMS); | ||
| 199 | + String canBreakLine = resultSet.getString(CAN_BREAK_LINE); | ||
| 200 | + | ||
| 201 | + coverageRateDO.setSerialNumber(index++); | ||
| 202 | + coverageRateDO.setName(proName); | ||
| 203 | + coverageRateDO.setOid(oid); | ||
| 204 | + coverageRateDO.setCid(cid); | ||
| 205 | + int totalLine = canBreakLine.split(COMMA).length; | ||
| 206 | + coverageRateDO.setTotalRows(totalLine); | ||
| 207 | + int executeLine = coverageLines.split(COMMA).length; | ||
| 208 | + coverageRateDO.setExecutionRows(executeLine); | ||
| 209 | + BigDecimal divide = BigDecimal.valueOf(executeLine * 100L).divide(BigDecimal.valueOf(totalLine), 1, | ||
| 210 | + RoundingMode.CEILING); | ||
| 211 | + coverageRateDO.setTotalCoverage(divide + "%"); | ||
| 212 | + coverageRateDO.setAllLineNumber(canBreakLine); | ||
| 213 | + coverageRateDO.setExecutionLineNumber(coverageLines); | ||
| 214 | + coverageRateDO.setExecutionCoverage(divide + "%"); | ||
| 215 | + coverageRateDO.setInputParams(params); | ||
| 216 | + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
| 217 | + coverageRateDO.setUpdateTime(df.format(endTime)); | ||
| 218 | + coverageRateDO.setSourcecode(sourcecode); | ||
| 219 | + log.info("CoverageRateServiceImpl getCoverageList coverageRateDO: " + coverageRateDO); | ||
| 220 | + list.add(coverageRateDO); | ||
| 221 | + } | ||
| 222 | + return list; | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + private String parseHtml(List<CoverageRateDO> coverageRateList, List<Long> cidList) { | ||
| 226 | + Document document = Jsoup.parse(EXPORT_HTML, "gbk"); | ||
| 227 | + convert(document); | ||
| 228 | + log.info("CoverageRateServiceImpl parseHtml document: " + document); | ||
| 229 | + | ||
| 230 | + Element data = document.getElementById("data"); | ||
| 231 | + for (CoverageRateDO coverageRateDO : coverageRateList) { | ||
| 232 | + if (!cidList.contains(coverageRateDO.getCid())) { | ||
| 233 | + continue; | ||
| 234 | + } | ||
| 235 | + log.info("CoverageRateServiceImpl parseHtml coverageRateDO: " + coverageRateDO); | ||
| 236 | + List<String> list = beanToList(coverageRateDO); | ||
| 237 | + Element dataTr = data.appendElement("tr"); | ||
| 238 | + list.forEach(item -> { | ||
| 239 | + Element dataTd = dataTr.appendElement("td"); | ||
| 240 | + dataTd.text(item); | ||
| 241 | + }); | ||
| 242 | + | ||
| 243 | + boolean[] flag = new boolean[]{true}; | ||
| 244 | + Element executeSql = document.getElementById("executeSql"); | ||
| 245 | + Map<String, Integer> offset = new HashMap<>(); | ||
| 246 | + Map<Integer, String> sqlMap = splitSourceCode(coverageRateDO.getSourcecode(), offset); | ||
| 247 | + sqlMap.forEach((k, v) -> { | ||
| 248 | + Element tr = executeSql.appendElement("tr"); | ||
| 249 | + if (flag[0]) { | ||
| 250 | + Element td = tr.appendElement("td"); | ||
| 251 | + td.attr("rowspan", sqlMap.values().size() + ""); | ||
| 252 | + td.text(String.valueOf(coverageRateDO.getSerialNumber())); | ||
| 253 | + flag[0] = false; | ||
| 254 | + } | ||
| 255 | + | ||
| 256 | + Element serial = tr.appendElement("td"); | ||
| 257 | + serial.text(k.toString()); | ||
| 258 | + Element td = tr.appendElement("td"); | ||
| 259 | + Element td2 = tr.appendElement("td"); | ||
| 260 | + Element div = td.appendElement("div"); | ||
| 261 | + td2.text(v); | ||
| 262 | + | ||
| 263 | + if (Arrays.asList(coverageRateDO.getAllLineNumber().split(COMMA)).contains(k.toString())) { | ||
| 264 | + td2.addClass("bac_remark"); | ||
| 265 | + } | ||
| 266 | + boolean isMarkRow = Arrays.asList(coverageRateDO.getAllLineNumber().split(COMMA)).contains( | ||
| 267 | + String.valueOf(k)); | ||
| 268 | + if (Arrays.asList(coverageRateDO.getExecutionLineNumber().split(COMMA)).contains( | ||
| 269 | + (k - 1) + "") && isMarkRow) { | ||
| 270 | + div.addClass("bac_pass"); | ||
| 271 | + } else { | ||
| 272 | + if (k > (offset.get(BEGIN) + 1) && k < (offset.get(END) + 1) && isMarkRow) { | ||
| 273 | + div.addClass("bac_fail"); | ||
| 274 | + } | ||
| 275 | + } | ||
| 276 | + }); | ||
| 277 | + } | ||
| 278 | + return document.outerHtml(); | ||
| 279 | + } | ||
| 280 | + | ||
| 281 | + private void convert(Document document) { | ||
| 282 | + Element execStatement = document.getElementById("EXECUTE_STATEMENT"); | ||
| 283 | + execStatement.text(LocaleString.transLanguage("3001")); | ||
| 284 | + Element serial = document.getElementById("SERIAL_NUMBER"); | ||
| 285 | + serial.text(LocaleString.transLanguage("3002")); | ||
| 286 | + Element totalRows = document.getElementById("TOTAL_ROWS"); | ||
| 287 | + totalRows.text(LocaleString.transLanguage("3003")); | ||
| 288 | + Element totalExecLines = document.getElementById("EXECUTION_ROWS"); | ||
| 289 | + totalExecLines.text(LocaleString.transLanguage("3004")); | ||
| 290 | + Element totalCoverage = document.getElementById("TOTAL_COVERAGE"); | ||
| 291 | + totalCoverage.text(LocaleString.transLanguage("3005")); | ||
| 292 | + Element markRows = document.getElementById("ALL_LINE_NUMBER"); | ||
| 293 | + markRows.text(LocaleString.transLanguage("3006")); | ||
| 294 | + Element markExecLines = document.getElementById("EXECUTION_LINE_NUMBER"); | ||
| 295 | + markExecLines.text(LocaleString.transLanguage("3007")); | ||
| 296 | + Element markCoverage = document.getElementById("EXECUTION_COVERAGE"); | ||
| 297 | + markCoverage.text(LocaleString.transLanguage("3008")); | ||
| 298 | + Element inputParams = document.getElementById("INPUT_PARAMS"); | ||
| 299 | + inputParams.text(LocaleString.transLanguage("3009")); | ||
| 300 | + Element updateTime = document.getElementById("UPDATE_TIME"); | ||
| 301 | + updateTime.text(LocaleString.transLanguage("3010")); | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + private List<String> beanToList(CoverageRateDO coverageRateDO) { | ||
| 305 | + log.info("CoverageRateServiceImpl beanToList coverageRateDO: " + coverageRateDO); | ||
| 306 | + List<String> list = new ArrayList<>(); | ||
| 307 | + Field[] fields = coverageRateDO.getClass().getDeclaredFields(); | ||
| 308 | + try { | ||
| 309 | + for (int i = 3; i < fields.length - 1; i++) { | ||
| 310 | + Field f = coverageRateDO.getClass().getDeclaredField(fields[i].getName()); | ||
| 311 | + f.setAccessible(true); | ||
| 312 | + Object o = f.get(coverageRateDO); | ||
| 313 | + list.add(o.toString()); | ||
| 314 | + } | ||
| 315 | + } catch (Exception e) { | ||
| 316 | + log.info(e.getMessage()); | ||
| 317 | + } | ||
| 318 | + log.info("CoverageRateServiceImpl beanToList list: " + list); | ||
| 319 | + return list; | ||
| 320 | + } | ||
| 321 | + | ||
| 322 | + private Map<Integer, String> splitSourceCode(String sourceCode, Map<String, Integer> offsetMap) { | ||
| 323 | + log.info("CoverageRateServiceImpl splitSourceCode sourceCode: " + sourceCode); | ||
| 324 | + Map<Integer, String> map = new HashMap<>(); | ||
| 325 | + String[] split = sourceCode.split(LF); | ||
| 326 | + for (int i = 0; i < split.length; i++) { | ||
| 327 | + map.put(i + 1, split[i]); | ||
| 328 | + if (split[i].trim().equalsIgnoreCase(BEGIN)) { | ||
| 329 | + offsetMap.put(BEGIN, i + 1); | ||
| 330 | + } | ||
| 331 | + if (split[i].trim().toLowerCase().startsWith(END)) { | ||
| 332 | + offsetMap.put(END, i + 1); | ||
| 333 | + } | ||
| 334 | + } | ||
| 335 | + log.info("CoverageRateServiceImpl splitSourceCode map: " + map); | ||
| 336 | + log.info("CoverageRateServiceImpl splitSourceCode offsetMap: " + offsetMap); | ||
| 337 | + return map; | ||
| 338 | + } | ||
| 339 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/CreateCoverageRateImpl.java+183-0
| @@ -0,0 +1,183 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.service.impl.debug; | ||
| 6 | + | ||
| 7 | +import com.alibaba.fastjson.JSON; | ||
| 8 | +import com.nctigba.datastudio.base.WebSocketServer; | ||
| 9 | +import com.nctigba.datastudio.model.PublicParamReq; | ||
| 10 | +import com.nctigba.datastudio.service.OperationInterface; | ||
| 11 | +import lombok.extern.slf4j.Slf4j; | ||
| 12 | +import org.apache.logging.log4j.util.Strings; | ||
| 13 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 15 | +import org.springframework.stereotype.Service; | ||
| 16 | + | ||
| 17 | +import java.sql.Connection; | ||
| 18 | +import java.sql.PreparedStatement; | ||
| 19 | +import java.sql.ResultSet; | ||
| 20 | +import java.sql.SQLException; | ||
| 21 | +import java.sql.Statement; | ||
| 22 | +import java.util.ArrayList; | ||
| 23 | +import java.util.List; | ||
| 24 | +import java.util.Map; | ||
| 25 | +import java.util.Set; | ||
| 26 | + | ||
| 27 | +import static com.nctigba.datastudio.constants.CommonConstants.CAN_BREAK; | ||
| 28 | +import static com.nctigba.datastudio.constants.CommonConstants.CONNECTION; | ||
| 29 | +import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; | ||
| 30 | +import static com.nctigba.datastudio.constants.CommonConstants.FUNC_OID; | ||
| 31 | +import static com.nctigba.datastudio.constants.CommonConstants.LINE_NO; | ||
| 32 | +import static com.nctigba.datastudio.constants.CommonConstants.NODE_NAME; | ||
| 33 | +import static com.nctigba.datastudio.constants.CommonConstants.PORT; | ||
| 34 | +import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; | ||
| 35 | +import static com.nctigba.datastudio.constants.CommonConstants.T; | ||
| 36 | +import static com.nctigba.datastudio.constants.SqlConstants.ATTACH_SQL; | ||
| 37 | +import static com.nctigba.datastudio.constants.SqlConstants.COMMA; | ||
| 38 | +import static com.nctigba.datastudio.constants.SqlConstants.CONTINUE_SQL; | ||
| 39 | +import static com.nctigba.datastudio.constants.SqlConstants.CREATE_COVERAGE_SQL; | ||
| 40 | +import static com.nctigba.datastudio.constants.SqlConstants.DEBUG_SERVER_INFO_SQL; | ||
| 41 | +import static com.nctigba.datastudio.constants.SqlConstants.INFO_CODE_SQL; | ||
| 42 | +import static com.nctigba.datastudio.constants.SqlConstants.INSERT_COVERAGE_SQL; | ||
| 43 | +import static com.nctigba.datastudio.constants.SqlConstants.NEXT_SQL; | ||
| 44 | +import static com.nctigba.datastudio.constants.SqlConstants.TURN_ON_SQL; | ||
| 45 | + | ||
| 46 | +/** | ||
| 47 | + * input param | ||
| 48 | + */ | ||
| 49 | + | ||
| 50 | + | ||
| 51 | +public class CreateCoverageRateImpl implements OperationInterface { | ||
| 52 | + | ||
| 53 | + private AsyncHelper asyncHelper; | ||
| 54 | + | ||
| 55 | + | ||
| 56 | + public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | ||
| 57 | + PublicParamReq paramReq = (PublicParamReq) obj; | ||
| 58 | + log.info("createCoverage paramReq: " + paramReq); | ||
| 59 | + String windowName = paramReq.getWindowName(); | ||
| 60 | + Connection connection = webSocketServer.getConnection(windowName); | ||
| 61 | + Statement statement = connection.createStatement(); | ||
| 62 | + webSocketServer.setStatement(windowName, statement); | ||
| 63 | + | ||
| 64 | + List<String> oidList = new ArrayList<>(); | ||
| 65 | + List<String> nodeNameList = new ArrayList<>(); | ||
| 66 | + List<String> portList = new ArrayList<>(); | ||
| 67 | + try ( | ||
| 68 | + ResultSet serverInfo = statement.executeQuery(DEBUG_SERVER_INFO_SQL) | ||
| 69 | + ) { | ||
| 70 | + while (serverInfo.next()) { | ||
| 71 | + oidList.add(serverInfo.getString(FUNC_OID)); | ||
| 72 | + nodeNameList.add(serverInfo.getString(NODE_NAME)); | ||
| 73 | + portList.add(serverInfo.getString(PORT)); | ||
| 74 | + } | ||
| 75 | + log.info("createCoverage oidList: " + oidList); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + String nodeName = Strings.EMPTY; | ||
| 79 | + String port = Strings.EMPTY; | ||
| 80 | + String oid = paramReq.getOid(); | ||
| 81 | + if (oidList.contains(oid)) { | ||
| 82 | + int index = oidList.indexOf(oid); | ||
| 83 | + nodeName = nodeNameList.get(index); | ||
| 84 | + port = portList.get(index); | ||
| 85 | + } else { | ||
| 86 | + try ( | ||
| 87 | + ResultSet turnNoResult = statement.executeQuery(String.format(TURN_ON_SQL, oid)) | ||
| 88 | + ) { | ||
| 89 | + while (turnNoResult.next()) { | ||
| 90 | + nodeName = turnNoResult.getString(NODE_NAME); | ||
| 91 | + port = turnNoResult.getString(PORT); | ||
| 92 | + log.info("inputParam nodeName and port is: " + nodeName + "---" + port); | ||
| 93 | + } | ||
| 94 | + } catch (Exception e) { | ||
| 95 | + log.info(e.getMessage()); | ||
| 96 | + throw new CustomException(e.getMessage(), e); | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + boolean coverage = paramReq.isCoverage(); | ||
| 101 | + paramReq.setCoverage(true); | ||
| 102 | + asyncHelper.task(webSocketServer, paramReq); | ||
| 103 | + Connection conn = webSocketServer.createConnection(paramReq.getUuid(), windowName); | ||
| 104 | + Statement statNew = conn.createStatement(); | ||
| 105 | + webSocketServer.setParamMap(windowName, CONNECTION, conn); | ||
| 106 | + webSocketServer.setParamMap(windowName, STATEMENT, statNew); | ||
| 107 | + if (coverage) { | ||
| 108 | + int differ = (int) webSocketServer.getParamMap(windowName).get(DIFFER); | ||
| 109 | + StringBuilder runLines = new StringBuilder(); | ||
| 110 | + try ( | ||
| 111 | + ResultSet rs = statNew.executeQuery(String.format(ATTACH_SQL, nodeName, port)) | ||
| 112 | + ) { | ||
| 113 | + while (rs.next()) { | ||
| 114 | + runLines.append(rs.getInt(LINE_NO) + differ).append(COMMA); | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + statNew.execute(CREATE_COVERAGE_SQL); | ||
| 118 | + StringBuilder allLines = new StringBuilder(); | ||
| 119 | + try ( | ||
| 120 | + ResultSet allLineResult = statNew.executeQuery(String.format(INFO_CODE_SQL, paramReq.getOid())) | ||
| 121 | + ) { | ||
| 122 | + while (allLineResult.next()) { | ||
| 123 | + if (T.equals(allLineResult.getString(CAN_BREAK))) { | ||
| 124 | + allLines.append(allLineResult.getInt(LINE_NO) + differ).append(COMMA); | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + allLines.deleteCharAt(allLines.length() - 1); | ||
| 129 | + log.info("createCoverage allLines: " + allLines); | ||
| 130 | + | ||
| 131 | + int index = 0; | ||
| 132 | + do { | ||
| 133 | + try ( | ||
| 134 | + ResultSet resultSet = statNew.executeQuery(NEXT_SQL) | ||
| 135 | + ) { | ||
| 136 | + if (resultSet.next()) { | ||
| 137 | + index = resultSet.getInt(LINE_NO); | ||
| 138 | + if (index != 0) { | ||
| 139 | + runLines.append(index + differ).append(COMMA); | ||
| 140 | + } | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | + } while (index != 0); | ||
| 144 | + runLines.deleteCharAt(runLines.length() - 1); | ||
| 145 | + log.info("createCoverage runLines: " + runLines); | ||
| 146 | + insertTable(connection, paramReq, runLines.toString(), allLines.toString()); | ||
| 147 | + } else { | ||
| 148 | + statNew.execute(String.format(ATTACH_SQL, nodeName, port)); | ||
| 149 | + statNew.executeQuery(CONTINUE_SQL); | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + private void insertTable(Connection connection, PublicParamReq paramReq, String runLines, | ||
| 154 | + String allLines) throws SQLException { | ||
| 155 | + List<Object> list = new ArrayList<>(); | ||
| 156 | + List<Map<String, Object>> inputParamsList = paramReq.getInputParams(); | ||
| 157 | + for (Map<String, Object> map : inputParamsList) { | ||
| 158 | + Set<String> keys = map.keySet(); | ||
| 159 | + for (String key : keys) { | ||
| 160 | + list.add(map.get(key)); | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + try ( | ||
| 165 | + PreparedStatement preparedStatement = connection.prepareStatement(INSERT_COVERAGE_SQL) | ||
| 166 | + ) { | ||
| 167 | + preparedStatement.setObject(1, paramReq.getOid()); | ||
| 168 | + preparedStatement.setObject(2, System.currentTimeMillis()); | ||
| 169 | + preparedStatement.setObject(3, runLines); | ||
| 170 | + preparedStatement.setObject(4, null); | ||
| 171 | + preparedStatement.setObject(5, System.currentTimeMillis()); | ||
| 172 | + preparedStatement.setObject(6, paramReq.getSql()); | ||
| 173 | + preparedStatement.setObject(7, list.toString()); | ||
| 174 | + preparedStatement.setObject(8, allLines); | ||
| 175 | + preparedStatement.execute(); | ||
| 176 | + } | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + | ||
| 180 | + public Object formatJson(String str) { | ||
| 181 | + return JSON.parseObject(str, PublicParamReq.class); | ||
| 182 | + } | ||
| 183 | +} | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/DeleteBreakPointImpl.java+21-17
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| @@ -6,15 +10,16 @@ import com.nctigba.datastudio.model.PublicParamReq; | |||
| 6 | import com.nctigba.datastudio.service.OperationInterface; | 10 | import com.nctigba.datastudio.service.OperationInterface; |
| 7 | import com.nctigba.datastudio.util.DebugUtils; | 11 | import com.nctigba.datastudio.util.DebugUtils; |
| 8 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 9 | -import org.apache.commons.lang3.StringUtils; | ||
| 10 | import org.springframework.stereotype.Service; | 13 | import org.springframework.stereotype.Service; |
| 11 | 14 | ||
| 12 | import java.sql.ResultSet; | 15 | import java.sql.ResultSet; |
| 13 | import java.sql.Statement; | 16 | import java.sql.Statement; |
| 14 | import java.util.Iterator; | 17 | import java.util.Iterator; |
| 18 | +import java.util.List; | ||
| 15 | import java.util.Map; | 19 | import java.util.Map; |
| 16 | 20 | ||
| 17 | import static com.nctigba.datastudio.constants.CommonConstants.BREAK_POINT; | 21 | import static com.nctigba.datastudio.constants.CommonConstants.BREAK_POINT; |
| 22 | +import static com.nctigba.datastudio.constants.CommonConstants.CAN_BREAK; | ||
| 18 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; | 23 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; |
| 19 | import static com.nctigba.datastudio.constants.CommonConstants.OID; | 24 | import static com.nctigba.datastudio.constants.CommonConstants.OID; |
| 20 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; | 25 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; |
| @@ -22,7 +27,6 @@ import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | |||
| 22 | import static com.nctigba.datastudio.constants.SqlConstants.DELETE_BREAKPOINT_SQL; | 27 | import static com.nctigba.datastudio.constants.SqlConstants.DELETE_BREAKPOINT_SQL; |
| 23 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_PRE; | 28 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_PRE; |
| 24 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_SQL; | 29 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_SQL; |
| 25 | -import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_SEMICOLON; | ||
| 26 | import static com.nctigba.datastudio.enums.MessageEnum.breakPoint; | 30 | import static com.nctigba.datastudio.enums.MessageEnum.breakPoint; |
| 27 | 31 | ||
| 28 | /** | 32 | /** |
| @@ -33,28 +37,28 @@ import static com.nctigba.datastudio.enums.MessageEnum.breakPoint; | |||
| 33 | public class DeleteBreakPointImpl implements OperationInterface { | 37 | public class DeleteBreakPointImpl implements OperationInterface { |
| 34 | 38 | ||
| 35 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 39 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 36 | - log.info("deleteBreakPoint obj is: " + obj); | ||
| 37 | PublicParamReq paramReq = (PublicParamReq) obj; | 40 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 38 | - String windowName = paramReq.getWindowName(); | 41 | + log.info("deleteBreakPoint paramReq: " + paramReq); |
| 39 | - int line = paramReq.getLine(); | ||
| 40 | - int differ = (int) webSocketServer.getParamMap(windowName).get(DIFFER); | ||
| 41 | - Map<Integer, String> breakPointMap = (Map<Integer, String>) webSocketServer.getParamMap(windowName).get(BREAK_POINT); | ||
| 42 | - log.info("deleteBreakPoint breakPointMap is: " + breakPointMap); | ||
| 43 | 42 | ||
| 44 | - String name = paramReq.getOldWindowName(); | 43 | + String windowName = paramReq.getWindowName(); |
| 45 | - if (StringUtils.isEmpty(name)) { | 44 | + Map<Integer, String> breakPointMap = (Map<Integer, String>) webSocketServer.getParamMap(windowName).get( |
| 46 | - name = windowName; | 45 | + BREAK_POINT); |
| 47 | - } | 46 | + log.info("deleteBreakPoint breakPointMap: " + breakPointMap); |
| 48 | - Statement stat = (Statement) webSocketServer.getParamMap(name).get(STATEMENT); | 47 | + |
| 48 | + String rootWindowName = paramReq.getRootWindowName(); | ||
| 49 | + Statement stat = (Statement) webSocketServer.getParamMap(rootWindowName).get(STATEMENT); | ||
| 49 | if (stat == null) { | 50 | if (stat == null) { |
| 50 | return; | 51 | return; |
| 51 | } | 52 | } |
| 52 | 53 | ||
| 53 | - if (webSocketServer.checkLine(windowName, line)) { | 54 | + int line = paramReq.getLine(); |
| 55 | + int differ = (int) webSocketServer.getParamMap(windowName).get(DIFFER); | ||
| 56 | + List<Integer> list = (List<Integer>) webSocketServer.getParamMap(windowName).get(CAN_BREAK); | ||
| 57 | + if (list.contains(line - differ)) { | ||
| 54 | int no = Integer.parseInt(breakPointMap.get(line)); | 58 | int no = Integer.parseInt(breakPointMap.get(line)); |
| 55 | - stat.execute(DELETE_BREAKPOINT_SQL + no + PARENTHESES_SEMICOLON); | 59 | + stat.execute(String.format(DELETE_BREAKPOINT_SQL, no)); |
| 56 | Iterator<Integer> iterator = breakPointMap.keySet().iterator(); | 60 | Iterator<Integer> iterator = breakPointMap.keySet().iterator(); |
| 57 | - log.info("deleteBreakPoint iterator is: " + iterator); | 61 | + log.info("deleteBreakPoint iterator: " + iterator); |
| 58 | while (iterator.hasNext()) { | 62 | while (iterator.hasNext()) { |
| 59 | if (line == iterator.next()) { | 63 | if (line == iterator.next()) { |
| 60 | iterator.remove(); | 64 | iterator.remove(); |
| @@ -66,7 +70,7 @@ public class DeleteBreakPointImpl implements OperationInterface { | |||
| 66 | if (!paramReq.isCloseWindow()) { | 70 | if (!paramReq.isCloseWindow()) { |
| 67 | ResultSet bpResult = stat.executeQuery(INFO_BREAKPOINT_PRE + differ + INFO_BREAKPOINT_SQL); | 71 | ResultSet bpResult = stat.executeQuery(INFO_BREAKPOINT_PRE + differ + INFO_BREAKPOINT_SQL); |
| 68 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); | 72 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); |
| 69 | - webSocketServer.sendMessage(windowName, breakPoint, SUCCESS, DebugUtils.parseBeakPoint(bpResult, oid)); | 73 | + webSocketServer.sendMessage(windowName, breakPoint, SUCCESS, DebugUtils.parseBreakPoint(bpResult, oid)); |
| 70 | } | 74 | } |
| 71 | } | 75 | } |
| 72 | 76 | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/DisableBreakPointImpl.java+21-17
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| @@ -6,14 +10,15 @@ import com.nctigba.datastudio.model.PublicParamReq; | |||
| 6 | import com.nctigba.datastudio.service.OperationInterface; | 10 | import com.nctigba.datastudio.service.OperationInterface; |
| 7 | import com.nctigba.datastudio.util.DebugUtils; | 11 | import com.nctigba.datastudio.util.DebugUtils; |
| 8 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 9 | -import org.apache.commons.lang3.StringUtils; | ||
| 10 | import org.springframework.stereotype.Service; | 13 | import org.springframework.stereotype.Service; |
| 11 | 14 | ||
| 12 | import java.sql.ResultSet; | 15 | import java.sql.ResultSet; |
| 13 | import java.sql.Statement; | 16 | import java.sql.Statement; |
| 17 | +import java.util.List; | ||
| 14 | import java.util.Map; | 18 | import java.util.Map; |
| 15 | 19 | ||
| 16 | import static com.nctigba.datastudio.constants.CommonConstants.BREAK_POINT; | 20 | import static com.nctigba.datastudio.constants.CommonConstants.BREAK_POINT; |
| 21 | +import static com.nctigba.datastudio.constants.CommonConstants.CAN_BREAK; | ||
| 17 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; | 22 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; |
| 18 | import static com.nctigba.datastudio.constants.CommonConstants.OID; | 23 | import static com.nctigba.datastudio.constants.CommonConstants.OID; |
| 19 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; | 24 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; |
| @@ -21,7 +26,6 @@ import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | |||
| 21 | import static com.nctigba.datastudio.constants.SqlConstants.DISABLE_BREAKPOINT_SQL; | 26 | import static com.nctigba.datastudio.constants.SqlConstants.DISABLE_BREAKPOINT_SQL; |
| 22 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_PRE; | 27 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_PRE; |
| 23 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_SQL; | 28 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_SQL; |
| 24 | -import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_SEMICOLON; | ||
| 25 | import static com.nctigba.datastudio.enums.MessageEnum.breakPoint; | 29 | import static com.nctigba.datastudio.enums.MessageEnum.breakPoint; |
| 26 | 30 | ||
| 27 | /** | 31 | /** |
| @@ -32,32 +36,32 @@ import static com.nctigba.datastudio.enums.MessageEnum.breakPoint; | |||
| 32 | public class DisableBreakPointImpl implements OperationInterface { | 36 | public class DisableBreakPointImpl implements OperationInterface { |
| 33 | 37 | ||
| 34 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 38 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 35 | - log.info("disableBreakPoint obj is: " + obj); | ||
| 36 | PublicParamReq paramReq = (PublicParamReq) obj; | 39 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 37 | - String windowName = paramReq.getWindowName(); | 40 | + log.info("disableBreakPoint paramReq: " + paramReq); |
| 38 | - int line = paramReq.getLine(); | ||
| 39 | - int differ = (int) webSocketServer.getParamMap(windowName).get(DIFFER); | ||
| 40 | - Map<Integer, String> breakPointMap = (Map<Integer, String>) webSocketServer.getParamMap(windowName).get(BREAK_POINT); | ||
| 41 | - log.info("disableBreakPoint breakPointMap is: " + breakPointMap); | ||
| 42 | 41 | ||
| 43 | - String name = paramReq.getOldWindowName(); | 42 | + String windowName = paramReq.getWindowName(); |
| 44 | - if (StringUtils.isEmpty(name)) { | 43 | + Map<Integer, String> breakPointMap = (Map<Integer, String>) webSocketServer.getParamMap(windowName).get( |
| 45 | - name = windowName; | 44 | + BREAK_POINT); |
| 46 | - } | 45 | + log.info("disableBreakPoint breakPointMap: " + breakPointMap); |
| 47 | - Statement stat = (Statement) webSocketServer.getParamMap(name).get(STATEMENT); | 46 | + |
| 47 | + String rootWindowName = paramReq.getRootWindowName(); | ||
| 48 | + Statement stat = (Statement) webSocketServer.getParamMap(rootWindowName).get(STATEMENT); | ||
| 48 | if (stat == null) { | 49 | if (stat == null) { |
| 49 | return; | 50 | return; |
| 50 | } | 51 | } |
| 51 | 52 | ||
| 52 | - if (webSocketServer.checkLine(windowName, line)) { | 53 | + int line = paramReq.getLine(); |
| 54 | + int differ = (int) webSocketServer.getParamMap(windowName).get(DIFFER); | ||
| 55 | + List<Integer> list = (List<Integer>) webSocketServer.getParamMap(windowName).get(CAN_BREAK); | ||
| 56 | + if (list.contains(line - differ)) { | ||
| 53 | String no = breakPointMap.get(line); | 57 | String no = breakPointMap.get(line); |
| 54 | - log.info("disableBreakPoint no is: " + no); | 58 | + log.info("disableBreakPoint no: " + no); |
| 55 | - stat.execute(DISABLE_BREAKPOINT_SQL + no + PARENTHESES_SEMICOLON); | 59 | + stat.execute(String.format(DISABLE_BREAKPOINT_SQL, no)); |
| 56 | } | 60 | } |
| 57 | 61 | ||
| 58 | ResultSet bpResult = stat.executeQuery(INFO_BREAKPOINT_PRE + differ + INFO_BREAKPOINT_SQL); | 62 | ResultSet bpResult = stat.executeQuery(INFO_BREAKPOINT_PRE + differ + INFO_BREAKPOINT_SQL); |
| 59 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); | 63 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); |
| 60 | - webSocketServer.sendMessage(windowName, breakPoint, SUCCESS, DebugUtils.parseBeakPoint(bpResult, oid)); | 64 | + webSocketServer.sendMessage(windowName, breakPoint, SUCCESS, DebugUtils.parseBreakPoint(bpResult, oid)); |
| 61 | } | 65 | } |
| 62 | 66 | ||
| 63 | 67 | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/EnableBreakPointImpl.java+20-16
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| @@ -6,14 +10,15 @@ import com.nctigba.datastudio.model.PublicParamReq; | |||
| 6 | import com.nctigba.datastudio.service.OperationInterface; | 10 | import com.nctigba.datastudio.service.OperationInterface; |
| 7 | import com.nctigba.datastudio.util.DebugUtils; | 11 | import com.nctigba.datastudio.util.DebugUtils; |
| 8 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 9 | -import org.apache.commons.lang3.StringUtils; | ||
| 10 | import org.springframework.stereotype.Service; | 13 | import org.springframework.stereotype.Service; |
| 11 | 14 | ||
| 12 | import java.sql.ResultSet; | 15 | import java.sql.ResultSet; |
| 13 | import java.sql.Statement; | 16 | import java.sql.Statement; |
| 17 | +import java.util.List; | ||
| 14 | import java.util.Map; | 18 | import java.util.Map; |
| 15 | 19 | ||
| 16 | import static com.nctigba.datastudio.constants.CommonConstants.BREAK_POINT; | 20 | import static com.nctigba.datastudio.constants.CommonConstants.BREAK_POINT; |
| 21 | +import static com.nctigba.datastudio.constants.CommonConstants.CAN_BREAK; | ||
| 17 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; | 22 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; |
| 18 | import static com.nctigba.datastudio.constants.CommonConstants.OID; | 23 | import static com.nctigba.datastudio.constants.CommonConstants.OID; |
| 19 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; | 24 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; |
| @@ -21,7 +26,6 @@ import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | |||
| 21 | import static com.nctigba.datastudio.constants.SqlConstants.ENABLE_BREAKPOINT_SQL; | 26 | import static com.nctigba.datastudio.constants.SqlConstants.ENABLE_BREAKPOINT_SQL; |
| 22 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_PRE; | 27 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_PRE; |
| 23 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_SQL; | 28 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_SQL; |
| 24 | -import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_SEMICOLON; | ||
| 25 | import static com.nctigba.datastudio.enums.MessageEnum.breakPoint; | 29 | import static com.nctigba.datastudio.enums.MessageEnum.breakPoint; |
| 26 | 30 | ||
| 27 | /** | 31 | /** |
| @@ -32,32 +36,32 @@ import static com.nctigba.datastudio.enums.MessageEnum.breakPoint; | |||
| 32 | public class EnableBreakPointImpl implements OperationInterface { | 36 | public class EnableBreakPointImpl implements OperationInterface { |
| 33 | 37 | ||
| 34 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 38 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 35 | - log.info("enableBreakPoint obj is: " + obj); | ||
| 36 | PublicParamReq paramReq = (PublicParamReq) obj; | 39 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 37 | - String windowName = paramReq.getWindowName(); | 40 | + log.info("enableBreakPoint paramReq: " + paramReq); |
| 38 | - int line = paramReq.getLine(); | ||
| 39 | - int differ = (int) webSocketServer.getParamMap(windowName).get(DIFFER); | ||
| 40 | - Map<Integer, String> breakPointMap = (Map<Integer, String>) webSocketServer.getParamMap(windowName).get(BREAK_POINT); | ||
| 41 | - log.info("enableBreakPoint breakPointMap is: " + breakPointMap); | ||
| 42 | 41 | ||
| 43 | - String name = paramReq.getOldWindowName(); | 42 | + String windowName = paramReq.getWindowName(); |
| 44 | - if (StringUtils.isEmpty(name)) { | 43 | + Map<Integer, String> breakPointMap = (Map<Integer, String>) webSocketServer.getParamMap(windowName).get( |
| 45 | - name = windowName; | 44 | + BREAK_POINT); |
| 46 | - } | 45 | + log.info("enableBreakPoint breakPointMap: " + breakPointMap); |
| 47 | - Statement stat = (Statement) webSocketServer.getParamMap(name).get(STATEMENT); | 46 | + |
| 47 | + String rootWindowName = paramReq.getRootWindowName(); | ||
| 48 | + Statement stat = (Statement) webSocketServer.getParamMap(rootWindowName).get(STATEMENT); | ||
| 48 | if (stat == null) { | 49 | if (stat == null) { |
| 49 | return; | 50 | return; |
| 50 | } | 51 | } |
| 51 | 52 | ||
| 52 | - if (webSocketServer.checkLine(windowName, line)) { | 53 | + int line = paramReq.getLine(); |
| 54 | + int differ = (int) webSocketServer.getParamMap(windowName).get(DIFFER); | ||
| 55 | + List<Integer> list = (List<Integer>) webSocketServer.getParamMap(windowName).get(CAN_BREAK); | ||
| 56 | + if (list.contains(line - differ)) { | ||
| 53 | String no = breakPointMap.get(line); | 57 | String no = breakPointMap.get(line); |
| 54 | log.info("enableBreakPoint no is: " + no); | 58 | log.info("enableBreakPoint no is: " + no); |
| 55 | - stat.execute(ENABLE_BREAKPOINT_SQL + no + PARENTHESES_SEMICOLON); | 59 | + stat.execute(String.format(ENABLE_BREAKPOINT_SQL, no)); |
| 56 | } | 60 | } |
| 57 | 61 | ||
| 58 | ResultSet bpResult = stat.executeQuery(INFO_BREAKPOINT_PRE + differ + INFO_BREAKPOINT_SQL); | 62 | ResultSet bpResult = stat.executeQuery(INFO_BREAKPOINT_PRE + differ + INFO_BREAKPOINT_SQL); |
| 59 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); | 63 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); |
| 60 | - webSocketServer.sendMessage(windowName, breakPoint, SUCCESS, DebugUtils.parseBeakPoint(bpResult, oid)); | 64 | + webSocketServer.sendMessage(windowName, breakPoint, SUCCESS, DebugUtils.parseBreakPoint(bpResult, oid)); |
| 61 | } | 65 | } |
| 62 | 66 | ||
| 63 | 67 | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| @@ -8,19 +12,24 @@ import com.nctigba.datastudio.service.OperationInterface; | |||
| 8 | import com.nctigba.datastudio.util.DebugUtils; | 12 | import com.nctigba.datastudio.util.DebugUtils; |
| 9 | import com.nctigba.datastudio.util.LocaleString; | 13 | import com.nctigba.datastudio.util.LocaleString; |
| 10 | import lombok.extern.slf4j.Slf4j; | 14 | import lombok.extern.slf4j.Slf4j; |
| 15 | +import org.apache.logging.log4j.util.Strings; | ||
| 16 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
| 19 | +import org.springframework.util.CollectionUtils; | ||
| 13 | 20 | ||
| 14 | -import java.sql.Connection; | ||
| 15 | import java.sql.ResultSet; | 21 | import java.sql.ResultSet; |
| 16 | import java.sql.Statement; | 22 | import java.sql.Statement; |
| 17 | import java.util.HashMap; | 23 | import java.util.HashMap; |
| 24 | +import java.util.List; | ||
| 18 | import java.util.Map; | 25 | import java.util.Map; |
| 19 | 26 | ||
| 27 | +import static com.nctigba.datastudio.constants.CommonConstants.DEFINITION; | ||
| 20 | import static com.nctigba.datastudio.constants.CommonConstants.RESULT; | 28 | import static com.nctigba.datastudio.constants.CommonConstants.RESULT; |
| 21 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | 29 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; |
| 22 | -import static com.nctigba.datastudio.enums.MessageEnum.refresh; | 30 | +import static com.nctigba.datastudio.constants.SqlConstants.QUERY_DEF_SQL; |
| 23 | -import static com.nctigba.datastudio.enums.MessageEnum.text; | 31 | +import static com.nctigba.datastudio.enums.MessageEnum.confirm; |
| 32 | +import static com.nctigba.datastudio.enums.MessageEnum.paramWindow; | ||
| 24 | 33 | ||
| 25 | /** | 34 | /** |
| 26 | * execute | 35 | * execute |
| @@ -29,54 +38,56 @@ import static com.nctigba.datastudio.enums.MessageEnum.text; | |||
| 29 | 38 | ||
| 30 | public class ExecuteImpl implements OperationInterface { | 39 | public class ExecuteImpl implements OperationInterface { |
| 31 | 40 | ||
| 32 | - private StartDebugImpl startDebug; | 41 | + private InputParamImpl inputParam; |
| 33 | - | ||
| 34 | - | ||
| 35 | - private StopDebugImpl stopDebug; | ||
| 36 | 42 | ||
| 37 | 43 | ||
| 38 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 44 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 39 | - log.info("execute obj is: " + obj); | ||
| 40 | PublicParamReq paramReq = (PublicParamReq) obj; | 45 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 41 | - String sql = paramReq.getSql(); | 46 | + log.info("execute paramReq: " + paramReq); |
| 42 | - String windowName = paramReq.getWindowName(); | ||
| 43 | - String schema = DebugUtils.prepareFuncName(sql).split("\\.")[0]; | ||
| 44 | - Statement statement = webSocketServer.getStatement(windowName); | ||
| 45 | - if (statement == null) { | ||
| 46 | - Connection connection = webSocketServer.getConnection(windowName); | ||
| 47 | - if (connection == null) { | ||
| 48 | - connection = webSocketServer.createConnection(paramReq.getUuid(), windowName); | ||
| 49 | - webSocketServer.setConnection(windowName, connection); | ||
| 50 | - } | ||
| 51 | - statement = connection.createStatement(); | ||
| 52 | - webSocketServer.setStatement(windowName, statement); | ||
| 53 | - } | ||
| 54 | - String name = DebugUtils.prepareName(sql); | ||
| 55 | - log.info("execute name is: " + name); | ||
| 56 | - ResultSet result = statement.executeQuery(DebugUtils.getFuncSql(windowName, schema, name, webSocketServer)); | ||
| 57 | - if (!result.next()) { | ||
| 58 | - statement.execute(sql); | ||
| 59 | - OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); | ||
| 60 | - operateStatus.enableStartDebug(); | ||
| 61 | - webSocketServer.setOperateStatus(windowName, operateStatus); | ||
| 62 | 47 | ||
| 63 | - Map<String, String> resultMap = new HashMap<>(); | 48 | + String rootWindowName = paramReq.getRootWindowName(); |
| 64 | - resultMap.put(RESULT, name); | 49 | + String windowName = paramReq.getWindowName(); |
| 65 | - webSocketServer.sendMessage(windowName, refresh, SUCCESS, resultMap); | 50 | + OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); |
| 51 | + operateStatus.setDebug(false); | ||
| 52 | + webSocketServer.setOperateStatus(windowName, operateStatus); | ||
| 53 | + | ||
| 54 | + Statement statement = webSocketServer.getStatement(rootWindowName); | ||
| 55 | + if (statement == null) { | ||
| 56 | + statement = webSocketServer.getConnection(rootWindowName).createStatement(); | ||
| 57 | + webSocketServer.setStatement(rootWindowName, statement); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + String oid = paramReq.getOid(); | ||
| 61 | + String definition = Strings.EMPTY; | ||
| 62 | + try ( | ||
| 63 | + ResultSet defResultSet = statement.executeQuery(String.format(QUERY_DEF_SQL, oid)) | ||
| 64 | + ) { | ||
| 65 | + while (defResultSet.next()) { | ||
| 66 | + definition = DebugUtils.sqlHandleAfter(defResultSet.getString(DEFINITION)); | ||
| 67 | + } | ||
| 68 | + log.info("execute definition: " + definition); | ||
| 69 | + } catch (Exception e) { | ||
| 70 | + log.info(e.getMessage()); | ||
| 71 | + throw new CustomException(e.getMessage(), e); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + String sql = DebugUtils.sqlFormat(paramReq.getSql()); | ||
| 75 | + if (!sql.equals(DebugUtils.sqlFormat(definition)) && !paramReq.isContinue()) { | ||
| 76 | + Map<String, String> map = new HashMap<>(); | ||
| 77 | + map.put(RESULT, LocaleString.transLanguageWs("1006", webSocketServer)); | ||
| 78 | + webSocketServer.sendMessage(windowName, confirm, SUCCESS, map); | ||
| 66 | return; | 79 | return; |
| 67 | } | 80 | } |
| 68 | 81 | ||
| 69 | - statement.execute(sql); | 82 | + Map<String, List<Map<String, Object>>> map = new HashMap<>(); |
| 70 | - | 83 | + List<Map<String, Object>> paramList = DebugUtils.getParamMap(webSocketServer, windowName, oid); |
| 71 | - OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); | 84 | + log.info("execute paramList: " + paramList); |
| 72 | - operateStatus.enableStartDebug(); | 85 | + map.put(RESULT, paramList); |
| 73 | - operateStatus.setDebug(paramReq.isDebug()); | 86 | + if (CollectionUtils.isEmpty(paramList)) { |
| 74 | - webSocketServer.setOperateStatus(windowName, operateStatus); | 87 | + inputParam.operate(webSocketServer, paramReq); |
| 75 | - | 88 | + } else { |
| 76 | - Map<String, String> map = new HashMap<>(); | 89 | + webSocketServer.sendMessage(windowName, paramWindow, SUCCESS, map); |
| 77 | - map.put(RESULT, LocaleString.transLanguageWs("1002", webSocketServer)); | 90 | + } |
| 78 | - webSocketServer.sendMessage(windowName, text, SUCCESS, map); | ||
| 79 | - startDebug.operate(webSocketServer, paramReq); | ||
| 80 | } | 91 | } |
| 81 | 92 | ||
| 82 | 93 | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/FuncProcedureImpl.java+54-192
| @@ -1,57 +1,37 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| 4 | import com.nctigba.datastudio.base.WebSocketServer; | 8 | import com.nctigba.datastudio.base.WebSocketServer; |
| 5 | -import com.nctigba.datastudio.enums.ParamTypeEnum; | ||
| 6 | import com.nctigba.datastudio.model.PublicParamReq; | 9 | import com.nctigba.datastudio.model.PublicParamReq; |
| 7 | import com.nctigba.datastudio.model.entity.OperateStatusDO; | 10 | import com.nctigba.datastudio.model.entity.OperateStatusDO; |
| 8 | import com.nctigba.datastudio.service.OperationInterface; | 11 | import com.nctigba.datastudio.service.OperationInterface; |
| 9 | import com.nctigba.datastudio.util.DebugUtils; | 12 | import com.nctigba.datastudio.util.DebugUtils; |
| 10 | -import com.nctigba.datastudio.util.LocaleString; | ||
| 11 | import lombok.extern.slf4j.Slf4j; | 13 | import lombok.extern.slf4j.Slf4j; |
| 12 | import org.apache.commons.lang3.StringUtils; | 14 | import org.apache.commons.lang3.StringUtils; |
| 13 | import org.apache.logging.log4j.util.Strings; | 15 | import org.apache.logging.log4j.util.Strings; |
| 16 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 14 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
| 16 | -import org.springframework.util.CollectionUtils; | ||
| 17 | 19 | ||
| 18 | import java.sql.Connection; | 20 | import java.sql.Connection; |
| 19 | import java.sql.ResultSet; | 21 | import java.sql.ResultSet; |
| 20 | -import java.sql.SQLException; | ||
| 21 | import java.sql.Statement; | 22 | import java.sql.Statement; |
| 22 | import java.util.HashMap; | 23 | import java.util.HashMap; |
| 23 | import java.util.Map; | 24 | import java.util.Map; |
| 24 | 25 | ||
| 25 | -import static com.nctigba.datastudio.constants.CommonConstants.FEN_CED_MODE; | 26 | +import static com.nctigba.datastudio.constants.CommonConstants.DEFINITION; |
| 26 | -import static com.nctigba.datastudio.constants.CommonConstants.FIVE_HUNDRED; | 27 | +import static com.nctigba.datastudio.constants.CommonConstants.OID; |
| 27 | -import static com.nctigba.datastudio.constants.CommonConstants.LAN_NAME; | ||
| 28 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_ALL_ARG_TYPES; | ||
| 29 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_ARG_MODES; | ||
| 30 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_ARG_NAMES; | ||
| 31 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_ARG_SRC; | ||
| 32 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_ARG_TYPES; | ||
| 33 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_BIN; | ||
| 34 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_COST; | ||
| 35 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_IS_STRICT; | ||
| 36 | import static com.nctigba.datastudio.constants.CommonConstants.PRO_KIND; | 28 | import static com.nctigba.datastudio.constants.CommonConstants.PRO_KIND; |
| 37 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_NAME; | ||
| 38 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_RET_SET; | ||
| 39 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_ROWS; | ||
| 40 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_SHIPPABLE; | ||
| 41 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_SRC; | ||
| 42 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_VOLATILE; | ||
| 43 | import static com.nctigba.datastudio.constants.CommonConstants.RESULT; | 29 | import static com.nctigba.datastudio.constants.CommonConstants.RESULT; |
| 44 | -import static com.nctigba.datastudio.constants.CommonConstants.SPACE; | 30 | +import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; |
| 45 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | 31 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; |
| 46 | import static com.nctigba.datastudio.constants.CommonConstants.TYPE; | 32 | import static com.nctigba.datastudio.constants.CommonConstants.TYPE; |
| 47 | -import static com.nctigba.datastudio.constants.CommonConstants.TYP_NAME; | 33 | +import static com.nctigba.datastudio.constants.SqlConstants.PROC_SQL; |
| 48 | -import static com.nctigba.datastudio.constants.SqlConstants.COMMA; | 34 | +import static com.nctigba.datastudio.constants.SqlConstants.QUERY_DEF_SQL; |
| 49 | -import static com.nctigba.datastudio.constants.SqlConstants.COMMA_SPACE; | ||
| 50 | -import static com.nctigba.datastudio.constants.SqlConstants.GET_OID_NAME_SQL; | ||
| 51 | -import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_LEFT; | ||
| 52 | -import static com.nctigba.datastudio.constants.SqlConstants.POINT; | ||
| 53 | -import static com.nctigba.datastudio.constants.SqlConstants.SEMICOLON; | ||
| 54 | -import static com.nctigba.datastudio.enums.MessageEnum.ignoreWindow; | ||
| 55 | import static com.nctigba.datastudio.enums.MessageEnum.view; | 35 | import static com.nctigba.datastudio.enums.MessageEnum.view; |
| 56 | 36 | ||
| 57 | /** | 37 | /** |
| @@ -65,179 +45,61 @@ public class FuncProcedureImpl implements OperationInterface { | |||
| 65 | 45 | ||
| 66 | 46 | ||
| 67 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 47 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 68 | - log.info("funcProcedure obj is: " + obj); | ||
| 69 | PublicParamReq paramReq = (PublicParamReq) obj; | 48 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 70 | - String windowName = paramReq.getWindowName(); | 49 | + log.info("funcProcedure paramReq: " + paramReq); |
| 71 | - String name = paramReq.getFullName(); | ||
| 72 | - String schema = paramReq.getSchema(); | ||
| 73 | 50 | ||
| 51 | + String rootWindowName = paramReq.getRootWindowName(); | ||
| 52 | + String oldWindowName = paramReq.getOldWindowName(); | ||
| 53 | + String windowName = paramReq.getWindowName(); | ||
| 74 | OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); | 54 | OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); |
| 75 | operateStatus.enableStartDebug(); | 55 | operateStatus.enableStartDebug(); |
| 76 | webSocketServer.setOperateStatus(windowName, operateStatus); | 56 | webSocketServer.setOperateStatus(windowName, operateStatus); |
| 77 | - Connection connection = webSocketServer.getConnection(windowName); | ||
| 78 | - if (connection == null) { | ||
| 79 | - connection = webSocketServer.createConnection(paramReq.getUuid(), windowName); | ||
| 80 | - webSocketServer.setConnection(windowName, connection); | ||
| 81 | - } | ||
| 82 | - Statement statement = connection.createStatement(); | ||
| 83 | - webSocketServer.setStatement(windowName, statement); | ||
| 84 | - webSocketServer.setStatement(windowName, statement); | ||
| 85 | 57 | ||
| 86 | - ResultSet funcResult = statement.executeQuery(DebugUtils.getFuncSql(windowName, schema, name, webSocketServer)); | 58 | + Statement statement; |
| 87 | - Map<String, Object> paramMap = new HashMap<>(); | 59 | + if (StringUtils.isEmpty(oldWindowName)) { |
| 88 | - while (funcResult.next()) { | 60 | + statement = webSocketServer.getStatement(rootWindowName); |
| 89 | - paramMap.put(PRO_NAME, funcResult.getString(PRO_NAME)); | 61 | + if (statement == null) { |
| 90 | - paramMap.put(LAN_NAME, funcResult.getString(LAN_NAME)); | 62 | + Connection connection = webSocketServer.getConnection(rootWindowName); |
| 91 | - paramMap.put(TYP_NAME, funcResult.getString(TYP_NAME)); | 63 | + if (connection == null) { |
| 92 | - paramMap.put(PRO_ARG_TYPES, funcResult.getString(PRO_ARG_TYPES)); | 64 | + connection = webSocketServer.createConnection(paramReq.getUuid(), windowName); |
| 93 | - paramMap.put(PRO_ALL_ARG_TYPES, funcResult.getString(PRO_ALL_ARG_TYPES)); | ||
| 94 | - paramMap.put(PRO_ARG_MODES, funcResult.getString(PRO_ARG_MODES)); | ||
| 95 | - paramMap.put(PRO_ARG_NAMES, funcResult.getString(PRO_ARG_NAMES)); | ||
| 96 | - paramMap.put(PRO_SRC, funcResult.getString(PRO_SRC)); | ||
| 97 | - paramMap.put(PRO_BIN, funcResult.getString(PRO_BIN)); | ||
| 98 | - paramMap.put(PRO_ARG_SRC, funcResult.getString(PRO_ARG_SRC)); | ||
| 99 | - paramMap.put(PRO_KIND, funcResult.getString(PRO_KIND)); | ||
| 100 | - paramMap.put(PRO_VOLATILE, funcResult.getString(PRO_VOLATILE)); | ||
| 101 | - paramMap.put(PRO_COST, funcResult.getInt(PRO_COST)); | ||
| 102 | - paramMap.put(PRO_ROWS, funcResult.getInt(PRO_ROWS)); | ||
| 103 | - paramMap.put(FEN_CED_MODE, funcResult.getBoolean(FEN_CED_MODE)); | ||
| 104 | - paramMap.put(PRO_SHIPPABLE, funcResult.getBoolean(PRO_SHIPPABLE)); | ||
| 105 | - paramMap.put(PRO_IS_STRICT, funcResult.getBoolean(PRO_IS_STRICT)); | ||
| 106 | - paramMap.put(PRO_RET_SET, funcResult.getBoolean(PRO_RET_SET)); | ||
| 107 | - } | ||
| 108 | - log.info("funcProcedure paramMap is: " + paramMap); | ||
| 109 | - if (CollectionUtils.isEmpty(paramMap)) { | ||
| 110 | - webSocketServer.sendMessage(windowName, ignoreWindow, FIVE_HUNDRED, | ||
| 111 | - LocaleString.transLanguageWs("1006", webSocketServer), null); | ||
| 112 | - return; | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - String sql = parseResult(windowName, paramMap, webSocketServer, schema); | ||
| 116 | - log.info("funcProcedure sql is: " + sql); | ||
| 117 | - Map<String, Object> map = new HashMap<>(); | ||
| 118 | - map.put(RESULT, sql); | ||
| 119 | - webSocketServer.sendMessage(windowName, view, SUCCESS, map); | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - public String parseResult(String windowName, Map<String, Object> map, WebSocketServer webSocketServer, String schema) throws SQLException { | ||
| 123 | - String proKind = (String) map.get(PRO_KIND); | ||
| 124 | - String proName = (String) map.get(PRO_NAME); | ||
| 125 | - String proSrc = (String) map.get(PRO_SRC); | ||
| 126 | - StringBuilder sb = new StringBuilder(); | ||
| 127 | - webSocketServer.setParamMap(windowName, TYPE, proKind); | ||
| 128 | - if ("p".equals(proKind)) { | ||
| 129 | - sb.append("CREATE OR REPLACE PROCEDURE ").append(schema).append(POINT).append(proName).append(PARENTHESES_LEFT); | ||
| 130 | - sb.append(parseSql(windowName, map, webSocketServer)); | ||
| 131 | - sb.append(")\nAS").append(proSrc).append(";\n/\n/"); | ||
| 132 | - } else if ("f".equals(proKind)) { | ||
| 133 | - sb.append("CREATE OR REPLACE FUNCTION ").append(schema).append(".").append(map.get(PRO_NAME)).append(PARENTHESES_LEFT); | ||
| 134 | - sb.append(parseSql(windowName, map, webSocketServer)); | ||
| 135 | - sb.append(")\n RETURNS "); | ||
| 136 | - if ((boolean) map.get(PRO_RET_SET)) { | ||
| 137 | - sb.append("SETOF "); | ||
| 138 | - } | ||
| 139 | - String lanName = (String) map.get(LAN_NAME); | ||
| 140 | - sb.append(ParamTypeEnum.parseType((String) map.get(TYP_NAME))).append("\n LANGUAGE ").append(lanName).append("\n "); | ||
| 141 | - String proVolatile = (String) map.get(PRO_VOLATILE); | ||
| 142 | - if ("i".equals(proVolatile)) { | ||
| 143 | - sb.append("IMMUTABLE "); | ||
| 144 | - } else if ("s".equals(proVolatile)) { | ||
| 145 | - sb.append("STABLE "); | ||
| 146 | - } | ||
| 147 | - if ((boolean) map.get(PRO_IS_STRICT)) { | ||
| 148 | - sb.append("STRICT "); | ||
| 149 | - } | ||
| 150 | - if (!(boolean) map.get(FEN_CED_MODE)) { | ||
| 151 | - sb.append("NOT "); | ||
| 152 | - } | ||
| 153 | - sb.append("FENCED "); | ||
| 154 | - if (!(boolean) map.get(PRO_SHIPPABLE)) { | ||
| 155 | - sb.append("NOT "); | ||
| 156 | - } | ||
| 157 | - sb.append("SHIPPABLE"); | ||
| 158 | - | ||
| 159 | - int proCost = (int) map.get(PRO_COST); | ||
| 160 | - int proRows = (int) map.get(PRO_ROWS); | ||
| 161 | - if ("plpgsql".equals(lanName) && proCost != 100) { | ||
| 162 | - sb.append(" COST ").append(proCost); | ||
| 163 | - } | ||
| 164 | - if ("plpgsql".equals(lanName) && proRows != 1000 && proRows != 0) { | ||
| 165 | - sb.append(" ROWS ").append(proRows); | ||
| 166 | - } | ||
| 167 | - sb.append("\nAS "); | ||
| 168 | - String proBin = (String) map.get(PRO_BIN); | ||
| 169 | - if (!StringUtils.isEmpty(proBin)) { | ||
| 170 | - sb.append("'").append(proBin).append("', "); | ||
| 171 | - } | ||
| 172 | - sb.append("$$").append(map.get(PRO_SRC)).append("$$;\n/"); | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | - log.info("funcProcedure parseResult is: " + sb); | ||
| 176 | - return sb.toString(); | ||
| 177 | - } | ||
| 178 | - | ||
| 179 | - public String parseSql(String windowName, Map<String, Object> map, WebSocketServer webSocketServer) throws SQLException { | ||
| 180 | - StringBuilder sb = new StringBuilder(); | ||
| 181 | - String proArgModes = (String) map.get(PRO_ARG_MODES); | ||
| 182 | - String proArgNames = (String) map.get(PRO_ARG_NAMES); | ||
| 183 | - if (!StringUtils.isEmpty(proArgModes)) { | ||
| 184 | - String proAllArgTypes = (String) map.get(PRO_ALL_ARG_TYPES); | ||
| 185 | - String[] argModes = proArgModes.substring(1, proArgModes.length() - 1).split(COMMA); | ||
| 186 | - String[] argNames = proArgNames.substring(1, proArgNames.length() - 1).split(COMMA); | ||
| 187 | - String[] argTypes = proAllArgTypes.substring(1, proAllArgTypes.length() - 1).split(COMMA); | ||
| 188 | - for (int i = 0; i < argModes.length; i++) { | ||
| 189 | - ResultSet typeNameResult = webSocketServer.getStatement(windowName).executeQuery(GET_OID_NAME_SQL + argTypes[i] + SEMICOLON); | ||
| 190 | - while (typeNameResult.next()) { | ||
| 191 | - switch (argModes[i].trim()) { | ||
| 192 | - case "o": | ||
| 193 | - sb.append("OUT "); | ||
| 194 | - break; | ||
| 195 | - case "b": | ||
| 196 | - sb.append("INOUT "); | ||
| 197 | - break; | ||
| 198 | - case "v": | ||
| 199 | - sb.append("VARIADIC "); | ||
| 200 | - break; | ||
| 201 | - } | ||
| 202 | - sb.append(argNames[i]).append(SPACE).append(ParamTypeEnum.parseType(typeNameResult.getString(TYP_NAME))); | ||
| 203 | - } | ||
| 204 | - if (i != argModes.length - 1) { | ||
| 205 | - sb.append(COMMA_SPACE); | ||
| 206 | } | 65 | } |
| 66 | + statement = connection.createStatement(); | ||
| 67 | + webSocketServer.setStatement(rootWindowName, statement); | ||
| 207 | } | 68 | } |
| 208 | } else { | 69 | } else { |
| 209 | - String proArgTypes = (String) map.get(PRO_ARG_TYPES); | 70 | + statement = (Statement) webSocketServer.getParamMap(rootWindowName).get(STATEMENT); |
| 210 | - if (!StringUtils.isEmpty(proArgTypes)) { | ||
| 211 | - String[] argTypes = proArgTypes.split(SPACE); | ||
| 212 | - if (StringUtils.isEmpty(proArgNames)) { | ||
| 213 | - for (int i = 0; i < argTypes.length; i++) { | ||
| 214 | - ResultSet typeNameResult = webSocketServer.getStatement(windowName).executeQuery(GET_OID_NAME_SQL + argTypes[i] + SEMICOLON); | ||
| 215 | - while (typeNameResult.next()) { | ||
| 216 | - sb.append(ParamTypeEnum.parseType(typeNameResult.getString(TYP_NAME))); | ||
| 217 | - } | ||
| 218 | - | ||
| 219 | - if (i != argTypes.length - 1) { | ||
| 220 | - sb.append(COMMA_SPACE); | ||
| 221 | - } | ||
| 222 | - } | ||
| 223 | - } else { | ||
| 224 | - String[] argNames = proArgNames.substring(1, proArgNames.length() - 1).split(COMMA); | ||
| 225 | - for (int i = 0; i < argTypes.length; i++) { | ||
| 226 | - ResultSet typeNameResult = webSocketServer.getStatement(windowName).executeQuery(GET_OID_NAME_SQL + argTypes[i] + SEMICOLON); | ||
| 227 | - while (typeNameResult.next()) { | ||
| 228 | - sb.append(argNames[i]).append(SPACE).append(ParamTypeEnum.parseType(typeNameResult.getString(TYP_NAME))); | ||
| 229 | - } | ||
| 230 | - | ||
| 231 | - if (i != argTypes.length - 1) { | ||
| 232 | - sb.append(COMMA_SPACE); | ||
| 233 | - } | ||
| 234 | - } | ||
| 235 | - } | ||
| 236 | - } | ||
| 237 | } | 71 | } |
| 238 | 72 | ||
| 239 | - log.info("funcProcedure parseSql is: " + sb); | 73 | + String oid = paramReq.getOid(); |
| 240 | - return sb.toString(); | 74 | + webSocketServer.setParamMap(windowName, OID, oid); |
| 75 | + log.info("funcProcedure oid: " + oid); | ||
| 76 | + String definition = Strings.EMPTY; | ||
| 77 | + try ( | ||
| 78 | + ResultSet defResultSet = statement.executeQuery(String.format(QUERY_DEF_SQL, oid)) | ||
| 79 | + ) { | ||
| 80 | + while (defResultSet.next()) { | ||
| 81 | + definition = DebugUtils.sqlHandleAfter(defResultSet.getString(DEFINITION)); | ||
| 82 | + } | ||
| 83 | + log.info("funcProcedure definition: " + definition); | ||
| 84 | + } catch (Exception e) { | ||
| 85 | + log.info(e.getMessage()); | ||
| 86 | + throw new CustomException(e.getMessage(), e); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + try ( | ||
| 90 | + ResultSet resultSet = statement.executeQuery(String.format(PROC_SQL, oid)) | ||
| 91 | + ) { | ||
| 92 | + while (resultSet.next()) { | ||
| 93 | + webSocketServer.setParamMap(windowName, TYPE, resultSet.getString(PRO_KIND)); | ||
| 94 | + } | ||
| 95 | + } catch (Exception e) { | ||
| 96 | + log.info(e.getMessage()); | ||
| 97 | + throw new CustomException(e.getMessage(), e); | ||
| 98 | + } | ||
| 99 | + Map<String, Object> map = new HashMap<>(); | ||
| 100 | + map.put(RESULT, definition); | ||
| 101 | + webSocketServer.sendMessage(windowName, view, SUCCESS, map); | ||
| 102 | + webSocketServer.setParamMap(rootWindowName, oid, windowName); | ||
| 241 | } | 103 | } |
| 242 | 104 | ||
| 243 | 105 | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/InitStepImpl.java+15-44
| @@ -1,23 +1,22 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| 4 | import com.nctigba.datastudio.base.WebSocketServer; | 8 | import com.nctigba.datastudio.base.WebSocketServer; |
| 5 | import com.nctigba.datastudio.model.PublicParamReq; | 9 | import com.nctigba.datastudio.model.PublicParamReq; |
| 6 | -import com.nctigba.datastudio.model.entity.OperateStatusDO; | ||
| 7 | import com.nctigba.datastudio.service.OperationInterface; | 10 | import com.nctigba.datastudio.service.OperationInterface; |
| 8 | import com.nctigba.datastudio.util.DebugUtils; | 11 | import com.nctigba.datastudio.util.DebugUtils; |
| 9 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 10 | -import org.apache.logging.log4j.util.Strings; | ||
| 11 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | import org.springframework.stereotype.Service; | 13 | import org.springframework.stereotype.Service; |
| 13 | 14 | ||
| 14 | import java.sql.ResultSet; | 15 | import java.sql.ResultSet; |
| 15 | import java.sql.Statement; | 16 | import java.sql.Statement; |
| 16 | -import java.util.List; | ||
| 17 | import java.util.Map; | 17 | import java.util.Map; |
| 18 | 18 | ||
| 19 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; | 19 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; |
| 20 | -import static com.nctigba.datastudio.constants.CommonConstants.OID; | ||
| 21 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; | 20 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; |
| 22 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | 21 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; |
| 23 | import static com.nctigba.datastudio.constants.SqlConstants.BACKTRACE_SQL; | 22 | import static com.nctigba.datastudio.constants.SqlConstants.BACKTRACE_SQL; |
| @@ -32,55 +31,27 @@ import static com.nctigba.datastudio.enums.MessageEnum.variable; | |||
| 32 | 31 | ||
| 33 | 32 | ||
| 34 | public class InitStepImpl implements OperationInterface { | 33 | public class InitStepImpl implements OperationInterface { |
| 35 | - | ||
| 36 | - private InputParamImpl inputParam; | ||
| 37 | - | ||
| 38 | - | ||
| 39 | - private AddBreakPointImpl addBreakPoint; | ||
| 40 | - | ||
| 41 | 34 | ||
| 42 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 35 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 43 | - log.info("initStep obj is: " + obj); | ||
| 44 | PublicParamReq paramReq = (PublicParamReq) obj; | 36 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 37 | + log.info("initStep paramReq: " + paramReq); | ||
| 45 | String windowName = paramReq.getWindowName(); | 38 | String windowName = paramReq.getWindowName(); |
| 46 | - String oldWindowName = paramReq.getOldWindowName(); | 39 | + DebugUtils.enableButton(webSocketServer, windowName); |
| 47 | - String sql = paramReq.getSql(); | ||
| 48 | - String schema = DebugUtils.prepareFuncName(sql).split("\\.")[0]; | ||
| 49 | - OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); | ||
| 50 | - operateStatus.enableStopDebug(); | ||
| 51 | - webSocketServer.setOperateStatus(windowName, operateStatus); | ||
| 52 | 40 | ||
| 53 | - Statement stat = (Statement) webSocketServer.getParamMap(oldWindowName).get(STATEMENT); | 41 | + String rootWindowName = paramReq.getRootWindowName(); |
| 42 | + Statement stat = (Statement) webSocketServer.getParamMap(rootWindowName).get(STATEMENT); | ||
| 54 | if (stat == null) { | 43 | if (stat == null) { |
| 55 | return; | 44 | return; |
| 56 | } | 45 | } |
| 57 | - String name = DebugUtils.prepareName(sql); | ||
| 58 | - ResultSet oidResult = stat.executeQuery(DebugUtils.getFuncSql(oldWindowName, schema, name, webSocketServer)); | ||
| 59 | - String oid = Strings.EMPTY; | ||
| 60 | - while (oidResult.next()) { | ||
| 61 | - oid = oidResult.getString(OID); | ||
| 62 | - webSocketServer.setParamMap(windowName, OID, oid); | ||
| 63 | - } | ||
| 64 | - log.info("initStep oid is: " + oid); | ||
| 65 | 46 | ||
| 66 | - List<Integer> breakPoints = inputParam.getAvailableBreakPoints(windowName, paramReq, webSocketServer); | 47 | + DebugUtils.getAvailableBreakPoints(paramReq, webSocketServer); |
| 67 | - log.info("initStep breakPoints is: " + breakPoints); | 48 | + int differ = (int) webSocketServer.getParamMap(windowName).get(DIFFER); |
| 68 | - for (Integer i : breakPoints) { | 49 | + ResultSet stackResult = stat.executeQuery(BACKTRACE_SQL_PRE + differ + BACKTRACE_SQL); |
| 69 | - paramReq.setLine(i); | 50 | + webSocketServer.sendMessage(windowName, stack, SUCCESS, DebugUtils.parseResultSet(stackResult)); |
| 70 | - addBreakPoint.operate(webSocketServer, paramReq); | ||
| 71 | - } | ||
| 72 | 51 | ||
| 73 | - try { | 52 | + Map<String, Object> variableMap = DebugUtils.parseVariable(stat.executeQuery(INFO_LOCALS_SQL)); |
| 74 | - int differ = (int) webSocketServer.getParamMap(windowName).get(DIFFER); | 53 | + Map<String, Object> paramMap = DebugUtils.addMapParam(variableMap, webSocketServer, paramReq); |
| 75 | - ResultSet stackResult = stat.executeQuery(BACKTRACE_SQL_PRE + differ + BACKTRACE_SQL); | 54 | + webSocketServer.sendMessage(windowName, variable, SUCCESS, paramMap); |
| 76 | - webSocketServer.sendMessage(windowName, stack, SUCCESS, DebugUtils.parseResultSet(stackResult)); | ||
| 77 | - | ||
| 78 | - ResultSet variableResult = stat.executeQuery(INFO_LOCALS_SQL); | ||
| 79 | - Map<String, Object> variableMap = DebugUtils.parseResultSet(variableResult); | ||
| 80 | - webSocketServer.sendMessage(windowName, variable, SUCCESS, DebugUtils.addMapParam(variableMap, paramReq.getSql())); | ||
| 81 | - } catch (Exception e) { | ||
| 82 | - e.printStackTrace(); | ||
| 83 | - } | ||
| 84 | } | 55 | } |
| 85 | 56 | ||
| 86 | 57 | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/InputParamImpl.java+54-79
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| @@ -9,6 +13,7 @@ import com.nctigba.datastudio.util.DebugUtils; | |||
| 9 | import com.nctigba.datastudio.util.LocaleString; | 13 | import com.nctigba.datastudio.util.LocaleString; |
| 10 | import lombok.extern.slf4j.Slf4j; | 14 | import lombok.extern.slf4j.Slf4j; |
| 11 | import org.apache.logging.log4j.util.Strings; | 15 | import org.apache.logging.log4j.util.Strings; |
| 16 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
| 14 | import org.springframework.util.CollectionUtils; | 19 | import org.springframework.util.CollectionUtils; |
| @@ -21,12 +26,9 @@ import java.util.HashMap; | |||
| 21 | import java.util.List; | 26 | import java.util.List; |
| 22 | import java.util.Map; | 27 | import java.util.Map; |
| 23 | 28 | ||
| 24 | -import static com.nctigba.datastudio.constants.CommonConstants.BEGIN; | ||
| 25 | import static com.nctigba.datastudio.constants.CommonConstants.CONNECTION; | 29 | import static com.nctigba.datastudio.constants.CommonConstants.CONNECTION; |
| 26 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; | 30 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; |
| 27 | -import static com.nctigba.datastudio.constants.CommonConstants.END; | ||
| 28 | import static com.nctigba.datastudio.constants.CommonConstants.FUNC_OID; | 31 | import static com.nctigba.datastudio.constants.CommonConstants.FUNC_OID; |
| 29 | -import static com.nctigba.datastudio.constants.CommonConstants.LINE_FEED; | ||
| 30 | import static com.nctigba.datastudio.constants.CommonConstants.NODE_NAME; | 32 | import static com.nctigba.datastudio.constants.CommonConstants.NODE_NAME; |
| 31 | import static com.nctigba.datastudio.constants.CommonConstants.OID; | 33 | import static com.nctigba.datastudio.constants.CommonConstants.OID; |
| 32 | import static com.nctigba.datastudio.constants.CommonConstants.PORT; | 34 | import static com.nctigba.datastudio.constants.CommonConstants.PORT; |
| @@ -37,10 +39,11 @@ import static com.nctigba.datastudio.constants.SqlConstants.ATTACH_SQL; | |||
| 37 | import static com.nctigba.datastudio.constants.SqlConstants.BACKTRACE_SQL; | 39 | import static com.nctigba.datastudio.constants.SqlConstants.BACKTRACE_SQL; |
| 38 | import static com.nctigba.datastudio.constants.SqlConstants.BACKTRACE_SQL_PRE; | 40 | import static com.nctigba.datastudio.constants.SqlConstants.BACKTRACE_SQL_PRE; |
| 39 | import static com.nctigba.datastudio.constants.SqlConstants.DEBUG_SERVER_INFO_SQL; | 41 | import static com.nctigba.datastudio.constants.SqlConstants.DEBUG_SERVER_INFO_SQL; |
| 42 | +import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_PRE; | ||
| 43 | +import static com.nctigba.datastudio.constants.SqlConstants.INFO_BREAKPOINT_SQL; | ||
| 40 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_LOCALS_SQL; | 44 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_LOCALS_SQL; |
| 41 | -import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_SEMICOLON; | ||
| 42 | -import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_COMMA; | ||
| 43 | import static com.nctigba.datastudio.constants.SqlConstants.TURN_ON_SQL; | 45 | import static com.nctigba.datastudio.constants.SqlConstants.TURN_ON_SQL; |
| 46 | +import static com.nctigba.datastudio.enums.MessageEnum.breakPoint; | ||
| 44 | import static com.nctigba.datastudio.enums.MessageEnum.stack; | 47 | import static com.nctigba.datastudio.enums.MessageEnum.stack; |
| 45 | import static com.nctigba.datastudio.enums.MessageEnum.table; | 48 | import static com.nctigba.datastudio.enums.MessageEnum.table; |
| 46 | import static com.nctigba.datastudio.enums.MessageEnum.text; | 49 | import static com.nctigba.datastudio.enums.MessageEnum.text; |
| @@ -60,23 +63,24 @@ public class InputParamImpl implements OperationInterface { | |||
| 60 | 63 | ||
| 61 | 64 | ||
| 62 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 65 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 63 | - log.info("inputParam obj is: " + obj); | ||
| 64 | PublicParamReq paramReq = (PublicParamReq) obj; | 66 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 67 | + log.info("inputParam paramReq: " + paramReq); | ||
| 65 | String windowName = paramReq.getWindowName(); | 68 | String windowName = paramReq.getWindowName(); |
| 66 | - String schema = DebugUtils.prepareFuncName(paramReq.getSql()).split("\\.")[0]; | 69 | + |
| 67 | - OperateStatusDO operateStatusDO = webSocketServer.getOperateStatus(windowName); | 70 | + OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); |
| 68 | - if (!operateStatusDO.isDebug()) { | 71 | + if (!operateStatus.isDebug()) { |
| 69 | Statement statement = webSocketServer.getStatement(windowName); | 72 | Statement statement = webSocketServer.getStatement(windowName); |
| 70 | ResultSet resultSet = statement.executeQuery(DebugUtils.prepareSql(paramReq)); | 73 | ResultSet resultSet = statement.executeQuery(DebugUtils.prepareSql(paramReq)); |
| 71 | Map<String, Object> map = DebugUtils.parseResultSet(resultSet); | 74 | Map<String, Object> map = DebugUtils.parseResultSet(resultSet); |
| 72 | - log.info("inputParam result map is: " + map); | 75 | + log.info("inputParam result map: " + map); |
| 76 | + | ||
| 73 | List<List<Object>> list = (List<List<Object>>) map.get(RESULT); | 77 | List<List<Object>> list = (List<List<Object>>) map.get(RESULT); |
| 74 | if (list.size() == 1) { | 78 | if (list.size() == 1) { |
| 75 | if (list.get(0).size() == 1) { | 79 | if (list.get(0).size() == 1) { |
| 76 | webSocketServer.sendMessage(windowName, text, SUCCESS, map); | 80 | webSocketServer.sendMessage(windowName, text, SUCCESS, map); |
| 77 | } else { | 81 | } else { |
| 78 | Map<String, String> messageMap = new HashMap<>(); | 82 | Map<String, String> messageMap = new HashMap<>(); |
| 79 | - messageMap.put(RESULT, LocaleString.transLanguageWs("1007", webSocketServer)); | 83 | + messageMap.put(RESULT, LocaleString.transLanguageWs("1008", webSocketServer)); |
| 80 | webSocketServer.sendMessage(windowName, text, SUCCESS, messageMap); | 84 | webSocketServer.sendMessage(windowName, text, SUCCESS, messageMap); |
| 81 | webSocketServer.sendMessage(windowName, table, SUCCESS, map); | 85 | webSocketServer.sendMessage(windowName, table, SUCCESS, map); |
| 82 | } | 86 | } |
| @@ -86,42 +90,47 @@ public class InputParamImpl implements OperationInterface { | |||
| 86 | statement.close(); | 90 | statement.close(); |
| 87 | webSocketServer.setStatement(windowName, null); | 91 | webSocketServer.setStatement(windowName, null); |
| 88 | } else { | 92 | } else { |
| 89 | - debugOperate(windowName, schema, webSocketServer, paramReq); | 93 | + debugOperate(webSocketServer, paramReq); |
| 90 | } | 94 | } |
| 91 | } | 95 | } |
| 92 | 96 | ||
| 93 | - private void debugOperate(String windowName, String schema, WebSocketServer webSocketServer, PublicParamReq paramReq) throws Exception { | 97 | + private void debugOperate(WebSocketServer webSocketServer, PublicParamReq paramReq) throws Exception { |
| 98 | + String windowName = paramReq.getWindowName(); | ||
| 94 | Statement statement = webSocketServer.getStatement(windowName); | 99 | Statement statement = webSocketServer.getStatement(windowName); |
| 95 | - String name = DebugUtils.prepareName(paramReq.getSql()); | ||
| 96 | - ResultSet oidResult = statement.executeQuery(DebugUtils.getFuncSql(windowName, schema, name, webSocketServer)); | ||
| 97 | - String oid = Strings.EMPTY; | ||
| 98 | - while (oidResult.next()) { | ||
| 99 | - oid = oidResult.getString(OID); | ||
| 100 | - } | ||
| 101 | - log.info("inputParam oid is: " + oid); | ||
| 102 | 100 | ||
| 103 | - ResultSet resultSet = statement.executeQuery(DEBUG_SERVER_INFO_SQL); | ||
| 104 | List<String> oidList = new ArrayList<>(); | 101 | List<String> oidList = new ArrayList<>(); |
| 105 | List<String> nodeNameList = new ArrayList<>(); | 102 | List<String> nodeNameList = new ArrayList<>(); |
| 106 | List<String> portList = new ArrayList<>(); | 103 | List<String> portList = new ArrayList<>(); |
| 107 | - while (resultSet.next()) { | 104 | + try ( |
| 108 | - oidList.add(resultSet.getString(FUNC_OID)); | 105 | + ResultSet resultSet = statement.executeQuery(DEBUG_SERVER_INFO_SQL) |
| 109 | - nodeNameList.add(resultSet.getString(NODE_NAME)); | 106 | + ) { |
| 110 | - portList.add(resultSet.getString(PORT)); | 107 | + while (resultSet.next()) { |
| 108 | + oidList.add(resultSet.getString(FUNC_OID)); | ||
| 109 | + nodeNameList.add(resultSet.getString(NODE_NAME)); | ||
| 110 | + portList.add(resultSet.getString(PORT)); | ||
| 111 | + } | ||
| 112 | + log.info("inputParam debugOperate oidList: " + oidList); | ||
| 111 | } | 113 | } |
| 112 | 114 | ||
| 113 | String nodeName = Strings.EMPTY; | 115 | String nodeName = Strings.EMPTY; |
| 114 | String port = Strings.EMPTY; | 116 | String port = Strings.EMPTY; |
| 117 | + String oid = paramReq.getOid(); | ||
| 115 | if (oidList.contains(oid)) { | 118 | if (oidList.contains(oid)) { |
| 116 | int index = oidList.indexOf(oid); | 119 | int index = oidList.indexOf(oid); |
| 117 | nodeName = nodeNameList.get(index); | 120 | nodeName = nodeNameList.get(index); |
| 118 | port = portList.get(index); | 121 | port = portList.get(index); |
| 119 | } else { | 122 | } else { |
| 120 | - ResultSet turnNoResult = statement.executeQuery(TURN_ON_SQL + oid + PARENTHESES_SEMICOLON); | 123 | + try ( |
| 121 | - while (turnNoResult.next()) { | 124 | + ResultSet turnNoResult = statement.executeQuery(String.format(TURN_ON_SQL, oid)) |
| 122 | - nodeName = turnNoResult.getString(NODE_NAME); | 125 | + ) { |
| 123 | - port = turnNoResult.getString(PORT); | 126 | + while (turnNoResult.next()) { |
| 124 | - log.info("inputParam nodeName and port is: " + nodeName + "---" + port); | 127 | + nodeName = turnNoResult.getString(NODE_NAME); |
| 128 | + port = turnNoResult.getString(PORT); | ||
| 129 | + log.info("inputParam nodeName and port is: " + nodeName + "---" + port); | ||
| 130 | + } | ||
| 131 | + } catch (Exception e) { | ||
| 132 | + log.info(e.getMessage()); | ||
| 133 | + throw new CustomException(e.getMessage(), e); | ||
| 125 | } | 134 | } |
| 126 | } | 135 | } |
| 127 | 136 | ||
| @@ -132,62 +141,28 @@ public class InputParamImpl implements OperationInterface { | |||
| 132 | webSocketServer.setParamMap(windowName, CONNECTION, conn); | 141 | webSocketServer.setParamMap(windowName, CONNECTION, conn); |
| 133 | webSocketServer.setParamMap(windowName, STATEMENT, statNew); | 142 | webSocketServer.setParamMap(windowName, STATEMENT, statNew); |
| 134 | 143 | ||
| 135 | - statNew.execute(ATTACH_SQL + nodeName + QUOTES_COMMA + port + PARENTHESES_SEMICOLON); | 144 | + statNew.execute(String.format(ATTACH_SQL, nodeName, port)); |
| 136 | - List<Integer> breakPoints = getAvailableBreakPoints(windowName, paramReq, webSocketServer); | 145 | + List<Integer> list = DebugUtils.getAvailableBreakPoints(paramReq, webSocketServer); |
| 137 | - log.info("inputParam breakPoints is: " + breakPoints); | ||
| 138 | - for (Integer i : breakPoints) { | ||
| 139 | - paramReq.setLine(i); | ||
| 140 | - addBreakPoint.operate(webSocketServer, paramReq); | ||
| 141 | - } | ||
| 142 | - | ||
| 143 | - int differ = (int) webSocketServer.getParamMap(windowName).get(DIFFER); | ||
| 144 | - ResultSet stackResult = statNew.executeQuery(BACKTRACE_SQL_PRE + differ + BACKTRACE_SQL); | ||
| 145 | - webSocketServer.sendMessage(windowName, stack, SUCCESS, DebugUtils.parseResultSet(stackResult)); | ||
| 146 | - | ||
| 147 | - ResultSet variableResult = statNew.executeQuery(INFO_LOCALS_SQL); | ||
| 148 | - Map<String, Object> variableMap = DebugUtils.parseResultSet(variableResult); | ||
| 149 | - webSocketServer.sendMessage(windowName, variable, SUCCESS, DebugUtils.addMapParam(variableMap, paramReq.getSql())); | ||
| 150 | - } | ||
| 151 | - | ||
| 152 | - public List<Integer> getAvailableBreakPoints(String windowName, PublicParamReq paramReq, WebSocketServer webSocketServer) { | ||
| 153 | - List<Integer> list = new ArrayList<>(); | ||
| 154 | - String sql = paramReq.getSql(); | ||
| 155 | List<Integer> breakPoints = paramReq.getBreakPoints(); | 146 | List<Integer> breakPoints = paramReq.getBreakPoints(); |
| 156 | - | 147 | + int differ = (int) webSocketServer.getParamMap(windowName).get(DIFFER); |
| 157 | - int begin = 0; | ||
| 158 | - int end = 0; | ||
| 159 | - int differ = 0; | ||
| 160 | - String[] split = sql.split(LINE_FEED); | ||
| 161 | - for (int i = 0; i < split.length; i++) { | ||
| 162 | - if (split[i].trim().equalsIgnoreCase("as") || split[i].trim().equalsIgnoreCase("as $$") | ||
| 163 | - || split[i].trim().equalsIgnoreCase("as declare")) { | ||
| 164 | - differ = i; | ||
| 165 | - } | ||
| 166 | - | ||
| 167 | - if (split[i].toLowerCase().startsWith(BEGIN)) { | ||
| 168 | - begin = i + 1; | ||
| 169 | - } | ||
| 170 | - if (split[i].toLowerCase().startsWith(END)) { | ||
| 171 | - end = i + 1; | ||
| 172 | - } | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | if (!CollectionUtils.isEmpty(breakPoints)) { | 148 | if (!CollectionUtils.isEmpty(breakPoints)) { |
| 176 | for (Integer i : breakPoints) { | 149 | for (Integer i : breakPoints) { |
| 177 | - if (i > begin && i < end) { | 150 | + if (list.contains(i - differ)) { |
| 178 | - list.add(i); | 151 | + paramReq.setLine(i); |
| 152 | + addBreakPoint.operate(webSocketServer, paramReq); | ||
| 179 | } | 153 | } |
| 180 | } | 154 | } |
| 181 | } | 155 | } |
| 182 | 156 | ||
| 183 | - log.info("break point is: " + list); | 157 | + ResultSet stackResult = statNew.executeQuery(BACKTRACE_SQL_PRE + differ + BACKTRACE_SQL); |
| 184 | - log.info("break point begin is: " + begin); | 158 | + webSocketServer.sendMessage(windowName, stack, SUCCESS, DebugUtils.parseResultSet(stackResult)); |
| 185 | - log.info("break point end is: " + end); | 159 | + |
| 186 | - log.info("break point differ is: " + differ); | 160 | + ResultSet bpResult = statNew.executeQuery(INFO_BREAKPOINT_PRE + differ + INFO_BREAKPOINT_SQL); |
| 187 | - webSocketServer.setParamMap(windowName, BEGIN, begin); | 161 | + webSocketServer.sendMessage(windowName, breakPoint, SUCCESS, DebugUtils.parseBreakPoint(bpResult, oid)); |
| 188 | - webSocketServer.setParamMap(windowName, END, end); | 162 | + |
| 189 | - webSocketServer.setParamMap(windowName, DIFFER, differ); | 163 | + Map<String, Object> variableMap = DebugUtils.parseVariable(statNew.executeQuery(INFO_LOCALS_SQL)); |
| 190 | - return list; | 164 | + Map<String, Object> paramMap = DebugUtils.addMapParam(variableMap, webSocketServer, paramReq); |
| 165 | + webSocketServer.sendMessage(windowName, variable, SUCCESS, paramMap); | ||
| 191 | } | 166 | } |
| 192 | 167 | ||
| 193 | 168 | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/OperateStatusImpl.java+4-0
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/SingleStepImpl.java+61-45
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| @@ -6,19 +10,22 @@ import com.nctigba.datastudio.model.PublicParamReq; | |||
| 6 | import com.nctigba.datastudio.service.OperationInterface; | 10 | import com.nctigba.datastudio.service.OperationInterface; |
| 7 | import com.nctigba.datastudio.util.DebugUtils; | 11 | import com.nctigba.datastudio.util.DebugUtils; |
| 8 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 9 | -import org.apache.commons.lang3.StringUtils; | ||
| 10 | import org.apache.logging.log4j.util.Strings; | 13 | import org.apache.logging.log4j.util.Strings; |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | import org.springframework.stereotype.Service; | 15 | import org.springframework.stereotype.Service; |
| 16 | +import org.springframework.util.CollectionUtils; | ||
| 13 | 17 | ||
| 14 | import java.sql.ResultSet; | 18 | import java.sql.ResultSet; |
| 15 | import java.sql.Statement; | 19 | import java.sql.Statement; |
| 20 | +import java.util.HashMap; | ||
| 21 | +import java.util.List; | ||
| 16 | import java.util.Map; | 22 | import java.util.Map; |
| 17 | 23 | ||
| 18 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; | 24 | import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; |
| 19 | import static com.nctigba.datastudio.constants.CommonConstants.FUNC_OID; | 25 | import static com.nctigba.datastudio.constants.CommonConstants.FUNC_OID; |
| 20 | import static com.nctigba.datastudio.constants.CommonConstants.LINE_NO; | 26 | import static com.nctigba.datastudio.constants.CommonConstants.LINE_NO; |
| 21 | import static com.nctigba.datastudio.constants.CommonConstants.OID; | 27 | import static com.nctigba.datastudio.constants.CommonConstants.OID; |
| 28 | +import static com.nctigba.datastudio.constants.CommonConstants.RESULT; | ||
| 22 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; | 29 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; |
| 23 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | 30 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; |
| 24 | import static com.nctigba.datastudio.constants.CommonConstants.TYPE; | 31 | import static com.nctigba.datastudio.constants.CommonConstants.TYPE; |
| @@ -28,6 +35,7 @@ import static com.nctigba.datastudio.constants.SqlConstants.INFO_LOCALS_SQL; | |||
| 28 | import static com.nctigba.datastudio.constants.SqlConstants.NEXT_SQL; | 35 | import static com.nctigba.datastudio.constants.SqlConstants.NEXT_SQL; |
| 29 | import static com.nctigba.datastudio.enums.MessageEnum.closeWindow; | 36 | import static com.nctigba.datastudio.enums.MessageEnum.closeWindow; |
| 30 | import static com.nctigba.datastudio.enums.MessageEnum.stack; | 37 | import static com.nctigba.datastudio.enums.MessageEnum.stack; |
| 38 | +import static com.nctigba.datastudio.enums.MessageEnum.switchWindow; | ||
| 31 | import static com.nctigba.datastudio.enums.MessageEnum.variable; | 39 | import static com.nctigba.datastudio.enums.MessageEnum.variable; |
| 32 | 40 | ||
| 33 | /** | 41 | /** |
| @@ -41,41 +49,54 @@ public class SingleStepImpl implements OperationInterface { | |||
| 41 | 49 | ||
| 42 | 50 | ||
| 43 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 51 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 44 | - log.info("singleStep obj is: " + obj); | ||
| 45 | PublicParamReq paramReq = (PublicParamReq) obj; | 52 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 46 | - String name = paramReq.getOldWindowName(); | 53 | + log.info("singleStep paramReq: " + paramReq); |
| 47 | - String windowName = paramReq.getWindowName(); | 54 | + String rootWindowName = paramReq.getRootWindowName(); |
| 48 | String oldWindowName = paramReq.getOldWindowName(); | 55 | String oldWindowName = paramReq.getOldWindowName(); |
| 49 | - if (StringUtils.isEmpty(name)) { | 56 | + String windowName = paramReq.getWindowName(); |
| 50 | - name = windowName; | ||
| 51 | - } | ||
| 52 | 57 | ||
| 53 | - Statement stat = (Statement) webSocketServer.getParamMap(name).get(STATEMENT); | 58 | + Statement stat = (Statement) webSocketServer.getParamMap(rootWindowName).get(STATEMENT); |
| 54 | if (stat == null) { | 59 | if (stat == null) { |
| 55 | return; | 60 | return; |
| 56 | } | 61 | } |
| 57 | - ResultSet resultSet = stat.executeQuery(NEXT_SQL); | ||
| 58 | int lineNo = -1; | 62 | int lineNo = -1; |
| 59 | - String newOid = Strings.EMPTY; | 63 | + try ( |
| 60 | - while (resultSet.next()) { | 64 | + ResultSet resultSet = stat.executeQuery(NEXT_SQL) |
| 61 | - lineNo = resultSet.getInt(LINE_NO); | 65 | + ) { |
| 62 | - newOid = resultSet.getString(FUNC_OID); | 66 | + if (resultSet.next()) { |
| 63 | - log.info("singleStep lineNo is: " + lineNo); | 67 | + lineNo = resultSet.getInt(LINE_NO); |
| 64 | - } | ||
| 65 | - String type = (String) webSocketServer.getParamMap(windowName).get(TYPE); | ||
| 66 | - if ("p".equals(type) && StringUtils.isNotEmpty(oldWindowName)) { | ||
| 67 | - String oid = (String) webSocketServer.getParamMap(windowName).get(OID); | ||
| 68 | - if (!oid.equals(newOid)) { | ||
| 69 | - stepOut.deleteBreakPoint(webSocketServer, paramReq); | ||
| 70 | - webSocketServer.sendMessage(windowName, closeWindow, SUCCESS, null); | ||
| 71 | - paramReq.setCloseWindow(true); | ||
| 72 | } | 68 | } |
| 73 | - } else if ("f".equals(type)) { | 69 | + } |
| 74 | - if (lineNo == 0 && StringUtils.isNotEmpty(oldWindowName)) { | 70 | + |
| 75 | - stepOut.deleteBreakPoint(webSocketServer, paramReq); | 71 | + String type = (String) webSocketServer.getParamMap(windowName).get(TYPE); |
| 76 | - stat.execute(NEXT_SQL); | 72 | + String oid = (String) webSocketServer.getParamMap(windowName).get(OID); |
| 77 | - webSocketServer.sendMessage(windowName, closeWindow, SUCCESS, null); | 73 | + List<String> oidList = DebugUtils.getOidList(webSocketServer, rootWindowName); |
| 74 | + if (!CollectionUtils.isEmpty(oidList)) { | ||
| 75 | + String newOid = Strings.EMPTY; | ||
| 76 | + if ("f".equals(type) && lineNo == 0) { | ||
| 77 | + ResultSet resultSet = stat.executeQuery(NEXT_SQL); | ||
| 78 | + if (resultSet.next()) { | ||
| 79 | + newOid = resultSet.getString(FUNC_OID); | ||
| 80 | + } | ||
| 81 | + oidList = DebugUtils.getOidList(webSocketServer, rootWindowName); | ||
| 82 | + } | ||
| 83 | + if (oidList.contains(oid) && !oidList.get(0).equals(oid)) { | ||
| 84 | + Map<String, String> map = new HashMap<>(); | ||
| 85 | + map.put(RESULT, oidList.get(0)); | ||
| 86 | + webSocketServer.sendMessage(windowName, switchWindow, SUCCESS, map); | ||
| 87 | + String name = DebugUtils.getOldWindowName(webSocketServer, rootWindowName, newOid); | ||
| 88 | + DebugUtils.disableButton(webSocketServer, windowName); | ||
| 89 | + DebugUtils.enableButton(webSocketServer, name); | ||
| 78 | paramReq.setCloseWindow(true); | 90 | paramReq.setCloseWindow(true); |
| 91 | + paramReq.setOldWindowName(name); | ||
| 92 | + } | ||
| 93 | + if (!oidList.contains(oid)) { | ||
| 94 | + stepOut.deleteBreakPoint(webSocketServer, paramReq); | ||
| 95 | + webSocketServer.sendMessage(windowName, closeWindow, SUCCESS, null); | ||
| 96 | + DebugUtils.enableButton(webSocketServer, oldWindowName); | ||
| 97 | + paramReq.setCloseWindow(true); | ||
| 98 | + Map<String, Object> paramMap = webSocketServer.getParamMap(rootWindowName); | ||
| 99 | + paramMap.keySet().removeIf(oid::equals); | ||
| 79 | } | 100 | } |
| 80 | } | 101 | } |
| 81 | showDebugInfo(webSocketServer, paramReq); | 102 | showDebugInfo(webSocketServer, paramReq); |
| @@ -83,33 +104,28 @@ public class SingleStepImpl implements OperationInterface { | |||
| 83 | 104 | ||
| 84 | public void showDebugInfo(WebSocketServer webSocketServer, PublicParamReq paramReq) { | 105 | public void showDebugInfo(WebSocketServer webSocketServer, PublicParamReq paramReq) { |
| 85 | log.info("singleStep showDebugInfo paramReq is: " + paramReq); | 106 | log.info("singleStep showDebugInfo paramReq is: " + paramReq); |
| 86 | - String windowName = paramReq.getWindowName(); | 107 | + String rootWindowName = paramReq.getRootWindowName(); |
| 87 | - String oldWindowName = paramReq.getOldWindowName(); | 108 | + Statement stat = (Statement) webSocketServer.getParamMap(rootWindowName).get(STATEMENT); |
| 88 | - String name = oldWindowName; | ||
| 89 | - if (StringUtils.isEmpty(name)) { | ||
| 90 | - name = windowName; | ||
| 91 | - } | ||
| 92 | - Statement stat = (Statement) webSocketServer.getParamMap(name).get(STATEMENT); | ||
| 93 | if (stat == null) { | 109 | if (stat == null) { |
| 94 | return; | 110 | return; |
| 95 | } | 111 | } |
| 96 | 112 | ||
| 113 | + String name = paramReq.getWindowName(); | ||
| 114 | + if (paramReq.isCloseWindow()) { | ||
| 115 | + name = paramReq.getOldWindowName(); | ||
| 116 | + } | ||
| 117 | + int differ = (int) webSocketServer.getParamMap(name).get(DIFFER); | ||
| 118 | + log.info("singleStep showDebugInfo differ is: " + differ); | ||
| 119 | + | ||
| 97 | try { | 120 | try { |
| 98 | - if (paramReq.getOperation().equals("stepOut") || paramReq.isCloseWindow()) { | ||
| 99 | - name = oldWindowName; | ||
| 100 | - } else { | ||
| 101 | - name = windowName; | ||
| 102 | - } | ||
| 103 | - int differ = (int) webSocketServer.getParamMap(name).get(DIFFER); | ||
| 104 | - log.info("singleStep showDebugInfo differ is: " + differ); | ||
| 105 | ResultSet stackResult = stat.executeQuery(BACKTRACE_SQL_PRE + differ + BACKTRACE_SQL); | 121 | ResultSet stackResult = stat.executeQuery(BACKTRACE_SQL_PRE + differ + BACKTRACE_SQL); |
| 106 | webSocketServer.sendMessage(name, stack, SUCCESS, DebugUtils.parseResultSet(stackResult)); | 122 | webSocketServer.sendMessage(name, stack, SUCCESS, DebugUtils.parseResultSet(stackResult)); |
| 107 | 123 | ||
| 108 | - ResultSet variableResult = stat.executeQuery(INFO_LOCALS_SQL); | 124 | + Map<String, Object> variableMap = DebugUtils.parseVariable(stat.executeQuery(INFO_LOCALS_SQL)); |
| 109 | - Map<String, Object> variableMap = DebugUtils.parseResultSet(variableResult); | 125 | + Map<String, Object> paramMap = DebugUtils.addMapParam(variableMap, webSocketServer, paramReq); |
| 110 | - webSocketServer.sendMessage(name, variable, SUCCESS, DebugUtils.addMapParam(variableMap, paramReq.getSql())); | 126 | + webSocketServer.sendMessage(name, variable, SUCCESS, paramMap); |
| 111 | } catch (Exception e) { | 127 | } catch (Exception e) { |
| 112 | - e.printStackTrace(); | 128 | + log.info(e.getMessage()); |
| 113 | } | 129 | } |
| 114 | } | 130 | } |
| 115 | 131 | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/debug/StartDebugImpl.java+38-118
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| @@ -8,46 +12,22 @@ import com.nctigba.datastudio.service.OperationInterface; | |||
| 8 | import com.nctigba.datastudio.util.DebugUtils; | 12 | import com.nctigba.datastudio.util.DebugUtils; |
| 9 | import com.nctigba.datastudio.util.LocaleString; | 13 | import com.nctigba.datastudio.util.LocaleString; |
| 10 | import lombok.extern.slf4j.Slf4j; | 14 | import lombok.extern.slf4j.Slf4j; |
| 11 | -import org.apache.commons.lang3.StringUtils; | ||
| 12 | import org.apache.logging.log4j.util.Strings; | 15 | import org.apache.logging.log4j.util.Strings; |
| 16 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 13 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 14 | import org.springframework.stereotype.Service; | 18 | import org.springframework.stereotype.Service; |
| 15 | import org.springframework.util.CollectionUtils; | 19 | import org.springframework.util.CollectionUtils; |
| 16 | 20 | ||
| 17 | -import java.sql.Connection; | ||
| 18 | import java.sql.ResultSet; | 21 | import java.sql.ResultSet; |
| 19 | import java.sql.Statement; | 22 | import java.sql.Statement; |
| 20 | -import java.util.ArrayList; | ||
| 21 | import java.util.HashMap; | 23 | import java.util.HashMap; |
| 22 | import java.util.List; | 24 | import java.util.List; |
| 23 | import java.util.Map; | 25 | import java.util.Map; |
| 24 | 26 | ||
| 25 | -import static com.nctigba.datastudio.constants.CommonConstants.FEN_CED_MODE; | 27 | +import static com.nctigba.datastudio.constants.CommonConstants.DEFINITION; |
| 26 | -import static com.nctigba.datastudio.constants.CommonConstants.FIVE_HUNDRED; | ||
| 27 | -import static com.nctigba.datastudio.constants.CommonConstants.LAN_NAME; | ||
| 28 | -import static com.nctigba.datastudio.constants.CommonConstants.LINE_FEED; | ||
| 29 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_ALL_ARG_TYPES; | ||
| 30 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_ARG_MODES; | ||
| 31 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_ARG_NAMES; | ||
| 32 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_ARG_SRC; | ||
| 33 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_ARG_TYPES; | ||
| 34 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_BIN; | ||
| 35 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_COST; | ||
| 36 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_IS_STRICT; | ||
| 37 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_KIND; | ||
| 38 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_NAME; | ||
| 39 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_RET_SET; | ||
| 40 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_ROWS; | ||
| 41 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_SHIPPABLE; | ||
| 42 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_SRC; | ||
| 43 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_VOLATILE; | ||
| 44 | import static com.nctigba.datastudio.constants.CommonConstants.RESULT; | 28 | import static com.nctigba.datastudio.constants.CommonConstants.RESULT; |
| 45 | -import static com.nctigba.datastudio.constants.CommonConstants.SPACE; | ||
| 46 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | 29 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; |
| 47 | -import static com.nctigba.datastudio.constants.CommonConstants.TYP_NAME; | 30 | +import static com.nctigba.datastudio.constants.SqlConstants.QUERY_DEF_SQL; |
| 48 | -import static com.nctigba.datastudio.constants.SqlConstants.COMMA; | ||
| 49 | -import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_LEFT; | ||
| 50 | -import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_RIGHT; | ||
| 51 | import static com.nctigba.datastudio.enums.MessageEnum.paramWindow; | 31 | import static com.nctigba.datastudio.enums.MessageEnum.paramWindow; |
| 52 | import static com.nctigba.datastudio.enums.MessageEnum.window; | 32 | import static com.nctigba.datastudio.enums.MessageEnum.window; |
| 53 | 33 | ||
| @@ -65,113 +45,53 @@ public class StartDebugImpl implements OperationInterface { | |||
| 65 | 45 | ||
| 66 | 46 | ||
| 67 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 47 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 68 | - log.info("startDebug obj is: " + obj); | ||
| 69 | PublicParamReq paramReq = (PublicParamReq) obj; | 48 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 49 | + log.info("startDebug paramReq: " + paramReq); | ||
| 50 | + | ||
| 51 | + String rootWindowName = paramReq.getRootWindowName(); | ||
| 70 | String windowName = paramReq.getWindowName(); | 52 | String windowName = paramReq.getWindowName(); |
| 71 | OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); | 53 | OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); |
| 72 | - operateStatus.setDebug(paramReq.isDebug()); | 54 | + operateStatus.setDebug(true); |
| 73 | - if (!operateStatus.isStartDebug()) { | 55 | + operateStatus.enableStopDebug(); |
| 74 | - return; | 56 | + webSocketServer.setOperateStatus(windowName, operateStatus); |
| 75 | - } | ||
| 76 | - String sql = paramReq.getSql(); | ||
| 77 | - String name = DebugUtils.prepareName(sql); | ||
| 78 | - String schema = DebugUtils.prepareFuncName(sql).split("\\.")[0]; | ||
| 79 | - log.info("startDebug sql is: " + sql); | ||
| 80 | 57 | ||
| 81 | - Statement statement = webSocketServer.getStatement(windowName); | 58 | + Statement statement = webSocketServer.getStatement(rootWindowName); |
| 82 | if (statement == null) { | 59 | if (statement == null) { |
| 83 | - Connection connection = webSocketServer.getConnection(windowName); | 60 | + statement = webSocketServer.getConnection(rootWindowName).createStatement(); |
| 84 | - if (connection == null) { | 61 | + webSocketServer.setStatement(rootWindowName, statement); |
| 85 | - connection = webSocketServer.createConnection(paramReq.getUuid(), windowName); | ||
| 86 | - webSocketServer.setConnection(windowName, connection); | ||
| 87 | - } | ||
| 88 | - statement = connection.createStatement(); | ||
| 89 | - webSocketServer.setStatement(windowName, statement); | ||
| 90 | } | 62 | } |
| 91 | - ResultSet funcResult = statement.executeQuery(DebugUtils.getFuncSql(windowName, schema, name, webSocketServer)); | ||
| 92 | - Map<String, Object> paramMap = new HashMap<>(); | ||
| 93 | - while (funcResult.next()) { | ||
| 94 | - paramMap.put(PRO_NAME, funcResult.getString(PRO_NAME)); | ||
| 95 | - paramMap.put(LAN_NAME, funcResult.getString(LAN_NAME)); | ||
| 96 | - paramMap.put(TYP_NAME, funcResult.getString(TYP_NAME)); | ||
| 97 | - paramMap.put(PRO_ARG_TYPES, funcResult.getString(PRO_ARG_TYPES)); | ||
| 98 | - paramMap.put(PRO_ALL_ARG_TYPES, funcResult.getString(PRO_ALL_ARG_TYPES)); | ||
| 99 | - paramMap.put(PRO_ARG_MODES, funcResult.getString(PRO_ARG_MODES)); | ||
| 100 | - paramMap.put(PRO_ARG_NAMES, funcResult.getString(PRO_ARG_NAMES)); | ||
| 101 | - paramMap.put(PRO_SRC, funcResult.getString(PRO_SRC)); | ||
| 102 | - paramMap.put(PRO_BIN, funcResult.getString(PRO_BIN)); | ||
| 103 | - paramMap.put(PRO_ARG_SRC, funcResult.getString(PRO_ARG_SRC)); | ||
| 104 | - paramMap.put(PRO_KIND, funcResult.getString(PRO_KIND)); | ||
| 105 | - paramMap.put(PRO_VOLATILE, funcResult.getString(PRO_VOLATILE)); | ||
| 106 | - paramMap.put(PRO_COST, funcResult.getInt(PRO_COST)); | ||
| 107 | - paramMap.put(PRO_ROWS, funcResult.getInt(PRO_ROWS)); | ||
| 108 | - paramMap.put(FEN_CED_MODE, funcResult.getBoolean(FEN_CED_MODE)); | ||
| 109 | - paramMap.put(PRO_SHIPPABLE, funcResult.getBoolean(PRO_SHIPPABLE)); | ||
| 110 | - paramMap.put(PRO_IS_STRICT, funcResult.getBoolean(PRO_IS_STRICT)); | ||
| 111 | - paramMap.put(PRO_RET_SET, funcResult.getBoolean(PRO_RET_SET)); | ||
| 112 | - } | ||
| 113 | - log.info("startDebug paramMap is: " + paramMap); | ||
| 114 | 63 | ||
| 115 | - if (CollectionUtils.isEmpty(paramMap)) { | 64 | + String oid = paramReq.getOid(); |
| 116 | - webSocketServer.sendMessage(windowName, window, FIVE_HUNDRED, LocaleString.transLanguageWs("1006", webSocketServer), null); | 65 | + String definition = Strings.EMPTY; |
| 66 | + try ( | ||
| 67 | + ResultSet defResultSet = statement.executeQuery(String.format(QUERY_DEF_SQL, oid)) | ||
| 68 | + ) { | ||
| 69 | + while (defResultSet.next()) { | ||
| 70 | + definition = DebugUtils.sqlHandleAfter(defResultSet.getString(DEFINITION)); | ||
| 71 | + } | ||
| 72 | + log.info("startDebug definition: " + definition); | ||
| 73 | + } catch (Exception e) { | ||
| 74 | + log.info(e.getMessage()); | ||
| 75 | + throw new CustomException(e.getMessage(), e); | ||
| 76 | + } | ||
| 77 | + String sql = DebugUtils.sqlFormat(paramReq.getSql()); | ||
| 78 | + if (!sql.equals(DebugUtils.sqlFormat(definition))) { | ||
| 79 | + webSocketServer.sendMessage(windowName, window, LocaleString.transLanguageWs("1007", webSocketServer), | ||
| 80 | + null); | ||
| 117 | return; | 81 | return; |
| 118 | - } else { | ||
| 119 | - String currentSql = funcProcedure.parseResult(windowName, paramMap, webSocketServer, schema); | ||
| 120 | - String replaceSql = sql.replace(LINE_FEED, Strings.EMPTY).replace(SPACE, Strings.EMPTY); | ||
| 121 | - String replaceCurrentSql = currentSql.replace(LINE_FEED, Strings.EMPTY).replace(SPACE, Strings.EMPTY); | ||
| 122 | - if (!replaceSql.equals(replaceCurrentSql)) { | ||
| 123 | - webSocketServer.sendMessage(windowName, window, FIVE_HUNDRED, LocaleString.transLanguageWs("1005", webSocketServer), null); | ||
| 124 | - return; | ||
| 125 | - } | ||
| 126 | } | 82 | } |
| 127 | 83 | ||
| 128 | - if (operateStatus.isDebug()) { | 84 | + Map<String, List<Map<String, Object>>> map = new HashMap<>(); |
| 129 | - operateStatus.enableStopDebug(); | 85 | + List<Map<String, Object>> paramList = DebugUtils.getParamMap(webSocketServer, windowName, oid); |
| 130 | - webSocketServer.setOperateStatus(windowName, operateStatus); | 86 | + log.info("startDebug paramList: " + paramList); |
| 131 | - } | 87 | + map.put(RESULT, paramList); |
| 132 | - Map<String, List<Map<String, String>>> map = new HashMap<>(); | 88 | + if (CollectionUtils.isEmpty(paramList)) { |
| 133 | - List<Map<String, String>> itemList = getInputParam(sql); | ||
| 134 | - map.put(RESULT, itemList); | ||
| 135 | - log.info("startDebug inputParam map is: " + itemList); | ||
| 136 | - | ||
| 137 | - if (CollectionUtils.isEmpty(itemList)) { | ||
| 138 | inputParam.operate(webSocketServer, paramReq); | 89 | inputParam.operate(webSocketServer, paramReq); |
| 139 | } else { | 90 | } else { |
| 140 | webSocketServer.sendMessage(windowName, paramWindow, SUCCESS, map); | 91 | webSocketServer.sendMessage(windowName, paramWindow, SUCCESS, map); |
| 141 | } | 92 | } |
| 142 | } | 93 | } |
| 143 | 94 | ||
| 144 | - private List<Map<String, String>> getInputParam(String sql) { | ||
| 145 | - List<Integer> leftList = DebugUtils.getIndexList(sql, PARENTHESES_LEFT); | ||
| 146 | - List<Integer> rightList = DebugUtils.getIndexList(sql, PARENTHESES_RIGHT); | ||
| 147 | - int start = leftList.get(0); | ||
| 148 | - int end = rightList.get(rightList.size() - 1); | ||
| 149 | - sql = sql.replace(LINE_FEED, SPACE); | ||
| 150 | - String substring = sql.substring(start + 1, end); | ||
| 151 | - log.info("startDebug substring is: " + substring); | ||
| 152 | - | ||
| 153 | - List<Map<String, String>> list = new ArrayList<>(); | ||
| 154 | - if (!StringUtils.isEmpty(substring)) { | ||
| 155 | - String[] splits = substring.split(COMMA); | ||
| 156 | - for (String s : splits) { | ||
| 157 | - if (!s.trim().toLowerCase().startsWith("out")) { | ||
| 158 | - Map<String, String> itemMap = new HashMap<>(); | ||
| 159 | - String[] split = s.trim().split(SPACE); | ||
| 160 | - if (split.length == 1) { | ||
| 161 | - itemMap.put(Strings.EMPTY, split[0]); | ||
| 162 | - } else if (split.length == 3) { | ||
| 163 | - itemMap.put(split[1], split[2]); | ||
| 164 | - } else { | ||
| 165 | - itemMap.put(split[0], split[1]); | ||
| 166 | - } | ||
| 167 | - list.add(itemMap); | ||
| 168 | - } | ||
| 169 | - } | ||
| 170 | - } | ||
| 171 | - log.info("startDebug getInputParam list is: " + list); | ||
| 172 | - return list; | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | 95 | ||
| 176 | public Object formatJson(String str) { | 96 | public Object formatJson(String str) { |
| 177 | return JSON.parseObject(str, PublicParamReq.class); | 97 | return JSON.parseObject(str, PublicParamReq.class); |
| @@ -1,39 +1,44 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| 4 | import com.nctigba.datastudio.base.WebSocketServer; | 8 | import com.nctigba.datastudio.base.WebSocketServer; |
| 5 | import com.nctigba.datastudio.model.PublicParamReq; | 9 | import com.nctigba.datastudio.model.PublicParamReq; |
| 6 | -import com.nctigba.datastudio.model.entity.OperateStatusDO; | ||
| 7 | import com.nctigba.datastudio.service.OperationInterface; | 10 | import com.nctigba.datastudio.service.OperationInterface; |
| 8 | import com.nctigba.datastudio.util.DebugUtils; | 11 | import com.nctigba.datastudio.util.DebugUtils; |
| 9 | -import com.nctigba.datastudio.util.LocaleString; | ||
| 10 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 11 | -import org.apache.commons.lang3.StringUtils; | ||
| 12 | import org.apache.logging.log4j.util.Strings; | 13 | import org.apache.logging.log4j.util.Strings; |
| 13 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 14 | import org.springframework.stereotype.Service; | 15 | import org.springframework.stereotype.Service; |
| 16 | +import org.springframework.util.CollectionUtils; | ||
| 15 | 17 | ||
| 16 | import java.sql.ResultSet; | 18 | import java.sql.ResultSet; |
| 17 | import java.sql.Statement; | 19 | import java.sql.Statement; |
| 20 | +import java.util.ArrayList; | ||
| 18 | import java.util.HashMap; | 21 | import java.util.HashMap; |
| 22 | +import java.util.List; | ||
| 19 | import java.util.Map; | 23 | import java.util.Map; |
| 20 | 24 | ||
| 21 | -import static com.nctigba.datastudio.constants.CommonConstants.FIVE_HUNDRED; | 25 | +import static com.nctigba.datastudio.constants.CommonConstants.CAN_BREAK; |
| 22 | import static com.nctigba.datastudio.constants.CommonConstants.FUNC_OID; | 26 | import static com.nctigba.datastudio.constants.CommonConstants.FUNC_OID; |
| 23 | -import static com.nctigba.datastudio.constants.CommonConstants.LINE_FEED; | ||
| 24 | import static com.nctigba.datastudio.constants.CommonConstants.LINE_NO; | 27 | import static com.nctigba.datastudio.constants.CommonConstants.LINE_NO; |
| 25 | import static com.nctigba.datastudio.constants.CommonConstants.OID; | 28 | import static com.nctigba.datastudio.constants.CommonConstants.OID; |
| 26 | import static com.nctigba.datastudio.constants.CommonConstants.RESULT; | 29 | import static com.nctigba.datastudio.constants.CommonConstants.RESULT; |
| 27 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; | 30 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; |
| 28 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | 31 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; |
| 32 | +import static com.nctigba.datastudio.constants.CommonConstants.T; | ||
| 29 | import static com.nctigba.datastudio.constants.CommonConstants.TYPE; | 33 | import static com.nctigba.datastudio.constants.CommonConstants.TYPE; |
| 34 | +import static com.nctigba.datastudio.constants.SqlConstants.BACKTRACE_SQL; | ||
| 35 | +import static com.nctigba.datastudio.constants.SqlConstants.BACKTRACE_SQL_PRE; | ||
| 30 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_CODE_SQL; | 36 | import static com.nctigba.datastudio.constants.SqlConstants.INFO_CODE_SQL; |
| 31 | import static com.nctigba.datastudio.constants.SqlConstants.NEXT_SQL; | 37 | import static com.nctigba.datastudio.constants.SqlConstants.NEXT_SQL; |
| 32 | -import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_SEMICOLON; | ||
| 33 | import static com.nctigba.datastudio.constants.SqlConstants.STEP_SQL; | 38 | import static com.nctigba.datastudio.constants.SqlConstants.STEP_SQL; |
| 34 | import static com.nctigba.datastudio.enums.MessageEnum.closeWindow; | 39 | import static com.nctigba.datastudio.enums.MessageEnum.closeWindow; |
| 35 | import static com.nctigba.datastudio.enums.MessageEnum.newWindow; | 40 | import static com.nctigba.datastudio.enums.MessageEnum.newWindow; |
| 36 | -import static com.nctigba.datastudio.enums.MessageEnum.window; | 41 | +import static com.nctigba.datastudio.enums.MessageEnum.switchWindow; |
| 37 | 42 | ||
| 38 | /** | 43 | /** |
| 39 | * step in | 44 | * step in |
| @@ -52,81 +57,105 @@ public class StepInImpl implements OperationInterface { | |||
| 52 | 57 | ||
| 53 | 58 | ||
| 54 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 59 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 55 | - log.info("stepIn obj is: " + obj); | ||
| 56 | PublicParamReq paramReq = (PublicParamReq) obj; | 60 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 57 | - String name = paramReq.getOldWindowName(); | 61 | + log.info("stepIn paramReq: " + paramReq); |
| 58 | - String windowName = paramReq.getWindowName(); | 62 | + String rootWindowName = paramReq.getRootWindowName(); |
| 59 | - String oldWindowName = paramReq.getOldWindowName(); | 63 | + Statement stat = (Statement) webSocketServer.getParamMap(rootWindowName).get(STATEMENT); |
| 60 | - if (StringUtils.isEmpty(name)) { | ||
| 61 | - name = windowName; | ||
| 62 | - } | ||
| 63 | - OperateStatusDO operateStatus = webSocketServer.getOperateStatus(name); | ||
| 64 | - if (!operateStatus.isStepIn()) { | ||
| 65 | - return; | ||
| 66 | - } | ||
| 67 | - Statement stat = (Statement) webSocketServer.getParamMap(name).get(STATEMENT); | ||
| 68 | if (stat == null) { | 64 | if (stat == null) { |
| 69 | return; | 65 | return; |
| 70 | } | 66 | } |
| 71 | 67 | ||
| 68 | + String windowName = paramReq.getWindowName(); | ||
| 72 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); | 69 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); |
| 73 | - log.info("stepIn oid is: " + oid); | 70 | + log.info("stepIn oid: " + oid); |
| 74 | - ResultSet resultSet = stat.executeQuery(STEP_SQL); | 71 | + |
| 75 | - String newOid = Strings.EMPTY; | 72 | + List<Integer> lineList = new ArrayList<>(); |
| 76 | - int lineNo = -1; | 73 | + ResultSet stackResult = stat.executeQuery(BACKTRACE_SQL_PRE + 0 + BACKTRACE_SQL); |
| 77 | - while (resultSet.next()) { | 74 | + while (stackResult.next()) { |
| 78 | - lineNo = resultSet.getInt(LINE_NO); | 75 | + lineList.add(stackResult.getInt(LINE_NO)); |
| 79 | - newOid = resultSet.getString(FUNC_OID); | ||
| 80 | - log.info("stepIn newOid is: " + newOid); | ||
| 81 | } | 76 | } |
| 82 | - String type = (String) webSocketServer.getParamMap(windowName).get(TYPE); | 77 | + log.info("stepIn lineList: " + lineList); |
| 83 | - if ("p".equals(type)) { | 78 | + |
| 84 | - if (!oid.equals(newOid) && StringUtils.isNotEmpty(oldWindowName)) { | 79 | + int lastLine = 0; |
| 85 | - String id = (String) webSocketServer.getParamMap(oldWindowName).get(OID); | 80 | + try ( |
| 86 | - if (id.equals(newOid)) { | 81 | + ResultSet allLineResult = stat.executeQuery(String.format(INFO_CODE_SQL, oid)) |
| 87 | - stepOut.deleteBreakPoint(webSocketServer, paramReq); | 82 | + ) { |
| 88 | - webSocketServer.sendMessage(windowName, closeWindow, SUCCESS, null); | 83 | + while (allLineResult.next()) { |
| 89 | - paramReq.setCloseWindow(true); | 84 | + if (T.equals(allLineResult.getString(CAN_BREAK))) { |
| 90 | - singleStep.showDebugInfo(webSocketServer, paramReq); | 85 | + lastLine = allLineResult.getInt(LINE_NO); |
| 91 | - return; | ||
| 92 | - } else { | ||
| 93 | - try { | ||
| 94 | - stopDebug.operate(webSocketServer, paramReq); | ||
| 95 | - webSocketServer.sendMessage(windowName, closeWindow, SUCCESS, null); | ||
| 96 | - webSocketServer.sendMessage(oldWindowName, window, FIVE_HUNDRED, | ||
| 97 | - LocaleString.transLanguageWs("1008", webSocketServer), null); | ||
| 98 | - return; | ||
| 99 | - } catch (Exception e) { | ||
| 100 | - webSocketServer.sendMessage(windowName, closeWindow, SUCCESS, null); | ||
| 101 | - webSocketServer.sendMessage(oldWindowName, window, FIVE_HUNDRED, | ||
| 102 | - LocaleString.transLanguageWs("1008", webSocketServer), null); | ||
| 103 | - return; | ||
| 104 | - } | ||
| 105 | } | 86 | } |
| 106 | } | 87 | } |
| 107 | - } else if ("f".equals(type)) { | 88 | + } |
| 108 | - if (lineNo == 0 && StringUtils.isNotEmpty(oldWindowName)) { | 89 | + log.info("stepIn lastLine: " + lastLine); |
| 109 | - stepOut.deleteBreakPoint(webSocketServer, paramReq); | 90 | + List<String> oidList = DebugUtils.getOidList(webSocketServer, rootWindowName); |
| 110 | - stat.execute(NEXT_SQL); | 91 | + |
| 111 | - webSocketServer.sendMessage(windowName, closeWindow, SUCCESS, null); | 92 | + String newOid = Strings.EMPTY; |
| 112 | - paramReq.setCloseWindow(true); | 93 | + int lineNo = -1; |
| 94 | + try ( | ||
| 95 | + ResultSet resultSet = stat.executeQuery(STEP_SQL) | ||
| 96 | + ) { | ||
| 97 | + while (resultSet.next()) { | ||
| 98 | + lineNo = resultSet.getInt(LINE_NO); | ||
| 99 | + newOid = resultSet.getString(FUNC_OID); | ||
| 100 | + log.info("stepIn newOid: " + newOid); | ||
| 101 | + log.info("stepIn lineNo: " + lineNo); | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + if (lineList.get(0) != lastLine) { | ||
| 106 | + if (newOid.equals(oid)) { | ||
| 113 | singleStep.showDebugInfo(webSocketServer, paramReq); | 107 | singleStep.showDebugInfo(webSocketServer, paramReq); |
| 114 | - return; | 108 | + } else if (oidList.contains(newOid)) { |
| 109 | + Map<String, String> map = new HashMap<>(); | ||
| 110 | + map.put(RESULT, newOid); | ||
| 111 | + webSocketServer.sendMessage(windowName, switchWindow, SUCCESS, map); | ||
| 112 | + String name = DebugUtils.getOldWindowName(webSocketServer, rootWindowName, newOid); | ||
| 113 | + DebugUtils.disableButton(webSocketServer, windowName); | ||
| 114 | + DebugUtils.enableButton(webSocketServer, name); | ||
| 115 | + paramReq.setCloseWindow(true); | ||
| 116 | + paramReq.setOldWindowName(name); | ||
| 117 | + singleStep.showDebugInfo(webSocketServer, paramReq); | ||
| 118 | + } else { | ||
| 119 | + paramReq.setWindowName(rootWindowName); | ||
| 120 | + paramReq.setOid(newOid); | ||
| 121 | + Map<String, Map<String, String>> resultMap = DebugUtils.getResultMap(webSocketServer, paramReq); | ||
| 122 | + webSocketServer.sendMessage(windowName, newWindow, SUCCESS, resultMap); | ||
| 123 | + DebugUtils.disableButton(webSocketServer, windowName); | ||
| 124 | + } | ||
| 125 | + return; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + oidList = DebugUtils.getOidList(webSocketServer, rootWindowName); | ||
| 129 | + String oldWindowName = paramReq.getOldWindowName(); | ||
| 130 | + String type = (String) webSocketServer.getParamMap(windowName).get(TYPE); | ||
| 131 | + if (!CollectionUtils.isEmpty(oidList)) { | ||
| 132 | + if ("f".equals(type) && lineNo == 0) { | ||
| 133 | + ResultSet resultSet = stat.executeQuery(NEXT_SQL); | ||
| 134 | + if (resultSet.next()) { | ||
| 135 | + newOid = resultSet.getString(FUNC_OID); | ||
| 136 | + } | ||
| 137 | + oidList = DebugUtils.getOidList(webSocketServer, rootWindowName); | ||
| 138 | + } | ||
| 139 | + if (oidList.contains(oid) && !oidList.get(0).equals(oid)) { | ||
| 140 | + Map<String, String> map = new HashMap<>(); | ||
| 141 | + map.put(RESULT, oidList.get(0)); | ||
| 142 | + webSocketServer.sendMessage(windowName, switchWindow, SUCCESS, map); | ||
| 143 | + String name = DebugUtils.getOldWindowName(webSocketServer, rootWindowName, newOid); | ||
| 144 | + DebugUtils.disableButton(webSocketServer, windowName); | ||
| 145 | + DebugUtils.enableButton(webSocketServer, name); | ||
| 146 | + paramReq.setCloseWindow(true); | ||
| 147 | + paramReq.setOldWindowName(name); | ||
| 148 | + } | ||
| 149 | + if (!oidList.contains(oid)) { | ||
| 150 | + stepOut.deleteBreakPoint(webSocketServer, paramReq); | ||
| 151 | + webSocketServer.sendMessage(windowName, closeWindow, SUCCESS, null); | ||
| 152 | + DebugUtils.enableButton(webSocketServer, oldWindowName); | ||
| 153 | + paramReq.setCloseWindow(true); | ||
| 154 | + Map<String, Object> paramMap = webSocketServer.getParamMap(rootWindowName); | ||
| 155 | + paramMap.keySet().removeIf(oid::equals); | ||
| 115 | } | 156 | } |
| 116 | } | 157 | } |
| 117 | - if (oid.equals(newOid)) { | 158 | + singleStep.showDebugInfo(webSocketServer, paramReq); |
| 118 | - singleStep.showDebugInfo(webSocketServer, paramReq); | ||
| 119 | - } else { | ||
| 120 | - Map<String, String> map = new HashMap<>(); | ||
| 121 | - ResultSet infoCodeResult = stat.executeQuery(INFO_CODE_SQL + newOid + PARENTHESES_SEMICOLON); | ||
| 122 | - StringBuilder sb = new StringBuilder(); | ||
| 123 | - while (infoCodeResult.next()) { | ||
| 124 | - sb.append(infoCodeResult.getString("query")).append(LINE_FEED); | ||
| 125 | - } | ||
| 126 | - log.info("stepIn sb is: " + sb); | ||
| 127 | - map.put(RESULT, DebugUtils.prepareName(sb.toString())); | ||
| 128 | - webSocketServer.sendMessage(name, newWindow, SUCCESS, map); | ||
| 129 | - } | ||
| 130 | } | 159 | } |
| 131 | 160 | ||
| 132 | 161 | ||
| @@ -1,9 +1,14 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| 4 | import com.nctigba.datastudio.base.WebSocketServer; | 8 | import com.nctigba.datastudio.base.WebSocketServer; |
| 5 | import com.nctigba.datastudio.model.PublicParamReq; | 9 | import com.nctigba.datastudio.model.PublicParamReq; |
| 6 | import com.nctigba.datastudio.service.OperationInterface; | 10 | import com.nctigba.datastudio.service.OperationInterface; |
| 11 | +import com.nctigba.datastudio.util.DebugUtils; | ||
| 7 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 8 | import org.apache.logging.log4j.util.Strings; | 13 | import org.apache.logging.log4j.util.Strings; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -13,22 +18,20 @@ import org.springframework.util.CollectionUtils; | |||
| 13 | import java.sql.ResultSet; | 18 | import java.sql.ResultSet; |
| 14 | import java.sql.Statement; | 19 | import java.sql.Statement; |
| 15 | import java.util.ArrayList; | 20 | import java.util.ArrayList; |
| 21 | +import java.util.HashMap; | ||
| 16 | import java.util.List; | 22 | import java.util.List; |
| 17 | import java.util.Map; | 23 | import java.util.Map; |
| 18 | import java.util.Set; | 24 | import java.util.Set; |
| 19 | 25 | ||
| 20 | import static com.nctigba.datastudio.constants.CommonConstants.BREAK_POINT; | 26 | import static com.nctigba.datastudio.constants.CommonConstants.BREAK_POINT; |
| 21 | -import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; | ||
| 22 | import static com.nctigba.datastudio.constants.CommonConstants.FUNC_OID; | 27 | import static com.nctigba.datastudio.constants.CommonConstants.FUNC_OID; |
| 23 | -import static com.nctigba.datastudio.constants.CommonConstants.LINE_NO; | ||
| 24 | import static com.nctigba.datastudio.constants.CommonConstants.OID; | 28 | import static com.nctigba.datastudio.constants.CommonConstants.OID; |
| 29 | +import static com.nctigba.datastudio.constants.CommonConstants.RESULT; | ||
| 25 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; | 30 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; |
| 26 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; | 31 | import static com.nctigba.datastudio.constants.CommonConstants.SUCCESS; |
| 27 | -import static com.nctigba.datastudio.constants.SqlConstants.BACKTRACE_SQL; | ||
| 28 | -import static com.nctigba.datastudio.constants.SqlConstants.BACKTRACE_SQL_PRE; | ||
| 29 | -import static com.nctigba.datastudio.constants.SqlConstants.CONTINUE_SQL; | ||
| 30 | import static com.nctigba.datastudio.constants.SqlConstants.FINISH_SQL; | 32 | import static com.nctigba.datastudio.constants.SqlConstants.FINISH_SQL; |
| 31 | import static com.nctigba.datastudio.enums.MessageEnum.closeWindow; | 33 | import static com.nctigba.datastudio.enums.MessageEnum.closeWindow; |
| 34 | +import static com.nctigba.datastudio.enums.MessageEnum.switchWindow; | ||
| 32 | 35 | ||
| 33 | /** | 36 | /** |
| 34 | * step out | 37 | * step out |
| @@ -44,40 +47,61 @@ public class StepOutImpl implements OperationInterface { | |||
| 44 | 47 | ||
| 45 | 48 | ||
| 46 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 49 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 47 | - log.info("stepOut obj is: " + obj); | ||
| 48 | PublicParamReq paramReq = (PublicParamReq) obj; | 50 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 49 | - String windowName = paramReq.getWindowName(); | 51 | + log.info("stepOut paramReq: " + paramReq); |
| 50 | - String oldWindowName = paramReq.getOldWindowName(); | 52 | + String rootWindowName = paramReq.getRootWindowName(); |
| 51 | - Statement stat = (Statement) webSocketServer.getParamMap(oldWindowName).get(STATEMENT); | 53 | + Statement stat = (Statement) webSocketServer.getParamMap(rootWindowName).get(STATEMENT); |
| 52 | if (stat == null) { | 54 | if (stat == null) { |
| 53 | return; | 55 | return; |
| 54 | } | 56 | } |
| 55 | 57 | ||
| 56 | - deleteBreakPoint(webSocketServer, paramReq); | 58 | + String windowName = paramReq.getWindowName(); |
| 57 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); | 59 | String oid = (String) webSocketServer.getParamMap(windowName).get(OID); |
| 58 | - log.info("stepOut oid is: " + oid); | 60 | + log.info("stepOut oid: " + oid); |
| 59 | - ResultSet resultSet = stat.executeQuery(FINISH_SQL); | 61 | + |
| 60 | String newOid = Strings.EMPTY; | 62 | String newOid = Strings.EMPTY; |
| 61 | - while (resultSet.next()) { | 63 | + try ( |
| 62 | - newOid = resultSet.getString(FUNC_OID); | 64 | + ResultSet resultSet = stat.executeQuery(FINISH_SQL) |
| 63 | - log.info("stepOut newOid is: " + newOid); | 65 | + ) { |
| 66 | + if (resultSet.next()) { | ||
| 67 | + newOid = resultSet.getString(FUNC_OID); | ||
| 68 | + log.info("stepOut newOid: " + newOid); | ||
| 69 | + } | ||
| 64 | } | 70 | } |
| 65 | 71 | ||
| 66 | - if (!oid.equals(newOid) && !paramReq.isCloseWindow()) { | 72 | + List<String> oidList = DebugUtils.getOidList(webSocketServer, rootWindowName); |
| 67 | - webSocketServer.sendMessage(windowName, closeWindow, SUCCESS, null); | 73 | + if (oid.equals(newOid)) { |
| 74 | + singleStep.showDebugInfo(webSocketServer, paramReq); | ||
| 75 | + return; | ||
| 68 | } | 76 | } |
| 77 | + if (oidList.contains(oid)) { | ||
| 78 | + Map<String, String> map = new HashMap<>(); | ||
| 79 | + map.put(RESULT, newOid); | ||
| 80 | + webSocketServer.sendMessage(windowName, switchWindow, SUCCESS, map); | ||
| 81 | + DebugUtils.disableButton(webSocketServer, windowName); | ||
| 82 | + } else { | ||
| 83 | + deleteBreakPoint(webSocketServer, paramReq); | ||
| 84 | + webSocketServer.sendMessage(windowName, closeWindow, SUCCESS, null); | ||
| 85 | + Map<String, Object> paramMap = webSocketServer.getParamMap(rootWindowName); | ||
| 86 | + paramMap.keySet().removeIf(oid::equals); | ||
| 87 | + } | ||
| 88 | + String name = DebugUtils.getOldWindowName(webSocketServer, rootWindowName, newOid); | ||
| 89 | + DebugUtils.enableButton(webSocketServer, name); | ||
| 90 | + paramReq.setCloseWindow(true); | ||
| 91 | + paramReq.setOldWindowName(name); | ||
| 69 | singleStep.showDebugInfo(webSocketServer, paramReq); | 92 | singleStep.showDebugInfo(webSocketServer, paramReq); |
| 70 | } | 93 | } |
| 71 | 94 | ||
| 72 | public void deleteBreakPoint(WebSocketServer webSocketServer, PublicParamReq paramReq) throws Exception { | 95 | public void deleteBreakPoint(WebSocketServer webSocketServer, PublicParamReq paramReq) throws Exception { |
| 73 | Map<Integer, String> breakPointMap = (Map<Integer, String>) webSocketServer | 96 | Map<Integer, String> breakPointMap = (Map<Integer, String>) webSocketServer |
| 74 | .getParamMap(paramReq.getWindowName()).get(BREAK_POINT); | 97 | .getParamMap(paramReq.getWindowName()).get(BREAK_POINT); |
| 75 | - log.info("stepOut breakPointMap is: " + breakPointMap); | 98 | + log.info("stepOut deleteBreakPoint breakPointMap: " + breakPointMap); |
| 99 | + | ||
| 76 | if (!CollectionUtils.isEmpty(breakPointMap)) { | 100 | if (!CollectionUtils.isEmpty(breakPointMap)) { |
| 77 | Set<Integer> integers = breakPointMap.keySet(); | 101 | Set<Integer> integers = breakPointMap.keySet(); |
| 78 | List<Integer> list = new ArrayList<>(integers); | 102 | List<Integer> list = new ArrayList<>(integers); |
| 79 | - for (int i = 0; i < list.size(); i++) { | 103 | + for (Integer integer : list) { |
| 80 | - paramReq.setLine(list.get(i)); | 104 | + paramReq.setLine(integer); |
| 81 | deleteBreakPoint.operate(webSocketServer, paramReq); | 105 | deleteBreakPoint.operate(webSocketServer, paramReq); |
| 82 | } | 106 | } |
| 83 | } | 107 | } |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.debug; | 5 | package com.nctigba.datastudio.service.impl.debug; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
| @@ -29,8 +33,8 @@ import static com.nctigba.datastudio.enums.MessageEnum.text; | |||
| 29 | public class StopDebugImpl implements OperationInterface { | 33 | public class StopDebugImpl implements OperationInterface { |
| 30 | 34 | ||
| 31 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { | 35 | public void operate(WebSocketServer webSocketServer, Object obj) throws Exception { |
| 32 | - log.info("stopDebug obj is: " + obj); | ||
| 33 | PublicParamReq paramReq = (PublicParamReq) obj; | 36 | PublicParamReq paramReq = (PublicParamReq) obj; |
| 37 | + log.info("stopDebug paramReq: " + paramReq); | ||
| 34 | String windowName = paramReq.getWindowName(); | 38 | String windowName = paramReq.getWindowName(); |
| 35 | Connection conn = (Connection) webSocketServer.getParamMap(windowName).get(CONNECTION); | 39 | Connection conn = (Connection) webSocketServer.getParamMap(windowName).get(CONNECTION); |
| 36 | Statement statNew = (Statement) webSocketServer.getParamMap(windowName).get(STATEMENT); | 40 | Statement statNew = (Statement) webSocketServer.getParamMap(windowName).get(STATEMENT); |
| @@ -39,7 +43,7 @@ public class StopDebugImpl implements OperationInterface { | |||
| 39 | statNew.execute(ABORT_SQL); | 43 | statNew.execute(ABORT_SQL); |
| 40 | } | 44 | } |
| 41 | } catch (Exception e) { | 45 | } catch (Exception e) { |
| 42 | - e.printStackTrace(); | 46 | + log.info(e.getMessage()); |
| 43 | } finally { | 47 | } finally { |
| 44 | if (statNew != null) { | 48 | if (statNew != null) { |
| 45 | statNew.close(); | 49 | statNew.close(); |
| @@ -55,22 +59,16 @@ public class StopDebugImpl implements OperationInterface { | |||
| 55 | OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); | 59 | OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); |
| 56 | operateStatus.enableStartDebug(); | 60 | operateStatus.enableStartDebug(); |
| 57 | webSocketServer.setOperateStatus(windowName, operateStatus); | 61 | webSocketServer.setOperateStatus(windowName, operateStatus); |
| 58 | - | ||
| 59 | Map<String, String> map = new HashMap<>(); | 62 | Map<String, String> map = new HashMap<>(); |
| 60 | map.put(RESULT, LocaleString.transLanguageWs("1003", webSocketServer)); | 63 | map.put(RESULT, LocaleString.transLanguageWs("1003", webSocketServer)); |
| 61 | webSocketServer.sendMessage(windowName, text, SUCCESS, map); | 64 | webSocketServer.sendMessage(windowName, text, SUCCESS, map); |
| 62 | 65 | ||
| 63 | - Connection connection = webSocketServer.getConnection(windowName); | ||
| 64 | Statement statement = webSocketServer.getStatement(windowName); | 66 | Statement statement = webSocketServer.getStatement(windowName); |
| 65 | if (statement != null) { | 67 | if (statement != null) { |
| 66 | statement.close(); | 68 | statement.close(); |
| 67 | statement.cancel(); | 69 | statement.cancel(); |
| 68 | webSocketServer.setStatement(windowName, null); | 70 | webSocketServer.setStatement(windowName, null); |
| 69 | } | 71 | } |
| 70 | - if (connection != null) { | ||
| 71 | - connection.close(); | ||
| 72 | - webSocketServer.setConnection(windowName, null); | ||
| 73 | - } | ||
| 74 | } | 72 | } |
| 75 | 73 | ||
| 76 | 74 | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/sql/CreateDatabaseServiceImpl.java+74-42
| @@ -1,6 +1,10 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 3 | -import com.alibaba.druid.util.StringUtils; | 7 | +import com.nctigba.datastudio.compatible.DatabaseObjectSQLService; |
| 4 | import com.nctigba.datastudio.config.ConnectionConfig; | 8 | import com.nctigba.datastudio.config.ConnectionConfig; |
| 5 | import com.nctigba.datastudio.dao.ConnectionMapDAO; | 9 | import com.nctigba.datastudio.dao.ConnectionMapDAO; |
| 6 | import com.nctigba.datastudio.dao.DatabaseConnectionDAO; | 10 | import com.nctigba.datastudio.dao.DatabaseConnectionDAO; |
| @@ -23,10 +27,14 @@ import javax.annotation.Resource; | |||
| 23 | import java.sql.Connection; | 27 | import java.sql.Connection; |
| 24 | import java.sql.ResultSet; | 28 | import java.sql.ResultSet; |
| 25 | import java.sql.Statement; | 29 | import java.sql.Statement; |
| 30 | +import java.util.HashMap; | ||
| 31 | +import java.util.List; | ||
| 26 | import java.util.Map; | 32 | import java.util.Map; |
| 27 | import java.util.UUID; | 33 | import java.util.UUID; |
| 28 | 34 | ||
| 29 | -import static com.nctigba.datastudio.constants.SqlConstants.*; | 35 | +import static com.nctigba.datastudio.constants.SqlConstants.CONFIGURE_TIME; |
| 36 | +import static com.nctigba.datastudio.constants.SqlConstants.GET_URL_JDBC; | ||
| 37 | +import static com.nctigba.datastudio.dao.ConnectionMapDAO.conMap; | ||
| 30 | 38 | ||
| 31 | 39 | ||
| 32 | 40 | ||
| @@ -39,28 +47,30 @@ public class CreateDatabaseServiceImpl implements CreateDatabaseService { | |||
| 39 | 47 | ||
| 40 | private MetaDataByJdbcService metaDataByJdbcService; | 48 | private MetaDataByJdbcService metaDataByJdbcService; |
| 41 | 49 | ||
| 50 | + private Map<String, DatabaseObjectSQLService> databaseObjectSQLService; | ||
| 51 | + | ||
| 52 | + | ||
| 53 | + public void setDatabaseObjectSQLService(List<DatabaseObjectSQLService> SQLServiceList) { | ||
| 54 | + databaseObjectSQLService = new HashMap<>(); | ||
| 55 | + for (DatabaseObjectSQLService s : SQLServiceList) { | ||
| 56 | + databaseObjectSQLService.put(s.type(), s); | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + | ||
| 42 | 61 | ||
| 43 | public void createDatabase(CreateDatabaseDTO request) throws Exception { | 62 | public void createDatabase(CreateDatabaseDTO request) throws Exception { |
| 44 | log.info("createDatabase request is: " + request); | 63 | log.info("createDatabase request is: " + request); |
| 45 | - try (Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 46 | - Statement statement = connection.createStatement()) { | ||
| 47 | - String ddl = CREATE_SQL + DATABASE_SQL + request.getDatabaseName() + WITH_ENCODING_SQL + request.getDatabaseCode() + DBCOMPATIBILITY_SQL + request.getCompatibleType(); | ||
| 48 | - if (!StringUtils.isEmpty(request.getCollation())) { | ||
| 49 | - ddl = ddl + LC_COLLATE_SQL + request.getCollation(); | ||
| 50 | - } | ||
| 51 | - if (!StringUtils.isEmpty(request.getCharacterType())) { | ||
| 52 | - ddl = ddl + LC_CTYPE_SQL + request.getCharacterType(); | ||
| 53 | - } | ||
| 54 | - if (Integer.valueOf(request.getConRestrictions()) >= -1) { | ||
| 55 | - ddl = ddl + QUOTES + CONNECTION_LIMIT_SQL + request.getConRestrictions() + SEMICOLON; | ||
| 56 | - } else { | ||
| 57 | - throw new CustomException(LocaleString.transLanguage("2013")); | ||
| 58 | - } | ||
| 59 | 64 | ||
| 65 | + try ( | ||
| 66 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 67 | + Statement statement = connection.createStatement() | ||
| 68 | + ) { | ||
| 69 | + String ddl = databaseObjectSQLService.get(conMap.get(request.getUuid()).getType()).createDatabase(request); | ||
| 60 | statement.execute(ddl); | 70 | statement.execute(ddl); |
| 61 | log.info("createDatabase sql is: " + ddl); | 71 | log.info("createDatabase sql is: " + ddl); |
| 62 | } catch (Exception e) { | 72 | } catch (Exception e) { |
| 63 | - e.printStackTrace(); | 73 | + log.info(e.getMessage()); |
| 64 | throw new CustomException(e.getMessage(), e); | 74 | throw new CustomException(e.getMessage(), e); |
| 65 | } | 75 | } |
| 66 | } | 76 | } |
| @@ -70,15 +80,19 @@ public class CreateDatabaseServiceImpl implements CreateDatabaseService { | |||
| 70 | log.info("connectionDatabase request is: " + database); | 80 | log.info("connectionDatabase request is: " + database); |
| 71 | ConnectionDTO connectionDTO = new ConnectionDTO(); | 81 | ConnectionDTO connectionDTO = new ConnectionDTO(); |
| 72 | DatabaseConnectionUrlDO databaseConnectionUrlDO = new DatabaseConnectionUrlDO(); | 82 | DatabaseConnectionUrlDO databaseConnectionUrlDO = new DatabaseConnectionUrlDO(); |
| 73 | - DatabaseConnectionDO databaseConnectionDO = databaseConnectionDAO.getByIdDatabase(Integer.parseInt(database.getId()), database.getWebUser()); | 83 | + DatabaseConnectionDO databaseConnectionDO = databaseConnectionDAO.getByIdDatabase( |
| 84 | + Integer.parseInt(database.getId()), database.getWebUser()); | ||
| 74 | String uuid = UUID.randomUUID().toString(); | 85 | String uuid = UUID.randomUUID().toString(); |
| 75 | databaseConnectionDO.setConnectionid(uuid); | 86 | databaseConnectionDO.setConnectionid(uuid); |
| 76 | databaseConnectionDO.setDataName(database.getDataName()); | 87 | databaseConnectionDO.setDataName(database.getDataName()); |
| 77 | - databaseConnectionUrlDO.setUrl(GET_URL_JDBC + databaseConnectionDO.getIp() + ":" + databaseConnectionDO.getPort() + "/" + database.getDataName() + CONFIGURE_TIME); | 88 | + databaseConnectionUrlDO.setUrl( |
| 89 | + GET_URL_JDBC + databaseConnectionDO.getIp() + ":" + databaseConnectionDO.getPort() + "/" + database.getDataName() + CONFIGURE_TIME); | ||
| 78 | databaseConnectionUrlDO.setUserName(databaseConnectionDO.getUserName()); | 90 | databaseConnectionUrlDO.setUserName(databaseConnectionDO.getUserName()); |
| 79 | databaseConnectionUrlDO.setPassword(databaseConnectionDO.getPassword()); | 91 | databaseConnectionUrlDO.setPassword(databaseConnectionDO.getPassword()); |
| 80 | - metaDataByJdbcService.testQuerySQL(databaseConnectionUrlDO.getUrl(), databaseConnectionUrlDO.getUserName(), databaseConnectionUrlDO.getPassword(), | 92 | + databaseConnectionUrlDO.setType(databaseConnectionDO.getType()); |
| 81 | - "SELECT 1"); | 93 | + metaDataByJdbcService.testQuerySQL(databaseConnectionUrlDO.getUrl(), databaseConnectionUrlDO.getUserName(), |
| 94 | + databaseConnectionUrlDO.getPassword(), | ||
| 95 | + databaseObjectSQLService.get(databaseConnectionDO.getType()).connectionDatabaseTest()); | ||
| 82 | connectionDTO.setConnectionDTO(databaseConnectionUrlDO); | 96 | connectionDTO.setConnectionDTO(databaseConnectionUrlDO); |
| 83 | ConnectionMapDAO.setConMap(uuid, connectionDTO); | 97 | ConnectionMapDAO.setConMap(uuid, connectionDTO); |
| 84 | return databaseConnectionDO; | 98 | return databaseConnectionDO; |
| @@ -86,14 +100,16 @@ public class CreateDatabaseServiceImpl implements CreateDatabaseService { | |||
| 86 | 100 | ||
| 87 | 101 | ||
| 88 | public void deleteDatabase(DatabaseNameDTO request) throws Exception { | 102 | public void deleteDatabase(DatabaseNameDTO request) throws Exception { |
| 89 | - log.info("deleteDatabase request is: " + request); | 103 | + log.info("deleteDatabase request is: {}", request); |
| 90 | - String ddl = DROP_SQL + DATABASE_SQL + request.getDatabaseName() + SEMICOLON; | 104 | + String ddl = databaseObjectSQLService.get(conMap.get(request.getUuid()).getType()).deleteDatabaseSQL(request); |
| 91 | - try (Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 105 | + try ( |
| 92 | - Statement statement = connection.createStatement()) { | 106 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 107 | + Statement statement = connection.createStatement() | ||
| 108 | + ) { | ||
| 93 | statement.execute(ddl); | 109 | statement.execute(ddl); |
| 94 | log.info("deleteDatabase sql is: " + ddl); | 110 | log.info("deleteDatabase sql is: " + ddl); |
| 95 | } catch (Exception e) { | 111 | } catch (Exception e) { |
| 96 | - e.printStackTrace(); | 112 | + log.info(e.getMessage()); |
| 97 | throw new CustomException(e.getMessage(), e); | 113 | throw new CustomException(e.getMessage(), e); |
| 98 | } | 114 | } |
| 99 | } | 115 | } |
| @@ -102,17 +118,23 @@ public class CreateDatabaseServiceImpl implements CreateDatabaseService { | |||
| 102 | public void renameDatabase(RenameDatabaseDTO request) throws Exception { | 118 | public void renameDatabase(RenameDatabaseDTO request) throws Exception { |
| 103 | log.info("deleteDatabase request is: " + request); | 119 | log.info("deleteDatabase request is: " + request); |
| 104 | String ddl = null; | 120 | String ddl = null; |
| 105 | - try (Connection connection = connectionConfig.connectDatabase(request.getUuid())) { | 121 | + try ( |
| 122 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()) | ||
| 123 | + ) { | ||
| 106 | if (!request.getOldDatabaseName().equals(request.getDatabaseName())) { | 124 | if (!request.getOldDatabaseName().equals(request.getDatabaseName())) { |
| 107 | - ddl = ALTER_SQL + DATABASE_SQL + request.getOldDatabaseName() + RENAME_TO_SQL + request.getDatabaseName() + SEMICOLON; | 125 | + ddl = databaseObjectSQLService.get(conMap.get(request.getUuid()).getType()).renameDatabaseSQL(request); |
| 108 | - try (Statement statement = connection.createStatement()) { | 126 | + try ( |
| 127 | + Statement statement = connection.createStatement() | ||
| 128 | + ) { | ||
| 109 | statement.execute(ddl); | 129 | statement.execute(ddl); |
| 110 | log.info("deleteDatabase sql is: " + ddl); | 130 | log.info("deleteDatabase sql is: " + ddl); |
| 111 | } | 131 | } |
| 112 | } | 132 | } |
| 113 | if (Integer.valueOf(request.getConRestrictions()) >= -1) { | 133 | if (Integer.valueOf(request.getConRestrictions()) >= -1) { |
| 114 | - ddl = ALTER_SQL + DATABASE_SQL + request.getDatabaseName() + WITH_KEYWORD_SQL + CONNECTION_LIMIT_SQL + request.getConRestrictions() + SEMICOLON; | 134 | + ddl = databaseObjectSQLService.get(conMap.get(request.getUuid()).getType()).conRestrictionsSQL(request); |
| 115 | - try (Statement statement = connection.createStatement()) { | 135 | + try ( |
| 136 | + Statement statement = connection.createStatement() | ||
| 137 | + ) { | ||
| 116 | statement.execute(ddl); | 138 | statement.execute(ddl); |
| 117 | log.info("deleteDatabase sql is: " + ddl); | 139 | log.info("deleteDatabase sql is: " + ddl); |
| 118 | } | 140 | } |
| @@ -120,7 +142,7 @@ public class CreateDatabaseServiceImpl implements CreateDatabaseService { | |||
| 120 | throw new CustomException(LocaleString.transLanguage("2013")); | 142 | throw new CustomException(LocaleString.transLanguage("2013")); |
| 121 | } | 143 | } |
| 122 | } catch (Exception e) { | 144 | } catch (Exception e) { |
| 123 | - e.printStackTrace(); | 145 | + log.info(e.getMessage()); |
| 124 | throw new CustomException(e.getMessage(), e); | 146 | throw new CustomException(e.getMessage(), e); |
| 125 | } | 147 | } |
| 126 | } | 148 | } |
| @@ -129,17 +151,22 @@ public class CreateDatabaseServiceImpl implements CreateDatabaseService { | |||
| 129 | public Map<String, Object> databaseAttribute(DatabaseNameDTO request) throws Exception { | 151 | public Map<String, Object> databaseAttribute(DatabaseNameDTO request) throws Exception { |
| 130 | log.info("deleteDatabase request is: " + request); | 152 | log.info("deleteDatabase request is: " + request); |
| 131 | Map<String, Object> resultMap; | 153 | Map<String, Object> resultMap; |
| 132 | - try (Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 154 | + try ( |
| 133 | - Statement statement = connection.createStatement()) { | 155 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 134 | - String ddl = DATABASE_ATTRIBUTE_SQL + request.getDatabaseName() + QUOTES_SEMICOLON; | 156 | + Statement statement = connection.createStatement() |
| 135 | - try (ResultSet resultSet = statement.executeQuery(ddl);) { | 157 | + ) { |
| 158 | + String ddl = databaseObjectSQLService.get(conMap.get(request.getUuid()).getType()).databaseAttributeSQL( | ||
| 159 | + request); | ||
| 160 | + try ( | ||
| 161 | + ResultSet resultSet = statement.executeQuery(ddl) | ||
| 162 | + ) { | ||
| 136 | resultMap = DebugUtils.parseResultSet(resultSet); | 163 | resultMap = DebugUtils.parseResultSet(resultSet); |
| 137 | log.info("synonymAttribute sql is: " + ddl); | 164 | log.info("synonymAttribute sql is: " + ddl); |
| 138 | log.info("synonymAttribute response is: " + resultMap); | 165 | log.info("synonymAttribute response is: " + resultMap); |
| 139 | } | 166 | } |
| 140 | return resultMap; | 167 | return resultMap; |
| 141 | } catch (Exception e) { | 168 | } catch (Exception e) { |
| 142 | - e.printStackTrace(); | 169 | + log.info(e.getMessage()); |
| 143 | throw new CustomException(e.getMessage(), e); | 170 | throw new CustomException(e.getMessage(), e); |
| 144 | } | 171 | } |
| 145 | } | 172 | } |
| @@ -148,17 +175,22 @@ public class CreateDatabaseServiceImpl implements CreateDatabaseService { | |||
| 148 | public Map<String, Object> databaseAttributeUpdate(DatabaseNameDTO request) throws Exception { | 175 | public Map<String, Object> databaseAttributeUpdate(DatabaseNameDTO request) throws Exception { |
| 149 | log.info("deleteDatabase request is: " + request); | 176 | log.info("deleteDatabase request is: " + request); |
| 150 | Map<String, Object> resultMap; | 177 | Map<String, Object> resultMap; |
| 151 | - try (Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 178 | + try ( |
| 152 | - Statement statement = connection.createStatement()) { | 179 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 153 | - String ddl = DATABASE_UPDATA_ATTRIBUTE_SQL + request.getDatabaseName() + QUOTES_SEMICOLON; | 180 | + Statement statement = connection.createStatement() |
| 154 | - try (ResultSet resultSet = statement.executeQuery(ddl)) { | 181 | + ) { |
| 182 | + String ddl = databaseObjectSQLService.get( | ||
| 183 | + conMap.get(request.getUuid()).getType()).databaseAttributeUpdateSQL(request); | ||
| 184 | + try ( | ||
| 185 | + ResultSet resultSet = statement.executeQuery(ddl) | ||
| 186 | + ) { | ||
| 155 | resultMap = DebugUtils.parseResultSet(resultSet); | 187 | resultMap = DebugUtils.parseResultSet(resultSet); |
| 156 | log.info("synonymAttribute sql is: " + ddl); | 188 | log.info("synonymAttribute sql is: " + ddl); |
| 157 | log.info("synonymAttribute response is: " + resultMap); | 189 | log.info("synonymAttribute response is: " + resultMap); |
| 158 | } | 190 | } |
| 159 | return resultMap; | 191 | return resultMap; |
| 160 | } catch (Exception e) { | 192 | } catch (Exception e) { |
| 161 | - e.printStackTrace(); | 193 | + log.info(e.getMessage()); |
| 162 | throw new CustomException(e.getMessage(), e); | 194 | throw new CustomException(e.getMessage(), e); |
| 163 | } | 195 | } |
| 164 | } | 196 | } |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/sql/DataListByJdbcServiceImpl.java+66-35
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.enums.ParamTypeEnum; | 7 | import com.nctigba.datastudio.enums.ParamTypeEnum; |
| @@ -16,6 +20,9 @@ import java.util.HashMap; | |||
| 16 | import java.util.List; | 20 | import java.util.List; |
| 17 | import java.util.Map; | 21 | import java.util.Map; |
| 18 | 22 | ||
| 23 | +import static com.nctigba.datastudio.constants.CommonConstants.NAME; | ||
| 24 | +import static com.nctigba.datastudio.constants.CommonConstants.OID; | ||
| 25 | +import static com.nctigba.datastudio.constants.CommonConstants.PARTTYPE; | ||
| 19 | import static com.nctigba.datastudio.constants.CommonConstants.SPACE; | 26 | import static com.nctigba.datastudio.constants.CommonConstants.SPACE; |
| 20 | import static com.nctigba.datastudio.constants.SqlConstants.GET_TYPENAME_SQL; | 27 | import static com.nctigba.datastudio.constants.SqlConstants.GET_TYPENAME_SQL; |
| 21 | 28 | ||
| @@ -24,53 +31,66 @@ public class DataListByJdbcServiceImpl implements DataListByJdbcService { | |||
| 24 | 31 | ||
| 25 | public List<String> schemaListQuerySQL(String jdbcUrl, String username, String password, String sql) { | 32 | public List<String> schemaListQuerySQL(String jdbcUrl, String username, String password, String sql) { |
| 26 | List<String> list = new ArrayList<>(); | 33 | List<String> list = new ArrayList<>(); |
| 27 | - try (Connection connection = ConnectionUtils.connectGet(jdbcUrl, username, password); | 34 | + try ( |
| 28 | - PreparedStatement ps = connection.prepareStatement(sql); | 35 | + Connection connection = ConnectionUtils.connectGet(jdbcUrl, username, password); |
| 29 | - ResultSet rs = ps.executeQuery()) { | 36 | + PreparedStatement ps = connection.prepareStatement(sql); |
| 37 | + ResultSet rs = ps.executeQuery() | ||
| 38 | + ) { | ||
| 30 | while (rs.next()) { | 39 | while (rs.next()) { |
| 31 | list.add(rs.getString("schema_name")); | 40 | list.add(rs.getString("schema_name")); |
| 32 | } | 41 | } |
| 33 | 42 | ||
| 34 | } catch (Exception e) { | 43 | } catch (Exception e) { |
| 35 | - throw new CustomException(e.getMessage(),e); | 44 | + throw new CustomException(e.getMessage(), e); |
| 36 | } | 45 | } |
| 37 | return list; | 46 | return list; |
| 38 | } | 47 | } |
| 39 | 48 | ||
| 40 | 49 | ||
| 41 | - public DataListDTO dataListQuerySQL(String jdbcUrl, String username, String password, String tableSql, String viewSql, String fun_prosSql, String sequenceSql, String synonymSql, String schema_name) { | 50 | + public DataListDTO dataListQuerySQL(String jdbcUrl, String username, String password, String tableSql, |
| 51 | + String viewSql, String fun_prosSql, String sequenceSql, String synonymSql, | ||
| 52 | + String schema_name) { | ||
| 42 | DataListDTO dataList = new DataListDTO(); | 53 | DataListDTO dataList = new DataListDTO(); |
| 43 | - List<String> table = new ArrayList<>(); | 54 | + List<Map<String, String>> table = new ArrayList<>(); |
| 44 | - List<String> view = new ArrayList<>(); | 55 | + List<Map<String, String>> view = new ArrayList<>(); |
| 45 | - List<String> sequence = new ArrayList<>(); | 56 | + List<Map<String, String>> sequence = new ArrayList<>(); |
| 46 | - List<String> synonym = new ArrayList<>(); | 57 | + List<Map<String, String>> synonym = new ArrayList<>(); |
| 47 | - List<String> fun_pro = new ArrayList<>(); | 58 | + List<Map<String, String>> fun_pro = new ArrayList<>(); |
| 48 | Map funTypeMap = new HashMap<>(); | 59 | Map funTypeMap = new HashMap<>(); |
| 49 | - try (Connection connection = ConnectionUtils.connectGet(jdbcUrl, username, password); | 60 | + try ( |
| 50 | - PreparedStatement tableValue = connection.prepareStatement(tableSql); | 61 | + Connection connection = ConnectionUtils.connectGet(jdbcUrl, username, password); |
| 51 | - PreparedStatement viewValue = connection.prepareStatement(viewSql); | 62 | + PreparedStatement tableValue = connection.prepareStatement(tableSql); |
| 52 | - PreparedStatement fun_proValue = connection.prepareStatement(fun_prosSql); | 63 | + PreparedStatement viewValue = connection.prepareStatement(viewSql); |
| 53 | - PreparedStatement sequenceValue = connection.prepareStatement(sequenceSql); | 64 | + PreparedStatement fun_proValue = connection.prepareStatement(fun_prosSql); |
| 54 | - PreparedStatement synonymValue = connection.prepareStatement(synonymSql); | 65 | + PreparedStatement sequenceValue = connection.prepareStatement(sequenceSql); |
| 55 | - PreparedStatement fun_type = connection.prepareStatement(GET_TYPENAME_SQL); | 66 | + PreparedStatement synonymValue = connection.prepareStatement(synonymSql); |
| 56 | - ResultSet rs1 = tableValue.executeQuery(); | 67 | + PreparedStatement fun_type = connection.prepareStatement(GET_TYPENAME_SQL); |
| 57 | - ResultSet rs2 = viewValue.executeQuery(); | 68 | + ResultSet rs1 = tableValue.executeQuery(); |
| 58 | - ResultSet rs3 = fun_proValue.executeQuery(); | 69 | + ResultSet rs2 = viewValue.executeQuery(); |
| 59 | - ResultSet rs4 = fun_type.executeQuery(); | 70 | + ResultSet rs3 = fun_proValue.executeQuery(); |
| 60 | - ResultSet rs5 = sequenceValue.executeQuery(); | 71 | + ResultSet rs4 = fun_type.executeQuery(); |
| 61 | - ResultSet rs6 = synonymValue.executeQuery();) { | 72 | + ResultSet rs5 = sequenceValue.executeQuery(); |
| 73 | + ResultSet rs6 = synonymValue.executeQuery() | ||
| 74 | + ) { | ||
| 62 | while (rs1.next()) { | 75 | while (rs1.next()) { |
| 63 | - table.add(rs1.getString("tablename")); | 76 | + Map<String, String> map = new HashMap(); |
| 77 | + map.put(OID, rs1.getString(OID)); | ||
| 78 | + map.put(NAME, rs1.getString("tablename")); | ||
| 79 | + map.put(PARTTYPE, rs1.getString("parttype")); | ||
| 80 | + table.add(map); | ||
| 64 | } | 81 | } |
| 65 | while (rs2.next()) { | 82 | while (rs2.next()) { |
| 66 | - view.add(rs2.getString("viewname")); | 83 | + Map<String, String> map = new HashMap(); |
| 84 | + map.put(OID, rs2.getString(OID)); | ||
| 85 | + map.put(NAME, rs2.getString("viewname")); | ||
| 86 | + view.add(map); | ||
| 67 | } | 87 | } |
| 68 | while (rs4.next()) { | 88 | while (rs4.next()) { |
| 69 | - funTypeMap.put(rs4.getString("oid"), rs4.getString("typname")); | 89 | + funTypeMap.put(rs4.getString(OID), rs4.getString("typname")); |
| 70 | } | 90 | } |
| 71 | while (rs3.next()) { | 91 | while (rs3.next()) { |
| 72 | String proArgTypes = rs3.getString("proargtypes"); | 92 | String proArgTypes = rs3.getString("proargtypes"); |
| 73 | - var splited = proArgTypes.split(SPACE); | 93 | + String[] splited = proArgTypes.split(SPACE); |
| 74 | String asd = ""; | 94 | String asd = ""; |
| 75 | for (int i = 0; i < splited.length; i++) { | 95 | for (int i = 0; i < splited.length; i++) { |
| 76 | if (!StringUtils.isEmpty(splited[i])) { | 96 | if (!StringUtils.isEmpty(splited[i])) { |
| @@ -84,13 +104,22 @@ public class DataListByJdbcServiceImpl implements DataListByJdbcService { | |||
| 84 | } | 104 | } |
| 85 | } | 105 | } |
| 86 | } | 106 | } |
| 87 | - fun_pro.add(rs3.getString("proname") + "(" + asd + ")"); | 107 | + Map<String, String> map = new HashMap(); |
| 108 | + map.put(OID, rs3.getString(OID)); | ||
| 109 | + map.put(NAME, rs3.getString("proname") + "(" + asd + ")"); | ||
| 110 | + fun_pro.add(map); | ||
| 88 | } | 111 | } |
| 89 | while (rs5.next()) { | 112 | while (rs5.next()) { |
| 90 | - sequence.add(rs5.getString("relname")); | 113 | + Map<String, String> map = new HashMap(); |
| 114 | + map.put(OID, rs5.getString(OID)); | ||
| 115 | + map.put(NAME, rs5.getString("relname")); | ||
| 116 | + sequence.add(map); | ||
| 91 | } | 117 | } |
| 92 | while (rs6.next()) { | 118 | while (rs6.next()) { |
| 93 | - synonym.add(rs6.getString("synname")); | 119 | + Map<String, String> map = new HashMap(); |
| 120 | + map.put(OID, rs6.getString(OID)); | ||
| 121 | + map.put(NAME, rs6.getString("synname")); | ||
| 122 | + synonym.add(map); | ||
| 94 | } | 123 | } |
| 95 | dataList.setSchema_name(schema_name); | 124 | dataList.setSchema_name(schema_name); |
| 96 | dataList.setTable(table); | 125 | dataList.setTable(table); |
| @@ -99,7 +128,7 @@ public class DataListByJdbcServiceImpl implements DataListByJdbcService { | |||
| 99 | dataList.setSynonym(synonym); | 128 | dataList.setSynonym(synonym); |
| 100 | dataList.setFun_pro(fun_pro); | 129 | dataList.setFun_pro(fun_pro); |
| 101 | } catch (Exception e) { | 130 | } catch (Exception e) { |
| 102 | - throw new CustomException(e.getMessage(),e); | 131 | + throw new CustomException(e.getMessage(), e); |
| 103 | } | 132 | } |
| 104 | return dataList; | 133 | return dataList; |
| 105 | } | 134 | } |
| @@ -107,15 +136,17 @@ public class DataListByJdbcServiceImpl implements DataListByJdbcService { | |||
| 107 | 136 | ||
| 108 | public List<String> databaseListQuerySQL(String jdbcUrl, String username, String password, String sql) { | 137 | public List<String> databaseListQuerySQL(String jdbcUrl, String username, String password, String sql) { |
| 109 | List<String> list = new ArrayList<>(); | 138 | List<String> list = new ArrayList<>(); |
| 110 | - try (Connection connection = ConnectionUtils.connectGet(jdbcUrl, username, password); | 139 | + try ( |
| 111 | - PreparedStatement ps = connection.prepareStatement(sql); | 140 | + Connection connection = ConnectionUtils.connectGet(jdbcUrl, username, password); |
| 112 | - ResultSet rs = ps.executeQuery()) { | 141 | + PreparedStatement ps = connection.prepareStatement(sql); |
| 142 | + ResultSet rs = ps.executeQuery() | ||
| 143 | + ) { | ||
| 113 | while (rs.next()) { | 144 | while (rs.next()) { |
| 114 | list.add(rs.getString("dataname")); | 145 | list.add(rs.getString("dataname")); |
| 115 | } | 146 | } |
| 116 | 147 | ||
| 117 | } catch (Exception e) { | 148 | } catch (Exception e) { |
| 118 | - throw new CustomException(e.getMessage(),e); | 149 | + throw new CustomException(e.getMessage(), e); |
| 119 | } | 150 | } |
| 120 | return list; | 151 | return list; |
| 121 | } | 152 | } |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/sql/DatabaseFunctionSPServiceImpl.java+29-67
| @@ -1,34 +1,26 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 7 | +import com.nctigba.datastudio.compatible.FunctionSPObjectSQLService; | ||
| 3 | import com.nctigba.datastudio.config.ConnectionConfig; | 8 | import com.nctigba.datastudio.config.ConnectionConfig; |
| 4 | import com.nctigba.datastudio.model.dto.DatabaseFunctionSPDTO; | 9 | import com.nctigba.datastudio.model.dto.DatabaseFunctionSPDTO; |
| 5 | import com.nctigba.datastudio.service.DatabaseFunctionSPService; | 10 | import com.nctigba.datastudio.service.DatabaseFunctionSPService; |
| 6 | -import com.nctigba.datastudio.util.DebugUtils; | ||
| 7 | -import com.nctigba.datastudio.util.LocaleString; | ||
| 8 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
| 9 | import org.opengauss.admin.common.exception.CustomException; | 12 | import org.opengauss.admin.common.exception.CustomException; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
| 12 | 15 | ||
| 16 | +import javax.annotation.Resource; | ||
| 13 | import java.sql.Connection; | 17 | import java.sql.Connection; |
| 14 | -import java.sql.ResultSet; | ||
| 15 | -import java.sql.SQLException; | ||
| 16 | import java.sql.Statement; | 18 | import java.sql.Statement; |
| 17 | -import java.util.ArrayList; | 19 | +import java.util.HashMap; |
| 18 | import java.util.List; | 20 | import java.util.List; |
| 21 | +import java.util.Map; | ||
| 19 | 22 | ||
| 20 | -import static com.nctigba.datastudio.constants.CommonConstants.OID; | 23 | +import static com.nctigba.datastudio.dao.ConnectionMapDAO.conMap; |
| 21 | -import static com.nctigba.datastudio.constants.CommonConstants.PRO_KIND; | ||
| 22 | -import static com.nctigba.datastudio.constants.CommonConstants.SPACE; | ||
| 23 | -import static com.nctigba.datastudio.constants.SqlConstants.DROP_SQL; | ||
| 24 | -import static com.nctigba.datastudio.constants.SqlConstants.FUNCTION_KEYWORD_SQL; | ||
| 25 | -import static com.nctigba.datastudio.constants.SqlConstants.GET_PROC_TYPE_SQL; | ||
| 26 | -import static com.nctigba.datastudio.constants.SqlConstants.GET_PROC_SQL; | ||
| 27 | -import static com.nctigba.datastudio.constants.SqlConstants.GET_TYPE_OID_SQL; | ||
| 28 | -import static com.nctigba.datastudio.constants.SqlConstants.POINT; | ||
| 29 | -import static com.nctigba.datastudio.constants.SqlConstants.PROCEDURE_KEYWORD_SQL; | ||
| 30 | -import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_SEMICOLON; | ||
| 31 | -import static com.nctigba.datastudio.constants.SqlConstants.SEMICOLON; | ||
| 32 | 24 | ||
| 33 | 25 | ||
| 34 | 26 | ||
| @@ -36,61 +28,31 @@ public class DatabaseFunctionSPServiceImpl implements DatabaseFunctionSPService | |||
| 36 | 28 | ||
| 37 | private ConnectionConfig connectionConfig; | 29 | private ConnectionConfig connectionConfig; |
| 38 | 30 | ||
| 31 | + private Map<String, FunctionSPObjectSQLService> functionSPObjectSQLService; | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + public void setfunctionSPObjectSQLService(List<FunctionSPObjectSQLService> SQLServiceList) { | ||
| 35 | + functionSPObjectSQLService = new HashMap<>(); | ||
| 36 | + for (FunctionSPObjectSQLService s : SQLServiceList) { | ||
| 37 | + functionSPObjectSQLService.put(s.type(), s); | ||
| 38 | + } | ||
| 39 | + } | ||
| 40 | + | ||
| 39 | 41 | ||
| 40 | public void dropFunctionSP(DatabaseFunctionSPDTO request) { | 42 | public void dropFunctionSP(DatabaseFunctionSPDTO request) { |
| 41 | log.info("dropFunctionSP request is: " + request); | 43 | log.info("dropFunctionSP request is: " + request); |
| 42 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 44 | + try ( |
| 43 | - Statement statement = connection.createStatement()){ | 45 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 44 | - try(ResultSet funcResult = statement.executeQuery(getFuncSql(request.getFunctionSPName(), statement));){ | 46 | + Statement statement = connection.createStatement() |
| 45 | - String proKind = ""; | 47 | + ) { |
| 46 | - if (funcResult.next()) { | 48 | + String sql = functionSPObjectSQLService.get(conMap.get(request.getUuid()).getType()).dropFunctionSP( |
| 47 | - proKind = funcResult.getString(PRO_KIND); | 49 | + request); |
| 48 | - }else{ | 50 | + statement.execute(sql); |
| 49 | - throw new CustomException(LocaleString.transLanguage("2015")); | 51 | + log.info("dropFunctionSP sql is: " + sql); |
| 50 | - } | ||
| 51 | - String sql = ""; | ||
| 52 | - if ("f".equals(proKind)) { | ||
| 53 | - sql = DROP_SQL + FUNCTION_KEYWORD_SQL + request.getSchema() + POINT + request.getFunctionSPName() + SEMICOLON; | ||
| 54 | - } else if ("p".equals(proKind)) { | ||
| 55 | - sql = DROP_SQL + PROCEDURE_KEYWORD_SQL + request.getSchema() + POINT + request.getFunctionSPName() + SEMICOLON; | ||
| 56 | - } | ||
| 57 | - statement.execute(sql); | ||
| 58 | - log.info("dropFunctionSP sql is: " + sql);} | ||
| 59 | } catch (Exception e) { | 52 | } catch (Exception e) { |
| 60 | - e.printStackTrace(); | 53 | + log.info(e.getMessage()); |
| 61 | - throw new CustomException(e.getMessage(),e); | 54 | + throw new CustomException(e.getMessage(), e); |
| 62 | } | 55 | } |
| 63 | } | 56 | } |
| 64 | 57 | ||
| 65 | - public static String getFuncSql(String name, Statement statement) throws SQLException { | ||
| 66 | - List<String> oidList = new ArrayList<>(); | ||
| 67 | - List<String> paramTypeList = DebugUtils.getParamTypeList(name); | ||
| 68 | - for (int i = 0; i < paramTypeList.size(); i++) { | ||
| 69 | - try(ResultSet typeNameResult = statement.executeQuery(GET_TYPE_OID_SQL | ||
| 70 | - + paramTypeList.get(i) + QUOTES_SEMICOLON)){ | ||
| 71 | - while (typeNameResult.next()) { | ||
| 72 | - oidList.add(typeNameResult.getString(OID)); | ||
| 73 | - } | ||
| 74 | - } | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - StringBuilder sb = new StringBuilder(); | ||
| 78 | - sb.append(GET_PROC_SQL + DebugUtils.getFuncName(name) + GET_PROC_TYPE_SQL); | ||
| 79 | - | ||
| 80 | - if (oidList.size() == 0) { | ||
| 81 | - sb.append(SPACE); | ||
| 82 | - } else { | ||
| 83 | - for (int i = 0; i < oidList.size(); i++) { | ||
| 84 | - sb.append(oidList.get(i)); | ||
| 85 | - if (i != oidList.size() - 1) { | ||
| 86 | - sb.append(SPACE); | ||
| 87 | - } | ||
| 88 | - } | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - sb.append(QUOTES_SEMICOLON); | ||
| 92 | - log.info("func sql is: " + sb); | ||
| 93 | - return sb.toString(); | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | } | 58 | } |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/sql/DatabaseSequenceServiceImpl.java+34-90
| @@ -1,23 +1,28 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 7 | +import com.nctigba.datastudio.compatible.SequenceObjectSQLService; | ||
| 3 | import com.nctigba.datastudio.config.ConnectionConfig; | 8 | import com.nctigba.datastudio.config.ConnectionConfig; |
| 4 | import com.nctigba.datastudio.model.dto.DatabaseCreateSequenceDTO; | 9 | import com.nctigba.datastudio.model.dto.DatabaseCreateSequenceDTO; |
| 5 | import com.nctigba.datastudio.model.dto.DatabaseDropSequenceDTO; | 10 | import com.nctigba.datastudio.model.dto.DatabaseDropSequenceDTO; |
| 6 | import com.nctigba.datastudio.model.dto.DatabaseSequenceDdlDTO; | 11 | import com.nctigba.datastudio.model.dto.DatabaseSequenceDdlDTO; |
| 7 | import com.nctigba.datastudio.service.DatabaseSequenceService; | 12 | import com.nctigba.datastudio.service.DatabaseSequenceService; |
| 8 | -import com.nctigba.datastudio.util.LocaleString; | ||
| 9 | import lombok.extern.slf4j.Slf4j; | 13 | import lombok.extern.slf4j.Slf4j; |
| 10 | import org.opengauss.admin.common.exception.CustomException; | 14 | import org.opengauss.admin.common.exception.CustomException; |
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
| 13 | 17 | ||
| 18 | +import javax.annotation.Resource; | ||
| 14 | import java.sql.Connection; | 19 | import java.sql.Connection; |
| 15 | -import java.sql.ResultSet; | ||
| 16 | import java.sql.Statement; | 20 | import java.sql.Statement; |
| 17 | -import java.util.Objects; | 21 | +import java.util.HashMap; |
| 22 | +import java.util.List; | ||
| 23 | +import java.util.Map; | ||
| 18 | 24 | ||
| 19 | -import static com.nctigba.datastudio.constants.SqlConstants.*; | 25 | +import static com.nctigba.datastudio.dao.ConnectionMapDAO.conMap; |
| 20 | -import static org.apache.commons.lang3.StringUtils.isNumeric; | ||
| 21 | 26 | ||
| 22 | 27 | ||
| 23 | 28 | ||
| @@ -25,47 +30,20 @@ public class DatabaseSequenceServiceImpl implements DatabaseSequenceService { | |||
| 25 | 30 | ||
| 26 | private ConnectionConfig connectionConfig; | 31 | private ConnectionConfig connectionConfig; |
| 27 | 32 | ||
| 28 | - @Override | 33 | + private Map<String, SequenceObjectSQLService> sequenceObjectSQLService; |
| 29 | - public String splicingSequenceDDL(DatabaseCreateSequenceDTO request) throws Exception { | 34 | + |
| 30 | - log.info("splicingSequenceDDL request is: " + request); | 35 | + @Resource |
| 31 | - String ddl = CREATE_SQL + SEQUENCE_KEYWORD_SQL + request.getSchema() + POINT + request.getSequenceName(); | 36 | + public void setSequenceObjectSQLService(List<SequenceObjectSQLService> SQLServiceList) { |
| 32 | - if (isNumeric(request.getStart())) { | 37 | + sequenceObjectSQLService = new HashMap<>(); |
| 33 | - ddl = ddl + "\n" + START_KEYWORD_SQL + request.getStart(); | 38 | + for (SequenceObjectSQLService s : SQLServiceList) { |
| 39 | + sequenceObjectSQLService.put(s.type(), s); | ||
| 34 | } | 40 | } |
| 35 | - if (isNumeric(request.getIncrement())) { | ||
| 36 | - ddl = ddl + "\n" + INCREMENT_KEYWORD_SQL + request.getIncrement(); | ||
| 37 | - } | ||
| 38 | - if (isNumeric(request.getMinValue())) { | ||
| 39 | - ddl = ddl + "\n" + MINVALUE_KEYWORD_SQL + request.getMinValue(); | ||
| 40 | - } else { | ||
| 41 | - ddl = ddl + "\n" + NO_MINVALUE_KEYWORD_SQL; | ||
| 42 | - } | ||
| 43 | - if (isNumeric(request.getMaxValue())) { | ||
| 44 | - ddl = ddl + "\n" + MAXVALUE_KEYWORD_SQL + request.getMaxValue(); | ||
| 45 | - } | ||
| 46 | - if (isNumeric(request.getCache())) { | ||
| 47 | - ddl = ddl + "\n" + CACHE_KEYWORD_SQL + request.getCache(); | ||
| 48 | - } | ||
| 49 | - if (request.getCycle().equals("CYCLE")) { | ||
| 50 | - ddl = ddl + "\n" + CYCLE_KEYWORD_SQL; | ||
| 51 | - } | ||
| 52 | - if (!Objects.nonNull(request.getTableSchema())) { | ||
| 53 | - ddl = ddl + "\n" + OWNED_KEYWORD_SQL + request.getTableSchema() + POINT; | ||
| 54 | - } | ||
| 55 | - if (!Objects.nonNull(request.getTableName())) { | ||
| 56 | - ddl = ddl + request.getTableName() + POINT; | ||
| 57 | - } | ||
| 58 | - if (!Objects.nonNull(request.getTableColumn())) { | ||
| 59 | - ddl = ddl + request.getTableColumn(); | ||
| 60 | - } | ||
| 61 | - log.info("splicingSequenceDDL response is: " + ddl); | ||
| 62 | - return ddl; | ||
| 63 | } | 41 | } |
| 64 | 42 | ||
| 65 | 43 | ||
| 66 | public String createSequenceDDL(DatabaseCreateSequenceDTO request) throws Exception { | 44 | public String createSequenceDDL(DatabaseCreateSequenceDTO request) throws Exception { |
| 67 | log.info("createSequenceDDL request is: " + request); | 45 | log.info("createSequenceDDL request is: " + request); |
| 68 | - String ddl = splicingSequenceDDL(request); | 46 | + String ddl = sequenceObjectSQLService.get(conMap.get(request.getUuid()).getType()).splicingSequenceDDL(request); |
| 69 | log.info("createSequenceDDL response is: " + ddl); | 47 | log.info("createSequenceDDL response is: " + ddl); |
| 70 | return ddl; | 48 | return ddl; |
| 71 | } | 49 | } |
| @@ -73,73 +51,39 @@ public class DatabaseSequenceServiceImpl implements DatabaseSequenceService { | |||
| 73 | 51 | ||
| 74 | public void createSequence(DatabaseCreateSequenceDTO request) { | 52 | public void createSequence(DatabaseCreateSequenceDTO request) { |
| 75 | log.info("createSequence request is: " + request); | 53 | log.info("createSequence request is: " + request); |
| 76 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 54 | + try ( |
| 77 | - Statement statement = connection.createStatement()) { | 55 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 78 | - String ddl = splicingSequenceDDL(request); | 56 | + Statement statement = connection.createStatement() |
| 79 | - | 57 | + ) { |
| 58 | + String ddl = sequenceObjectSQLService.get(conMap.get(request.getUuid()).getType()).splicingSequenceDDL( | ||
| 59 | + request); | ||
| 80 | statement.execute(ddl); | 60 | statement.execute(ddl); |
| 81 | log.info("createSequence sql is: " + ddl); | 61 | log.info("createSequence sql is: " + ddl); |
| 82 | } catch (Exception e) { | 62 | } catch (Exception e) { |
| 83 | - e.printStackTrace(); | 63 | + log.info(e.getMessage()); |
| 84 | - throw new CustomException(e.getMessage(),e); | 64 | + throw new CustomException(e.getMessage(), e); |
| 85 | } | 65 | } |
| 86 | } | 66 | } |
| 87 | 67 | ||
| 88 | 68 | ||
| 89 | public void dropSequence(DatabaseDropSequenceDTO request) { | 69 | public void dropSequence(DatabaseDropSequenceDTO request) { |
| 90 | log.info("dropSequence request is: " + request); | 70 | log.info("dropSequence request is: " + request); |
| 91 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 71 | + try ( |
| 92 | - Statement statement = connection.createStatement()) { | 72 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 93 | - String sql = DROP_SQL + SEQUENCE_KEYWORD_SQL + request.getSchema() + POINT + request.getSequenceName(); | 73 | + Statement statement = connection.createStatement() |
| 74 | + ) { | ||
| 75 | + String sql = sequenceObjectSQLService.get(conMap.get(request.getUuid()).getType()).dropSequenceDDL(request); | ||
| 94 | statement.execute(sql); | 76 | statement.execute(sql); |
| 95 | log.info("dropSequence sql is: " + sql); | 77 | log.info("dropSequence sql is: " + sql); |
| 96 | } catch (Exception e) { | 78 | } catch (Exception e) { |
| 97 | - e.printStackTrace(); | 79 | + log.info(e.getMessage()); |
| 98 | - throw new CustomException(e.getMessage(),e); | 80 | + throw new CustomException(e.getMessage(), e); |
| 99 | } | 81 | } |
| 100 | } | 82 | } |
| 101 | 83 | ||
| 102 | 84 | ||
| 103 | public String returnSequenceDDL(DatabaseSequenceDdlDTO request) throws Exception { | 85 | public String returnSequenceDDL(DatabaseSequenceDdlDTO request) throws Exception { |
| 104 | log.info("returnSequenceDDL request is: " + request); | 86 | log.info("returnSequenceDDL request is: " + request); |
| 105 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 87 | + return sequenceObjectSQLService.get(conMap.get(request.getUuid()).getType()).returnSequenceDDL(request); |
| 106 | - Statement statement = connection.createStatement()) { | ||
| 107 | - String selectSql = SELECT_SEQUENCE_DDL_SQL + request.getSchema() + SELECT_SEQUENCE_DDL_WHERE_SQL + request.getSequenceName() + QUOTES_SEMICOLON; | ||
| 108 | - try(ResultSet count = statement.executeQuery(SELECT_KEYWORD_SQL + COUNT_SQL +FROM_CLASS_SQL+ | ||
| 109 | - request.getSchema() + FROM_CLASS_WHERE_SQL + request.getSequenceName() + RELKIND_SQL+ "S" + QUOTES_SEMICOLON)){ | ||
| 110 | - count.next(); | ||
| 111 | - int a = count.getInt("count"); | ||
| 112 | - if(a==0){ | ||
| 113 | - throw new CustomException(LocaleString.transLanguage("2012")); | ||
| 114 | - } | ||
| 115 | - } | ||
| 116 | - String ddl = ""; | ||
| 117 | - try(ResultSet resultSet = statement.executeQuery(selectSql)) { | ||
| 118 | - while (resultSet.next()) { | ||
| 119 | - ddl = SEQUENCE_SET_SQL + resultSet.getString("sequence_schema") + SEMICOLON + "\n" | ||
| 120 | - + CREATE_SQL + SEQUENCE_KEYWORD_SQL + resultSet.getString("sequence_name") + "\n" | ||
| 121 | - + START_WITH_SQL + resultSet.getString("start_value") + "\n" | ||
| 122 | - + INCREMENT_BY_SQL + resultSet.getString("increment") + "\n"; | ||
| 123 | - if (resultSet.getInt("minimum_value") == 1) { | ||
| 124 | - ddl = ddl + NO_MINVALUE_SQL + "\n" | ||
| 125 | - + MAXVALUE_SQL + resultSet.getString("maximum_value") + "\n"; | ||
| 126 | - | ||
| 127 | - } else { | ||
| 128 | - ddl = ddl + MINVALUE_SQL + resultSet.getString("minimum_value") + "\n" | ||
| 129 | - + MAXVALUE_SQL + resultSet.getString("maximum_value") + "\n"; | ||
| 130 | - | ||
| 131 | - } | ||
| 132 | - if (resultSet.getString("cycle_option").equals("YES")) { | ||
| 133 | - ddl = ddl + CYCLE_SQL + "\n"; | ||
| 134 | - } | ||
| 135 | - ddl = ddl + SEMICOLON; | ||
| 136 | - } | ||
| 137 | - log.info("returnSequenceDDL response is: " + ddl); | ||
| 138 | - } | ||
| 139 | - return ddl; | ||
| 140 | - } catch (Exception e) { | ||
| 141 | - e.printStackTrace(); | ||
| 142 | - throw new CustomException(e.getMessage(),e); | ||
| 143 | - } | ||
| 144 | } | 88 | } |
| 145 | } | 89 | } |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/sql/DatabaseSynonymServiceImpl.java+48-31
| @@ -1,5 +1,10 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 7 | +import com.nctigba.datastudio.compatible.SynonymObjectSQLService; | ||
| 3 | import com.nctigba.datastudio.config.ConnectionConfig; | 8 | import com.nctigba.datastudio.config.ConnectionConfig; |
| 4 | import com.nctigba.datastudio.model.dto.DatabaseCreateSynonymDTO; | 9 | import com.nctigba.datastudio.model.dto.DatabaseCreateSynonymDTO; |
| 5 | import com.nctigba.datastudio.model.dto.DatabaseDropSynonymDTO; | 10 | import com.nctigba.datastudio.model.dto.DatabaseDropSynonymDTO; |
| @@ -8,16 +13,20 @@ import com.nctigba.datastudio.service.DatabaseSynonymService; | |||
| 8 | import com.nctigba.datastudio.util.DebugUtils; | 13 | import com.nctigba.datastudio.util.DebugUtils; |
| 9 | import com.nctigba.datastudio.util.LocaleString; | 14 | import com.nctigba.datastudio.util.LocaleString; |
| 10 | import lombok.extern.slf4j.Slf4j; | 15 | import lombok.extern.slf4j.Slf4j; |
| 16 | +import org.apache.commons.lang3.StringUtils; | ||
| 11 | import org.opengauss.admin.common.exception.CustomException; | 17 | import org.opengauss.admin.common.exception.CustomException; |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| 14 | 20 | ||
| 21 | +import javax.annotation.Resource; | ||
| 15 | import java.sql.Connection; | 22 | import java.sql.Connection; |
| 16 | import java.sql.ResultSet; | 23 | import java.sql.ResultSet; |
| 17 | import java.sql.Statement; | 24 | import java.sql.Statement; |
| 25 | +import java.util.HashMap; | ||
| 26 | +import java.util.List; | ||
| 18 | import java.util.Map; | 27 | import java.util.Map; |
| 19 | 28 | ||
| 20 | -import static com.nctigba.datastudio.constants.SqlConstants.*; | 29 | +import static com.nctigba.datastudio.dao.ConnectionMapDAO.conMap; |
| 21 | 30 | ||
| 22 | 31 | ||
| 23 | 32 | ||
| @@ -25,23 +34,20 @@ public class DatabaseSynonymServiceImpl implements DatabaseSynonymService { | |||
| 25 | 34 | ||
| 26 | private ConnectionConfig connectionConfig; | 35 | private ConnectionConfig connectionConfig; |
| 27 | 36 | ||
| 28 | - @Override | 37 | + private Map<String, SynonymObjectSQLService> synonymObjectSQLService; |
| 29 | - public String splicingSequenceDDL(DatabaseCreateSynonymDTO request) throws Exception { | 38 | + |
| 30 | - log.info("splicingSequenceDDL request is: " + request); | 39 | + @Resource |
| 31 | - String ddl; | 40 | + public void setSynonymObjectSQLService(List<SynonymObjectSQLService> SQLServiceList) { |
| 32 | - if (request.isReplace()) { | 41 | + synonymObjectSQLService = new HashMap<>(); |
| 33 | - ddl = CREATE_SQL + REPLACE_KEYWORD_SQL + "\n" + SYNONYM_KEYWORD_SQL + request.getSchema() + POINT + request.getSynonymName() + "\n" + FOR_KEYWORD_SQL + "\n" + request.getSchema() + POINT + request.getObjectName(); | 42 | + for (SynonymObjectSQLService s : SQLServiceList) { |
| 34 | - } else { | 43 | + synonymObjectSQLService.put(s.type(), s); |
| 35 | - ddl = CREATE_SQL + "\n" + SYNONYM_KEYWORD_SQL + request.getSchema() + POINT + request.getSynonymName() + "\n" + FOR_KEYWORD_SQL + "\n" + request.getSchema() + POINT + request.getObjectName(); | ||
| 36 | } | 44 | } |
| 37 | - log.info("splicingSequenceDDL response is: " + ddl); | ||
| 38 | - return ddl; | ||
| 39 | } | 45 | } |
| 40 | 46 | ||
| 41 | 47 | ||
| 42 | public String createSynonymDDL(DatabaseCreateSynonymDTO request) throws Exception { | 48 | public String createSynonymDDL(DatabaseCreateSynonymDTO request) throws Exception { |
| 43 | log.info("createSynonymDDL request is: " + request); | 49 | log.info("createSynonymDDL request is: " + request); |
| 44 | - String ddl = splicingSequenceDDL(request); | 50 | + String ddl = synonymObjectSQLService.get(conMap.get(request.getUuid()).getType()).splicingSequenceDDL(request); |
| 45 | log.info("createSynonymDDL response is: " + ddl); | 51 | log.info("createSynonymDDL response is: " + ddl); |
| 46 | return ddl; | 52 | return ddl; |
| 47 | } | 53 | } |
| @@ -49,54 +55,65 @@ public class DatabaseSynonymServiceImpl implements DatabaseSynonymService { | |||
| 49 | 55 | ||
| 50 | public Map<String, Object> synonymAttribute(DatabaseSynonymAttributeDTO request) { | 56 | public Map<String, Object> synonymAttribute(DatabaseSynonymAttributeDTO request) { |
| 51 | log.info("synonymAttribute request is: " + request); | 57 | log.info("synonymAttribute request is: " + request); |
| 52 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 58 | + try ( |
| 53 | - Statement statement = connection.createStatement();) { | 59 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 54 | - String ddl = SYNONYM_ATTRIBUTE_SQL + request.getSynonymName() + QUOTES_SEMICOLON; | 60 | + Statement statement = connection.createStatement() |
| 55 | - try(ResultSet count = statement.executeQuery(SYNONYM_COUNT_SQL + request.getSynonymName() + QUOTES_SEMICOLON)) { | 61 | + ) { |
| 62 | + String ddl = synonymObjectSQLService.get(conMap.get(request.getUuid()).getType()).synonymAttributeSQL( | ||
| 63 | + request); | ||
| 64 | + try ( | ||
| 65 | + ResultSet count = statement.executeQuery(ddl) | ||
| 66 | + ) { | ||
| 56 | count.next(); | 67 | count.next(); |
| 57 | - int a = count.getInt("count"); | 68 | + if (StringUtils.isBlank(String.valueOf(count.getString("synname")))) { |
| 58 | - if (a == 0) { | ||
| 59 | throw new CustomException(LocaleString.transLanguage("2011")); | 69 | throw new CustomException(LocaleString.transLanguage("2011")); |
| 60 | } | 70 | } |
| 61 | } | 71 | } |
| 62 | Map<String, Object> resultMap; | 72 | Map<String, Object> resultMap; |
| 63 | - try(ResultSet resultSet = statement.executeQuery(ddl)){ | 73 | + try ( |
| 74 | + ResultSet resultSet = statement.executeQuery(ddl) | ||
| 75 | + ) { | ||
| 64 | resultMap = DebugUtils.parseResultSet(resultSet); | 76 | resultMap = DebugUtils.parseResultSet(resultSet); |
| 65 | log.info("synonymAttribute sql is: " + ddl); | 77 | log.info("synonymAttribute sql is: " + ddl); |
| 66 | log.info("synonymAttribute response is: " + resultMap); | 78 | log.info("synonymAttribute response is: " + resultMap); |
| 67 | } | 79 | } |
| 68 | return resultMap; | 80 | return resultMap; |
| 69 | } catch (Exception e) { | 81 | } catch (Exception e) { |
| 70 | - e.printStackTrace(); | 82 | + log.info(e.getMessage()); |
| 71 | - throw new CustomException(e.getMessage(),e); | 83 | + throw new CustomException(e.getMessage(), e); |
| 72 | } | 84 | } |
| 73 | } | 85 | } |
| 74 | 86 | ||
| 75 | 87 | ||
| 76 | public void createSynonym(DatabaseCreateSynonymDTO request) { | 88 | public void createSynonym(DatabaseCreateSynonymDTO request) { |
| 77 | log.info("createSynonym request is: " + request); | 89 | log.info("createSynonym request is: " + request); |
| 78 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 90 | + try ( |
| 79 | - Statement statement = connection.createStatement()) { | 91 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 80 | - String ddl = splicingSequenceDDL(request); | 92 | + Statement statement = connection.createStatement() |
| 93 | + ) { | ||
| 94 | + String ddl = synonymObjectSQLService.get(conMap.get(request.getUuid()).getType()).splicingSequenceDDL( | ||
| 95 | + request); | ||
| 81 | statement.execute(ddl); | 96 | statement.execute(ddl); |
| 82 | log.info("createSynonym sql is: " + ddl); | 97 | log.info("createSynonym sql is: " + ddl); |
| 83 | } catch (Exception e) { | 98 | } catch (Exception e) { |
| 84 | - e.printStackTrace(); | 99 | + log.info(e.getMessage()); |
| 85 | - throw new CustomException(e.getMessage(),e); | 100 | + throw new CustomException(e.getMessage(), e); |
| 86 | } | 101 | } |
| 87 | } | 102 | } |
| 88 | 103 | ||
| 89 | 104 | ||
| 90 | public void dropSynonym(DatabaseDropSynonymDTO request) { | 105 | public void dropSynonym(DatabaseDropSynonymDTO request) { |
| 91 | log.info("dropSynonym request is: " + request); | 106 | log.info("dropSynonym request is: " + request); |
| 92 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 107 | + try ( |
| 93 | - Statement statement = connection.createStatement()){ | 108 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 94 | - String sql = DROP_SQL + SYNONYM_KEYWORD_SQL + request.getSchema() + POINT + request.getSynonymName(); | 109 | + Statement statement = connection.createStatement() |
| 110 | + ) { | ||
| 111 | + String sql = synonymObjectSQLService.get(conMap.get(request.getUuid()).getType()).dropSynonymSQL(request); | ||
| 95 | statement.execute(sql); | 112 | statement.execute(sql); |
| 96 | log.info("dropSynonym sql is: " + sql); | 113 | log.info("dropSynonym sql is: " + sql); |
| 97 | } catch (Exception e) { | 114 | } catch (Exception e) { |
| 98 | - e.printStackTrace(); | 115 | + log.info(e.getMessage()); |
| 99 | - throw new CustomException(e.getMessage(),e); | 116 | + throw new CustomException(e.getMessage(), e); |
| 100 | } | 117 | } |
| 101 | } | 118 | } |
| 102 | } | 119 | } |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/sql/DatabaseViewServiceImpl.java+41-116
| @@ -1,50 +1,50 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 7 | +import com.nctigba.datastudio.compatible.ViewObjectSQLService; | ||
| 3 | import com.nctigba.datastudio.config.ConnectionConfig; | 8 | import com.nctigba.datastudio.config.ConnectionConfig; |
| 4 | import com.nctigba.datastudio.model.dto.DatabaseCreateViewDTO; | 9 | import com.nctigba.datastudio.model.dto.DatabaseCreateViewDTO; |
| 5 | import com.nctigba.datastudio.model.dto.DatabaseSelectViewDTO; | 10 | import com.nctigba.datastudio.model.dto.DatabaseSelectViewDTO; |
| 6 | import com.nctigba.datastudio.model.dto.DatabaseViewDdlDTO; | 11 | import com.nctigba.datastudio.model.dto.DatabaseViewDdlDTO; |
| 7 | import com.nctigba.datastudio.service.DatabaseViewService; | 12 | import com.nctigba.datastudio.service.DatabaseViewService; |
| 8 | import com.nctigba.datastudio.util.DebugUtils; | 13 | import com.nctigba.datastudio.util.DebugUtils; |
| 9 | -import com.nctigba.datastudio.util.LocaleString; | ||
| 10 | import lombok.extern.slf4j.Slf4j; | 14 | import lombok.extern.slf4j.Slf4j; |
| 11 | import org.opengauss.admin.common.exception.CustomException; | 15 | import org.opengauss.admin.common.exception.CustomException; |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
| 14 | 18 | ||
| 19 | +import javax.annotation.Resource; | ||
| 15 | import java.sql.Connection; | 20 | import java.sql.Connection; |
| 16 | import java.sql.ResultSet; | 21 | import java.sql.ResultSet; |
| 17 | -import java.sql.ResultSetMetaData; | ||
| 18 | import java.sql.Statement; | 22 | import java.sql.Statement; |
| 19 | import java.util.HashMap; | 23 | import java.util.HashMap; |
| 24 | +import java.util.List; | ||
| 20 | import java.util.Map; | 25 | import java.util.Map; |
| 21 | 26 | ||
| 22 | -import static com.nctigba.datastudio.constants.SqlConstants.*; | 27 | +import static com.nctigba.datastudio.dao.ConnectionMapDAO.conMap; |
| 23 | 28 | ||
| 24 | 29 | ||
| 25 | 30 | ||
| 26 | public class DatabaseViewServiceImpl implements DatabaseViewService { | 31 | public class DatabaseViewServiceImpl implements DatabaseViewService { |
| 27 | 32 | ||
| 28 | private ConnectionConfig connectionConfig; | 33 | private ConnectionConfig connectionConfig; |
| 34 | + private Map<String, ViewObjectSQLService> viewObjectSQLService; | ||
| 29 | 35 | ||
| 30 | - @Override | 36 | + @Resource |
| 31 | - public String splicingViewDDL(DatabaseCreateViewDTO request) throws Exception { | 37 | + public void setViewObjectSQLService(List<ViewObjectSQLService> SQLServiceList) { |
| 32 | - log.info("splicingViewDDL request is: " + request); | 38 | + viewObjectSQLService = new HashMap<>(); |
| 33 | - String viewType; | 39 | + for (ViewObjectSQLService s : SQLServiceList) { |
| 34 | - if (request.getViewType().equals("MATERIALIZED")) { | 40 | + viewObjectSQLService.put(s.type(), s); |
| 35 | - viewType = MATERIALIZED_VIEW_SQL; | ||
| 36 | - } else { | ||
| 37 | - viewType = COMMON_VIEW_SQL; | ||
| 38 | } | 41 | } |
| 39 | - String ddl = CREATE_SQL + viewType + VIEW_KEYWORD_SQL + request.getSchema() + POINT + request.getViewName() + "\n" + CONNECTIVES_SQL + "\n" + request.getSql(); | ||
| 40 | - log.info("splicingViewDDL response is: " + ddl); | ||
| 41 | - return ddl; | ||
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | public String createViewDDL(DatabaseCreateViewDTO request) throws Exception { | 45 | public String createViewDDL(DatabaseCreateViewDTO request) throws Exception { |
| 46 | log.info("createViewDDL request is: " + request); | 46 | log.info("createViewDDL request is: " + request); |
| 47 | - String ddl = splicingViewDDL(request); | 47 | + String ddl = viewObjectSQLService.get(conMap.get(request.getUuid()).getType()).splicingViewDDL(request); |
| 48 | log.info("createViewDDL response is: " + ddl); | 48 | log.info("createViewDDL response is: " + ddl); |
| 49 | return ddl; | 49 | return ddl; |
| 50 | } | 50 | } |
| @@ -52,134 +52,59 @@ public class DatabaseViewServiceImpl implements DatabaseViewService { | |||
| 52 | 52 | ||
| 53 | public String returnViewDDL(DatabaseViewDdlDTO request) throws Exception { | 53 | public String returnViewDDL(DatabaseViewDdlDTO request) throws Exception { |
| 54 | log.info("returnViewDDL request is: " + request); | 54 | log.info("returnViewDDL request is: " + request); |
| 55 | - try{ | 55 | + return viewObjectSQLService.get(conMap.get(request.getUuid()).getType()).returnDatabaseViewDDL(request); |
| 56 | - Map<String, Object> resultMap = returnViewDDLData(request); | ||
| 57 | - String viewType; | ||
| 58 | - String ddl = null; | ||
| 59 | - if (resultMap.get("relkind").equals("m")) { | ||
| 60 | - viewType = MATERIALIZED_VIEW_SQL; | ||
| 61 | - } else { | ||
| 62 | - viewType = COMMON_VIEW_SQL; | ||
| 63 | - } | ||
| 64 | - ddl = CREATE_SQL + viewType + VIEW_KEYWORD_SQL + resultMap.get("schemaname") + POINT + resultMap.get("matviewname") + "\n" + CONNECTIVES_SQL + "\n" + resultMap.get("definition"); | ||
| 65 | - | ||
| 66 | - log.info("returnViewDDL response is: " + ddl); | ||
| 67 | - return ddl; | ||
| 68 | - } catch (Exception e) { | ||
| 69 | - e.printStackTrace(); | ||
| 70 | - throw new CustomException(e.getMessage(),e); | ||
| 71 | - } | ||
| 72 | 56 | ||
| 73 | } | 57 | } |
| 74 | 58 | ||
| 75 | - | ||
| 76 | - public Map<String, Object> returnViewDDLData(DatabaseViewDdlDTO request) throws Exception { | ||
| 77 | - log.info("returnViewDDLData request is: " + request); | ||
| 78 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid());){ | ||
| 79 | - Statement statement = connection.createStatement(); | ||
| 80 | - String selectsql = SELECT_VIEW_DDL_SQL + request.getSchema() + SELECT_VIEWNAME_DDL_WHERE_SQL + request.getViewName() + SELECT_VIEW_DDL_WHERE_SQL; | ||
| 81 | - try(ResultSet count = statement.executeQuery(SELECT_KEYWORD_SQL + COUNT_SQL +FROM_CLASS_SQL+ | ||
| 82 | - request.getSchema() + FROM_CLASS_WHERE_SQL + request.getViewName() + RELKIND_SQL+ "v" + QUOTES_SEMICOLON)){ | ||
| 83 | - count.next(); | ||
| 84 | - int a = count.getInt("count"); | ||
| 85 | - if(a==0){ | ||
| 86 | - throw new CustomException(LocaleString.transLanguage("2010")); | ||
| 87 | - } | ||
| 88 | - } | ||
| 89 | - ResultSet resultSet = statement.executeQuery(selectsql); | ||
| 90 | - log.info("returnViewDDLData sql is: " + selectsql); | ||
| 91 | - log.info("returnViewDDLData response is: " + resultSet); | ||
| 92 | - Map<String, Object> resultMap = new HashMap<>(); | ||
| 93 | - ResultSetMetaData metaData = resultSet.getMetaData(); | ||
| 94 | - String column; | ||
| 95 | - while (resultSet.next()) { | ||
| 96 | - for (int i = 0; i < metaData.getColumnCount(); i++) { | ||
| 97 | - column = metaData.getColumnName(i + 1); | ||
| 98 | - resultMap.put(column,resultSet.getString(column)); | ||
| 99 | - } | ||
| 100 | - } | ||
| 101 | - return resultMap; | ||
| 102 | - } catch (Exception e) { | ||
| 103 | - e.printStackTrace(); | ||
| 104 | - throw new CustomException(e.getMessage(),e); | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - public String viewTypeData(DatabaseViewDdlDTO request) throws Exception { | ||
| 110 | - log.info("viewAttributeData request is: " + request); | ||
| 111 | - try (Connection connection = connectionConfig.connectDatabase(request.getUuid());) { | ||
| 112 | - Statement statement = connection.createStatement(); | ||
| 113 | - String selectsql = SELECT_VIEW_TYPE_SQL + request.getSchema() + SELECT_VIEWNAME_DDL_WHERE_SQL + request.getViewName() + SELECT_VIEW_DDL_WHERE_SQL; | ||
| 114 | - try (ResultSet resultSet = statement.executeQuery(selectsql)) { | ||
| 115 | - log.info("count sql is: " + resultSet); | ||
| 116 | - log.info("viewAttributeData sql is: " + selectsql); | ||
| 117 | - String type; | ||
| 118 | - if (resultSet.next()) { | ||
| 119 | - type = resultSet.getString("relkind"); | ||
| 120 | - } else { | ||
| 121 | - throw new CustomException(LocaleString.transLanguage("2010")); | ||
| 122 | - } | ||
| 123 | - log.info("resultMap response is: " + type); | ||
| 124 | - return type; | ||
| 125 | - } | ||
| 126 | - } catch (Exception e) { | ||
| 127 | - e.printStackTrace(); | ||
| 128 | - throw new CustomException(e.getMessage(),e); | ||
| 129 | - } | ||
| 130 | - | ||
| 131 | - } | ||
| 132 | 59 | ||
| 133 | public void createView(DatabaseCreateViewDTO request) { | 60 | public void createView(DatabaseCreateViewDTO request) { |
| 134 | log.info("createView request is: " + request); | 61 | log.info("createView request is: " + request); |
| 135 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 62 | + try ( |
| 136 | - Statement statement = connection.createStatement();){ | 63 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 137 | - String ddl = splicingViewDDL(request); | 64 | + Statement statement = connection.createStatement() |
| 65 | + ) { | ||
| 66 | + String ddl = viewObjectSQLService.get(conMap.get(request.getUuid()).getType()).splicingViewDDL(request); | ||
| 138 | statement.execute(ddl); | 67 | statement.execute(ddl); |
| 139 | log.info("createView response is: " + ddl); | 68 | log.info("createView response is: " + ddl); |
| 140 | } catch (Exception e) { | 69 | } catch (Exception e) { |
| 141 | - e.printStackTrace(); | 70 | + log.info(e.getMessage()); |
| 142 | - throw new CustomException(e.getMessage(),e); | 71 | + throw new CustomException(e.getMessage(), e); |
| 143 | } | 72 | } |
| 144 | } | 73 | } |
| 145 | 74 | ||
| 146 | 75 | ||
| 147 | public void dropView(DatabaseViewDdlDTO request) { | 76 | public void dropView(DatabaseViewDdlDTO request) { |
| 148 | log.info("dropView request is: " + request); | 77 | log.info("dropView request is: " + request); |
| 149 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 78 | + try ( |
| 150 | - Statement statement = connection.createStatement();){ | ||
| 151 | - | ||
| 152 | - String type = viewTypeData(request); | ||
| 153 | - if (type.equals("m")) { | ||
| 154 | - String materializedSql = DROP_SQL + MATERIALIZED_VIEW_SQL + VIEW_KEYWORD_SQL + IF_EXISTS_SQL + request.getSchema() + POINT + request.getViewName(); | ||
| 155 | - statement.execute(materializedSql); | ||
| 156 | - log.info("dropView sql is: " + materializedSql); | ||
| 157 | - } else { | ||
| 158 | - String sql = DROP_SQL + VIEW_KEYWORD_SQL + request.getSchema() + POINT + request.getViewName(); | ||
| 159 | - statement.execute(sql); | ||
| 160 | - log.info("dropView sql is: " + sql); | ||
| 161 | - } | ||
| 162 | 79 | ||
| 80 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 81 | + Statement statement = connection.createStatement() | ||
| 82 | + ) { | ||
| 83 | + statement.execute( | ||
| 84 | + viewObjectSQLService.get(conMap.get(request.getUuid()).getType()).returnDropViewSQL(request)); | ||
| 163 | } catch (Exception e) { | 85 | } catch (Exception e) { |
| 164 | - e.printStackTrace(); | 86 | + log.info(e.getMessage()); |
| 165 | - throw new CustomException(e.getMessage(),e); | 87 | + throw new CustomException(e.getMessage(), e); |
| 166 | } | 88 | } |
| 167 | } | 89 | } |
| 168 | 90 | ||
| 169 | 91 | ||
| 170 | public Map<String, Object> selectView(DatabaseSelectViewDTO request) { | 92 | public Map<String, Object> selectView(DatabaseSelectViewDTO request) { |
| 171 | log.info("selectView request is: " + request); | 93 | log.info("selectView request is: " + request); |
| 172 | - String ddl = TABLE_DATA_SQL + request.getSchema() + POINT + request.getViewName() + LIMIT_SQL; | 94 | + try ( |
| 173 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 95 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 174 | - Statement statement = connection.createStatement(); | 96 | + Statement statement = connection.createStatement(); |
| 175 | - ResultSet resultSet = statement.executeQuery(ddl);){ | 97 | + ResultSet resultSet = statement.executeQuery(viewObjectSQLService.get( |
| 98 | + conMap.get(request.getUuid()).getType()).returnSelectViewSQL(request)) | ||
| 99 | + ) { | ||
| 176 | Map<String, Object> resultMap = DebugUtils.parseResultSet(resultSet); | 100 | Map<String, Object> resultMap = DebugUtils.parseResultSet(resultSet); |
| 177 | - log.info("selectView sql is: " + ddl); | 101 | + log.info("selectView sql is: " + viewObjectSQLService.get( |
| 102 | + conMap.get(request.getUuid()).getType()).returnSelectViewSQL(request)); | ||
| 178 | log.info("selectView response is: " + resultMap); | 103 | log.info("selectView response is: " + resultMap); |
| 179 | return resultMap; | 104 | return resultMap; |
| 180 | } catch (Exception e) { | 105 | } catch (Exception e) { |
| 181 | - e.printStackTrace(); | 106 | + log.info(e.getMessage()); |
| 182 | - throw new CustomException(e.getMessage(),e); | 107 | + throw new CustomException(e.getMessage(), e); |
| 183 | } | 108 | } |
| 184 | } | 109 | } |
| 185 | } | 110 | } |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/sql/DbConnectionServiceImpl.java+42-72
| @@ -1,5 +1,10 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 7 | +import com.nctigba.datastudio.compatible.GainObjectSQLService; | ||
| 3 | import com.nctigba.datastudio.dao.ConnectionMapDAO; | 8 | import com.nctigba.datastudio.dao.ConnectionMapDAO; |
| 4 | import com.nctigba.datastudio.dao.DatabaseConnectionDAO; | 9 | import com.nctigba.datastudio.dao.DatabaseConnectionDAO; |
| 5 | import com.nctigba.datastudio.model.dto.ConnectionDTO; | 10 | import com.nctigba.datastudio.model.dto.ConnectionDTO; |
| @@ -12,17 +17,22 @@ import com.nctigba.datastudio.service.DataListByJdbcService; | |||
| 12 | import com.nctigba.datastudio.service.DbConnectionService; | 17 | import com.nctigba.datastudio.service.DbConnectionService; |
| 13 | import com.nctigba.datastudio.service.MetaDataByJdbcService; | 18 | import com.nctigba.datastudio.service.MetaDataByJdbcService; |
| 14 | import com.nctigba.datastudio.util.LocaleString; | 19 | import com.nctigba.datastudio.util.LocaleString; |
| 20 | +import lombok.extern.slf4j.Slf4j; | ||
| 15 | import org.opengauss.admin.common.exception.CustomException; | 21 | import org.opengauss.admin.common.exception.CustomException; |
| 16 | import org.springframework.stereotype.Service; | 22 | import org.springframework.stereotype.Service; |
| 17 | 23 | ||
| 18 | import javax.annotation.Resource; | 24 | import javax.annotation.Resource; |
| 19 | import java.util.ArrayList; | 25 | import java.util.ArrayList; |
| 26 | +import java.util.HashMap; | ||
| 20 | import java.util.List; | 27 | import java.util.List; |
| 28 | +import java.util.Map; | ||
| 21 | import java.util.UUID; | 29 | import java.util.UUID; |
| 22 | 30 | ||
| 23 | -import static com.nctigba.datastudio.constants.SqlConstants.*; | 31 | +import static com.nctigba.datastudio.constants.SqlConstants.CONFIGURE_TIME; |
| 32 | +import static com.nctigba.datastudio.constants.SqlConstants.GET_URL_JDBC; | ||
| 24 | import static com.nctigba.datastudio.dao.ConnectionMapDAO.conMap; | 33 | import static com.nctigba.datastudio.dao.ConnectionMapDAO.conMap; |
| 25 | 34 | ||
| 35 | + | ||
| 26 | 36 | ||
| 27 | public class DbConnectionServiceImpl implements DbConnectionService { | 37 | public class DbConnectionServiceImpl implements DbConnectionService { |
| 28 | 38 | ||
| @@ -36,6 +46,16 @@ public class DbConnectionServiceImpl implements DbConnectionService { | |||
| 36 | 46 | ||
| 37 | private DataListByJdbcService dataListByJdbcService; | 47 | private DataListByJdbcService dataListByJdbcService; |
| 38 | 48 | ||
| 49 | + private Map<String, GainObjectSQLService> gainObjectSQLService; | ||
| 50 | + | ||
| 51 | + | ||
| 52 | + public void setGainObjectSQLService(List<GainObjectSQLService> SQLServiceList) { | ||
| 53 | + gainObjectSQLService = new HashMap<>(); | ||
| 54 | + for (GainObjectSQLService s : SQLServiceList) { | ||
| 55 | + gainObjectSQLService.put(s.type(), s); | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 39 | 59 | ||
| 40 | public DatabaseConnectionDO addDatabaseConnection(DbConnectionCreateDTO request) { | 60 | public DatabaseConnectionDO addDatabaseConnection(DbConnectionCreateDTO request) { |
| 41 | if (databaseConnectionDAO.getJudgeName(request.getName(), request.getWebUser()) == 0) { | 61 | if (databaseConnectionDAO.getJudgeName(request.getName(), request.getWebUser()) == 0) { |
| @@ -43,7 +63,8 @@ public class DbConnectionServiceImpl implements DbConnectionService { | |||
| 43 | try { | 63 | try { |
| 44 | conn.setEdition(test(request)); | 64 | conn.setEdition(test(request)); |
| 45 | databaseConnectionDAO.insertTable(conn); | 65 | databaseConnectionDAO.insertTable(conn); |
| 46 | - DatabaseConnectionDO dataList = databaseConnectionDAO.getAttributeByName(request.getName(), request.getWebUser()); | 66 | + DatabaseConnectionDO dataList = databaseConnectionDAO.getAttributeByName(request.getName(), |
| 67 | + request.getWebUser()); | ||
| 47 | String uuid = UUID.randomUUID().toString(); | 68 | String uuid = UUID.randomUUID().toString(); |
| 48 | dataList.setConnectionid(uuid); | 69 | dataList.setConnectionid(uuid); |
| 49 | ConnectionDTO connectionDTO = new ConnectionDTO(); | 70 | ConnectionDTO connectionDTO = new ConnectionDTO(); |
| @@ -97,13 +118,15 @@ public class DbConnectionServiceImpl implements DbConnectionService { | |||
| 97 | conn.setEdition(test(request)); | 118 | conn.setEdition(test(request)); |
| 98 | connectionMapDAO.deleteConnection(request.getConnectionid()); | 119 | connectionMapDAO.deleteConnection(request.getConnectionid()); |
| 99 | databaseConnectionDAO.updateTable(conn); | 120 | databaseConnectionDAO.updateTable(conn); |
| 100 | - DatabaseConnectionDO dataList = databaseConnectionDAO.getAttributeByName(request.getName(), request.getWebUser()); | 121 | + DatabaseConnectionDO dataList = databaseConnectionDAO.getAttributeByName(request.getName(), |
| 122 | + request.getWebUser()); | ||
| 101 | String uuid = UUID.randomUUID().toString(); | 123 | String uuid = UUID.randomUUID().toString(); |
| 102 | dataList.setConnectionid(uuid); | 124 | dataList.setConnectionid(uuid); |
| 103 | ConnectionDTO connectionDTO = new ConnectionDTO(); | 125 | ConnectionDTO connectionDTO = new ConnectionDTO(); |
| 104 | - DatabaseConnectionUrlDO databaseConnectionUrlDO = databaseConnectionDAO.getByName(request.getName(), request.getWebUser()); | 126 | + DatabaseConnectionUrlDO databaseConnectionUrlDO = databaseConnectionDAO.getByName(request.getName(), |
| 127 | + request.getWebUser()); | ||
| 105 | connectionDTO.setConnectionDTO(databaseConnectionUrlDO); | 128 | connectionDTO.setConnectionDTO(databaseConnectionUrlDO); |
| 106 | - connectionMapDAO.setConMap(uuid, connectionDTO); | 129 | + ConnectionMapDAO.setConMap(uuid, connectionDTO); |
| 107 | return dataList; | 130 | return dataList; |
| 108 | } catch (Exception e) { | 131 | } catch (Exception e) { |
| 109 | throw new CustomException(e.getMessage(), e); | 132 | throw new CustomException(e.getMessage(), e); |
| @@ -116,11 +139,13 @@ public class DbConnectionServiceImpl implements DbConnectionService { | |||
| 116 | DatabaseConnectionDO conn = request.toDatabaseConnection(); | 139 | DatabaseConnectionDO conn = request.toDatabaseConnection(); |
| 117 | conn.setEdition(test(request)); | 140 | conn.setEdition(test(request)); |
| 118 | databaseConnectionDAO.updateTable(conn); | 141 | databaseConnectionDAO.updateTable(conn); |
| 119 | - DatabaseConnectionDO dataList = databaseConnectionDAO.getAttributeByName(request.getName(), request.getWebUser()); | 142 | + DatabaseConnectionDO dataList = databaseConnectionDAO.getAttributeByName(request.getName(), |
| 143 | + request.getWebUser()); | ||
| 120 | String uuid = UUID.randomUUID().toString(); | 144 | String uuid = UUID.randomUUID().toString(); |
| 121 | dataList.setConnectionid(uuid); | 145 | dataList.setConnectionid(uuid); |
| 122 | ConnectionDTO connectionDTO = new ConnectionDTO(); | 146 | ConnectionDTO connectionDTO = new ConnectionDTO(); |
| 123 | - DatabaseConnectionUrlDO databaseConnectionUrlDO = databaseConnectionDAO.getByName(request.getName(), request.getWebUser()); | 147 | + DatabaseConnectionUrlDO databaseConnectionUrlDO = databaseConnectionDAO.getByName(request.getName(), |
| 148 | + request.getWebUser()); | ||
| 124 | connectionDTO.setConnectionDTO(databaseConnectionUrlDO); | 149 | connectionDTO.setConnectionDTO(databaseConnectionUrlDO); |
| 125 | ConnectionMapDAO.setConMap(uuid, connectionDTO); | 150 | ConnectionMapDAO.setConMap(uuid, connectionDTO); |
| 126 | return dataList; | 151 | return dataList; |
| @@ -129,47 +154,6 @@ public class DbConnectionServiceImpl implements DbConnectionService { | |||
| 129 | } | 154 | } |
| 130 | } | 155 | } |
| 131 | 156 | ||
| 132 | - | ||
| 133 | - public List<DataListDTO> dataList(String uuid) { | ||
| 134 | - | ||
| 135 | - try { | ||
| 136 | - ConnectionDTO connectionDTO = conMap.get(uuid); | ||
| 137 | - List<DataListDTO> listDataList = new ArrayList<>(); | ||
| 138 | - List<String> list = dataListByJdbcService.schemaListQuerySQL( | ||
| 139 | - connectionDTO.getUrl(), | ||
| 140 | - connectionDTO.getDbUser(), | ||
| 141 | - connectionDTO.getDbPassword(), | ||
| 142 | - GET_SCHEMA_NAME_SQL | ||
| 143 | - ); | ||
| 144 | - for (int i = 0; i < list.size(); i++) { | ||
| 145 | - DataListDTO dataList = new DataListDTO(); | ||
| 146 | - dataList = dataListByJdbcService.dataListQuerySQL( | ||
| 147 | - connectionDTO.getUrl(), | ||
| 148 | - connectionDTO.getDbUser(), | ||
| 149 | - connectionDTO.getDbPassword(), | ||
| 150 | - "SELECT tablename FROM pg_tables where schemaname ='" + list.get(i) + "';", | ||
| 151 | - "select c.relname as viewname from pg_class c INNER JOIN pg_namespace n ON n.oid = c.relnamespace and n.nspname = '" + list.get(i) + SELECT_OBJECT_WHERE_IN_SQL + "v','m" + QUOTES_PARENTHESES_SEMICOLON, | ||
| 152 | - "SELECT proname,proargtypes FROM pg_proc\n" + | ||
| 153 | - "WHERE pronamespace = (SELECT pg_namespace.oid FROM pg_namespace WHERE nspname = '" + list.get(i) + "')\n", | ||
| 154 | - | ||
| 155 | - "select c.relname as relname from\n" + | ||
| 156 | - "pg_class c INNER JOIN pg_namespace n ON n.oid = c.relnamespace \n" + | ||
| 157 | - "and n.nspname = '" + list.get(i) + "' where c.relkind = 'S'", | ||
| 158 | - "select synname from PG_SYNONYM where synobjschema ='" + list.get(i) + "'", | ||
| 159 | - list.get(i) | ||
| 160 | - ); | ||
| 161 | - listDataList.add(dataList); | ||
| 162 | - } | ||
| 163 | - connectionDTO.updataConnectionDTO(connectionDTO); | ||
| 164 | - ConnectionMapDAO.setConMap(uuid, connectionDTO); | ||
| 165 | - return listDataList; | ||
| 166 | - } catch (Exception e) { | ||
| 167 | - e.printStackTrace(); | ||
| 168 | - throw new CustomException(e.getMessage(), e); | ||
| 169 | - } | ||
| 170 | - } | ||
| 171 | - | ||
| 172 | - | ||
| 173 | 157 | ||
| 174 | public List<DataListDTO> schemaObjectList(DatabaseMetaarrayIdSchemaQuery schema) { | 158 | public List<DataListDTO> schemaObjectList(DatabaseMetaarrayIdSchemaQuery schema) { |
| 175 | try { | 159 | try { |
| @@ -182,27 +166,11 @@ public class DbConnectionServiceImpl implements DbConnectionService { | |||
| 182 | connectionDTO.getUrl(), | 166 | connectionDTO.getUrl(), |
| 183 | connectionDTO.getDbUser(), | 167 | connectionDTO.getDbUser(), |
| 184 | connectionDTO.getDbPassword(), | 168 | connectionDTO.getDbPassword(), |
| 185 | - "select relname as tablename\n" + | 169 | + gainObjectSQLService.get(conMap.get(schema.getUuid()).getType()).tableSql(schema.getSchema()), |
| 186 | - " from (select tbl.oid as oid, tbl.relname relname\n" + | 170 | + gainObjectSQLService.get(conMap.get(schema.getUuid()).getType()).viewSql(schema.getSchema()), |
| 187 | - " from pg_class tbl\n" + | 171 | + gainObjectSQLService.get(conMap.get(schema.getUuid()).getType()).fun_prosSql(schema.getSchema()), |
| 188 | - " inner join pg_namespace ns on tbl.relnamespace = ns.oid\n" + | 172 | + gainObjectSQLService.get(conMap.get(schema.getUuid()).getType()).sequenceSql(schema.getSchema()), |
| 189 | - " where tbl.relkind = 'r'\n" + | 173 | + gainObjectSQLService.get(conMap.get(schema.getUuid()).getType()).synonymSql(schema.getSchema()), |
| 190 | - " and ns.nspname = '" + schema.getSchema() + "' ) x\n" + | ||
| 191 | - " where has_table_privilege(x.oid, 'SELECT')" + | ||
| 192 | - " order by 1", | ||
| 193 | - "select c.relname as viewname from pg_class c INNER JOIN pg_namespace n ON n.oid = c.relnamespace and n.nspname = '" + schema.getSchema() + SELECT_OBJECT_WHERE_IN_SQL + "v','m" + "') order by 1" + SEMICOLON, | ||
| 194 | - "SELECT proname,proargtypes FROM pg_proc\n" + | ||
| 195 | - "WHERE pronamespace = (SELECT pg_namespace.oid FROM pg_namespace WHERE nspname = '" + schema.getSchema() + "')\n" + | ||
| 196 | - " order by 1\n", | ||
| 197 | - | ||
| 198 | - "select c.relname as relname from\n" + | ||
| 199 | - "pg_class c INNER JOIN pg_namespace n ON n.oid = c.relnamespace \n" + | ||
| 200 | - "and n.nspname = '" + schema.getSchema() + "' where c.relkind = 'S'\n" + | ||
| 201 | - " order by 1", | ||
| 202 | - "select synname from PG_SYNONYM pgs, pg_namespace pgn\n" + | ||
| 203 | - " where pgn.oid = pgs.synnamespace\n" + | ||
| 204 | - " and pgn.nspname ='" + schema.getSchema() + "'\n" + | ||
| 205 | - " order by 1", | ||
| 206 | schema.getSchema() | 174 | schema.getSchema() |
| 207 | ); | 175 | ); |
| 208 | connectionDTO.updataConnectionDTO(connectionDTO); | 176 | connectionDTO.updataConnectionDTO(connectionDTO); |
| @@ -210,19 +178,21 @@ public class DbConnectionServiceImpl implements DbConnectionService { | |||
| 210 | listDataList.add(dataList); | 178 | listDataList.add(dataList); |
| 211 | return listDataList; | 179 | return listDataList; |
| 212 | } catch (Exception e) { | 180 | } catch (Exception e) { |
| 213 | - e.printStackTrace(); | 181 | + log.info(e.getMessage()); |
| 214 | throw new CustomException(e.getMessage(), e); | 182 | throw new CustomException(e.getMessage(), e); |
| 215 | } | 183 | } |
| 216 | } | 184 | } |
| 217 | 185 | ||
| 218 | 186 | ||
| 219 | public String test(DbConnectionCreateDTO request) throws Exception { | 187 | public String test(DbConnectionCreateDTO request) throws Exception { |
| 188 | + log.info("{}", request); | ||
| 189 | + log.info("{}", gainObjectSQLService.keySet()); | ||
| 220 | return metaDataByJdbcService.versionSQL( | 190 | return metaDataByJdbcService.versionSQL( |
| 221 | GET_URL_JDBC + request.getIp() + ":" + request.getPort() + "/" + request.getDataName() + CONFIGURE_TIME, | 191 | GET_URL_JDBC + request.getIp() + ":" + request.getPort() + "/" + request.getDataName() + CONFIGURE_TIME, |
| 222 | request.getUserName(), | 192 | request.getUserName(), |
| 223 | request.getPassword(), | 193 | request.getPassword(), |
| 224 | - " select version();" | 194 | + gainObjectSQLService.get(request.getType()).databaseVersion() |
| 225 | ); | 195 | ); |
| 226 | } | 196 | } |
| 227 | 197 | ||
| 228 | -} | 198 | +} |
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/sql/ExportServiceImpl.java+592-0
| @@ -0,0 +1,592 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.service.impl.sql; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.config.ConnectionConfig; | ||
| 8 | +import com.nctigba.datastudio.model.dto.DataListDTO; | ||
| 9 | +import com.nctigba.datastudio.model.dto.DatabaseSequenceDdlDTO; | ||
| 10 | +import com.nctigba.datastudio.model.dto.DatabaseViewDdlDTO; | ||
| 11 | +import com.nctigba.datastudio.model.query.DatabaseMetaarrayIdSchemaQuery; | ||
| 12 | +import com.nctigba.datastudio.model.query.ExportRequest; | ||
| 13 | +import com.nctigba.datastudio.service.DatabaseSequenceService; | ||
| 14 | +import com.nctigba.datastudio.service.DatabaseViewService; | ||
| 15 | +import com.nctigba.datastudio.service.DbConnectionService; | ||
| 16 | +import com.nctigba.datastudio.service.ExportService; | ||
| 17 | +import com.nctigba.datastudio.util.DebugUtils; | ||
| 18 | +import com.nctigba.datastudio.util.LocaleString; | ||
| 19 | +import lombok.extern.slf4j.Slf4j; | ||
| 20 | +import org.apache.commons.lang3.BooleanUtils; | ||
| 21 | +import org.apache.commons.lang3.StringUtils; | ||
| 22 | +import org.apache.logging.log4j.util.Strings; | ||
| 23 | +import org.apache.poi.xssf.usermodel.XSSFRow; | ||
| 24 | +import org.apache.poi.xssf.usermodel.XSSFSheet; | ||
| 25 | +import org.apache.poi.xssf.usermodel.XSSFWorkbook; | ||
| 26 | +import org.opengauss.admin.common.exception.CustomException; | ||
| 27 | +import org.opengauss.copy.CopyManager; | ||
| 28 | +import org.opengauss.core.BaseConnection; | ||
| 29 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 30 | +import org.springframework.stereotype.Service; | ||
| 31 | + | ||
| 32 | +import javax.servlet.http.HttpServletResponse; | ||
| 33 | +import java.io.BufferedInputStream; | ||
| 34 | +import java.io.File; | ||
| 35 | +import java.io.FileInputStream; | ||
| 36 | +import java.io.FileOutputStream; | ||
| 37 | +import java.io.OutputStream; | ||
| 38 | +import java.net.URLEncoder; | ||
| 39 | +import java.nio.charset.StandardCharsets; | ||
| 40 | +import java.sql.Connection; | ||
| 41 | +import java.sql.ResultSet; | ||
| 42 | +import java.sql.ResultSetMetaData; | ||
| 43 | +import java.sql.SQLException; | ||
| 44 | +import java.sql.Statement; | ||
| 45 | +import java.sql.Types; | ||
| 46 | +import java.text.SimpleDateFormat; | ||
| 47 | +import java.util.ArrayList; | ||
| 48 | +import java.util.Date; | ||
| 49 | +import java.util.List; | ||
| 50 | +import java.util.Map; | ||
| 51 | +import java.util.stream.Collectors; | ||
| 52 | + | ||
| 53 | +import static com.nctigba.datastudio.constants.CommonConstants.DEFINITION; | ||
| 54 | +import static com.nctigba.datastudio.constants.CommonConstants.FUNCTION; | ||
| 55 | +import static com.nctigba.datastudio.constants.CommonConstants.IS_CALLED; | ||
| 56 | +import static com.nctigba.datastudio.constants.CommonConstants.MAX_VALUE; | ||
| 57 | +import static com.nctigba.datastudio.constants.CommonConstants.MIN_VALUE; | ||
| 58 | +import static com.nctigba.datastudio.constants.CommonConstants.NAME; | ||
| 59 | +import static com.nctigba.datastudio.constants.CommonConstants.NEXT_VALUE; | ||
| 60 | +import static com.nctigba.datastudio.constants.CommonConstants.OID; | ||
| 61 | +import static com.nctigba.datastudio.constants.CommonConstants.PG_GET_TABLEDEF; | ||
| 62 | +import static com.nctigba.datastudio.constants.CommonConstants.PRO_NAME; | ||
| 63 | +import static com.nctigba.datastudio.constants.CommonConstants.SCHEMA; | ||
| 64 | +import static com.nctigba.datastudio.constants.CommonConstants.SEQUENCE; | ||
| 65 | +import static com.nctigba.datastudio.constants.CommonConstants.TABLE; | ||
| 66 | +import static com.nctigba.datastudio.constants.CommonConstants.UNDERLINE; | ||
| 67 | +import static com.nctigba.datastudio.constants.CommonConstants.VIEW; | ||
| 68 | +import static com.nctigba.datastudio.constants.SqlConstants.COMMA; | ||
| 69 | +import static com.nctigba.datastudio.constants.SqlConstants.CREATE_SCHEMA_SQL; | ||
| 70 | +import static com.nctigba.datastudio.constants.SqlConstants.FROM_KEYWORD_SQL; | ||
| 71 | +import static com.nctigba.datastudio.constants.SqlConstants.LEFT_BRACKET; | ||
| 72 | +import static com.nctigba.datastudio.constants.SqlConstants.LF; | ||
| 73 | +import static com.nctigba.datastudio.constants.SqlConstants.NEXT_VALUE_SQL; | ||
| 74 | +import static com.nctigba.datastudio.constants.SqlConstants.POINT; | ||
| 75 | +import static com.nctigba.datastudio.constants.SqlConstants.PROC_SQL; | ||
| 76 | +import static com.nctigba.datastudio.constants.SqlConstants.QUERY_DEF_SQL; | ||
| 77 | +import static com.nctigba.datastudio.constants.SqlConstants.QUOTES; | ||
| 78 | +import static com.nctigba.datastudio.constants.SqlConstants.RIGHT_BRACKET; | ||
| 79 | +import static com.nctigba.datastudio.constants.SqlConstants.SELECT_KEYWORD_SQL; | ||
| 80 | +import static com.nctigba.datastudio.constants.SqlConstants.SEMICOLON; | ||
| 81 | +import static com.nctigba.datastudio.constants.SqlConstants.SEQUENCE_SQL; | ||
| 82 | +import static com.nctigba.datastudio.constants.SqlConstants.SET_VALUE_SQL; | ||
| 83 | +import static com.nctigba.datastudio.constants.SqlConstants.TABLE_DATA_SQL; | ||
| 84 | +import static com.nctigba.datastudio.constants.SqlConstants.TABLE_DDL_SQL; | ||
| 85 | + | ||
| 86 | + | ||
| 87 | + | ||
| 88 | +public class ExportServiceImpl implements ExportService { | ||
| 89 | + | ||
| 90 | + private ConnectionConfig connectionConfig; | ||
| 91 | + | ||
| 92 | + | ||
| 93 | + private DatabaseViewService viewService; | ||
| 94 | + | ||
| 95 | + | ||
| 96 | + private DatabaseSequenceService sequenceService; | ||
| 97 | + | ||
| 98 | + | ||
| 99 | + private DbConnectionService dbConnectionService; | ||
| 100 | + | ||
| 101 | + | ||
| 102 | + public void exportTableDdl(ExportRequest request, HttpServletResponse response) throws Exception { | ||
| 103 | + String fileName = getFileName(request.isDataFlag(), TABLE, request.getTableList()); | ||
| 104 | + DebugUtils.exportFile(fileName, getTableDdl(request), response); | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + | ||
| 108 | + public void exportTableData(ExportRequest request, HttpServletResponse response) throws Exception { | ||
| 109 | + log.info("ExportService exportTableData request: " + request); | ||
| 110 | + String fileType = request.getFileType(); | ||
| 111 | + String tableName = request.getTableName(); | ||
| 112 | + String fileName = Strings.EMPTY; | ||
| 113 | + if (fileType.contains("Excel")) { | ||
| 114 | + exportExcel(request, response); | ||
| 115 | + return; | ||
| 116 | + } else if (fileType.equals("Text")) { | ||
| 117 | + fileName = getDataFileName(tableName) + ".txt"; | ||
| 118 | + } else if (fileType.equals("Binary")) { | ||
| 119 | + fileName = getDataFileName(tableName) + ".bin"; | ||
| 120 | + } | ||
| 121 | + String path = System.getProperty("user.dir") + "\\" + fileName; | ||
| 122 | + log.info("ExportService exportTableData path: " + path); | ||
| 123 | + | ||
| 124 | + try ( | ||
| 125 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 126 | + FileOutputStream fileOutputStream = new FileOutputStream(path); | ||
| 127 | + BufferedInputStream bis = new BufferedInputStream(new FileInputStream(path)); | ||
| 128 | + OutputStream os = response.getOutputStream() | ||
| 129 | + ) { | ||
| 130 | + CopyManager copyManager = new CopyManager((BaseConnection) connection); | ||
| 131 | + StringBuilder sb = new StringBuilder(); | ||
| 132 | + sb.append("COPY ").append(request.getSchema()).append(POINT).append(tableName); | ||
| 133 | + List<String> columnList = request.getColumnList(); | ||
| 134 | + sb.append(LEFT_BRACKET); | ||
| 135 | + for (int i = 0; i < columnList.size(); i++) { | ||
| 136 | + sb.append(columnList.get(i)); | ||
| 137 | + if (i != columnList.size() - 1) { | ||
| 138 | + sb.append(COMMA); | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + sb.append(RIGHT_BRACKET); | ||
| 142 | + sb.append(" TO STDOUT "); | ||
| 143 | + if (fileType.equals("Binary")) { | ||
| 144 | + sb.append(fileType.toUpperCase()); | ||
| 145 | + } else if (fileType.equals("Text")) { | ||
| 146 | + String delimiter = request.getDelimiter(); | ||
| 147 | + if (StringUtils.isNotEmpty(delimiter)) { | ||
| 148 | + sb.append(" DELIMITERS ").append(QUOTES).append(delimiter).append(QUOTES); | ||
| 149 | + } | ||
| 150 | + String replaceNull = request.getReplaceNull(); | ||
| 151 | + if (StringUtils.isNotEmpty(replaceNull)) { | ||
| 152 | + sb.append(" NULL ").append(QUOTES).append(replaceNull).append(QUOTES); | ||
| 153 | + } | ||
| 154 | + sb.append(" CSV "); | ||
| 155 | + boolean titleFlag = request.isTitleFlag(); | ||
| 156 | + if (titleFlag) { | ||
| 157 | + sb.append(" HEADER "); | ||
| 158 | + } | ||
| 159 | + String quote = request.getQuote(); | ||
| 160 | + if (StringUtils.isNotEmpty(quote)) { | ||
| 161 | + sb.append(" QUOTE ").append(QUOTES).append(quote).append(QUOTES); | ||
| 162 | + } | ||
| 163 | + String escape = request.getEscape(); | ||
| 164 | + if (StringUtils.isNotEmpty(escape)) { | ||
| 165 | + sb.append(" ESCAPE ").append(QUOTES).append(escape).append(QUOTES); | ||
| 166 | + } | ||
| 167 | + } | ||
| 168 | + String encoding = request.getEncoding(); | ||
| 169 | + if (StringUtils.isNotEmpty(encoding)) { | ||
| 170 | + sb.append(" ENCODING ").append(QUOTES).append(encoding).append(QUOTES); | ||
| 171 | + } | ||
| 172 | + sb.append(SEMICOLON); | ||
| 173 | + copyManager.copyOut(sb.toString(), fileOutputStream); | ||
| 174 | + log.info("ExportService exportTableData sb: " + sb); | ||
| 175 | + | ||
| 176 | + response.setContentType("application/octet-stream"); | ||
| 177 | + response.setHeader("Content-Disposition", URLEncoder.encode(fileName, StandardCharsets.UTF_8)); | ||
| 178 | + response.addHeader("Response-Type", "blob"); | ||
| 179 | + | ||
| 180 | + byte[] buffer = new byte[1024]; | ||
| 181 | + int i = bis.read(buffer); | ||
| 182 | + while (i != -1) { | ||
| 183 | + os.write(buffer, 0, i); | ||
| 184 | + i = bis.read(buffer); | ||
| 185 | + } | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + File file = new File(path); | ||
| 189 | + if (file.exists()) { | ||
| 190 | + file.delete(); | ||
| 191 | + } | ||
| 192 | + log.info("ExportService exportTableData end: "); | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + private void exportExcel(ExportRequest request, HttpServletResponse response) throws Exception { | ||
| 196 | + log.info("ExportService exportExcel request: " + request); | ||
| 197 | + try ( | ||
| 198 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 199 | + Statement statement = connection.createStatement(); | ||
| 200 | + XSSFWorkbook xssfWorkbook = new XSSFWorkbook(); | ||
| 201 | + OutputStream outputStream = response.getOutputStream() | ||
| 202 | + ) { | ||
| 203 | + StringBuilder columnSb = new StringBuilder(); | ||
| 204 | + List<String> columnList = request.getColumnList(); | ||
| 205 | + columnList.forEach(column -> { | ||
| 206 | + columnSb.append(column).append(COMMA); | ||
| 207 | + }); | ||
| 208 | + log.info("ExportService exportExcel columnSb: " + columnSb); | ||
| 209 | + | ||
| 210 | + String tableName = request.getTableName(); | ||
| 211 | + String sql = SELECT_KEYWORD_SQL + columnSb.deleteCharAt(columnSb.length() - 1) + FROM_KEYWORD_SQL | ||
| 212 | + + request.getSchema() + POINT + tableName + SEMICOLON; | ||
| 213 | + ResultSet resultSet = statement.executeQuery(sql); | ||
| 214 | + log.info("ExportService exportExcel sql: " + sql); | ||
| 215 | + | ||
| 216 | + int index = 0; | ||
| 217 | + XSSFSheet sheet = xssfWorkbook.createSheet(tableName); | ||
| 218 | + XSSFRow row = sheet.createRow(index); | ||
| 219 | + for (int i = 0; i < columnList.size(); i++) { | ||
| 220 | + row.createCell(i).setCellValue(columnList.get(i)); | ||
| 221 | + } | ||
| 222 | + while (resultSet.next()) { | ||
| 223 | + row = sheet.createRow(++index); | ||
| 224 | + for (int i = 0; i < columnList.size(); i++) { | ||
| 225 | + row.createCell(i).setCellValue(resultSet.getString(columnList.get(i))); | ||
| 226 | + } | ||
| 227 | + } | ||
| 228 | + log.info("ExportService exportExcel hssfSheet: " + sheet.getLastRowNum()); | ||
| 229 | + | ||
| 230 | + String fileName = getDataFileName(tableName) + ".xlsx"; | ||
| 231 | + if (request.getFileType().equals("Excel(xls)")) { | ||
| 232 | + fileName = getDataFileName(tableName) + ".xls"; | ||
| 233 | + } | ||
| 234 | + log.info("ExportService exportExcel fileName: " + fileName); | ||
| 235 | + | ||
| 236 | + response.reset(); | ||
| 237 | + response.setContentType("application/octet-stream"); | ||
| 238 | + response.setHeader("Content-Disposition", URLEncoder.encode(fileName, StandardCharsets.UTF_8)); | ||
| 239 | + response.addHeader("Response-Type", "blob"); | ||
| 240 | + response.setCharacterEncoding(request.getEncoding()); | ||
| 241 | + xssfWorkbook.write(outputStream); | ||
| 242 | + outputStream.flush(); | ||
| 243 | + } | ||
| 244 | + log.info("ExportService exportExcel end: "); | ||
| 245 | + } | ||
| 246 | + | ||
| 247 | + | ||
| 248 | + public void exportFunctionDdl(ExportRequest request, HttpServletResponse response) throws Exception { | ||
| 249 | + String fileName = getFileName(false, FUNCTION, request.getFunctionMap()); | ||
| 250 | + DebugUtils.exportFile(fileName, getFunctionDdl(request), response); | ||
| 251 | + } | ||
| 252 | + | ||
| 253 | + | ||
| 254 | + public void exportViewDdl(ExportRequest request, HttpServletResponse response) throws Exception { | ||
| 255 | + String fileName = getFileName(false, VIEW, request.getViewList()); | ||
| 256 | + DebugUtils.exportFile(fileName, getViewDdl(request), response); | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + | ||
| 260 | + public void exportSequenceDdl(ExportRequest request, HttpServletResponse response) throws Exception { | ||
| 261 | + String fileName = getFileName(request.isDataFlag(), SEQUENCE, request.getSequenceList()); | ||
| 262 | + DebugUtils.exportFile(fileName, getSequenceDdl(request), response); | ||
| 263 | + } | ||
| 264 | + | ||
| 265 | + | ||
| 266 | + public void exportSchemaDdl(ExportRequest request, HttpServletResponse response) throws Exception { | ||
| 267 | + log.info("ExportService exportSchemaDdl request: " + request); | ||
| 268 | + String uuid = request.getUuid(); | ||
| 269 | + boolean dataFlag = request.isDataFlag(); | ||
| 270 | + List<String> schemaList = request.getSchemaList(); | ||
| 271 | + StringBuilder sb = new StringBuilder(); | ||
| 272 | + | ||
| 273 | + for (String schema : schemaList) { | ||
| 274 | + DatabaseMetaarrayIdSchemaQuery query = new DatabaseMetaarrayIdSchemaQuery(); | ||
| 275 | + query.setUuid(uuid); | ||
| 276 | + query.setSchema(schema); | ||
| 277 | + DataListDTO dataList = dbConnectionService.schemaObjectList(query).get(0); | ||
| 278 | + log.info("ExportService exportSchemaDdl dataList: " + dataList); | ||
| 279 | + | ||
| 280 | + List<String> tableList = parseList(dataList.getTable(), NAME); | ||
| 281 | + List<String> strings = parseList(dataList.getFun_pro(), OID); | ||
| 282 | + List<Integer> functionList = strings.stream().map(Integer::valueOf).collect(Collectors.toList()); | ||
| 283 | + List<String> viewList = parseList(dataList.getView(), NAME); | ||
| 284 | + List<String> sequenceList = parseList(dataList.getSequence(), NAME); | ||
| 285 | + | ||
| 286 | + ExportRequest exportRequest = new ExportRequest(); | ||
| 287 | + exportRequest.setDataFlag(dataFlag); | ||
| 288 | + exportRequest.setSchema(schema); | ||
| 289 | + exportRequest.setUuid(uuid); | ||
| 290 | + exportRequest.setTableList(tableList); | ||
| 291 | + exportRequest.setFunctionMap(functionList); | ||
| 292 | + exportRequest.setViewList(viewList); | ||
| 293 | + exportRequest.setSequenceList(sequenceList); | ||
| 294 | + | ||
| 295 | + sb.append(addHeader(false, schema, SCHEMA, schema)).append(CREATE_SCHEMA_SQL).append(schema) | ||
| 296 | + .append(getTableDdl(exportRequest)).append(getFunctionDdl(exportRequest)) | ||
| 297 | + .append(getViewDdl(exportRequest)).append(getSequenceDdl(exportRequest)); | ||
| 298 | + } | ||
| 299 | + | ||
| 300 | + String fileName = getFileName(dataFlag, SCHEMA, schemaList); | ||
| 301 | + DebugUtils.exportFile(fileName, sb.toString(), response); | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + private String getTableDdl(ExportRequest request) throws Exception { | ||
| 305 | + log.info("ExportService getTableDdl request: " + request); | ||
| 306 | + StringBuilder sb = new StringBuilder(); | ||
| 307 | + List<String> tableList = request.getTableList(); | ||
| 308 | + try ( | ||
| 309 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 310 | + Statement statement = connection.createStatement() | ||
| 311 | + ) { | ||
| 312 | + for (String table : tableList) { | ||
| 313 | + ResultSet resultSet = statement.executeQuery(String.format(TABLE_DDL_SQL, request.getSchema(), table)); | ||
| 314 | + if (resultSet.next()) { | ||
| 315 | + String tableDef = resultSet.getString(PG_GET_TABLEDEF); | ||
| 316 | + log.info("ExportService getTableDdl tableDef: " + tableDef); | ||
| 317 | + if (StringUtils.isEmpty(tableDef)) { | ||
| 318 | + throw new CustomException(LocaleString.transLanguage("2007")); | ||
| 319 | + } | ||
| 320 | + sb.append(addHeader(false, table, TABLE, request.getSchema())); | ||
| 321 | + sb.append(tableDef); | ||
| 322 | + | ||
| 323 | + if (request.isDataFlag()) { | ||
| 324 | + String tableData = getTableData(statement, request.getSchema(), table); | ||
| 325 | + if (StringUtils.isNotEmpty(tableData)) { | ||
| 326 | + sb.append(addHeader(true, table, TABLE, request.getSchema())).append(tableData); | ||
| 327 | + } | ||
| 328 | + } | ||
| 329 | + } | ||
| 330 | + } | ||
| 331 | + } | ||
| 332 | + log.info("ExportService getTableDdl sb: " + sb); | ||
| 333 | + return sb.toString(); | ||
| 334 | + } | ||
| 335 | + | ||
| 336 | + private String getFunctionDdl(ExportRequest request) throws Exception { | ||
| 337 | + log.info("ExportService getFunctionDdl request: " + request); | ||
| 338 | + StringBuilder sb = new StringBuilder(); | ||
| 339 | + try ( | ||
| 340 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 341 | + Statement statement = connection.createStatement() | ||
| 342 | + ) { | ||
| 343 | + List<Integer> functionList = request.getFunctionMap(); | ||
| 344 | + for (Integer oid : functionList) { | ||
| 345 | + String name = Strings.EMPTY; | ||
| 346 | + ResultSet nameResultSet = statement.executeQuery(String.format(PROC_SQL, oid)); | ||
| 347 | + if (nameResultSet.next()) { | ||
| 348 | + name = nameResultSet.getString(PRO_NAME); | ||
| 349 | + } | ||
| 350 | + ResultSet defResultSet = statement.executeQuery(String.format(QUERY_DEF_SQL, oid)); | ||
| 351 | + if (defResultSet.next()) { | ||
| 352 | + String definition = defResultSet.getString(DEFINITION); | ||
| 353 | + if (StringUtils.isEmpty(definition)) { | ||
| 354 | + throw new CustomException(LocaleString.transLanguage("2015")); | ||
| 355 | + } | ||
| 356 | + sb.append(addHeader(false, name, FUNCTION, request.getSchema())); | ||
| 357 | + sb.append(DebugUtils.sqlHandleAfter(definition)); | ||
| 358 | + } | ||
| 359 | + } | ||
| 360 | + } | ||
| 361 | + log.info("ExportService getFunctionDdl sb: " + sb); | ||
| 362 | + return sb.toString(); | ||
| 363 | + } | ||
| 364 | + | ||
| 365 | + private String getViewDdl(ExportRequest request) throws Exception { | ||
| 366 | + log.info("ExportService getViewDdl request: " + request); | ||
| 367 | + StringBuilder sb = new StringBuilder(); | ||
| 368 | + String uuid = request.getUuid(); | ||
| 369 | + String schema = request.getSchema(); | ||
| 370 | + | ||
| 371 | + List<String> viewList = request.getViewList(); | ||
| 372 | + for (String name : viewList) { | ||
| 373 | + DatabaseViewDdlDTO dto = new DatabaseViewDdlDTO(); | ||
| 374 | + dto.setUuid(uuid); | ||
| 375 | + dto.setSchema(schema); | ||
| 376 | + dto.setViewName(name); | ||
| 377 | + | ||
| 378 | + String ddl = viewService.returnViewDDL(dto); | ||
| 379 | + sb.append(addHeader(false, name, VIEW, schema)); | ||
| 380 | + sb.append(ddl); | ||
| 381 | + } | ||
| 382 | + log.info("ExportService getViewDdl sb: " + sb); | ||
| 383 | + return sb.toString(); | ||
| 384 | + } | ||
| 385 | + | ||
| 386 | + private String getSequenceDdl(ExportRequest request) throws Exception { | ||
| 387 | + log.info("ExportService getSequenceDdl request: " + request); | ||
| 388 | + StringBuilder sb = new StringBuilder(); | ||
| 389 | + String uuid = request.getUuid(); | ||
| 390 | + String schema = request.getSchema(); | ||
| 391 | + | ||
| 392 | + List<String> sequenceList = request.getSequenceList(); | ||
| 393 | + for (String name : sequenceList) { | ||
| 394 | + DatabaseSequenceDdlDTO dto = new DatabaseSequenceDdlDTO(); | ||
| 395 | + dto.setUuid(uuid); | ||
| 396 | + dto.setSchema(schema); | ||
| 397 | + dto.setSequenceName(name); | ||
| 398 | + | ||
| 399 | + String ddl = sequenceService.returnSequenceDDL(dto); | ||
| 400 | + sb.append(addHeader(false, name, SEQUENCE, schema)); | ||
| 401 | + sb.append(ddl); | ||
| 402 | + | ||
| 403 | + if (request.isDataFlag()) { | ||
| 404 | + sb.append(addHeader(true, name, SEQUENCE, schema)); | ||
| 405 | + sb.append(getSequenceData(request, name)); | ||
| 406 | + } | ||
| 407 | + } | ||
| 408 | + log.info("ExportService getSequenceDdl sb: " + sb); | ||
| 409 | + return sb.toString(); | ||
| 410 | + } | ||
| 411 | + | ||
| 412 | + private List<String> parseList(List<Map<String, String>> listMap, String key) { | ||
| 413 | + log.info("ExportService parseList key: " + key); | ||
| 414 | + List<String> list = new ArrayList<>(); | ||
| 415 | + for (Map<String, String> map : listMap) { | ||
| 416 | + list.add(map.get(key)); | ||
| 417 | + } | ||
| 418 | + log.info("ExportService parseList list: " + list); | ||
| 419 | + return list; | ||
| 420 | + } | ||
| 421 | + | ||
| 422 | + private String getFileName(boolean flag, String type, List list) { | ||
| 423 | + StringBuilder sb = new StringBuilder(); | ||
| 424 | + if (flag) { | ||
| 425 | + sb.append("ddl_data_"); | ||
| 426 | + } else { | ||
| 427 | + sb.append("ddl_"); | ||
| 428 | + } | ||
| 429 | + sb.append(type).append(UNDERLINE); | ||
| 430 | + if (list.size() == 1) { | ||
| 431 | + sb.append(list.get(0)).append(UNDERLINE); | ||
| 432 | + } | ||
| 433 | + | ||
| 434 | + SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); | ||
| 435 | + sb.append(format.format(new Date())).append(".sql"); | ||
| 436 | + log.info("ExportService getFileName sb: " + sb); | ||
| 437 | + return sb.toString(); | ||
| 438 | + } | ||
| 439 | + | ||
| 440 | + private String getDataFileName(String tableName) { | ||
| 441 | + StringBuilder sb = new StringBuilder(); | ||
| 442 | + sb.append("data_").append(tableName).append(UNDERLINE); | ||
| 443 | + SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); | ||
| 444 | + sb.append(format.format(new Date())); | ||
| 445 | + log.info("ExportService getFileName sb: " + sb); | ||
| 446 | + return sb.toString(); | ||
| 447 | + } | ||
| 448 | + | ||
| 449 | + private String addHeader(boolean flag, String name, String type, String schema) { | ||
| 450 | + String str = LF + LF + "-- "; | ||
| 451 | + if (flag) { | ||
| 452 | + str = str + "Data for "; | ||
| 453 | + } | ||
| 454 | + str = str + "Name: " + name + "; Type: " + type + "; Schema: " + schema + ";" + LF + LF; | ||
| 455 | + return str; | ||
| 456 | + } | ||
| 457 | + | ||
| 458 | + private String getTableData(Statement statement, String schema, String table) throws SQLException { | ||
| 459 | + log.info("ExportService getTableData schema--table: " + schema + "--" + table); | ||
| 460 | + StringBuilder columnSb = new StringBuilder(); | ||
| 461 | + columnSb.append(LF + "INSERT INTO ").append(schema).append(POINT).append(table).append(LEFT_BRACKET); | ||
| 462 | + | ||
| 463 | + ResultSet resultSet = statement.executeQuery(TABLE_DATA_SQL + schema + POINT + table + SEMICOLON); | ||
| 464 | + List<String> columnList = new ArrayList<>(); | ||
| 465 | + ResultSetMetaData metaData = resultSet.getMetaData(); | ||
| 466 | + for (int i = 0; i < metaData.getColumnCount(); i++) { | ||
| 467 | + String columnName = metaData.getColumnName(i + 1); | ||
| 468 | + columnList.add(columnName); | ||
| 469 | + columnSb.append(columnName); | ||
| 470 | + if (i != metaData.getColumnCount() - 1) { | ||
| 471 | + columnSb.append(COMMA); | ||
| 472 | + } else { | ||
| 473 | + columnSb.append(RIGHT_BRACKET).append(" VALUES "); | ||
| 474 | + } | ||
| 475 | + } | ||
| 476 | + log.info("ExportService getTableData columnList: " + columnList); | ||
| 477 | + | ||
| 478 | + StringBuilder sb = new StringBuilder(); | ||
| 479 | + while (resultSet.next()) { | ||
| 480 | + sb.append(columnSb).append(LEFT_BRACKET); | ||
| 481 | + for (int i = 0; i < columnList.size(); i++) { | ||
| 482 | + String value = resultSet.getString(columnList.get(i)); | ||
| 483 | + int columnType = metaData.getColumnType(i + 1); | ||
| 484 | + String columnTypeName = metaData.getColumnTypeName(i + 1); | ||
| 485 | + | ||
| 486 | + sb.append(typeChange(value, columnType, columnTypeName)); | ||
| 487 | + if (i != columnList.size() - 1) { | ||
| 488 | + sb.append(COMMA); | ||
| 489 | + } else { | ||
| 490 | + sb.append(RIGHT_BRACKET + SEMICOLON); | ||
| 491 | + } | ||
| 492 | + } | ||
| 493 | + } | ||
| 494 | + log.info("ExportService getTableData sb: " + sb); | ||
| 495 | + return sb.toString(); | ||
| 496 | + } | ||
| 497 | + | ||
| 498 | + private String getSequenceData(ExportRequest request, String name) throws Exception { | ||
| 499 | + log.info("ExportService getSequenceData request: " + request); | ||
| 500 | + String schema = request.getSchema(); | ||
| 501 | + boolean called = false; | ||
| 502 | + long nextVal = 0; | ||
| 503 | + long maxValue = 0; | ||
| 504 | + long minValue = 0; | ||
| 505 | + try ( | ||
| 506 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 507 | + Statement statement = connection.createStatement() | ||
| 508 | + ) { | ||
| 509 | + ResultSet resultSet = statement.executeQuery(String.format(SEQUENCE_SQL, schema + POINT + name)); | ||
| 510 | + while (resultSet.next()) { | ||
| 511 | + maxValue = resultSet.getLong(MAX_VALUE); | ||
| 512 | + minValue = resultSet.getLong(MIN_VALUE); | ||
| 513 | + called = resultSet.getBoolean(IS_CALLED); | ||
| 514 | + } | ||
| 515 | + | ||
| 516 | + ResultSet nextResultSet = statement.executeQuery(String.format(NEXT_VALUE_SQL, schema + POINT + name)); | ||
| 517 | + while (nextResultSet.next()) { | ||
| 518 | + nextVal = nextResultSet.getInt(NEXT_VALUE); | ||
| 519 | + } | ||
| 520 | + log.info("ExportService getSequenceData nextVal: " + nextVal); | ||
| 521 | + } catch (SQLException exception) { | ||
| 522 | + String msg = exception.getMessage(); | ||
| 523 | + if (msg.contains("Sequence reached maximum value")) { | ||
| 524 | + nextVal = maxValue; | ||
| 525 | + called = true; | ||
| 526 | + } | ||
| 527 | + if (msg.contains("Sequence reached minimum value")) { | ||
| 528 | + nextVal = minValue; | ||
| 529 | + called = true; | ||
| 530 | + } | ||
| 531 | + } | ||
| 532 | + | ||
| 533 | + String ddl = String.format(SET_VALUE_SQL, name, nextVal, called); | ||
| 534 | + log.info("ExportService getSequenceData ddl: " + ddl); | ||
| 535 | + return ddl; | ||
| 536 | + } | ||
| 537 | + | ||
| 538 | + private String typeChange(String value, int columnType, String columnTypeName) { | ||
| 539 | + String newValue; | ||
| 540 | + switch (columnType) { | ||
| 541 | + case Types.NULL: { | ||
| 542 | + newValue = null; | ||
| 543 | + break; | ||
| 544 | + } | ||
| 545 | + case Types.BIGINT: | ||
| 546 | + case Types.TINYINT: | ||
| 547 | + case Types.NUMERIC: | ||
| 548 | + case Types.DECIMAL: | ||
| 549 | + case Types.INTEGER: | ||
| 550 | + case Types.SMALLINT: | ||
| 551 | + case Types.FLOAT: | ||
| 552 | + case Types.REAL: { | ||
| 553 | + newValue = value; | ||
| 554 | + break; | ||
| 555 | + } | ||
| 556 | + case Types.DOUBLE: { | ||
| 557 | + if ("money".equalsIgnoreCase(columnTypeName)) { | ||
| 558 | + newValue = QUOTES + value + QUOTES; | ||
| 559 | + } else { | ||
| 560 | + newValue = value; | ||
| 561 | + } | ||
| 562 | + break; | ||
| 563 | + } | ||
| 564 | + case Types.BIT: { | ||
| 565 | + if ("bool".equalsIgnoreCase(columnTypeName)) { | ||
| 566 | + Boolean boolValue = BooleanUtils.toBooleanObject(value); | ||
| 567 | + if (boolValue != null) { | ||
| 568 | + newValue = boolValue.toString(); | ||
| 569 | + } else { | ||
| 570 | + newValue = value; | ||
| 571 | + } | ||
| 572 | + } else { | ||
| 573 | + if ("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value)) { | ||
| 574 | + if ("true".equalsIgnoreCase(value)) { | ||
| 575 | + newValue = QUOTES + "1" + QUOTES; | ||
| 576 | + } else { | ||
| 577 | + newValue = QUOTES + "0" + QUOTES; | ||
| 578 | + } | ||
| 579 | + } else { | ||
| 580 | + newValue = QUOTES + value + QUOTES; | ||
| 581 | + } | ||
| 582 | + } | ||
| 583 | + break; | ||
| 584 | + } | ||
| 585 | + default: { | ||
| 586 | + newValue = QUOTES + value + QUOTES; | ||
| 587 | + break; | ||
| 588 | + } | ||
| 589 | + } | ||
| 590 | + return newValue; | ||
| 591 | + } | ||
| 592 | +} | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/sql/MetaDataByJdbcServiceImpl.java+14-7
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.service.MetaDataByJdbcService; | 7 | import com.nctigba.datastudio.service.MetaDataByJdbcService; |
| @@ -8,8 +12,6 @@ import org.springframework.stereotype.Service; | |||
| 8 | import java.sql.Connection; | 12 | import java.sql.Connection; |
| 9 | import java.sql.ResultSet; | 13 | import java.sql.ResultSet; |
| 10 | import java.sql.Statement; | 14 | import java.sql.Statement; |
| 11 | -import java.util.regex.Matcher; | ||
| 12 | -import java.util.regex.Pattern; | ||
| 13 | 15 | ||
| 14 | /** | 16 | /** |
| 15 | * MetaDataByJdbcServiceImpl | 17 | * MetaDataByJdbcServiceImpl |
| @@ -22,7 +24,9 @@ public class MetaDataByJdbcServiceImpl implements MetaDataByJdbcService { | |||
| 22 | 24 | ||
| 23 | 25 | ||
| 24 | public void testQuerySQL(String jdbcUrl, String userName, String password, String sql) { | 26 | public void testQuerySQL(String jdbcUrl, String userName, String password, String sql) { |
| 25 | - try (Connection connection = ConnectionUtils.connectGet(jdbcUrl, userName, password)) { | 27 | + try ( |
| 28 | + Connection connection = ConnectionUtils.connectGet(jdbcUrl, userName, password) | ||
| 29 | + ) { | ||
| 26 | connection.prepareStatement(sql); | 30 | connection.prepareStatement(sql); |
| 27 | } catch (Exception e) { | 31 | } catch (Exception e) { |
| 28 | throw new CustomException(e.getMessage()); | 32 | throw new CustomException(e.getMessage()); |
| @@ -31,14 +35,17 @@ public class MetaDataByJdbcServiceImpl implements MetaDataByJdbcService { | |||
| 31 | 35 | ||
| 32 | 36 | ||
| 33 | public String versionSQL(String jdbcUrl, String userName, String password, String sql) { | 37 | public String versionSQL(String jdbcUrl, String userName, String password, String sql) { |
| 34 | - try (Connection connection = ConnectionUtils.connectGet(jdbcUrl, userName, password); | 38 | + try ( |
| 35 | - Statement statement = connection.createStatement();) { | 39 | + Connection connection = ConnectionUtils.connectGet(jdbcUrl, userName, password); |
| 36 | - ResultSet resultSet = statement.executeQuery(sql); | 40 | + Statement statement = connection.createStatement(); |
| 41 | + ResultSet resultSet = statement.executeQuery(sql) | ||
| 42 | + ) { | ||
| 43 | + | ||
| 37 | resultSet.next(); | 44 | resultSet.next(); |
| 38 | String edition = resultSet.getNString(1); | 45 | String edition = resultSet.getNString(1); |
| 39 | StringBuilder sb = new StringBuilder(); | 46 | StringBuilder sb = new StringBuilder(); |
| 40 | boolean ba = false; | 47 | boolean ba = false; |
| 41 | - for (var c : edition.toCharArray()) { | 48 | + for (char c : edition.toCharArray()) { |
| 42 | if (c == ')') break; | 49 | if (c == ')') break; |
| 43 | if (ba) sb.append(c); | 50 | if (ba) sb.append(c); |
| 44 | if (c == '(') { | 51 | if (c == '(') { |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/sql/QueryMetaArrayServiceImpl.java+73-97
| @@ -1,5 +1,10 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 7 | +import com.nctigba.datastudio.compatible.GainObjectSQLService; | ||
| 3 | import com.nctigba.datastudio.config.ConnectionConfig; | 8 | import com.nctigba.datastudio.config.ConnectionConfig; |
| 4 | import com.nctigba.datastudio.model.query.DatabaseMetaarrayColumnQuery; | 9 | import com.nctigba.datastudio.model.query.DatabaseMetaarrayColumnQuery; |
| 5 | import com.nctigba.datastudio.model.query.DatabaseMetaarrayQuery; | 10 | import com.nctigba.datastudio.model.query.DatabaseMetaarrayQuery; |
| @@ -10,6 +15,7 @@ import org.opengauss.admin.common.exception.CustomException; | |||
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
| 12 | 17 | ||
| 18 | +import javax.annotation.Resource; | ||
| 13 | import java.sql.Connection; | 19 | import java.sql.Connection; |
| 14 | import java.sql.ResultSet; | 20 | import java.sql.ResultSet; |
| 15 | import java.sql.Statement; | 21 | import java.sql.Statement; |
| @@ -18,16 +24,7 @@ import java.util.HashMap; | |||
| 18 | import java.util.List; | 24 | import java.util.List; |
| 19 | import java.util.Map; | 25 | import java.util.Map; |
| 20 | 26 | ||
| 21 | -import static com.nctigba.datastudio.constants.SqlConstants.GET_DATABASE_SQL; | 27 | +import static com.nctigba.datastudio.dao.ConnectionMapDAO.conMap; |
| 22 | -import static com.nctigba.datastudio.constants.SqlConstants.GET_SCHEMA_NAME_SQL; | ||
| 23 | -import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_PARENTHESES_SEMICOLON; | ||
| 24 | -import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_SEMICOLON; | ||
| 25 | -import static com.nctigba.datastudio.constants.SqlConstants.SELECT_COLUMN_SQL; | ||
| 26 | -import static com.nctigba.datastudio.constants.SqlConstants.SELECT_COLUMN_WHERE_SQL; | ||
| 27 | -import static com.nctigba.datastudio.constants.SqlConstants.SELECT_FUNCTION_SQL; | ||
| 28 | -import static com.nctigba.datastudio.constants.SqlConstants.SELECT_OBJECT_SQL; | ||
| 29 | -import static com.nctigba.datastudio.constants.SqlConstants.SELECT_OBJECT_WHERE_IN_SQL; | ||
| 30 | -import static com.nctigba.datastudio.constants.SqlConstants.SELECT_OBJECT_WHERE_SQL; | ||
| 31 | 28 | ||
| 32 | 29 | ||
| 33 | 30 | ||
| @@ -36,110 +33,89 @@ public class QueryMetaArrayServiceImpl implements QueryMetaArrayService { | |||
| 36 | private ConnectionConfig connectionConfig; | 33 | private ConnectionConfig connectionConfig; |
| 37 | 34 | ||
| 38 | 35 | ||
| 39 | - public List<String> databaseList(String uuid) { | 36 | + private Map<String, GainObjectSQLService> gainObjectSQLService; |
| 40 | - log.info("schemaList request is: " + uuid); | 37 | + |
| 41 | - String sql; | 38 | + @Resource |
| 42 | - List<String> databaseList = new ArrayList<>(); | 39 | + public void setGainObjectSQLService(List<GainObjectSQLService> SQLServiceList) { |
| 43 | - try { | 40 | + gainObjectSQLService = new HashMap<>(); |
| 44 | - Connection connection = connectionConfig.connectDatabase(uuid); | 41 | + for (GainObjectSQLService s : SQLServiceList) { |
| 45 | - Statement statement = connection.createStatement(); | 42 | + gainObjectSQLService.put(s.type(), s); |
| 46 | - sql = GET_DATABASE_SQL; | ||
| 47 | - ResultSet resultSet = statement.executeQuery(sql); | ||
| 48 | - while (resultSet.next()) { | ||
| 49 | - databaseList.add(resultSet.getString("datname")); | ||
| 50 | - } | ||
| 51 | - log.info("schemaList response is: " + databaseList); | ||
| 52 | - return databaseList; | ||
| 53 | - } catch (Exception e) { | ||
| 54 | - e.printStackTrace(); | ||
| 55 | - throw new CustomException(e.getMessage(),e); | ||
| 56 | } | 43 | } |
| 57 | } | 44 | } |
| 58 | 45 | ||
| 59 | - public List<String> schemaList(DatabaseMetaarraySchemaQuery request) throws Exception { | 46 | + public List<String> databaseList(String uuid) throws Exception { |
| 60 | - log.info("schemaList request is: " + request); | 47 | + log.info("schemaList request is: " + uuid); |
| 61 | - List<String> schemaList = new ArrayList<>(); | 48 | + String sql; |
| 62 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 49 | + List<String> databaseList = new ArrayList<>(); |
| 63 | - Statement statement = connection.createStatement(); | 50 | + try ( |
| 64 | - ResultSet resultSet = statement.executeQuery(GET_SCHEMA_NAME_SQL);){ | 51 | + Connection connection = connectionConfig.connectDatabase(uuid); |
| 65 | - while (resultSet.next()) { | 52 | + Statement statement = connection.createStatement() |
| 66 | - schemaList.add(resultSet.getString("schema_name")); | 53 | + ) { |
| 54 | + sql = gainObjectSQLService.get(conMap.get(uuid).getType()).databaseList(); | ||
| 55 | + try ( | ||
| 56 | + ResultSet resultSet = statement.executeQuery(sql) | ||
| 57 | + ) { | ||
| 58 | + while (resultSet.next()) { | ||
| 59 | + databaseList.add(resultSet.getString("datname")); | ||
| 60 | + } | ||
| 61 | + log.info("schemaList response is: " + databaseList); | ||
| 62 | + return databaseList; | ||
| 63 | + | ||
| 64 | + } catch (Exception e) { | ||
| 65 | + log.info(e.getMessage()); | ||
| 66 | + throw new CustomException(e.getMessage(), e); | ||
| 67 | } | 67 | } |
| 68 | - log.info("schemaList response is: " + schemaList); | ||
| 69 | - return schemaList; | ||
| 70 | } catch (Exception e) { | 68 | } catch (Exception e) { |
| 71 | - e.printStackTrace(); | 69 | + log.info(e.getMessage()); |
| 72 | - throw new CustomException(e.getMessage(),e); | 70 | + throw new CustomException(e.getMessage(), e); |
| 73 | } | 71 | } |
| 74 | } | 72 | } |
| 75 | 73 | ||
| 74 | + public List<Map<String, String>> schemaList(DatabaseMetaarraySchemaQuery request) throws Exception { | ||
| 75 | + log.info("schemaList request is: " + request); | ||
| 76 | + return gainObjectSQLService.get(conMap.get(request.getUuid()).getType()).schemaList(request); | ||
| 77 | + } | ||
| 78 | + | ||
| 76 | public List<String> objectList(DatabaseMetaarrayQuery request) throws Exception { | 79 | public List<String> objectList(DatabaseMetaarrayQuery request) throws Exception { |
| 77 | log.info("objectList request is: " + request); | 80 | log.info("objectList request is: " + request); |
| 78 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 81 | + List<String> objectList = gainObjectSQLService.get(conMap.get(request.getUuid()).getType()).objectList(request); |
| 79 | - Statement statement = connection.createStatement();){ | 82 | + return objectList; |
| 80 | - List<String> objectList = new ArrayList<>(); | ||
| 81 | - if (request.getObjectType().equals("ALL")) { | ||
| 82 | - try (ResultSet resultSet = statement.executeQuery(SELECT_FUNCTION_SQL + request.getSchema() + QUOTES_PARENTHESES_SEMICOLON);) { | ||
| 83 | - while (resultSet.next()) { | ||
| 84 | - objectList.add(resultSet.getString("proname")); | ||
| 85 | - } | ||
| 86 | - } | ||
| 87 | - try (ResultSet resultSetView = statement.executeQuery(SELECT_OBJECT_SQL + request.getSchema() + SELECT_OBJECT_WHERE_IN_SQL + "v','m" + QUOTES_PARENTHESES_SEMICOLON);) { | ||
| 88 | - while (resultSetView.next()) { | ||
| 89 | - objectList.add(resultSetView.getString("relname")); | ||
| 90 | - } | ||
| 91 | - } | ||
| 92 | - try (ResultSet resultSetTable = statement.executeQuery(SELECT_OBJECT_SQL + request.getSchema() + SELECT_OBJECT_WHERE_SQL + "r" + QUOTES_SEMICOLON);) { | ||
| 93 | - while (resultSetTable.next()) { | ||
| 94 | - objectList.add(resultSetTable.getString("relname")); | ||
| 95 | - } | ||
| 96 | - } | ||
| 97 | - return objectList; | ||
| 98 | - } else if (request.getObjectType().equals("FUN_PRO")) { | ||
| 99 | - try (ResultSet resultSet = statement.executeQuery(SELECT_FUNCTION_SQL + request.getSchema() + QUOTES_PARENTHESES_SEMICOLON);) { | ||
| 100 | - while (resultSet.next()) { | ||
| 101 | - objectList.add(resultSet.getString("proname")); | ||
| 102 | - } | ||
| 103 | - return objectList; | ||
| 104 | - } | ||
| 105 | - } else if (request.getObjectType().equals("VIEW")) { | ||
| 106 | - try (ResultSet resultSet = statement.executeQuery(SELECT_OBJECT_SQL + request.getSchema() + SELECT_OBJECT_WHERE_IN_SQL + "v','m" + QUOTES_PARENTHESES_SEMICOLON);) { | ||
| 107 | - while (resultSet.next()) { | ||
| 108 | - objectList.add(resultSet.getString("relname")); | ||
| 109 | - } | ||
| 110 | - return objectList; | ||
| 111 | - } | ||
| 112 | - } else { | ||
| 113 | - try (ResultSet resultSet = statement.executeQuery(SELECT_OBJECT_SQL + request.getSchema() + SELECT_OBJECT_WHERE_SQL + request.getObjectType() + QUOTES_SEMICOLON);) { | ||
| 114 | - while (resultSet.next()) { | ||
| 115 | - objectList.add(resultSet.getString("relname")); | ||
| 116 | - } | ||
| 117 | - log.info("objectList response is: " + objectList); | ||
| 118 | - return objectList; | ||
| 119 | - } | ||
| 120 | - } | ||
| 121 | - } catch (Exception e) { | ||
| 122 | - e.printStackTrace(); | ||
| 123 | - throw new CustomException(e.getMessage(),e); | ||
| 124 | - } | ||
| 125 | } | 83 | } |
| 126 | 84 | ||
| 127 | public List<String> tableColumnList(DatabaseMetaarrayColumnQuery request) throws Exception { | 85 | public List<String> tableColumnList(DatabaseMetaarrayColumnQuery request) throws Exception { |
| 128 | log.info("tableColumnList request is: " + request); | 86 | log.info("tableColumnList request is: " + request); |
| 129 | - String sql; | 87 | + List<String> columnList = gainObjectSQLService.get(conMap.get(request.getUuid()).getType()).tableColumnList( |
| 130 | - List<String> columnList = new ArrayList<>(); | 88 | + request); |
| 131 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 89 | + return columnList; |
| 132 | - Statement statement = connection.createStatement(); | 90 | + } |
| 133 | - ResultSet resultSet = statement.executeQuery(SELECT_COLUMN_SQL + request.getSchema() + SELECT_COLUMN_WHERE_SQL + request.getObjectName() + QUOTES_SEMICOLON);){ | 91 | + |
| 92 | + public List<String> baseTypeList(String uuid) throws Exception { | ||
| 93 | + try ( | ||
| 94 | + Connection connection = connectionConfig.connectDatabase(uuid); | ||
| 95 | + Statement statement = connection.createStatement(); | ||
| 96 | + ResultSet resultSet = statement.executeQuery( | ||
| 97 | + gainObjectSQLService.get(conMap.get(uuid).getType()).baseTypeListSQL()) | ||
| 98 | + ) { | ||
| 99 | + List<String> columnList = new ArrayList<>(); | ||
| 134 | while (resultSet.next()) { | 100 | while (resultSet.next()) { |
| 135 | - columnList.add(resultSet.getString("column_name")); | 101 | + columnList.add(resultSet.getString("type")); |
| 136 | } | 102 | } |
| 137 | - log.info("tableColumnList response is: " + columnList); | ||
| 138 | return columnList; | 103 | return columnList; |
| 139 | - } catch (Exception e) { | ||
| 140 | - e.printStackTrace(); | ||
| 141 | - throw new CustomException(e.getMessage(),e); | ||
| 142 | } | 104 | } |
| 143 | } | 105 | } |
| 144 | 106 | ||
| 145 | -} | 107 | + public List<String> tablespaceList(String uuid) throws Exception { |
| 108 | + try ( | ||
| 109 | + Connection connection = connectionConfig.connectDatabase(uuid); | ||
| 110 | + Statement statement = connection.createStatement(); | ||
| 111 | + ResultSet resultSet = statement.executeQuery( | ||
| 112 | + gainObjectSQLService.get(conMap.get(uuid).getType()).tablespaceListSQL()) | ||
| 113 | + ) { | ||
| 114 | + List<String> columnList = new ArrayList<>(); | ||
| 115 | + while (resultSet.next()) { | ||
| 116 | + columnList.add(resultSet.getString(1)); | ||
| 117 | + } | ||
| 118 | + return columnList; | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | +} | ||
Aplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/sql/SchemaManagerServiceImpl.java+147-0
| @@ -0,0 +1,147 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 5 | +package com.nctigba.datastudio.service.impl.sql; | ||
| 6 | + | ||
| 7 | +import com.nctigba.datastudio.config.ConnectionConfig; | ||
| 8 | +import com.nctigba.datastudio.model.query.SchemaManagerRequest; | ||
| 9 | +import com.nctigba.datastudio.service.SchemaManagerService; | ||
| 10 | +import lombok.extern.slf4j.Slf4j; | ||
| 11 | +import org.apache.commons.lang3.StringUtils; | ||
| 12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 13 | +import org.springframework.stereotype.Service; | ||
| 14 | + | ||
| 15 | +import java.sql.Connection; | ||
| 16 | +import java.sql.ResultSet; | ||
| 17 | +import java.sql.Statement; | ||
| 18 | +import java.util.ArrayList; | ||
| 19 | +import java.util.HashMap; | ||
| 20 | +import java.util.List; | ||
| 21 | +import java.util.Map; | ||
| 22 | + | ||
| 23 | +import static com.nctigba.datastudio.constants.CommonConstants.DESCRIPTION; | ||
| 24 | +import static com.nctigba.datastudio.constants.CommonConstants.NSP_NAME; | ||
| 25 | +import static com.nctigba.datastudio.constants.CommonConstants.OID; | ||
| 26 | +import static com.nctigba.datastudio.constants.CommonConstants.OWNER; | ||
| 27 | +import static com.nctigba.datastudio.constants.CommonConstants.ROL_NAME; | ||
| 28 | +import static com.nctigba.datastudio.constants.CommonConstants.SCHEMA_NAME; | ||
| 29 | +import static com.nctigba.datastudio.constants.SqlConstants.CREATE_SCHEMA_SQL; | ||
| 30 | +import static com.nctigba.datastudio.constants.SqlConstants.DROP_SCHEMA_SQL; | ||
| 31 | +import static com.nctigba.datastudio.constants.SqlConstants.IS_SQL; | ||
| 32 | +import static com.nctigba.datastudio.constants.SqlConstants.OWNER_CONDITION; | ||
| 33 | +import static com.nctigba.datastudio.constants.SqlConstants.QUERY_SCHEMA_SQL; | ||
| 34 | +import static com.nctigba.datastudio.constants.SqlConstants.QUERY_USERS_SQL; | ||
| 35 | +import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_SEMICOLON; | ||
| 36 | +import static com.nctigba.datastudio.constants.SqlConstants.RENAME_CONDITION; | ||
| 37 | +import static com.nctigba.datastudio.constants.SqlConstants.SEMICOLON; | ||
| 38 | +import static com.nctigba.datastudio.constants.SqlConstants.UPDATE_DESCRIPTION_SQL; | ||
| 39 | +import static com.nctigba.datastudio.constants.SqlConstants.UPDATE_SCHEMA_SQL; | ||
| 40 | +import static com.nctigba.datastudio.constants.SqlConstants.USER_CONDITION; | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + | ||
| 44 | +public class SchemaManagerServiceImpl implements SchemaManagerService { | ||
| 45 | + | ||
| 46 | + private ConnectionConfig connectionConfig; | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + public List<String> queryAllUsers(SchemaManagerRequest request) throws Exception { | ||
| 50 | + log.info("SchemaManagerService queryAllUsers request: " + request); | ||
| 51 | + try ( | ||
| 52 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 53 | + Statement statement = connection.createStatement(); | ||
| 54 | + ResultSet resultSet = statement.executeQuery(QUERY_USERS_SQL) | ||
| 55 | + ) { | ||
| 56 | + List<String> list = new ArrayList<>(); | ||
| 57 | + while (resultSet.next()) { | ||
| 58 | + list.add(resultSet.getString(ROL_NAME)); | ||
| 59 | + } | ||
| 60 | + log.info("SchemaManagerService queryAllUsers list: " + list); | ||
| 61 | + return list; | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + | ||
| 66 | + public Map<String, String> querySchema(SchemaManagerRequest request) throws Exception { | ||
| 67 | + log.info("SchemaManagerService querySchema request: " + request); | ||
| 68 | + try ( | ||
| 69 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 70 | + Statement statement = connection.createStatement(); | ||
| 71 | + ResultSet resultSet = statement.executeQuery(QUERY_SCHEMA_SQL + request.getOid() + SEMICOLON) | ||
| 72 | + ) { | ||
| 73 | + Map<String, String> map = new HashMap<>(); | ||
| 74 | + while (resultSet.next()) { | ||
| 75 | + map.put(OID, resultSet.getString(OID)); | ||
| 76 | + map.put(SCHEMA_NAME, resultSet.getString(NSP_NAME)); | ||
| 77 | + map.put(OWNER, resultSet.getString(ROL_NAME)); | ||
| 78 | + map.put(DESCRIPTION, resultSet.getString(DESCRIPTION)); | ||
| 79 | + } | ||
| 80 | + log.info("SchemaManagerService querySchema resultMap: " + map); | ||
| 81 | + return map; | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + | ||
| 86 | + public void createSchema(SchemaManagerRequest request) throws Exception { | ||
| 87 | + log.info("SchemaManagerService createSchema request: " + request); | ||
| 88 | + try ( | ||
| 89 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 90 | + Statement statement = connection.createStatement() | ||
| 91 | + ) { | ||
| 92 | + String schemaName = request.getSchemaName(); | ||
| 93 | + String owner = request.getOwner(); | ||
| 94 | + statement.execute( | ||
| 95 | + CREATE_SCHEMA_SQL + schemaName + USER_CONDITION + owner + SEMICOLON); | ||
| 96 | + String description = request.getDescription(); | ||
| 97 | + if (StringUtils.isNotEmpty(description)) { | ||
| 98 | + statement.execute(UPDATE_DESCRIPTION_SQL + schemaName + IS_SQL + description + QUOTES_SEMICOLON); | ||
| 99 | + } | ||
| 100 | + } | ||
| 101 | + log.info("SchemaManagerService createSchema end "); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + | ||
| 105 | + public void updateSchema(SchemaManagerRequest request) throws Exception { | ||
| 106 | + log.info("SchemaManagerService updateSchema request: " + request); | ||
| 107 | + try ( | ||
| 108 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 109 | + Statement statement = connection.createStatement(); | ||
| 110 | + ResultSet resultSet = statement.executeQuery(QUERY_SCHEMA_SQL + request.getOid() + SEMICOLON) | ||
| 111 | + ) { | ||
| 112 | + String oldSchemaName = request.getSchemaName(); | ||
| 113 | + String oldOwner = request.getOwner(); | ||
| 114 | + while (resultSet.next()) { | ||
| 115 | + oldSchemaName = resultSet.getString(NSP_NAME); | ||
| 116 | + oldOwner = resultSet.getString(ROL_NAME); | ||
| 117 | + } | ||
| 118 | + String schemaName = request.getSchemaName(); | ||
| 119 | + if (!oldSchemaName.equals(schemaName)) { | ||
| 120 | + statement.execute(UPDATE_SCHEMA_SQL + oldSchemaName + RENAME_CONDITION + schemaName + SEMICOLON); | ||
| 121 | + } | ||
| 122 | + String owner = request.getOwner(); | ||
| 123 | + if (!oldOwner.equals(owner)) { | ||
| 124 | + statement.execute(UPDATE_SCHEMA_SQL + oldSchemaName + OWNER_CONDITION + owner + SEMICOLON); | ||
| 125 | + } | ||
| 126 | + String description = request.getDescription(); | ||
| 127 | + String sql = UPDATE_DESCRIPTION_SQL + schemaName + IS_SQL + "" + QUOTES_SEMICOLON; | ||
| 128 | + if (StringUtils.isNotEmpty(description)) { | ||
| 129 | + sql = UPDATE_DESCRIPTION_SQL + schemaName + IS_SQL + description + QUOTES_SEMICOLON; | ||
| 130 | + } | ||
| 131 | + statement.execute(sql); | ||
| 132 | + } | ||
| 133 | + log.info("SchemaManagerService updateSchema end "); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + | ||
| 137 | + public void deleteSchema(SchemaManagerRequest request) throws Exception { | ||
| 138 | + log.info("SchemaManagerService deleteSchema request: " + request); | ||
| 139 | + try ( | ||
| 140 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 141 | + Statement statement = connection.createStatement() | ||
| 142 | + ) { | ||
| 143 | + statement.execute(DROP_SCHEMA_SQL + request.getSchemaName() + SEMICOLON); | ||
| 144 | + } | ||
| 145 | + log.info("SchemaManagerService deleteSchema end "); | ||
| 146 | + } | ||
| 147 | +} | ||
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/sql/SqlWindowByJdbcServiceImpl.java+41-19
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.model.dto.DataListDTO; | 7 | import com.nctigba.datastudio.model.dto.DataListDTO; |
| @@ -10,46 +14,64 @@ import java.sql.Connection; | |||
| 10 | import java.sql.PreparedStatement; | 14 | import java.sql.PreparedStatement; |
| 11 | import java.sql.ResultSet; | 15 | import java.sql.ResultSet; |
| 12 | import java.util.ArrayList; | 16 | import java.util.ArrayList; |
| 17 | +import java.util.HashMap; | ||
| 13 | import java.util.List; | 18 | import java.util.List; |
| 19 | +import java.util.Map; | ||
| 20 | + | ||
| 21 | +import static com.nctigba.datastudio.constants.CommonConstants.NAME; | ||
| 22 | +import static com.nctigba.datastudio.constants.CommonConstants.OID; | ||
| 14 | 23 | ||
| 15 | 24 | ||
| 16 | public class SqlWindowByJdbcServiceImpl implements SqlWindowByJdbcService { | 25 | public class SqlWindowByJdbcServiceImpl implements SqlWindowByJdbcService { |
| 17 | 26 | ||
| 18 | public List<String> schemaListQuerySQL(String jdbcUrl, String username, String password, String sql) { | 27 | public List<String> schemaListQuerySQL(String jdbcUrl, String username, String password, String sql) { |
| 19 | List<String> list = new ArrayList<>(); | 28 | List<String> list = new ArrayList<>(); |
| 20 | - try (Connection connection = ConnectionUtils.connectGet(jdbcUrl, username, password); | 29 | + try ( |
| 21 | - PreparedStatement ps = connection.prepareStatement(sql); | 30 | + Connection connection = ConnectionUtils.connectGet(jdbcUrl, username, password); |
| 22 | - ResultSet rs = ps.executeQuery();) { | 31 | + PreparedStatement ps = connection.prepareStatement(sql); |
| 32 | + ResultSet rs = ps.executeQuery()) { | ||
| 23 | while (rs.next()) { | 33 | while (rs.next()) { |
| 24 | list.add(rs.getString("schema_name")); | 34 | list.add(rs.getString("schema_name")); |
| 25 | } | 35 | } |
| 26 | } catch (Exception e) { | 36 | } catch (Exception e) { |
| 27 | - throw new CustomException(e.getMessage(),e); | 37 | + throw new CustomException(e.getMessage(), e); |
| 28 | } | 38 | } |
| 29 | return list; | 39 | return list; |
| 30 | } | 40 | } |
| 31 | 41 | ||
| 32 | 42 | ||
| 33 | - public DataListDTO dataListQuerySQL(String jdbcUrl, String username, String password, String tableSql, String viewSql, String fun_prosSql, String schema_name) { | 43 | + public DataListDTO dataListQuerySQL(String jdbcUrl, String username, String password, String tableSql, |
| 44 | + String viewSql, String fun_prosSql, String schema_name) { | ||
| 34 | DataListDTO dataList = new DataListDTO(); | 45 | DataListDTO dataList = new DataListDTO(); |
| 35 | - List<String> table = new ArrayList<>(); | 46 | + List<Map<String, String>> table = new ArrayList<>(); |
| 36 | - List<String> view = new ArrayList<>(); | 47 | + List<Map<String, String>> view = new ArrayList<>(); |
| 37 | - List<String> fun_pro = new ArrayList<>(); | 48 | + List<Map<String, String>> fun_pro = new ArrayList<>(); |
| 38 | - try (Connection connection = ConnectionUtils.connectGet(jdbcUrl, username, password); | 49 | + try ( |
| 39 | - PreparedStatement tableValue = connection.prepareStatement(tableSql); | 50 | + Connection connection = ConnectionUtils.connectGet(jdbcUrl, username, password); |
| 40 | - PreparedStatement viewValue = connection.prepareStatement(viewSql); | 51 | + PreparedStatement tableValue = connection.prepareStatement(tableSql); |
| 41 | - PreparedStatement fun_proValue = connection.prepareStatement(fun_prosSql); | 52 | + PreparedStatement viewValue = connection.prepareStatement(viewSql); |
| 42 | - ResultSet rs1 = tableValue.executeQuery(); | 53 | + PreparedStatement fun_proValue = connection.prepareStatement(fun_prosSql); |
| 43 | - ResultSet rs2 = viewValue.executeQuery(); | 54 | + ResultSet rs1 = tableValue.executeQuery(); |
| 44 | - ResultSet rs3 = fun_proValue.executeQuery();) { | 55 | + ResultSet rs2 = viewValue.executeQuery(); |
| 56 | + ResultSet rs3 = fun_proValue.executeQuery() | ||
| 57 | + ) { | ||
| 45 | while (rs1.next()) { | 58 | while (rs1.next()) { |
| 46 | - table.add(rs1.getString("tablename")); | 59 | + Map<String, String> map = new HashMap(); |
| 60 | + map.put(OID, rs1.getString(OID)); | ||
| 61 | + map.put(NAME, rs1.getString("tablename")); | ||
| 62 | + table.add(map); | ||
| 47 | } | 63 | } |
| 48 | while (rs2.next()) { | 64 | while (rs2.next()) { |
| 49 | - view.add(rs2.getString("viewname")); | 65 | + Map<String, String> map = new HashMap(); |
| 66 | + map.put(OID, rs2.getString(OID)); | ||
| 67 | + map.put(NAME, rs2.getString("viewname")); | ||
| 68 | + view.add(map); | ||
| 50 | } | 69 | } |
| 51 | while (rs3.next()) { | 70 | while (rs3.next()) { |
| 52 | - fun_pro.add(rs3.getString("proname")); | 71 | + Map<String, String> map = new HashMap<>(); |
| 72 | + map.put(OID, rs3.getString(OID)); | ||
| 73 | + map.put(NAME, rs3.getString("proname")); | ||
| 74 | + fun_pro.add(map); | ||
| 53 | } | 75 | } |
| 54 | 76 | ||
| 55 | dataList.setSchema_name(schema_name); | 77 | dataList.setSchema_name(schema_name); |
| @@ -57,7 +79,7 @@ public class SqlWindowByJdbcServiceImpl implements SqlWindowByJdbcService { | |||
| 57 | dataList.setView(view); | 79 | dataList.setView(view); |
| 58 | dataList.setFun_pro(fun_pro); | 80 | dataList.setFun_pro(fun_pro); |
| 59 | } catch (Exception e) { | 81 | } catch (Exception e) { |
| 60 | - throw new CustomException(e.getMessage(),e); | 82 | + throw new CustomException(e.getMessage(), e); |
| 61 | } | 83 | } |
| 62 | return dataList; | 84 | return dataList; |
| 63 | } | 85 | } |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 3 | import cn.hutool.core.thread.ThreadUtil; | 7 | import cn.hutool.core.thread.ThreadUtil; |
| @@ -18,7 +22,10 @@ import java.sql.SQLException; | |||
| 18 | import java.sql.Statement; | 22 | import java.sql.Statement; |
| 19 | 23 | ||
| 20 | import static com.nctigba.datastudio.constants.CommonConstants.FIVE_HUNDRED; | 24 | import static com.nctigba.datastudio.constants.CommonConstants.FIVE_HUNDRED; |
| 21 | -import static com.nctigba.datastudio.enums.MessageEnum.*; | 25 | +import static com.nctigba.datastudio.enums.MessageEnum.button; |
| 26 | +import static com.nctigba.datastudio.enums.MessageEnum.table; | ||
| 27 | +import static com.nctigba.datastudio.enums.MessageEnum.text; | ||
| 28 | +import static com.nctigba.datastudio.enums.MessageEnum.window; | ||
| 22 | 29 | ||
| 23 | 30 | ||
| 24 | 31 | ||
| @@ -36,31 +43,40 @@ public class StartSqlImpl implements OperationInterface { | |||
| 36 | log.info("tableColumnList request is: " + paramReq); | 43 | log.info("tableColumnList request is: " + paramReq); |
| 37 | ThreadUtil.execAsync(() -> { | 44 | ThreadUtil.execAsync(() -> { |
| 38 | try { | 45 | try { |
| 39 | - webSocketServer.sendMessage(windowName, text, LocaleString.transLanguageWs("2001", webSocketServer), null); | 46 | + webSocketServer.sendMessage(windowName, text, LocaleString.transLanguageWs("2001", webSocketServer), |
| 47 | + null); | ||
| 40 | boolean result = stat.execute(paramReq.getSql()); | 48 | boolean result = stat.execute(paramReq.getSql()); |
| 41 | - webSocketServer.sendMessage(windowName, button, LocaleString.transLanguageWs("2006", webSocketServer), null); | 49 | + webSocketServer.sendMessage(windowName, button, LocaleString.transLanguageWs("2006", webSocketServer), |
| 50 | + null); | ||
| 42 | OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); | 51 | OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); |
| 43 | operateStatus.enableStopRun(); | 52 | operateStatus.enableStopRun(); |
| 44 | webSocketServer.setOperateStatus(windowName, operateStatus); | 53 | webSocketServer.setOperateStatus(windowName, operateStatus); |
| 45 | while (true) { | 54 | while (true) { |
| 46 | if (result) { | 55 | if (result) { |
| 47 | - webSocketServer.sendMessage(windowName, table, LocaleString.transLanguageWs("2002", webSocketServer), DebugUtils.parseResultSet(stat.getResultSet())); | 56 | + webSocketServer.sendMessage(windowName, table, |
| 48 | - webSocketServer.sendMessage(windowName, text, LocaleString.transLanguageWs("2002", webSocketServer), null); | 57 | + LocaleString.transLanguageWs("2002", webSocketServer), |
| 58 | + DebugUtils.parseResultSet(stat.getResultSet())); | ||
| 59 | + webSocketServer.sendMessage(windowName, text, | ||
| 60 | + LocaleString.transLanguageWs("2002", webSocketServer), null); | ||
| 49 | } else { | 61 | } else { |
| 50 | if (stat.getUpdateCount() != -1) { | 62 | if (stat.getUpdateCount() != -1) { |
| 51 | - webSocketServer.sendMessage(windowName, text, LocaleString.transLanguageWs("2005", webSocketServer) + stat.getUpdateCount(), null); | 63 | + webSocketServer.sendMessage(windowName, text, |
| 64 | + LocaleString.transLanguageWs("2005", webSocketServer) + stat.getUpdateCount(), | ||
| 65 | + null); | ||
| 52 | } else { | 66 | } else { |
| 53 | break; | 67 | break; |
| 54 | } | 68 | } |
| 55 | } | 69 | } |
| 56 | result = stat.getMoreResults(); | 70 | result = stat.getMoreResults(); |
| 57 | } | 71 | } |
| 58 | - webSocketServer.sendMessage(windowName, text, LocaleString.transLanguageWs("2003", webSocketServer), null); | 72 | + webSocketServer.sendMessage(windowName, text, LocaleString.transLanguageWs("2003", webSocketServer), |
| 73 | + null); | ||
| 59 | } catch (IOException | SQLException e) { | 74 | } catch (IOException | SQLException e) { |
| 60 | - e.printStackTrace(); | 75 | + log.info(e.getMessage()); |
| 61 | try { | 76 | try { |
| 62 | webSocketServer.sendMessage(windowName, window, FIVE_HUNDRED, e.getMessage(), e.getStackTrace()); | 77 | webSocketServer.sendMessage(windowName, window, FIVE_HUNDRED, e.getMessage(), e.getStackTrace()); |
| 63 | - webSocketServer.sendMessage(windowName, button, LocaleString.transLanguageWs("2006", webSocketServer), null); | 78 | + webSocketServer.sendMessage(windowName, button, |
| 79 | + LocaleString.transLanguageWs("2006", webSocketServer), null); | ||
| 64 | OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); | 80 | OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); |
| 65 | operateStatus.enableStopRun(); | 81 | operateStatus.enableStopRun(); |
| 66 | webSocketServer.setOperateStatus(windowName, operateStatus); | 82 | webSocketServer.setOperateStatus(windowName, operateStatus); |
| @@ -73,7 +89,8 @@ public class StartSqlImpl implements OperationInterface { | |||
| 73 | stat.cancel(); | 89 | stat.cancel(); |
| 74 | webSocketServer.setStatement(windowName, null); | 90 | webSocketServer.setStatement(windowName, null); |
| 75 | } catch (SQLException e) { | 91 | } catch (SQLException e) { |
| 76 | - throw new RuntimeException(e); | 92 | + log.info(e.getMessage()); |
| 93 | + log.error("tableColumnList SQLException is: " + e.getMessage()); | ||
| 77 | } | 94 | } |
| 78 | } | 95 | } |
| 79 | }); | 96 | }); |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 3 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
Mplugins/data-studio/src/main/java/com/nctigba/datastudio/service/impl/sql/TableDataServiceImpl.java+371-43
| @@ -1,7 +1,27 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.service.impl.sql; | 5 | package com.nctigba.datastudio.service.impl.sql; |
| 2 | 6 | ||
| 7 | +import com.nctigba.datastudio.compatible.TableColumnSQLService; | ||
| 8 | +import com.nctigba.datastudio.compatible.TableObjectSQLService; | ||
| 3 | import com.nctigba.datastudio.config.ConnectionConfig; | 9 | import com.nctigba.datastudio.config.ConnectionConfig; |
| 10 | +import com.nctigba.datastudio.dao.ResultSetMapDAO; | ||
| 11 | +import com.nctigba.datastudio.model.dto.DatabaseConstraintDTO; | ||
| 12 | +import com.nctigba.datastudio.model.dto.DatabaseConstraintPkDTO; | ||
| 13 | +import com.nctigba.datastudio.model.dto.DatabaseCreUpdColumnDTO; | ||
| 14 | +import com.nctigba.datastudio.model.dto.DatabaseCreateTableDTO; | ||
| 15 | +import com.nctigba.datastudio.model.dto.DatabaseIndexDTO; | ||
| 16 | +import com.nctigba.datastudio.model.dto.TableAlterDTO; | ||
| 17 | +import com.nctigba.datastudio.model.dto.TableAttributeDTO; | ||
| 18 | +import com.nctigba.datastudio.model.dto.TableDataDTO; | ||
| 19 | +import com.nctigba.datastudio.model.dto.TableNameDTO; | ||
| 20 | +import com.nctigba.datastudio.model.dto.WinInfoDTO; | ||
| 4 | import com.nctigba.datastudio.model.query.SelectDataQuery; | 21 | import com.nctigba.datastudio.model.query.SelectDataQuery; |
| 22 | +import com.nctigba.datastudio.model.query.TableDataEditQuery; | ||
| 23 | +import com.nctigba.datastudio.model.query.TableDataQuery; | ||
| 24 | +import com.nctigba.datastudio.model.query.TablePKDataQuery; | ||
| 5 | import com.nctigba.datastudio.service.TableDataService; | 25 | import com.nctigba.datastudio.service.TableDataService; |
| 6 | import com.nctigba.datastudio.util.DebugUtils; | 26 | import com.nctigba.datastudio.util.DebugUtils; |
| 7 | import com.nctigba.datastudio.util.LocaleString; | 27 | import com.nctigba.datastudio.util.LocaleString; |
| @@ -10,48 +30,137 @@ import org.opengauss.admin.common.exception.CustomException; | |||
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 30 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.stereotype.Service; | 31 | import org.springframework.stereotype.Service; |
| 12 | 32 | ||
| 33 | +import javax.annotation.Resource; | ||
| 13 | import java.sql.Connection; | 34 | import java.sql.Connection; |
| 14 | import java.sql.ResultSet; | 35 | import java.sql.ResultSet; |
| 15 | import java.sql.Statement; | 36 | import java.sql.Statement; |
| 16 | import java.util.HashMap; | 37 | import java.util.HashMap; |
| 38 | +import java.util.List; | ||
| 17 | import java.util.Map; | 39 | import java.util.Map; |
| 18 | 40 | ||
| 19 | -import static com.nctigba.datastudio.constants.CommonConstants.OID; | 41 | +import static com.nctigba.datastudio.dao.ConnectionMapDAO.conMap; |
| 20 | -import static com.nctigba.datastudio.constants.CommonConstants.PG_GET_TABLEDEF; | 42 | +import static com.nctigba.datastudio.dao.ResultSetMapDAO.setWinMap; |
| 21 | -import static com.nctigba.datastudio.constants.CommonConstants.RESULT; | 43 | +import static com.nctigba.datastudio.dao.ResultSetMapDAO.winMap; |
| 22 | -import static com.nctigba.datastudio.constants.SqlConstants.*; | 44 | +import static java.lang.Math.ceil; |
| 23 | 45 | ||
| 24 | 46 | ||
| 25 | 47 | ||
| 26 | public class TableDataServiceImpl implements TableDataService { | 48 | public class TableDataServiceImpl implements TableDataService { |
| 49 | + public final Integer maxData = 5000; | ||
| 50 | + public final Map<String, ResultSet> resultSetMap = new HashMap<>(); | ||
| 51 | + | ||
| 52 | + private final Map<String, Connection> connectionMap = new HashMap<>(); | ||
| 53 | + | ||
| 54 | + private final Map<String, Statement> statementMap = new HashMap<>(); | ||
| 27 | 55 | ||
| 28 | private ConnectionConfig connectionConfig; | 56 | private ConnectionConfig connectionConfig; |
| 57 | + private Map<String, TableObjectSQLService> tableObjectSQLService; | ||
| 58 | + private Map<String, TableColumnSQLService> tableColumnSQLService; | ||
| 59 | + | ||
| 60 | + public void setResultSetMap(String winId, ResultSet resultSet) { | ||
| 61 | + this.resultSetMap.put(winId, resultSet); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public void setConnectionMap(String winId, Connection connection) { | ||
| 65 | + this.connectionMap.put(winId, connection); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public void statementMap(String winId, Statement statement) { | ||
| 69 | + this.statementMap.put(winId, statement); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + public ResultSet getResultSetMap(String winId) { | ||
| 73 | + return this.resultSetMap.get(winId); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + public Connection getConnectionMap(String winId) { | ||
| 77 | + return this.connectionMap.get(winId); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + public Statement getSatementMap(String winId) { | ||
| 81 | + return this.statementMap.get(winId); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + | ||
| 85 | + public void setTableObjectSQLService(List<TableObjectSQLService> SQLServiceList) { | ||
| 86 | + tableObjectSQLService = new HashMap<>(); | ||
| 87 | + for (TableObjectSQLService s : SQLServiceList) { | ||
| 88 | + tableObjectSQLService.put(s.type(), s); | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + | ||
| 93 | + public void setTableColumnSQLService(List<TableColumnSQLService> SQLServiceList) { | ||
| 94 | + tableColumnSQLService = new HashMap<>(); | ||
| 95 | + for (TableColumnSQLService s : SQLServiceList) { | ||
| 96 | + tableColumnSQLService.put(s.type(), s); | ||
| 97 | + } | ||
| 98 | + } | ||
| 29 | 99 | ||
| 30 | 100 | ||
| 31 | - public Map<String, Object> tableData(SelectDataQuery request) throws Exception { | 101 | + public TableDataDTO tableData(TableDataQuery request) throws Exception { |
| 32 | log.info("tableData request is: " + request); | 102 | log.info("tableData request is: " + request); |
| 33 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 103 | + Connection connection; |
| 34 | - Statement statement = connection.createStatement();ResultSet resultSet = statement.executeQuery(TABLE_DATA_SQL + | 104 | + Statement statement; |
| 35 | - request.getSchema() + POINT + request.getTableName() + LIMIT_SQL + SEMICOLON); | 105 | + ResultSet resultSet; |
| 106 | + if (resultSetMap.containsKey(request.getWinId())) { | ||
| 107 | + connection = getConnectionMap(request.getWinId()); | ||
| 108 | + statement = getSatementMap(request.getWinId()); | ||
| 109 | + resultSet = getResultSetMap(request.getWinId()); | ||
| 110 | + } else { | ||
| 111 | + connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 112 | + statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); | ||
| 113 | + resultSet = statement.executeQuery(tableObjectSQLService.get(conMap.get(request.getUuid()) | ||
| 114 | + .getType()).tableDataSQL(request.getSchema(), request.getTableName())); | ||
| 115 | + setConnectionMap(request.getWinId(), connection); | ||
| 116 | + statementMap(request.getWinId(), statement); | ||
| 117 | + setResultSetMap(request.getWinId(), resultSet); | ||
| 118 | + } | ||
| 119 | + TableDataDTO tableDataDTO = new TableDataDTO(); | ||
| 120 | + try ( | ||
| 121 | + Connection connectionCount = connectionConfig.connectDatabase(request.getUuid()); | ||
| 122 | + Statement statementCount = connectionCount.createStatement() | ||
| 36 | ) { | 123 | ) { |
| 37 | - Map<String, Object> resultMap = DebugUtils.parseResultSet(resultSet); | 124 | + statementCount.executeUpdate(tableObjectSQLService.get(conMap.get(request.getUuid()) |
| 38 | - log.info("tableData resultMap is: " + resultMap); | 125 | + .getType()).tableAnalyseSQL(request.getSchema(), request.getTableName())); |
| 39 | - return resultMap; | 126 | + } catch (Exception e) { |
| 127 | + log.info(e.getMessage()); | ||
| 128 | + } | ||
| 129 | + try ( | ||
| 130 | + Statement statementCount = connection.createStatement(); | ||
| 131 | + ResultSet resultSetCount = statementCount.executeQuery( | ||
| 132 | + tableObjectSQLService.get(conMap.get(request.getUuid()) | ||
| 133 | + .getType()).tableDataCountSQL(request.getSchema(), request.getTableName())) | ||
| 134 | + ) { | ||
| 135 | + resultSetCount.next(); | ||
| 136 | + Integer count = resultSetCount.getInt(1); | ||
| 137 | + tableDataDTO.setTableDataDTO(request); | ||
| 138 | + tableDataDTO.setDataSize(count); | ||
| 139 | + tableDataDTO.setPageTotal((int) ceil((double) count / Integer.valueOf(request.getPageSize()))); | ||
| 140 | + statement.setFetchSize(request.getPageSize()); | ||
| 141 | + resultSet.setFetchSize(request.getPageSize()); | ||
| 142 | + WinInfoDTO winInfoDTO = new WinInfoDTO(); | ||
| 143 | + winInfoDTO.setWinInfoDTO(request.getUuid(), request.getSchema(), request.getTableName()); | ||
| 144 | + setWinMap(request.getWinId(), winInfoDTO); | ||
| 145 | + Map<String, Object> resultMap = DebugUtils.parseResultSet(resultSet, request.getPageSize(), | ||
| 146 | + request.getPageNum()); | ||
| 147 | + tableDataDTO.setData(resultMap); | ||
| 148 | + return tableDataDTO; | ||
| 40 | } | 149 | } |
| 41 | } | 150 | } |
| 42 | 151 | ||
| 43 | 152 | ||
| 44 | public Map<String, Object> tableColumn(SelectDataQuery request) throws Exception { | 153 | public Map<String, Object> tableColumn(SelectDataQuery request) throws Exception { |
| 45 | log.info("tableColumn request is: " + request); | 154 | log.info("tableColumn request is: " + request); |
| 46 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 155 | + try ( |
| 47 | - Statement statement = connection.createStatement();){ | 156 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 48 | - String oid = ""; | 157 | + Statement statement = connection.createStatement()) { |
| 49 | - try(ResultSet oidResult = statement.executeQuery(GET_CLASS_OID_SQL + request.getTableName() | 158 | + try ( |
| 50 | - + NSPNAME_CONDITION + request.getSchema() + QUOTES_SEMICOLON);) { | 159 | + ResultSet resultSet = statement.executeQuery(tableColumnSQLService.get(conMap.get(request.getUuid()) |
| 51 | - while (oidResult.next()) { | 160 | + .getType()).tableColumnSQL(request.getOid(), request.getSchema(), |
| 52 | - oid = oidResult.getString(OID); | 161 | + request.getTableName())) |
| 53 | - } | 162 | + ) { |
| 54 | - }try(ResultSet resultSet = statement.executeQuery(GET_COLUMN_SQL + oid + ATTRELID_CONDITION_SQL + oid + SEMICOLON);){ | 163 | + log.info("tableColumn resultSet is: " + resultSet); |
| 55 | Map<String, Object> resultMap = DebugUtils.parseResultSet(resultSet); | 164 | Map<String, Object> resultMap = DebugUtils.parseResultSet(resultSet); |
| 56 | log.info("tableColumn resultMap is: " + resultMap); | 165 | log.info("tableColumn resultMap is: " + resultMap); |
| 57 | return resultMap; | 166 | return resultMap; |
| @@ -62,51 +171,270 @@ public class TableDataServiceImpl implements TableDataService { | |||
| 62 | 171 | ||
| 63 | public Map<String, Object> tableIndex(SelectDataQuery request) throws Exception { | 172 | public Map<String, Object> tableIndex(SelectDataQuery request) throws Exception { |
| 64 | log.info("tableIndex request is: " + request); | 173 | log.info("tableIndex request is: " + request); |
| 65 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 174 | + try ( |
| 66 | - Statement statement = connection.createStatement(); | 175 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 67 | - ResultSet resultSet = statement.executeQuery(GET_INDEX_SQL + request.getTableName() | 176 | + Statement statement = connection.createStatement(); |
| 68 | - + NSPNAME_CONDITION + request.getSchema() + INDEX_GROUP_BY_SQL);){ | 177 | + ResultSet resultSet = statement.executeQuery(tableColumnSQLService.get(conMap.get(request.getUuid()) |
| 178 | + .getType()).tableIndexSQL(request)) | ||
| 179 | + ) { | ||
| 69 | Map<String, Object> resultMap = DebugUtils.parseResultSet(resultSet); | 180 | Map<String, Object> resultMap = DebugUtils.parseResultSet(resultSet); |
| 70 | log.info("tableIndex resultMap is: " + resultMap); | 181 | log.info("tableIndex resultMap is: " + resultMap); |
| 71 | return resultMap; | 182 | return resultMap; |
| 72 | } | 183 | } |
| 73 | } | 184 | } |
| 74 | 185 | ||
| 186 | + | ||
| 187 | + public void tableEditIndex(DatabaseIndexDTO request) throws Exception { | ||
| 188 | + log.info("tableEditIndex request is: " + request); | ||
| 189 | + tableColumnSQLService.get(conMap.get(request.getUuid()).getType()).editIndex(request); | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + | ||
| 193 | + public void tableCreate(DatabaseCreateTableDTO request) throws Exception { | ||
| 194 | + log.info("DatabaseCreateTableDTO request is: " + request); | ||
| 195 | + try ( | ||
| 196 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 197 | + Statement statement = connection.createStatement() | ||
| 198 | + ) { | ||
| 199 | + statement.execute(tableColumnSQLService.get(conMap.get(request.getUuid()).getType()).createTable(request)); | ||
| 200 | + } | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + | ||
| 204 | + public String returnTableCreate(DatabaseCreateTableDTO request) throws Exception { | ||
| 205 | + log.info("DatabaseCreateTableDTO request is: " + request); | ||
| 206 | + return tableColumnSQLService.get(conMap.get(request.getUuid()).getType()).createTable(request); | ||
| 207 | + } | ||
| 208 | + | ||
| 75 | 209 | ||
| 76 | public Map<String, Object> tableConstraint(SelectDataQuery request) throws Exception { | 210 | public Map<String, Object> tableConstraint(SelectDataQuery request) throws Exception { |
| 77 | log.info("tableConstraint request is: " + request); | 211 | log.info("tableConstraint request is: " + request); |
| 78 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 212 | + try ( |
| 79 | - Statement statement = connection.createStatement(); | 213 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); |
| 80 | - ResultSet resultSet = statement.executeQuery(GET_CONSTRAINT_SQL + request.getSchema() | 214 | + Statement statement = connection.createStatement(); |
| 81 | - + RELNAME_CONDITION + request.getTableName() + CONSTRAINT_GROUP_BY_SQL);){ | 215 | + ResultSet resultSet = statement.executeQuery(tableColumnSQLService.get(conMap.get(request.getUuid()) |
| 216 | + .getType()).tableConstraintSQL(request)) | ||
| 217 | + ) { | ||
| 82 | Map<String, Object> resultMap = DebugUtils.parseResultSet(resultSet); | 218 | Map<String, Object> resultMap = DebugUtils.parseResultSet(resultSet); |
| 83 | log.info("tableConstraint resultMap is: " + resultMap); | 219 | log.info("tableConstraint resultMap is: " + resultMap); |
| 84 | return resultMap; | 220 | return resultMap; |
| 85 | } | 221 | } |
| 86 | } | 222 | } |
| 87 | 223 | ||
| 224 | + | ||
| 225 | + public void tableEditConstraint(DatabaseConstraintDTO request) throws Exception { | ||
| 226 | + log.info("tableEditConstraint request is: " + request); | ||
| 227 | + tableColumnSQLService.get(conMap.get(request.getUuid()).getType()).editConstraint(request); | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + | ||
| 231 | + public void tableEditPkConstraint(DatabaseConstraintPkDTO request) throws Exception { | ||
| 232 | + log.info("tableEditPkConstraint request is: {}" + request); | ||
| 233 | + tableColumnSQLService.get(conMap.get(request.getUuid()).getType()).editPkConstraint(request); | ||
| 234 | + } | ||
| 235 | + | ||
| 236 | + | ||
| 88 | 237 | ||
| 89 | public Map<String, String> tableDdl(SelectDataQuery request) throws Exception { | 238 | public Map<String, String> tableDdl(SelectDataQuery request) throws Exception { |
| 90 | log.info("tableDdl request is: " + request); | 239 | log.info("tableDdl request is: " + request); |
| 91 | - Map<String, String> resultMap = new HashMap<>(); | 240 | + Map<String, String> resultMap = tableObjectSQLService.get(conMap.get(request.getUuid()).getType()) |
| 92 | - try(Connection connection = connectionConfig.connectDatabase(request.getUuid()); | 241 | + .tableDdl(request); |
| 93 | - Statement statement = connection.createStatement();){ | 242 | + return resultMap; |
| 94 | - try(ResultSet count = statement.executeQuery(SELECT_KEYWORD_SQL + COUNT_SQL +FROM_CLASS_SQL+ | 243 | + } |
| 95 | - request.getSchema() + FROM_CLASS_WHERE_SQL + request.getTableName() + RELKIND_SQL+ "r" + QUOTES_SEMICOLON);){ | 244 | + |
| 96 | - count.next(); | 245 | + @Override |
| 97 | - int a = count.getInt("count"); | 246 | + public Map<String, Object> tableColumnEdit(DatabaseCreUpdColumnDTO request) throws Exception { |
| 98 | - if(a==0){ | 247 | + log.info("tableColumn request is: " + request); |
| 99 | - throw new CustomException(LocaleString.transLanguage("2007")); | 248 | + try ( |
| 249 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 250 | + Statement statement = connection.createStatement() | ||
| 251 | + ) { | ||
| 252 | + for (DatabaseCreUpdColumnDTO.CreUpdColumnDataDTO data : request.getData()) { | ||
| 253 | + TableColumnSQLService aa = tableColumnSQLService.get(conMap.get(request.getUuid()).getType()); | ||
| 254 | + switch (data.getOperationType()) { | ||
| 255 | + case 1: | ||
| 256 | + for (String list : aa.tableColumnAddSQL(data, request.getSchema(), request.getTableName())) { | ||
| 257 | + statement.execute(list); | ||
| 258 | + } | ||
| 259 | + break; | ||
| 260 | + case 2: | ||
| 261 | + statement.execute(aa.tableColumnDropSQL(data, request.getSchema(), request.getTableName())); | ||
| 262 | + break; | ||
| 263 | + case 3: | ||
| 264 | + for (String list : aa.tableColumnUpdateSQL(data, request.getSchema(), request.getTableName(), | ||
| 265 | + request.getUuid())) { | ||
| 266 | + statement.execute(list); | ||
| 267 | + } | ||
| 268 | + break; | ||
| 100 | } | 269 | } |
| 101 | } | 270 | } |
| 102 | - try(ResultSet resultSet = statement.executeQuery(TABLE_DEF_SQL + | 271 | + try ( |
| 103 | - request.getSchema() + POINT + request.getTableName() + QUOTES_PARENTHESES_SEMICOLON);){ | 272 | + ResultSet resultSet = statement.executeQuery(tableColumnSQLService.get(conMap.get(request.getUuid()) |
| 104 | - while (resultSet.next()) { | 273 | + .getType()).tableColumnSQL(request.getOid(), request.getSchema(), |
| 105 | - resultMap.put(RESULT, resultSet.getString(PG_GET_TABLEDEF)); | 274 | + request.getTableName())) |
| 106 | - } | 275 | + ) { |
| 107 | - log.info("tableDdl map is: " + resultMap); | 276 | + Map<String, Object> resultMap = DebugUtils.parseResultSet(resultSet); |
| 277 | + log.info("tableColumn resultMap is: " + resultMap); | ||
| 108 | return resultMap; | 278 | return resultMap; |
| 109 | } | 279 | } |
| 110 | } | 280 | } |
| 111 | } | 281 | } |
| 282 | + | ||
| 283 | + | ||
| 284 | + public void tableDataClose(String winId) throws Exception { | ||
| 285 | + log.info("tableDataClise request is: " + winId); | ||
| 286 | + ResultSetMapDAO resultSetMapDAO = new ResultSetMapDAO(); | ||
| 287 | + resultSetMapDAO.overtimeCloseWin(winId); | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + | ||
| 291 | + public TablePKDataQuery tableDataEdit(TableDataEditQuery request) throws Exception { | ||
| 292 | + log.info("tableDataEdit request is: {}", request); | ||
| 293 | + log.info("winMap is: {}", winMap); | ||
| 294 | + Connection connection = getConnectionMap(request.getWinId()); | ||
| 295 | + ResultSet resultSet = getResultSetMap(request.getWinId()); | ||
| 296 | + TablePKDataQuery tablePKDataQuery = new TablePKDataQuery(); | ||
| 297 | + boolean b = tableDataEdit(request, connection); | ||
| 298 | + if (!b) { | ||
| 299 | + tablePKDataQuery.setMsg(LocaleString.transLanguage("2017")); | ||
| 300 | + tablePKDataQuery.setPKCreate(true); | ||
| 301 | + log.info("TablePKDataQuery is: {}", tablePKDataQuery); | ||
| 302 | + return tablePKDataQuery; | ||
| 303 | + } | ||
| 304 | + connection.setAutoCommit(false); | ||
| 305 | + for (TableDataEditQuery.TableDataDTO data : request.getData()) { | ||
| 306 | + data.getType().rs(resultSet, data); | ||
| 307 | + } | ||
| 308 | + connection.commit(); | ||
| 309 | + tablePKDataQuery.setMsg(""); | ||
| 310 | + tablePKDataQuery.setPKCreate(false); | ||
| 311 | + return tablePKDataQuery; | ||
| 312 | + } | ||
| 313 | + | ||
| 314 | + public Boolean tableDataEdit(TableDataEditQuery request, Connection connection) throws Exception { | ||
| 315 | + log.info("tableDataEdit request is: {}", request); | ||
| 316 | + log.info("winMap is: {}", winMap); | ||
| 317 | + if (!winMap.containsKey(request.getWinId())) { | ||
| 318 | + throw new CustomException(LocaleString.transLanguage("1009")); | ||
| 319 | + } | ||
| 320 | + String uuid = winMap.get(request.getWinId()).getUuid(); | ||
| 321 | + String schema = winMap.get(request.getWinId()).getSchema(); | ||
| 322 | + String tableName = winMap.get(request.getWinId()).getTableName(); | ||
| 323 | + String sql = tableColumnSQLService.get(conMap.get(uuid).getType()).tablePKConstraintSQL(schema, tableName); | ||
| 324 | + try ( | ||
| 325 | + Statement statement = connection.createStatement(); | ||
| 326 | + ResultSet resultSetUnique = statement.executeQuery(sql) | ||
| 327 | + ) { | ||
| 328 | + if (resultSetUnique.next()) { | ||
| 329 | + log.info("resultSetUnique is: {}", true); | ||
| 330 | + return true; | ||
| 331 | + } else { | ||
| 332 | + log.info("resultSetUnique is: {}", false); | ||
| 333 | + return false; | ||
| 334 | + } | ||
| 335 | + } | ||
| 336 | + } | ||
| 337 | + | ||
| 338 | + | ||
| 339 | + public void tableTruncate(TableNameDTO request) throws Exception { | ||
| 340 | + log.info("DatabaseCreateTableDTO request is: " + request); | ||
| 341 | + try ( | ||
| 342 | + Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 343 | + Statement statement = connection.createStatement() | ||
| 344 | + ) { | ||
| 345 | + statement.execute(tableObjectSQLService.get(conMap.get(request.getUuid()).getType()).tableTruncateSQL( | ||
| 346 | + request.getSchema(), request.getTableName())); | ||
| 347 | + } | ||
| 348 | + } | ||
| 349 | + | ||
| 350 | + | ||
| 351 | + public void tableVacuum(TableNameDTO request) throws Exception { | ||
| 352 | + log.info("DatabaseCreateTableDTO request is: " + request); | ||
| 353 | + try (Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 354 | + Statement statement = connection.createStatement()) { | ||
| 355 | + statement.execute(tableObjectSQLService.get(conMap.get(request.getUuid()).getType()).tableVacuumSQL( | ||
| 356 | + request.getSchema(), request.getTableName())); | ||
| 357 | + } | ||
| 358 | + } | ||
| 359 | + | ||
| 360 | + | ||
| 361 | + public void tableReindex(TableNameDTO request) throws Exception { | ||
| 362 | + log.info("DatabaseCreateTableDTO request is: " + request); | ||
| 363 | + try (Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 364 | + Statement statement = connection.createStatement()) { | ||
| 365 | + statement.execute(tableObjectSQLService.get(conMap.get(request.getUuid()).getType()).tableReindexSQL( | ||
| 366 | + request.getSchema(), request.getTableName())); | ||
| 367 | + } | ||
| 368 | + } | ||
| 369 | + | ||
| 370 | + | ||
| 371 | + public void tableRename(TableAlterDTO request) throws Exception { | ||
| 372 | + log.info("DatabaseCreateTableDTO request is: " + request); | ||
| 373 | + try (Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 374 | + Statement statement = connection.createStatement()) { | ||
| 375 | + statement.execute(tableObjectSQLService.get(conMap.get(request.getUuid()).getType()).tableRenameSQL( | ||
| 376 | + request.getSchema(), request.getTableName(), request.getGeneralPurpose())); | ||
| 377 | + } | ||
| 378 | + } | ||
| 379 | + | ||
| 380 | + | ||
| 381 | + public void tableComment(TableAlterDTO request) throws Exception { | ||
| 382 | + log.info("DatabaseCreateTableDTO request is: " + request); | ||
| 383 | + try (Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 384 | + Statement statement = connection.createStatement()) { | ||
| 385 | + statement.execute(tableObjectSQLService.get(conMap.get(request.getUuid()).getType()).tableCommentSQL( | ||
| 386 | + request.getSchema(), request.getTableName(), request.getGeneralPurpose())); | ||
| 387 | + } | ||
| 388 | + } | ||
| 389 | + | ||
| 390 | + | ||
| 391 | + public void tableAlterSchema(TableAlterDTO request) throws Exception { | ||
| 392 | + log.info("DatabaseCreateTableDTO request is: " + request); | ||
| 393 | + try (Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 394 | + Statement statement = connection.createStatement()) { | ||
| 395 | + statement.execute(tableObjectSQLService.get(conMap.get(request.getUuid()).getType()).tableAlterSchemaSQL( | ||
| 396 | + request.getSchema(), request.getTableName(), request.getGeneralPurpose())); | ||
| 397 | + } | ||
| 398 | + } | ||
| 399 | + | ||
| 400 | + | ||
| 401 | + public void tableDrop(TableNameDTO request) throws Exception { | ||
| 402 | + log.info("DatabaseCreateTableDTO request is: " + request); | ||
| 403 | + try (Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 404 | + Statement statement = connection.createStatement()) { | ||
| 405 | + statement.execute( | ||
| 406 | + tableObjectSQLService.get(conMap.get(request.getUuid()).getType()).tableDropSQL(request.getSchema(), | ||
| 407 | + request.getTableName())); | ||
| 408 | + } | ||
| 409 | + } | ||
| 410 | + | ||
| 411 | + | ||
| 412 | + public void tableAlterTablespace(TableAlterDTO request) throws Exception { | ||
| 413 | + log.info("DatabaseCreateTableDTO request is: " + request); | ||
| 414 | + try (Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 415 | + Statement statement = connection.createStatement()) { | ||
| 416 | + statement.execute( | ||
| 417 | + tableObjectSQLService.get(conMap.get(request.getUuid()).getType()).tableAlterTablespaceSQL( | ||
| 418 | + request.getSchema(), request.getTableName(), request.getGeneralPurpose())); | ||
| 419 | + } | ||
| 420 | + } | ||
| 421 | + | ||
| 422 | + public Map<String, Object> tableSequence(TableNameDTO request) throws Exception { | ||
| 423 | + log.info("tableColumn request is: " + request); | ||
| 424 | + try (Connection connection = connectionConfig.connectDatabase(request.getUuid()); | ||
| 425 | + Statement statement = connection.createStatement()) { | ||
| 426 | + try (ResultSet resultSet = statement.executeQuery(tableObjectSQLService.get(conMap.get(request.getUuid()) | ||
| 427 | + .getType()).tableSequenceSQL(request.getSchema(), request.getTableName()))) { | ||
| 428 | + log.info("tableColumn resultSet is: " + resultSet); | ||
| 429 | + Map<String, Object> resultMap = DebugUtils.parseResultSet(resultSet); | ||
| 430 | + log.info("tableColumn resultMap is: " + resultMap); | ||
| 431 | + return resultMap; | ||
| 432 | + } | ||
| 433 | + } | ||
| 434 | + } | ||
| 435 | + | ||
| 436 | + public List<Map<String, Object>> tableAttribute(TableAttributeDTO request) throws Exception { | ||
| 437 | + return tableObjectSQLService.get(conMap.get(request.getUuid()) | ||
| 438 | + .getType()).tableAttributeSQL(request.getUuid(), request.getOid(), request.getTableType()); | ||
| 439 | + } | ||
| 112 | } | 440 | } |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.util; | 5 | package com.nctigba.datastudio.util; |
| 2 | 6 | ||
| 3 | import java.sql.Connection; | 7 | import java.sql.Connection; |
| @@ -7,8 +11,6 @@ import static com.nctigba.datastudio.util.SecretUtil.desEncrypt; | |||
| 7 | 11 | ||
| 8 | public final class ConnectionUtils { | 12 | public final class ConnectionUtils { |
| 9 | public static Connection connectGet(String jdbcUrl, String username, String password) throws Exception { | 13 | public static Connection connectGet(String jdbcUrl, String username, String password) throws Exception { |
| 10 | - String driver = "com.huawei.opengauss.jdbc.Driver"; | ||
| 11 | - Class.forName(driver); | ||
| 12 | return DriverManager.getConnection(jdbcUrl, username, desEncrypt(password)); | 14 | return DriverManager.getConnection(jdbcUrl, username, desEncrypt(password)); |
| 13 | } | 15 | } |
| 14 | } | 16 | } |
| @@ -1,13 +1,25 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.util; | 5 | package com.nctigba.datastudio.util; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.base.WebSocketServer; | 7 | import com.nctigba.datastudio.base.WebSocketServer; |
| 4 | import com.nctigba.datastudio.enums.ParamTypeEnum; | 8 | import com.nctigba.datastudio.enums.ParamTypeEnum; |
| 5 | import com.nctigba.datastudio.model.PublicParamReq; | 9 | import com.nctigba.datastudio.model.PublicParamReq; |
| 10 | +import com.nctigba.datastudio.model.entity.OperateStatusDO; | ||
| 6 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
| 7 | import org.apache.commons.lang3.StringUtils; | 12 | import org.apache.commons.lang3.StringUtils; |
| 8 | import org.apache.logging.log4j.util.Strings; | 13 | import org.apache.logging.log4j.util.Strings; |
| 9 | import org.springframework.util.CollectionUtils; | 14 | import org.springframework.util.CollectionUtils; |
| 10 | 15 | ||
| 16 | +import javax.servlet.http.HttpServletResponse; | ||
| 17 | +import java.io.ByteArrayInputStream; | ||
| 18 | +import java.io.InputStream; | ||
| 19 | +import java.io.OutputStream; | ||
| 20 | +import java.net.URLEncoder; | ||
| 21 | +import java.nio.charset.StandardCharsets; | ||
| 22 | +import java.sql.Connection; | ||
| 11 | import java.sql.ResultSet; | 23 | import java.sql.ResultSet; |
| 12 | import java.sql.ResultSetMetaData; | 24 | import java.sql.ResultSetMetaData; |
| 13 | import java.sql.SQLException; | 25 | import java.sql.SQLException; |
| @@ -19,144 +31,193 @@ import java.util.List; | |||
| 19 | import java.util.Map; | 31 | import java.util.Map; |
| 20 | import java.util.Set; | 32 | import java.util.Set; |
| 21 | 33 | ||
| 34 | +import static com.nctigba.datastudio.constants.CommonConstants.CAN_BREAK; | ||
| 22 | import static com.nctigba.datastudio.constants.CommonConstants.COLUMN; | 35 | import static com.nctigba.datastudio.constants.CommonConstants.COLUMN; |
| 23 | -import static com.nctigba.datastudio.constants.CommonConstants.FUNCTION; | 36 | +import static com.nctigba.datastudio.constants.CommonConstants.DIFFER; |
| 37 | +import static com.nctigba.datastudio.constants.CommonConstants.DOLLAR; | ||
| 38 | +import static com.nctigba.datastudio.constants.CommonConstants.FUNCTION_DOLLAR; | ||
| 24 | import static com.nctigba.datastudio.constants.CommonConstants.FUNC_OID; | 39 | import static com.nctigba.datastudio.constants.CommonConstants.FUNC_OID; |
| 25 | -import static com.nctigba.datastudio.constants.CommonConstants.LINE_FEED; | 40 | +import static com.nctigba.datastudio.constants.CommonConstants.IN; |
| 41 | +import static com.nctigba.datastudio.constants.CommonConstants.INOUT; | ||
| 42 | +import static com.nctigba.datastudio.constants.CommonConstants.LINE_NO; | ||
| 43 | +import static com.nctigba.datastudio.constants.CommonConstants.NAME; | ||
| 44 | +import static com.nctigba.datastudio.constants.CommonConstants.NSP_NAME; | ||
| 45 | +import static com.nctigba.datastudio.constants.CommonConstants.N_SLASH; | ||
| 26 | import static com.nctigba.datastudio.constants.CommonConstants.OID; | 46 | import static com.nctigba.datastudio.constants.CommonConstants.OID; |
| 27 | -import static com.nctigba.datastudio.constants.CommonConstants.PROCEDURE; | 47 | +import static com.nctigba.datastudio.constants.CommonConstants.OUT; |
| 48 | +import static com.nctigba.datastudio.constants.CommonConstants.PRON_ARGS; | ||
| 49 | +import static com.nctigba.datastudio.constants.CommonConstants.PRO_ARG_MODES; | ||
| 50 | +import static com.nctigba.datastudio.constants.CommonConstants.PRO_ARG_NAMES; | ||
| 51 | +import static com.nctigba.datastudio.constants.CommonConstants.PRO_ARG_TYPES; | ||
| 52 | +import static com.nctigba.datastudio.constants.CommonConstants.PRO_NAME; | ||
| 28 | import static com.nctigba.datastudio.constants.CommonConstants.RESULT; | 53 | import static com.nctigba.datastudio.constants.CommonConstants.RESULT; |
| 54 | +import static com.nctigba.datastudio.constants.CommonConstants.SLASH; | ||
| 29 | import static com.nctigba.datastudio.constants.CommonConstants.SPACE; | 55 | import static com.nctigba.datastudio.constants.CommonConstants.SPACE; |
| 30 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; | 56 | import static com.nctigba.datastudio.constants.CommonConstants.STATEMENT; |
| 57 | +import static com.nctigba.datastudio.constants.CommonConstants.T; | ||
| 58 | +import static com.nctigba.datastudio.constants.CommonConstants.TYP_NAME; | ||
| 59 | +import static com.nctigba.datastudio.constants.CommonConstants.VARIADIC; | ||
| 60 | +import static com.nctigba.datastudio.constants.SqlConstants.BACKTRACE_SQL; | ||
| 61 | +import static com.nctigba.datastudio.constants.SqlConstants.BACKTRACE_SQL_PRE; | ||
| 31 | import static com.nctigba.datastudio.constants.SqlConstants.COMMA; | 62 | import static com.nctigba.datastudio.constants.SqlConstants.COMMA; |
| 32 | import static com.nctigba.datastudio.constants.SqlConstants.COMMA_SPACE; | 63 | import static com.nctigba.datastudio.constants.SqlConstants.COMMA_SPACE; |
| 33 | -import static com.nctigba.datastudio.constants.SqlConstants.GET_PROC_NAME_SQL; | 64 | +import static com.nctigba.datastudio.constants.SqlConstants.GET_OID_NAME_SQL; |
| 34 | -import static com.nctigba.datastudio.constants.SqlConstants.GET_PROC_TYPE_SQL; | 65 | +import static com.nctigba.datastudio.constants.SqlConstants.INFO_CODE_SQL; |
| 35 | -import static com.nctigba.datastudio.constants.SqlConstants.GET_PROC_SQL; | 66 | +import static com.nctigba.datastudio.constants.SqlConstants.LEFT_BRACKET; |
| 36 | -import static com.nctigba.datastudio.constants.SqlConstants.GET_TYPE_OID_SQL; | ||
| 37 | -import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_LEFT; | ||
| 38 | -import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_RIGHT; | ||
| 39 | import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_SEMICOLON; | 67 | import static com.nctigba.datastudio.constants.SqlConstants.PARENTHESES_SEMICOLON; |
| 40 | import static com.nctigba.datastudio.constants.SqlConstants.POINT; | 68 | import static com.nctigba.datastudio.constants.SqlConstants.POINT; |
| 41 | -import static com.nctigba.datastudio.constants.SqlConstants.QUOTES_SEMICOLON; | 69 | +import static com.nctigba.datastudio.constants.SqlConstants.PROC_SQL; |
| 70 | +import static com.nctigba.datastudio.constants.SqlConstants.RIGHT_BRACKET; | ||
| 42 | import static com.nctigba.datastudio.constants.SqlConstants.TABLE_DATA_SQL; | 71 | import static com.nctigba.datastudio.constants.SqlConstants.TABLE_DATA_SQL; |
| 43 | 72 | ||
| 44 | 73 | ||
| 45 | public class DebugUtils { | 74 | public class DebugUtils { |
| 46 | - /** | 75 | + public static final String TRANS_POINT = "\\."; |
| 47 | - * get function/procedure name(include param) | ||
| 48 | - * | ||
| 49 | - * sql | ||
| 50 | - * | ||
| 51 | - */ | ||
| 52 | - public static String prepareName(String sql) { | ||
| 53 | - List<Integer> leftList = getIndexList(sql, PARENTHESES_LEFT); | ||
| 54 | - List<Integer> rightList = getIndexList(sql, PARENTHESES_RIGHT); | ||
| 55 | - sql = sql.replace(LINE_FEED, SPACE); | ||
| 56 | - int first = sql.indexOf(POINT); | ||
| 57 | - int start = leftList.get(0); | ||
| 58 | - int end = rightList.get(rightList.size() - 1); | ||
| 59 | 76 | ||
| 60 | - StringBuilder sb = new StringBuilder(); | 77 | + public static String getSchemaBySql(String sql) { |
| 61 | - if (first == -1) { | 78 | + String substring = sql.substring(0, sql.indexOf(LEFT_BRACKET)); |
| 62 | - String str = Strings.EMPTY; | 79 | + log.info("DebugUtils getSchemaBySql substring: " + substring); |
| 63 | - int functionIndex = sql.toLowerCase().indexOf(FUNCTION); | 80 | + String[] split = substring.trim().split(SPACE); |
| 64 | - int procedureIndex = sql.toLowerCase().indexOf(PROCEDURE); | ||
| 65 | - if (functionIndex != -1) { | ||
| 66 | - str = sql.substring(functionIndex, start); | ||
| 67 | - } | ||
| 68 | - if (procedureIndex != -1) { | ||
| 69 | - str = sql.substring(procedureIndex, start); | ||
| 70 | - } | ||
| 71 | - sb.append(str.trim().split(SPACE)[1]).append(PARENTHESES_LEFT); | ||
| 72 | - } else { | ||
| 73 | - sb.append(sql, first + 1, start + 1); | ||
| 74 | - } | ||
| 75 | - String[] splits = sql.substring(start + 1, end).split(COMMA); | ||
| 76 | - for (String s : splits) { | ||
| 77 | - log.info("DebugUtils prepareName splits is: " + s); | ||
| 78 | - } | ||
| 79 | 81 | ||
| 80 | - boolean isParam = false; | 82 | + String fullName = split[split.length - 1]; |
| 81 | - for (String split : splits) { | 83 | + log.info("DebugUtils getSchemaBySql fullName: " + fullName); |
| 82 | - if (!split.trim().toLowerCase().startsWith("out ")) { | 84 | + if (!fullName.contains(POINT)) { |
| 83 | - String[] params = split.trim().split(SPACE); | 85 | + return null; |
| 84 | - if (params.length == 1) { | ||
| 85 | - sb.append(params[0]).append(COMMA); | ||
| 86 | - } else if (params.length == 3) { | ||
| 87 | - sb.append(params[2]).append(COMMA); | ||
| 88 | - } else { | ||
| 89 | - sb.append(params[1]).append(COMMA); | ||
| 90 | - } | ||
| 91 | - isParam = true; | ||
| 92 | - } | ||
| 93 | } | 86 | } |
| 94 | - if (isParam) { | 87 | + return fullName.split(TRANS_POINT)[0]; |
| 95 | - sb.deleteCharAt(sb.length() - 1); | ||
| 96 | - } | ||
| 97 | - sb.append(PARENTHESES_RIGHT); | ||
| 98 | - log.info("DebugUtils prepareName name is: " + sb); | ||
| 99 | - return sb.toString(); | ||
| 100 | } | 88 | } |
| 101 | 89 | ||
| 102 | - public static List<Integer> getIndexList(String sql, String str) { | 90 | + public static String getNameBySql(String sql) { |
| 103 | - List<Integer> list = new ArrayList<>(); | 91 | + String substring = sql.substring(0, sql.indexOf(LEFT_BRACKET)); |
| 104 | - int index = 0; | 92 | + log.info("DebugUtils getNameBySql substring: " + substring); |
| 105 | - sql = sql.toLowerCase(); | 93 | + String[] split = substring.trim().split(SPACE); |
| 106 | - if (sql.contains("as\n")) { | 94 | + |
| 107 | - index = sql.indexOf("as\n"); | 95 | + String fullName = split[split.length - 1]; |
| 108 | - } else if (sql.contains("as $$")) { | 96 | + log.info("DebugUtils getNameBySql fullName: " + fullName); |
| 109 | - index = sql.indexOf("as $$"); | 97 | + if (!fullName.contains(POINT)) { |
| 110 | - } else if (sql.contains("as ")) { | 98 | + return fullName; |
| 111 | - index = sql.indexOf("as "); | 99 | + } |
| 112 | - } else { | 100 | + return fullName.split(TRANS_POINT)[1]; |
| 113 | - index = sql.length(); | 101 | + } |
| 102 | + | ||
| 103 | + public static List<Map<String, Object>> getParamMap(WebSocketServer webSocketServer, String windowName, | ||
| 104 | + String oid) throws SQLException { | ||
| 105 | + log.info("DebugUtils getParamMap windowName--oid: " + windowName + "--" + oid); | ||
| 106 | + List<Map<String, Object>> list = new ArrayList<>(); | ||
| 107 | + Statement statement = webSocketServer.getStatement(windowName); | ||
| 108 | + String[] proArgNames = new String[]{}; | ||
| 109 | + String argTypes = Strings.EMPTY; | ||
| 110 | + | ||
| 111 | + try ( | ||
| 112 | + ResultSet resultSet = statement.executeQuery(String.format(PROC_SQL, oid)) | ||
| 113 | + ) { | ||
| 114 | + while (resultSet.next()) { | ||
| 115 | + int pronArgs = resultSet.getInt(PRON_ARGS); | ||
| 116 | + if (pronArgs == 0) { | ||
| 117 | + return null; | ||
| 118 | + } | ||
| 119 | + argTypes = resultSet.getString(PRO_ARG_TYPES); | ||
| 120 | + String argNames = resultSet.getString(PRO_ARG_NAMES); | ||
| 121 | + proArgNames = argNames.substring(1, argNames.length() - 1).split(COMMA); | ||
| 122 | + } | ||
| 123 | + } catch (Exception e) { | ||
| 124 | + log.info(e.getMessage()); | ||
| 125 | + throw new RuntimeException(e.getMessage(), e); | ||
| 114 | } | 126 | } |
| 115 | 127 | ||
| 116 | - String subSql = sql.substring(0, index); | 128 | + try ( |
| 117 | - log.info("DebugUtils getIndexList subSql is: " + subSql); | 129 | + ResultSet nameResult = statement.executeQuery( |
| 118 | - for (int i = 0; i < subSql.length(); i++) { | 130 | + String.format(GET_OID_NAME_SQL, argTypes.replace(SPACE, COMMA))) |
| 119 | - if (str.equals(String.valueOf(subSql.charAt(i)))) { | 131 | + ) { |
| 120 | - list.add(i); | 132 | + while (nameResult.next()) { |
| 133 | + for (int i = 0; i < argTypes.split(SPACE).length; i++) { | ||
| 134 | + Map<String, Object> map = new HashMap<>(); | ||
| 135 | + map.put(proArgNames[i], ParamTypeEnum.parseType(nameResult.getString(TYP_NAME))); | ||
| 136 | + list.add(map); | ||
| 137 | + } | ||
| 121 | } | 138 | } |
| 139 | + log.info("DebugUtils getParamMap list: " + list); | ||
| 140 | + return list; | ||
| 141 | + } catch (Exception e) { | ||
| 142 | + log.info(e.getMessage()); | ||
| 143 | + throw new RuntimeException(e.getMessage(), e); | ||
| 122 | } | 144 | } |
| 123 | - log.info("DebugUtils getIndexList list is: " + list); | 145 | + } |
| 146 | + | ||
| 147 | + public static List<String> getOidList(WebSocketServer webSocketServer, String rootWindowName) throws SQLException { | ||
| 148 | + log.info("DebugUtils getOidList rootWindowName: " + rootWindowName); | ||
| 149 | + List<String> list = new ArrayList<>(); | ||
| 150 | + | ||
| 151 | + try { | ||
| 152 | + Statement statement = (Statement) webSocketServer.getParamMap(rootWindowName).get(STATEMENT); | ||
| 153 | + ResultSet stackResult = statement.executeQuery(BACKTRACE_SQL_PRE + 0 + BACKTRACE_SQL); | ||
| 154 | + while (stackResult.next()) { | ||
| 155 | + list.add(stackResult.getString(FUNC_OID)); | ||
| 156 | + } | ||
| 157 | + } catch (Exception e) { | ||
| 158 | + log.info(e.getMessage()); | ||
| 159 | + return new ArrayList<>(); | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + log.info("DebugUtils getOidList list: " + list); | ||
| 124 | return list; | 163 | return list; |
| 125 | } | 164 | } |
| 126 | 165 | ||
| 127 | - /** | 166 | + public static Map<String, Object> getParamType(WebSocketServer webSocketServer, PublicParamReq paramReq) { |
| 128 | - * get function/procedure name | 167 | + log.info("DebugUtils getParamType paramReq: " + paramReq); |
| 129 | - * | 168 | + Map<String, Object> map = new HashMap<>(); |
| 130 | - * @param sql | 169 | + try ( |
| 131 | - * @return | 170 | + Connection connection = webSocketServer.createConnection(paramReq.getUuid(), paramReq.getWindowName()); |
| 132 | - */ | 171 | + Statement statement = connection.createStatement(); |
| 133 | - public static String prepareFuncName(String sql) { | 172 | + ResultSet resultSet = statement.executeQuery(String.format(PROC_SQL, paramReq.getOid())) |
| 134 | - String[] split = sql.split("\\("); | 173 | + ) { |
| 135 | - String[] s = split[0].split(SPACE); | 174 | + while (resultSet.next()) { |
| 136 | - log.info("DebugUtils prepareFuncName s is: " + Arrays.toString(s)); | 175 | + String argName = resultSet.getString(PRO_ARG_NAMES); |
| 137 | - return s[s.length - 1]; | 176 | + String[] proArgNames = argName.substring(1, argName.length() - 1).split(COMMA); |
| 177 | + for (int i = 0; i < proArgNames.length; i++) { | ||
| 178 | + String argMode = resultSet.getString(PRO_ARG_MODES); | ||
| 179 | + if (StringUtils.isEmpty(argMode)) { | ||
| 180 | + map.put(proArgNames[i], IN); | ||
| 181 | + } else { | ||
| 182 | + String[] proArgModes = argMode.substring(1, argMode.length() - 1).split(COMMA); | ||
| 183 | + switch (proArgModes[i]) { | ||
| 184 | + case "i": | ||
| 185 | + map.put(proArgNames[i], IN); | ||
| 186 | + break; | ||
| 187 | + case "o": | ||
| 188 | + map.put(proArgNames[i], OUT); | ||
| 189 | + break; | ||
| 190 | + case "b": | ||
| 191 | + map.put(proArgNames[i], INOUT); | ||
| 192 | + break; | ||
| 193 | + case "v": | ||
| 194 | + map.put(proArgNames[i], VARIADIC); | ||
| 195 | + break; | ||
| 196 | + } | ||
| 197 | + } | ||
| 198 | + } | ||
| 199 | + } | ||
| 200 | + } catch (Exception e) { | ||
| 201 | + return map; | ||
| 202 | + } | ||
| 203 | + log.info("DebugUtils getParamType map: " + map); | ||
| 204 | + return map; | ||
| 138 | } | 205 | } |
| 139 | 206 | ||
| 140 | - /** | ||
| 141 | - * prepare function/procedure sql | ||
| 142 | - * | ||
| 143 | - * paramReq | ||
| 144 | - * | ||
| 145 | - */ | ||
| 146 | public static String prepareSql(PublicParamReq paramReq) { | 207 | public static String prepareSql(PublicParamReq paramReq) { |
| 147 | String sql = paramReq.getSql(); | 208 | String sql = paramReq.getSql(); |
| 148 | StringBuilder sb = new StringBuilder(); | 209 | StringBuilder sb = new StringBuilder(); |
| 149 | - sb.append(TABLE_DATA_SQL).append(prepareFuncName(sql)).append(PARENTHESES_LEFT); | 210 | + sb.append(TABLE_DATA_SQL).append(getFullName(sql)).append(LEFT_BRACKET); |
| 150 | List<Map<String, Object>> inputParams = paramReq.getInputParams(); | 211 | List<Map<String, Object>> inputParams = paramReq.getInputParams(); |
| 151 | - log.info("DebugUtils prepareSql inputParams is: " + inputParams); | 212 | + log.info("DebugUtils prepareSql inputParams: " + inputParams); |
| 152 | 213 | ||
| 153 | if (!CollectionUtils.isEmpty(inputParams)) { | 214 | if (!CollectionUtils.isEmpty(inputParams)) { |
| 154 | for (int i = 0; i < inputParams.size(); i++) { | 215 | for (int i = 0; i < inputParams.size(); i++) { |
| 155 | Map<String, Object> paramMap = inputParams.get(i); | 216 | Map<String, Object> paramMap = inputParams.get(i); |
| 156 | Set<String> keySet = paramMap.keySet(); | 217 | Set<String> keySet = paramMap.keySet(); |
| 157 | for (String key : keySet) { | 218 | for (String key : keySet) { |
| 158 | - if (key.contains("int") || key.contains("number") | 219 | + if (key.contains("int") || key.contains("number") || key.contains("float") || key.contains("double") |
| 159 | - || key.contains("float") || key.contains("double")) { | 220 | + || key.contains("real") || key.contains("serial")) { |
| 160 | sb.append(paramMap.get(key)); | 221 | sb.append(paramMap.get(key)); |
| 161 | } else { | 222 | } else { |
| 162 | sb.append("'").append(paramMap.get(key)).append("'"); | 223 | sb.append("'").append(paramMap.get(key)).append("'"); |
| @@ -170,60 +231,72 @@ public class DebugUtils { | |||
| 170 | } | 231 | } |
| 171 | 232 | ||
| 172 | sb.append(PARENTHESES_SEMICOLON); | 233 | sb.append(PARENTHESES_SEMICOLON); |
| 173 | - log.info("DebugUtils prepareSql sql is: " + sb); | 234 | + log.info("DebugUtils prepareSql sql: " + sb); |
| 174 | return sb.toString(); | 235 | return sb.toString(); |
| 175 | } | 236 | } |
| 176 | 237 | ||
| 177 | - /** | 238 | + public static String getFullName(String sql) { |
| 178 | - * parse resultSet | 239 | + String[] split = sql.split("\\("); |
| 179 | - * | 240 | + String[] s = split[0].trim().split(SPACE); |
| 180 | - * @param resultSet | 241 | + log.info("DebugUtils getFullName s: " + Arrays.toString(s)); |
| 181 | - * @return | 242 | + return s[s.length - 1]; |
| 182 | - * @throws SQLException | 243 | + } |
| 183 | - */ | 244 | + |
| 184 | public static Map<String, Object> parseResultSet(ResultSet resultSet) throws SQLException { | 245 | public static Map<String, Object> parseResultSet(ResultSet resultSet) throws SQLException { |
| 185 | - ResultSetMetaData metaData = resultSet.getMetaData(); | ||
| 186 | Map<String, Object> map = new HashMap<>(); | 246 | Map<String, Object> map = new HashMap<>(); |
| 187 | - List<String> columnList = new ArrayList<>(); | 247 | + List<String> columnList = getColumnList(resultSet.getMetaData(), map); |
| 188 | - for (int i = 0; i < metaData.getColumnCount(); i++) { | 248 | + |
| 189 | - columnList.add(metaData.getColumnName(i + 1)); | 249 | + List<List<Object>> dataList = new ArrayList<>(); |
| 250 | + while (resultSet.next()) { | ||
| 251 | + List<Object> list = new ArrayList<>(); | ||
| 252 | + for (String column : columnList) { | ||
| 253 | + list.add(resultSet.getObject(column)); | ||
| 254 | + } | ||
| 255 | + dataList.add(list); | ||
| 190 | } | 256 | } |
| 191 | - map.put(COLUMN, columnList); | 257 | + map.put(RESULT, dataList); |
| 258 | + log.info("DebugUtils parseResultSet map: " + map); | ||
| 259 | + return map; | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + public static Map<String, Object> parseResultSet(ResultSet resultSet, Integer size, | ||
| 263 | + Integer pageNum) throws SQLException { | ||
| 264 | + log.info("ResultSet map: " + resultSet); | ||
| 265 | + log.info("size map: " + size); | ||
| 266 | + log.info("pageNum map: " + pageNum); | ||
| 267 | + Map<String, Object> map = new HashMap<>(); | ||
| 268 | + List<String> columnList = getColumnList(resultSet.getMetaData(), map); | ||
| 269 | + List<List<Object>> dataList = new ArrayList<>(); | ||
| 270 | + Integer i = 0; | ||
| 271 | + if (pageNum != 1) { | ||
| 272 | + resultSet.absolute(size * pageNum - 1); | ||
| 273 | + } else { | ||
| 274 | + resultSet.absolute(0); | ||
| 275 | + } | ||
| 276 | + boolean a = i < size; | ||
| 277 | + while (resultSet.next() && i < size) { | ||
| 278 | + log.info("11111 map"); | ||
| 279 | + List<Object> list = new ArrayList<>(); | ||
| 280 | + for (String column : columnList) { | ||
| 281 | + list.add(resultSet.getObject(column)); | ||
| 282 | + } | ||
| 283 | + i++; | ||
| 284 | + dataList.add(list); | ||
| 285 | + } | ||
| 286 | + map.put(RESULT, dataList); | ||
| 287 | + log.info("DebugUtils parseResultSet map: " + map); | ||
| 288 | + return map; | ||
| 289 | + } | ||
| 290 | + | ||
| 291 | + public static Map<String, Object> parseBreakPoint(ResultSet resultSet, String oid) throws SQLException { | ||
| 292 | + Map<String, Object> map = new HashMap<>(); | ||
| 293 | + List<String> columnList = getColumnList(resultSet.getMetaData(), map); | ||
| 192 | 294 | ||
| 193 | List<List<Object>> dataList = new ArrayList<>(); | 295 | List<List<Object>> dataList = new ArrayList<>(); |
| 194 | while (resultSet.next()) { | 296 | while (resultSet.next()) { |
| 195 | List<Object> list = new ArrayList<>(); | 297 | List<Object> list = new ArrayList<>(); |
| 196 | for (String column : columnList) { | 298 | for (String column : columnList) { |
| 197 | String str = resultSet.getString(column); | 299 | String str = resultSet.getString(column); |
| 198 | - | ||
| 199 | - if (StringUtils.isEmpty(str)) { | ||
| 200 | - list.add(Strings.EMPTY); | ||
| 201 | - continue; | ||
| 202 | - } | ||
| 203 | - list.add(str); | ||
| 204 | - } | ||
| 205 | - dataList.add(list); | ||
| 206 | - } | ||
| 207 | - map.put(RESULT, dataList); | ||
| 208 | - log.info("DebugUtils parseResultSet map is: " + map); | ||
| 209 | - return map; | ||
| 210 | - } | ||
| 211 | - | ||
| 212 | - public static Map<String, Object> parseBeakPoint(ResultSet resultSet, String oid) throws SQLException { | ||
| 213 | - ResultSetMetaData metaData = resultSet.getMetaData(); | ||
| 214 | - Map<String, Object> map = new HashMap<>(); | ||
| 215 | - List<String> columnList = new ArrayList<>(); | ||
| 216 | - for (int i = 0; i < metaData.getColumnCount(); i++) { | ||
| 217 | - columnList.add(metaData.getColumnName(i + 1)); | ||
| 218 | - } | ||
| 219 | - map.put(COLUMN, columnList); | ||
| 220 | - log.info("DebugUtils parseBeakPoint columnList is: " + columnList); | ||
| 221 | - | ||
| 222 | - List<List<Object>> dataList = new ArrayList<>(); | ||
| 223 | - while (resultSet.next()) { | ||
| 224 | - List<Object> list = new ArrayList<>(); | ||
| 225 | - for (int i = 0; i < columnList.size(); i++) { | ||
| 226 | - String str = resultSet.getString(columnList.get(i)); | ||
| 227 | if (str.equals("t")) { | 300 | if (str.equals("t")) { |
| 228 | list.add(true); | 301 | list.add(true); |
| 229 | } else if (str.equals("f")) { | 302 | } else if (str.equals("f")) { |
| @@ -237,141 +310,207 @@ public class DebugUtils { | |||
| 237 | } | 310 | } |
| 238 | } | 311 | } |
| 239 | map.put(RESULT, dataList); | 312 | map.put(RESULT, dataList); |
| 240 | - log.info("DebugUtils parseBeakPoint map is: " + map); | 313 | + log.info("DebugUtils parseBeakPoint map: " + map); |
| 241 | return map; | 314 | return map; |
| 242 | } | 315 | } |
| 243 | 316 | ||
| 244 | - /** | 317 | + public static Map<String, Object> parseVariable(ResultSet resultSet) throws SQLException { |
| 245 | - * function/procedure sql | 318 | + Map<String, Object> map = new HashMap<>(); |
| 246 | - * | 319 | + List<String> columnList = getColumnList(resultSet.getMetaData(), map); |
| 247 | - * | ||
| 248 | - */ | ||
| 249 | - public static String getFuncSql(String windowName, String schema, String name, WebSocketServer webSocketServer) throws SQLException { | ||
| 250 | - List<String> oidList = new ArrayList<>(); | ||
| 251 | - List<String> paramTypeList = getParamTypeList(name); | ||
| 252 | - for (String s : paramTypeList) { | ||
| 253 | - Statement statement = (Statement) webSocketServer.getParamMap(windowName).get(STATEMENT); | ||
| 254 | - if (statement == null) { | ||
| 255 | - statement = webSocketServer.getStatement(windowName); | ||
| 256 | - } | ||
| 257 | - ResultSet typeNameResult = statement.executeQuery(GET_TYPE_OID_SQL + s + QUOTES_SEMICOLON); | ||
| 258 | - while (typeNameResult.next()) { | ||
| 259 | - oidList.add(typeNameResult.getString(OID)); | ||
| 260 | - } | ||
| 261 | - } | ||
| 262 | - log.info("DebugUtils getFuncSql oidList is: " + oidList); | ||
| 263 | 320 | ||
| 264 | - StringBuilder sb = new StringBuilder(); | 321 | + List<List<Object>> dataList = new ArrayList<>(); |
| 265 | - sb.append(GET_PROC_SQL).append(getFuncName(name).trim()).append(GET_PROC_TYPE_SQL); | 322 | + while (resultSet.next()) { |
| 266 | - | 323 | + List<Object> list = new ArrayList<>(); |
| 267 | - if (oidList.size() == 0) { | 324 | + for (String column : columnList) { |
| 268 | - sb.append(SPACE); | 325 | + String str = resultSet.getString(column); |
| 269 | - } else { | 326 | + if ("vartype".equals(column) || "typname".equals(column)) { |
| 270 | - for (int i = 0; i < oidList.size(); i++) { | 327 | + list.add(ParamTypeEnum.parseType(str)); |
| 271 | - sb.append(oidList.get(i)); | ||
| 272 | - if (i != oidList.size() - 1) { | ||
| 273 | - sb.append(SPACE); | ||
| 274 | - } | ||
| 275 | - } | ||
| 276 | - } | ||
| 277 | - sb.append(GET_PROC_NAME_SQL).append(schema); | ||
| 278 | - sb.append(QUOTES_SEMICOLON); | ||
| 279 | - log.info("DebugUtils getFuncSql sql is: " + sb); | ||
| 280 | - return sb.toString(); | ||
| 281 | - } | ||
| 282 | - | ||
| 283 | - /** | ||
| 284 | - * get function/procedure name | ||
| 285 | - * | ||
| 286 | - * name | ||
| 287 | - */ | ||
| 288 | - public static String getFuncName(String name) { | ||
| 289 | - int start = name.indexOf(PARENTHESES_LEFT); | ||
| 290 | - log.info("DebugUtils getFuncName name is: " + name); | ||
| 291 | - return name.substring(0, start); | ||
| 292 | - } | ||
| 293 | - | ||
| 294 | - /** | ||
| 295 | - * get param type list | ||
| 296 | - * | ||
| 297 | - * str | ||
| 298 | - */ | ||
| 299 | - public static List<String> getParamTypeList(String str) { | ||
| 300 | - List<String> list = new ArrayList<>(); | ||
| 301 | - | ||
| 302 | - List<Integer> leftList = getIndexList(str, PARENTHESES_LEFT); | ||
| 303 | - List<Integer> rightList = getIndexList(str, PARENTHESES_RIGHT); | ||
| 304 | - int start = leftList.get(0); | ||
| 305 | - int end = rightList.get(rightList.size() - 1); | ||
| 306 | - | ||
| 307 | - String substring = str.substring(start + 1, end); | ||
| 308 | - log.info("DebugUtils getParamTypeList substring is: " + substring); | ||
| 309 | - String[] splits = substring.split(COMMA); | ||
| 310 | - for (String s : splits) { | ||
| 311 | - if (s.contains(PARENTHESES_LEFT)) { | ||
| 312 | - int index = s.indexOf(PARENTHESES_LEFT); | ||
| 313 | - s = s.substring(0, index); | ||
| 314 | - } | ||
| 315 | - list.add(ParamTypeEnum.getName(s.trim())); | ||
| 316 | - } | ||
| 317 | - | ||
| 318 | - log.info("DebugUtils getParamTypeList paramType is: " + list); | ||
| 319 | - return list; | ||
| 320 | - } | ||
| 321 | - | ||
| 322 | - public static Map<String, String> getParamMap(String sql) { | ||
| 323 | - log.info("DebugUtils getParamMap sql is: " + sql); | ||
| 324 | - List<Integer> leftList = getIndexList(sql, PARENTHESES_LEFT); | ||
| 325 | - List<Integer> rightList = getIndexList(sql, PARENTHESES_RIGHT); | ||
| 326 | - sql = sql.replace(LINE_FEED, SPACE); | ||
| 327 | - int start = leftList.get(0); | ||
| 328 | - int end = rightList.get(rightList.size() - 1); | ||
| 329 | - String[] splits = sql.substring(start + 1, end).split(COMMA); | ||
| 330 | - for (String s : splits) { | ||
| 331 | - log.info("DebugUtils getParamMap splits is: " + s); | ||
| 332 | - } | ||
| 333 | - | ||
| 334 | - Map<String, String> map = new HashMap<>(); | ||
| 335 | - for (String split : splits) { | ||
| 336 | - String[] params = split.trim().split(SPACE); | ||
| 337 | - if (split.trim().toLowerCase().startsWith("out ")) { | ||
| 338 | - map.put(params[1], "OUT"); | ||
| 339 | - } else { | ||
| 340 | - if (split.trim().toLowerCase().startsWith("inout ")) { | ||
| 341 | - map.put(params[1], "INOUT"); | ||
| 342 | - continue; | ||
| 343 | - } | ||
| 344 | - if (params.length == 1) { | ||
| 345 | - map.put("param", "IN"); | ||
| 346 | } else { | 328 | } else { |
| 347 | - map.put(params[0], "IN"); | 329 | + list.add(str); |
| 348 | } | 330 | } |
| 349 | } | 331 | } |
| 332 | + dataList.add(list); | ||
| 350 | } | 333 | } |
| 351 | - log.info("DebugUtils getParamMap map is: " + map); | 334 | + map.put(RESULT, dataList); |
| 335 | + log.info("DebugUtils parseVariable map: " + map); | ||
| 352 | return map; | 336 | return map; |
| 353 | } | 337 | } |
| 354 | 338 | ||
| 355 | - public static Map<String, Object> addMapParam(Map<String, Object> map, String sql) { | 339 | + private static List<String> getColumnList(ResultSetMetaData metaData, Map<String, Object> map) throws SQLException { |
| 356 | - log.info("DebugUtils addMapParam map is: " + map); | 340 | + List<String> columnList = new ArrayList<>(); |
| 341 | + for (int i = 0; i < metaData.getColumnCount(); i++) { | ||
| 342 | + columnList.add(metaData.getColumnName(i + 1)); | ||
| 343 | + } | ||
| 344 | + map.put(COLUMN, columnList); | ||
| 345 | + log.info("DebugUtils getColumnList: " + columnList); | ||
| 346 | + return columnList; | ||
| 347 | + } | ||
| 348 | + | ||
| 349 | + public static Map<String, Object> addMapParam(Map<String, Object> map, WebSocketServer webSocketServer, | ||
| 350 | + PublicParamReq paramReq) { | ||
| 351 | + log.info("DebugUtils addMapParam map: " + map); | ||
| 357 | List<String> columnList = (List<String>) map.get(COLUMN); | 352 | List<String> columnList = (List<String>) map.get(COLUMN); |
| 358 | List<List<Object>> dataList = (List<List<Object>>) map.get(RESULT); | 353 | List<List<Object>> dataList = (List<List<Object>>) map.get(RESULT); |
| 359 | 354 | ||
| 360 | - Map<String, String> paramMap = getParamMap(sql); | 355 | + Map<String, Object> paramList = getParamType(webSocketServer, paramReq); |
| 361 | - log.info("DebugUtils paramMap map is: " + paramMap); | 356 | + log.info("DebugUtils addMapParam paramList: " + paramList); |
| 362 | if (!CollectionUtils.isEmpty(map)) { | 357 | if (!CollectionUtils.isEmpty(map)) { |
| 363 | columnList.add("paramType"); | 358 | columnList.add("paramType"); |
| 364 | for (int i = 0; i < dataList.size(); i++) { | 359 | for (int i = 0; i < dataList.size(); i++) { |
| 365 | List<Object> data = dataList.get(i); | 360 | List<Object> data = dataList.get(i); |
| 366 | - String value = paramMap.get(data.get(0)); | 361 | + if (!CollectionUtils.isEmpty(paramList)) { |
| 367 | - if (i < paramMap.size()) { | 362 | + if (i < paramList.size()) { |
| 368 | - data.add(value); | 363 | + String value = (String) paramList.get(data.get(0)); |
| 364 | + data.add(value); | ||
| 365 | + } else { | ||
| 366 | + data.add("temp"); | ||
| 367 | + } | ||
| 369 | } else { | 368 | } else { |
| 370 | data.add("temp"); | 369 | data.add("temp"); |
| 371 | } | 370 | } |
| 372 | } | 371 | } |
| 373 | } | 372 | } |
| 374 | - log.info("DebugUtils addMapParam result is: " + map); | 373 | + log.info("DebugUtils addMapParam map: " + map); |
| 375 | return map; | 374 | return map; |
| 376 | } | 375 | } |
| 376 | + | ||
| 377 | + public static String sqlHandleAfter(String sql) { | ||
| 378 | + sql = sql.replace(FUNCTION_DOLLAR, DOLLAR); | ||
| 379 | + return sql + SLASH; | ||
| 380 | + } | ||
| 381 | + | ||
| 382 | + public static String sqlFormat(String sql) { | ||
| 383 | + return sql.replace(N_SLASH, Strings.EMPTY).replace(SPACE, Strings.EMPTY); | ||
| 384 | + } | ||
| 385 | + | ||
| 386 | + public static void disableButton(WebSocketServer webSocketServer, String windowName) { | ||
| 387 | + OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); | ||
| 388 | + operateStatus.subAllFalse(); | ||
| 389 | + webSocketServer.setOperateStatus(windowName, operateStatus); | ||
| 390 | + } | ||
| 391 | + | ||
| 392 | + public static void enableButton(WebSocketServer webSocketServer, String windowName) { | ||
| 393 | + OperateStatusDO operateStatus = webSocketServer.getOperateStatus(windowName); | ||
| 394 | + operateStatus.subAllTrue(); | ||
| 395 | + webSocketServer.setOperateStatus(windowName, operateStatus); | ||
| 396 | + } | ||
| 397 | + | ||
| 398 | + public static List<Integer> getAvailableBreakPoints(PublicParamReq paramReq, WebSocketServer webSocketServer) { | ||
| 399 | + List<Integer> list = new ArrayList<>(); | ||
| 400 | + int differ = 0; | ||
| 401 | + try ( | ||
| 402 | + Connection connection = webSocketServer.createConnection(paramReq.getUuid(), paramReq.getWindowName()); | ||
| 403 | + Statement statement = connection.createStatement(); | ||
| 404 | + ResultSet resultSet = statement.executeQuery(String.format(INFO_CODE_SQL, paramReq.getOid())) | ||
| 405 | + ) { | ||
| 406 | + while (resultSet.next()) { | ||
| 407 | + String lineNo = resultSet.getString(LINE_NO); | ||
| 408 | + if (StringUtils.isEmpty(lineNo)) { | ||
| 409 | + differ++; | ||
| 410 | + } | ||
| 411 | + String canBreak = resultSet.getString(CAN_BREAK); | ||
| 412 | + if (T.equals(canBreak)) { | ||
| 413 | + list.add(Integer.valueOf(lineNo)); | ||
| 414 | + } | ||
| 415 | + } | ||
| 416 | + | ||
| 417 | + String windowName = paramReq.getWindowName(); | ||
| 418 | + webSocketServer.setParamMap(windowName, CAN_BREAK, list); | ||
| 419 | + webSocketServer.setParamMap(windowName, DIFFER, differ); | ||
| 420 | + log.info("DebugUtils getAvailableBreakPoints differ: " + differ); | ||
| 421 | + log.info("DebugUtils getAvailableBreakPoints list: " + list); | ||
| 422 | + } catch (Exception e) { | ||
| 423 | + return list; | ||
| 424 | + } | ||
| 425 | + return list; | ||
| 426 | + } | ||
| 427 | + | ||
| 428 | + public static Map<String, Map<String, String>> getResultMap(WebSocketServer webSocketServer, | ||
| 429 | + PublicParamReq paramReq) { | ||
| 430 | + log.info("DebugUtils getResultMap paramReq: " + paramReq); | ||
| 431 | + Map<String, String> paramMap = new HashMap<>(); | ||
| 432 | + String oid = paramReq.getOid(); | ||
| 433 | + paramMap.put(OID, oid); | ||
| 434 | + StringBuilder sb = new StringBuilder(); | ||
| 435 | + String proArgTypes = Strings.EMPTY; | ||
| 436 | + try ( | ||
| 437 | + Connection connection = webSocketServer.createConnection(paramReq.getUuid(), paramReq.getWindowName()); | ||
| 438 | + Statement statement = connection.createStatement(); | ||
| 439 | + ResultSet resultSet = statement.executeQuery(String.format(PROC_SQL, oid)) | ||
| 440 | + ) { | ||
| 441 | + while (resultSet.next()) { | ||
| 442 | + String schemaNew = resultSet.getString(NSP_NAME); | ||
| 443 | + String nameNew = resultSet.getString(PRO_NAME); | ||
| 444 | + proArgTypes = resultSet.getString(PRO_ARG_TYPES); | ||
| 445 | + log.info("DebugUtils getResultMap schemaNew: " + schemaNew); | ||
| 446 | + log.info("DebugUtils getResultMap nameNew: " + nameNew); | ||
| 447 | + log.info("DebugUtils getResultMap proArgTypes: " + proArgTypes); | ||
| 448 | + sb.append(schemaNew).append(POINT).append(nameNew).append(LEFT_BRACKET); | ||
| 449 | + } | ||
| 450 | + | ||
| 451 | + if (StringUtils.isNotEmpty(proArgTypes)) { | ||
| 452 | + try ( | ||
| 453 | + ResultSet nameResult = statement.executeQuery( | ||
| 454 | + String.format(GET_OID_NAME_SQL, proArgTypes.replace(SPACE, COMMA))) | ||
| 455 | + ) { | ||
| 456 | + while (nameResult.next()) { | ||
| 457 | + int length = proArgTypes.split(SPACE).length; | ||
| 458 | + for (int i = 0; i < length; i++) { | ||
| 459 | + sb.append(ParamTypeEnum.parseType(nameResult.getString(TYP_NAME))); | ||
| 460 | + if (i != length - 1) { | ||
| 461 | + sb.append(COMMA); | ||
| 462 | + } | ||
| 463 | + } | ||
| 464 | + } | ||
| 465 | + } catch (Exception e) { | ||
| 466 | + log.info(e.getMessage()); | ||
| 467 | + throw new RuntimeException(e.getMessage(), e); | ||
| 468 | + } | ||
| 469 | + } | ||
| 470 | + | ||
| 471 | + sb.append(RIGHT_BRACKET); | ||
| 472 | + log.info("DebugUtils sb: " + sb); | ||
| 473 | + paramMap.put(NAME, sb.toString()); | ||
| 474 | + } catch (Exception e) { | ||
| 475 | + return null; | ||
| 476 | + } | ||
| 477 | + | ||
| 478 | + Map<String, Map<String, String>> map = new HashMap<>(); | ||
| 479 | + map.put(RESULT, paramMap); | ||
| 480 | + log.info("DebugUtils map: " + map); | ||
| 481 | + return map; | ||
| 482 | + } | ||
| 483 | + | ||
| 484 | + public static void exportFile(String fileName, String content, HttpServletResponse response) throws Exception { | ||
| 485 | + response.reset(); | ||
| 486 | + response.setContentType("application/octet-stream"); | ||
| 487 | + response.setHeader("Content-Disposition", URLEncoder.encode(fileName, StandardCharsets.UTF_8)); | ||
| 488 | + response.addHeader("Response-Type", "blob"); | ||
| 489 | + response.setCharacterEncoding("UTF-8"); | ||
| 490 | + | ||
| 491 | + try ( | ||
| 492 | + InputStream inputStream = new ByteArrayInputStream(content.getBytes()); | ||
| 493 | + OutputStream outputStream = response.getOutputStream() | ||
| 494 | + ) { | ||
| 495 | + byte[] b = new byte[1024]; | ||
| 496 | + int len; | ||
| 497 | + while ((len = inputStream.read(b)) > 0) { | ||
| 498 | + outputStream.write(b, 0, len); | ||
| 499 | + } | ||
| 500 | + outputStream.flush(); | ||
| 501 | + } | ||
| 502 | + } | ||
| 503 | + | ||
| 504 | + public static String getOldWindowName(WebSocketServer webSocketServer, String rootWindowName, String oid) { | ||
| 505 | + String name = Strings.EMPTY; | ||
| 506 | + Map<String, Object> paramMap = webSocketServer.getParamMap(rootWindowName); | ||
| 507 | + log.info("DebugUtils getOldWindowName paramMap: " + paramMap); | ||
| 508 | + for (Object key : paramMap.keySet()) { | ||
| 509 | + if (key.equals(oid)) { | ||
| 510 | + name = (String) paramMap.get(key); | ||
| 511 | + } | ||
| 512 | + } | ||
| 513 | + log.info("DebugUtils getOldWindowName name: " + name); | ||
| 514 | + return name; | ||
| 515 | + } | ||
| 377 | } | 516 | } |
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.util; | 5 | package com.nctigba.datastudio.util; |
| 2 | 6 | ||
| 3 | import com.nctigba.datastudio.base.WebSocketServer; | 7 | import com.nctigba.datastudio.base.WebSocketServer; |
| @@ -17,15 +21,15 @@ import java.util.Locale; | |||
| 17 | public class LocaleString { | 21 | public class LocaleString { |
| 18 | private static MessageSource messageSource; | 22 | private static MessageSource messageSource; |
| 19 | 23 | ||
| 20 | - @Autowired | 24 | + @Autowired |
| 21 | - public void setMessageSource(MessageSource messageSource) { | 25 | + public void setMessageSource(MessageSource messageSource) { |
| 22 | - LocaleString.messageSource = messageSource; | 26 | + LocaleString.messageSource = messageSource; |
| 23 | - } | 27 | + } |
| 24 | 28 | ||
| 25 | public static String transLanguage(String str) { | 29 | public static String transLanguage(String str) { |
| 26 | ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes(); | 30 | ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes(); |
| 27 | String language = requestAttributes.getRequest().getHeader(HttpHeaders.ACCEPT_LANGUAGE); | 31 | String language = requestAttributes.getRequest().getHeader(HttpHeaders.ACCEPT_LANGUAGE); |
| 28 | - return translate(str, language); | 32 | + return translate(str, language); |
| 29 | } | 33 | } |
| 30 | 34 | ||
| 31 | public static String transLanguageWs(String str, WebSocketServer webSocketServer) { | 35 | public static String transLanguageWs(String str, WebSocketServer webSocketServer) { |
| @@ -34,8 +38,8 @@ public class LocaleString { | |||
| 34 | } | 38 | } |
| 35 | 39 | ||
| 36 | private static String translate(String str, String language) { | 40 | private static String translate(String str, String language) { |
| 37 | - log.info("LocaleString language is: " + language); | 41 | + log.info("LocaleString language is: " + language); |
| 38 | - Locale locale; | 42 | + Locale locale; |
| 39 | if (StringUtils.isEmpty(language)) { | 43 | if (StringUtils.isEmpty(language)) { |
| 40 | locale = Locale.CHINA; | 44 | locale = Locale.CHINA; |
| 41 | } else { | 45 | } else { |
| @@ -1,47 +1,26 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio.util; | 5 | package com.nctigba.datastudio.util; |
| 2 | 6 | ||
| 7 | +import lombok.extern.slf4j.Slf4j; | ||
| 3 | import org.apache.commons.codec.binary.Base64; | 8 | import org.apache.commons.codec.binary.Base64; |
| 4 | 9 | ||
| 5 | import javax.crypto.Cipher; | 10 | import javax.crypto.Cipher; |
| 6 | import javax.crypto.spec.IvParameterSpec; | 11 | import javax.crypto.spec.IvParameterSpec; |
| 7 | import javax.crypto.spec.SecretKeySpec; | 12 | import javax.crypto.spec.SecretKeySpec; |
| 8 | 13 | ||
| 14 | + | ||
| 9 | public class SecretUtil { | 15 | public class SecretUtil { |
| 10 | 16 | ||
| 11 | private static final String KEY = "R0JBLU5DVEktRFM="; | 17 | private static final String KEY = "R0JBLU5DVEktRFM="; |
| 12 | private static final String IV = "1234567890000000"; | 18 | private static final String IV = "1234567890000000"; |
| 13 | 19 | ||
| 14 | - public static String encrypt(String data) { | ||
| 15 | - return encrypt(data, KEY, IV); | ||
| 16 | - } | ||
| 17 | - | ||
| 18 | public static String desEncrypt(String data) { | 20 | public static String desEncrypt(String data) { |
| 19 | return desEncrypt(data, KEY, IV); | 21 | return desEncrypt(data, KEY, IV); |
| 20 | } | 22 | } |
| 21 | 23 | ||
| 22 | - static String encrypt(String data, String key, String iv) { | ||
| 23 | - try { | ||
| 24 | - Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); | ||
| 25 | - int blockSize = cipher.getBlockSize(); | ||
| 26 | - byte[] dataBytes = data.getBytes(); | ||
| 27 | - int plaintextLength = dataBytes.length; | ||
| 28 | - if (plaintextLength % blockSize != 0) { | ||
| 29 | - plaintextLength = plaintextLength + (blockSize - (plaintextLength % blockSize)); | ||
| 30 | - } | ||
| 31 | - byte[] plaintext = new byte[plaintextLength]; | ||
| 32 | - System.arraycopy(dataBytes, 0, plaintext, 0, dataBytes.length); | ||
| 33 | - SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES"); | ||
| 34 | - IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes()); | ||
| 35 | - cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec); | ||
| 36 | - byte[] encrypted = cipher.doFinal(plaintext); | ||
| 37 | - | ||
| 38 | - return new Base64().encodeToString(encrypted); | ||
| 39 | - } catch (Exception e) { | ||
| 40 | - e.printStackTrace(); | ||
| 41 | - return null; | ||
| 42 | - } | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | private static String desEncrypt(String data, String key, String iv) { | 24 | private static String desEncrypt(String data, String key, String iv) { |
| 46 | try { | 25 | try { |
| 47 | byte[] encrypted1 = new Base64().decode(data); | 26 | byte[] encrypted1 = new Base64().decode(data); |
| @@ -53,7 +32,7 @@ public class SecretUtil { | |||
| 53 | byte[] original = cipher.doFinal(encrypted1); | 32 | byte[] original = cipher.doFinal(encrypted1); |
| 54 | return new String(original).trim(); | 33 | return new String(original).trim(); |
| 55 | } catch (Exception e) { | 34 | } catch (Exception e) { |
| 56 | - e.printStackTrace(); | 35 | + log.info(e.getMessage()); |
| 57 | return null; | 36 | return null; |
| 58 | } | 37 | } |
| 59 | } | 38 | } |
| @@ -7,14 +7,8 @@ spring: | |||
| 7 | datasource: | 7 | datasource: |
| 8 | driver-class-name: org.sqlite.JDBC | 8 | driver-class-name: org.sqlite.JDBC |
| 9 | url: 'jdbc:sqlite:databaseLink.db' | 9 | url: 'jdbc:sqlite:databaseLink.db' |
| 10 | - servlet: | ||
| 11 | - multipart: | ||
| 12 | - max-file-size: 20MB #The maximum size of a single file is 20M | ||
| 13 | - max-request-size: 20MB #The total file size of a single request is 20M | ||
| 14 | - profiles: | ||
| 15 | - active: '@profiles.active@' | ||
| 16 | resources: | 10 | resources: |
| 17 | - static-locations: classpath:resources,file:D://static | 11 | + static-locations: classpath:resources |
| 18 | jackson: | 12 | jackson: |
| 19 | time-zone: GMT+8 | 13 | time-zone: GMT+8 |
| 20 | date-format: yyyy-MM-dd HH:mm:ss | 14 | date-format: yyyy-MM-dd HH:mm:ss |
| @@ -26,15 +20,3 @@ spring: | |||
| 26 | parser: | 20 | parser: |
| 27 | allow_unquoted_control_chars: true | 21 | allow_unquoted_control_chars: true |
| 28 | allow_single_quotes: true | 22 | allow_single_quotes: true |
| 29 | -server.compression: | ||
| 30 | - enabled: true | ||
| 31 | - mime-types: application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain | ||
| 32 | -mybatis-plus: | ||
| 33 | - # Search for the specified package alias | ||
| 34 | - typeAliasesPackage: com.nctigba.datastudio.entity | ||
| 35 | - # Configure mapper scanning and find all mapper.xml mapping files | ||
| 36 | - mapperLocations: classpath*:mapper/*.xml | ||
| 37 | - # Load global configuration file | ||
| 38 | - configuration: | ||
| 39 | - mapUnderscoreToCamelCase: true | ||
| 40 | - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl | ||
Dplugins/data-studio/src/main/resources/exception.properties+0-2
| @@ -1,2 +0,0 @@ | |||
| 1 | -# sso异常测试 | ||
| 2 | -EC00001=SSO的WEB层错误 | ||
Dplugins/data-studio/src/main/resources/lib/opengaussjdbc.jar+0-0
Binary files do not support preview
| @@ -1,87 +1,71 @@ | |||
| 1 | -TaskType.manual = def\u624B\u52A8\u521B\u5EFA | 1 | +1001=Connect successfully! |
| 2 | -TaskType.auto = def\u81EA\u52A8\u521B\u5EFA | ||
| 3 | 2 | ||
| 4 | -TaskState.create = def\u521B\u5EFA | 3 | +1002=Build successfully! |
| 5 | -TaskState.waiting = def\u6392\u961F\u4E2D | ||
| 6 | -TaskState.sqlRunning = defsql\u6267\u884C\u4E2D | ||
| 7 | -TaskState.receiving = def\u7B49\u5F85\u63A5\u6536\u6570\u636E\uFF0C\u5206\u6790\u4E2D | ||
| 8 | -TaskState.finish = def\u5DF2\u5B8C\u6210 | ||
| 9 | -TaskState.databaseConnectErr = def\u6570\u636E\u5E93\u8FDE\u63A5\u5931\u8D25 | ||
| 10 | -TaskState.sqlParseErr = defsql\u8BED\u6CD5\u9519\u8BEF | ||
| 11 | -TaskState.sqlErr = defsql\u6267\u884C\u5931\u8D25 | ||
| 12 | -TaskState.err = def\u672A\u77E5\u9519\u8BEF | ||
| 13 | 4 | ||
| 14 | -ResultType.TaskInfo = def\u4EFB\u52A1\u4FE1\u606F | 5 | +1003=Stop debug! |
| 15 | -ResultType.ObjectInfoCheck = def\u5BF9\u8C61\u4FE1\u606F\u68C0\u67E5 | ||
| 16 | -ResultType.ObjectRecommendedToUpdateStatistics = def\u5EFA\u8BAE\u6267\u884Canalyze\u66F4\u65B0\u5BF9\u8C61\u7EDF\u8BA1\u4FE1\u606F | ||
| 17 | -ResultType.ExecPlan = def\u6267\u884C\u8BA1\u5212 | ||
| 18 | -ResultType.PlanRecommendedToCreateIndex = def\u5EFA\u8BAE\u4E3Atestdata\u8868ID\u5217\u521B\u5EFA\u7D22\u5F15 | ||
| 19 | -ResultType.PlanChangedToPartitionTable = def\u5EFA\u8BAE\u5C06testdata\u8868\u6539\u6210\u5206\u533A\u8868 | ||
| 20 | -ResultType.PlanRecommendedToQueryBasedOnPartition = def\u5EFA\u8BAE\u57FA\u4E8E\u5206\u533A\u67E5\u8BE2\uFF0C\u907F\u514D\u626B\u63CF\u6240\u6709\u5206\u533A | ||
| 21 | -ResultType.PlanRecommendedToDoVacuumCleaning = def\u5EFA\u8BAE\u5BF9testdata\u8868\u505Avacuum\u6E05\u7406 | ||
| 22 | -ResultType.PlanRecommendedToOptimizeStatementsOrAddWorkMemSize = def\u5EFA\u8BAE\u4F18\u5316\u8BED\u53E5\u6216\u589E\u52A0work_mem\u5927\u5C0F | ||
| 23 | -ResultType.Performance = def\u6027\u80FD\u5206\u6790 | ||
| 24 | -ResultType.CPU = defCPU | ||
| 25 | -ResultType.OnCpu = defonCPU | ||
| 26 | -ResultType.user = def%usr\u9AD8 | ||
| 27 | -ResultType.system = def%system\u9AD8 | ||
| 28 | -ResultType.idle = def%idle\u9AD8 | ||
| 29 | -ResultType.iowait = def%iowait\u9AD8 | ||
| 30 | -ResultType.OffCpu = defoffCPU | ||
| 31 | -ResultType.CpuWait = defCPU\u7B49\u5F85\u961F\u5217\u8F83\u957F | ||
| 32 | -ResultType.runqlat = def\u670D\u52A1\u7EBF\u7A0B\u7B49\u5F85CPU\u961F\u5217\u8F83\u957F | ||
| 33 | -ResultType.Memory = def\u5185\u5B58 | ||
| 34 | -ResultType.cachestat = def\u670D\u52A1\u5668\u7F13\u5B58\u547D\u4E2D\u7387\u8FC7\u4F4E | ||
| 35 | -ResultType.Memleak = def\u5185\u5B58\u6CC4\u6F0F | ||
| 36 | -ResultType.FileSystem = def\u6587\u4EF6\u7CFB\u7EDF | ||
| 37 | -ResultType.Xfsdist = defXFS\u6587\u4EF6\u7CFB\u7EDF\u64CD\u4F5C\u5EF6\u8FDF | ||
| 38 | -ResultType.Xfsslower = defXFS\u6587\u4EF6\u7CFB\u7EDF\u8D85\u8FC7\u9608\u503C\u7684\u8BE6\u7EC6\u4FE1\u606F | ||
| 39 | -ResultType.IO = defI/O | ||
| 40 | -ResultType.Biolatency = def\u5757\u8BBE\u5907\u5EF6\u8FDF\u5206\u6790 | ||
| 41 | -ResultType.Biosnoop = def\u5757\u8BBE\u5907\u5EF6\u8FDF\u8BE6\u7EC6\u4FE1\u606F | ||
| 42 | -ResultType.FileTop = def\u8BFB\u5199\u6700\u9891\u7E41\u7684\u6587\u4EF6\u4FE1\u606F | ||
| 43 | -ResultType.NetWork = def\u7F51\u7EDC | ||
| 44 | -ResultType.TcplifeTCP = def\u4F1A\u8BDD\u7684\u751F\u547D\u5468\u671F\u548C\u541E\u5410\u91CF\u7EDF\u8BA1 | ||
| 45 | -ResultType.TcpTop = defTCP\u7684\u8FDB\u7A0B | ||
| 46 | -ResultType.ExecPlanDesc = def\u6267\u884C\u8BA1\u5212\u8BE6\u60C5 | ||
| 47 | -ResultType.TcpMaxTwBuckets = def\u540C\u65F6\u4FDD\u6301TIME_WAIT\u72B6\u6001\u7684TCP/IP\u8FDE\u63A5\u6700\u5927\u6570\u91CF | ||
| 48 | 6 | ||
| 49 | -Biolatency.unit = def\u5FAE\u79D2 | 7 | +1004=The current connection does not exist! |
| 50 | -Biolatency.title = def\u78C1\u76D8\u5904\u4E8E\u7E41\u5FD9\u72B6\u6001 | 8 | + |
| 51 | -Biolatency.tip = def\u63D0\u793A:\u5F53\u524D{0}\u78C1\u76D8\u5757\u8BBE\u5907\u5EF6\u8FDF\u4E3A1ms\u4EE5\u4E0A\u7684\u5360\u6BD4\u4E3A{1}%\uFF0C\u5DF2\u7ECF\u8D85\u8FC7\u8BBE\u5B9A\u9608\u503C{2}%\uFF0CIO\u54CD\u5E94\u65F6\u95F4\u8F83\u957F\uFF0C\u6267\u884C\u6162sql\u65F6\u5904\u7406I/O\u8BF7\u6C42\u7684\u65F6\u95F4\u4E5F\u4F1A\u6BD4\u8F83\u957F | 9 | +1005=New function/procedure has been opened, please refresh! |
| 52 | -Biosnoop.title = def\u5BF9\u6587\u4EF6\u64CD\u4F5C\u5EF6\u65F6\u8D85\u8FC710ms | 10 | + |
| 53 | -Biosnoop.TIP = def\u6162sql\u6267\u884C\u65F6\u5BF9\u6587\u4EF6{0}\u7684\u5EF6\u65F6\u8F83\u9AD8\uFF0C\u8D85\u8FC7\u4E8610ms | 11 | +1006=The source code has been changed. Do you want to continue! |
| 54 | -Cachestat.title = def\u670D\u52A1\u5668\u7F13\u5B58\u547D\u4E2D\u7387\u8FC7\u4F4E | 12 | + |
| 55 | -Cachestat.TIP = def\u6162sql {0}\u6267\u884C\u8FC7\u7A0B\u4E2D\u5B58\u5728\u7F13\u5B58\u547D\u4E2D\u7387\u4E3A{1}\uFF0C\u5DF2\u7ECF\u4F4E\u4E8E\u8BBE\u5B9A\u9608\u503C | 13 | +1007=Function/procedure has been changed, please compile first! |
| 56 | -Cachetop.title = def\u5BF9\u6587\u4EF6\u64CD\u4F5C\u5EF6\u65F6\u8D85\u8FC710ms | 14 | + |
| 57 | -Cachetop.TIP = def\u6162sql {0}\u6267\u884C\u8FC7\u7A0B\u4E2D\u8BFB\u7F13\u5B58\u547D\u4E2D\u7387\u4E3A{1}\uFF0C\u5199\u7F13\u5B58\u547D\u4E2D\u7387\u4E3A{2}\uFF0C\u5DF2\u7ECF\u4F4E\u4E8E\u8BBE\u5B9A\u9608\u503C | 15 | +1008=Debugging is over, Please check the result set on the right! |
| 58 | -FileTop.title = def\u5BF9\u6587\u4EF6\u64CD\u4F5C\u5EF6\u65F6\u8D85\u8FC710ms | 16 | + |
| 59 | -FileTop.TIP = def\u6162sqlTID {0}\u6267\u884C\u8FC7\u7A0B\u4E2D\u5BF9({1})\u9891\u7E41\u8BFB\u5199\u64CD\u4F5C | 17 | +1009=Generating a coverage report requires a long wait time. Do you want to continue? |
| 60 | -MemleakAnaly.TIP = def\u5185\u5B58\u5206\u914D\u548C\u91CA\u653E\u65F6\u95F4\u5BF9\u5E94\u7684\u8C03\u7528\u6808\u4FE1\u606F | 18 | + |
| 61 | -OffCpuAnaly.title = defOffCpu\u51B7\u706B\u7130\u56FE | 19 | +2001=Execution start! |
| 62 | -OnCpuAnaly.title = defOnCpu\u70ED\u706B\u7130\u56FE | 20 | + |
| 63 | -RunqlatAnaly.TIP = def\u63D0\u793A:\u6162sql\u5728\u6267\u884C\u8FC7\u7A0B\u4E2DCPU\u7B49\u5F85\u5EF6\u8FDF\u8D85\u8FC710ms\u7684\u5360\u6BD4\u4E3A{0}%\uFF0C\u5DF2\u7ECF\u8D85\u8FC7\u8BBE\u5B9A\u9608{1}% | 21 | +2002=Execution succeeded! |
| 64 | -RunqlatAnaly.unit = def\u6BEB\u79D2 | 22 | + |
| 65 | -RunqlatAnaly.name = defcpu\u7B49\u5F85\u5EF6\u8FDF\u5206\u6790 | 23 | +2003=End of execution! |
| 66 | -RunqlatAnaly.title = defCPU\u7B49\u5F85\u961F\u5217\u8F83\u957F | 24 | + |
| 67 | -RunqlenAnaly.TIP = def\u63D0\u793A:\u5F53\u524Dcpu\u7B49\u5F85\u961F\u5217\u957F\u5EA6\u4E3A3\u7684\u5360\u6BD4\u4E3A{0}%\uFF0C\u5DF2\u7ECF\u8D85\u8FC7\u8BBE\u5B9A\u9608\u503C{1}%\uFF0Ccpu\u5904\u4E8E\u7E41\u5FD9\u72B6\u6001\uFF0C\u6267\u884C\u6162sql\u65F6\u4F1A\u6709\u6BD4\u8F83\u957F\u7684cpu\u7B49\u5F85\u5EF6\u8FDF | 25 | +2004=Close successfully! |
| 68 | -RunqlenAnaly.Unit = def\u7B49\u5F85\u961F\u5217\u957F\u5EA6 | 26 | + |
| 69 | -RunqlenAnaly.name = def\u603BCPU\u7B49\u5F85\u961F\u5217\u957F\u5EA6\u70ED\u529B\u56FE | 27 | +2005=Number of rows affected by successful execution! |
| 70 | -RunqlenAnaly.title = defCPU\u7B49\u5F85\u961F\u5217\u8F83\u957F | 28 | + |
| 71 | -TcpLife.TIP0 = def\u6162sql {0}\u6267\u884C\u8FC7\u7A0B\u4E2D\u6709{1}\u4E2A\u77ED\u8FDE\u63A5\uFF0C\u5DF2\u7ECF\u8D85\u8FC7\u8BBE\u5B9A\u9608\u503C | 29 | +2006=Button status request! |
| 72 | -TcpLife.TIP1 = def\u5F53\u524D\u670D\u52A1\u5668{0}\uFF1A{1}\u5B58\u5728{2}\u4E2A\u77ED\u8FDE\u63A5\uFF0C\u5DF2\u7ECF\u8D85\u8FC7\u8BBE\u5B9A\u9608\u503C | 30 | + |
| 73 | -TcpLife.title = def\u77ED\u8FDE\u63A5\u8868\u683C | 31 | +2007=The table does not exist! |
| 74 | -TcpTop.TIP0 = def\u6162sql {0}\u6267\u884C\u8FC7\u7A0B\u4E2D\u6709{1}\u4E2A\u957F\u8FDE\u63A5\uFF0C\u5DF2\u7ECF\u8D85\u8FC7\u8BBE\u5B9A\u9608\u503C | 32 | + |
| 75 | -TcpTop.TIP1 = def{0}\u5B58\u5728{1}\u4E2A\u957F\u8FDE\u63A5\uFF0C\u5DF2\u7ECF\u8D85\u8FC7\u8BBE\u5B9A\u9608\u503C | 33 | +2008=not found id= |
| 76 | -TcpTop.title = def\u957F\u8FDE\u63A5\u5206\u6790 | 34 | + |
| 77 | -XfsdistAnaly.read = def\u63D0\u793A:\u5F53\u524Dext4\u8BFB\u53D6\u6587\u4EF6\u5EF6\u8FDF\u4E3A1ms\u4EE5\u4E0A\u7684\u5360\u6BD4\u4E3A{0}%\uFF0C\u5DF2\u7ECF\u8D85\u8FC7\u8BBE\u5B9A\u9608\u503C{1}%\uFF0C\u8BFB\u53D6\u6587\u4EF6\u65F6\u53EF\u80FD\u662F\u4ECE\u5B58\u50A8\u8BBE\u5907\u8BFB\u53D6\uFF0C\u800C\u4E0D\u662F\u4ECE\u7F13\u5B58\u4E2D\u8BFB\u53D6\uFF0C\u5F71\u54CD\u6267\u884C\u6162sql\u505A\u6570\u636E\u8BFB\u53D6\u64CD\u4F5C\u7684\u65F6\u95F4 | 35 | +2009=not found name= |
| 78 | -XfsdistAnaly.write = def\u63D0\u793A:\u5F53\u524Dext4\u5199\u5165\u6587\u4EF6\u5EF6\u8FDF\u4E3A1ms\u4EE5\u4E0A\u7684\u5360\u6BD4\u4E3A{0}%\uFF0C\u5DF2\u7ECF\u8D85\u8FC7\u8BBE\u5B9A\u9608\u503C{1}%\uFF0C\u5199\u5165\u6587\u4EF6\u65F6\u53EF\u80FD\u5757\u8BBE\u5907\u961F\u5217\u8F83\u957F\uFF0C\u5F71\u54CD\u6267\u884C\u6162sql\u505A\u6570\u636E\u5199\u5165\u64CD\u4F5C\u7684\u65F6\u95F4 | 36 | + |
| 79 | -XfsdistAnaly.open = def\u63D0\u793A:\u5F53\u524Dext4\u6253\u5F00\u6587\u4EF6\u5EF6\u8FDF\u4E3A1ms\u4EE5\u4E0A\u7684\u5360\u6BD4\u4E3A{0}%\uFF0C\u5DF2\u7ECF\u8D85\u8FC7\u8BBE\u5B9A\u9608\u503C{1}%\uFF0C\u6587\u4EF6\u9891\u7E41\u6253\u5F00\u521B\u5EFA\uFF0C\u5F71\u54CD\u6267\u884C\u6162sql\u505A\u6570\u636E\u8BFB\u5199\u64CD\u4F5C\u7684\u65F6\u95F4 | 37 | +2010=The view does not exist! |
| 80 | -XfsdistAnaly.fsync = def\u63D0\u793A:\u5F53\u524Dext4\u540C\u6B65\u6587\u4EF6\u5EF6\u8FDF\u4E3A1ms\u4EE5\u4E0A\u7684\u5360\u6BD4\u4E3A{0}%\uFF0C\u5DF2\u7ECF\u8D85\u8FC7\u8BBE\u5B9A\u9608\u503C{1}%\uFF0C\u6587\u4EF6\u4ECE\u7F13\u5B58\u540C\u6B65\u5230\u78C1\u76D8\u65F6\u95F4\u8F83\u957F\uFF0C\u5F71\u54CD\u6267\u884C\u6162sql\u505A\u6570\u636E\u8BFB\u5199\u64CD\u4F5C\u7684\u65F6\u95F4 | 38 | + |
| 81 | -XfsdistAnaly.title = def\u78C1\u76D8\u5904\u4E8E\u7E41\u5FD9\u72B6\u6001 | 39 | +2011=The synonym does not exist! |
| 82 | -XfsdistAnaly.unit = def\u5FAE\u79D2 | 40 | + |
| 83 | -XfsslowerAnaly.tip = def\u6162sql\u6267\u884C\u65F6\u5BF9\u6587\u4EF6({0})\u7684\u5EF6\u65F6\u8F83\u9AD8\uFF0C\u8D85\u8FC7\u4E8610ms | 41 | +2012=The sequence does not exist! |
| 84 | -XfsslowerAnaly.title = def\u5BF9\u6587\u4EF6\u64CD\u4F5C\u5EF6\u65F6\u8D85\u8FC710ms | 42 | + |
| 85 | -Pidstat1.title = def\u8FDB\u7A0B\u7528\u6237\u6001CPU\u4F7F\u7528\u7387\u5206\u5E03\u6298\u7EBF\u56FE | 43 | +2013=he number of connections is greater than - 1! |
| 86 | -MpstatP.title = def\u603BCPU\u4F7F\u7528\u5360\u6BD4\u56FE | 44 | + |
| 87 | -TcpMaxTwBuckets.title = def\u540C\u65F6\u4FDD\u6301TIME_WAIT\u72B6\u6001\u7684TCP/IP\u8FDE\u63A5\u6700\u5927\u6570\u91CF | 45 | +2014=The number of connections reached 100, unable to connect! |
| 46 | + | ||
| 47 | +2015=The function/stored does not exist! | ||
| 48 | + | ||
| 49 | +2016=This feature does not exist in the database! | ||
| 50 | + | ||
| 51 | +2017=If there is no primary key, create a primary key! | ||
| 52 | + | ||
| 53 | +3001=Execute Statement | ||
| 54 | + | ||
| 55 | +3002=Serial Number | ||
| 56 | + | ||
| 57 | +3003=Total Rows | ||
| 58 | + | ||
| 59 | +3004=Execution Rows | ||
| 60 | + | ||
| 61 | +3005=Total Coverage | ||
| 62 | + | ||
| 63 | +3006=All Line Number | ||
| 64 | + | ||
| 65 | +3007=Execution Line Number | ||
| 66 | + | ||
| 67 | +3008=Execution Coverage | ||
| 68 | + | ||
| 69 | +3009=Input Params | ||
| 70 | + | ||
| 71 | +3010=Update Time | ||
| @@ -6,13 +6,17 @@ | |||
| 6 | 6 | ||
| 7 | 1004=The current connection does not exist! | 7 | 1004=The current connection does not exist! |
| 8 | 8 | ||
| 9 | -1005=Function/procedure has been changed, please compile first! | 9 | +1005=New function/procedure has been opened, please refresh! |
| 10 | 10 | ||
| 11 | -1006=Function/procedure doesn't exist! | 11 | +1006=The source code has been changed. Do you want to continue! |
| 12 | 12 | ||
| 13 | -1007=Debugging is over, Please check the result set on the right! | 13 | +1007=Function/procedure has been changed, please compile first! |
| 14 | 14 | ||
| 15 | -1008=Subfunctions are not supported to enter sub-functions. Please click to stop debugging! | 15 | +1008=Debugging is over, Please check the result set on the right! |
| 16 | + | ||
| 17 | +1009=The current window connection is closed, please refresh the data to create a new connection! | ||
| 18 | + | ||
| 19 | +1010=Generating a coverage report requires a long wait time. Do you want to continue? | ||
| 16 | 20 | ||
| 17 | 2001=Execution start! | 21 | 2001=Execution start! |
| 18 | 22 | ||
| @@ -42,4 +46,58 @@ | |||
| 42 | 46 | ||
| 43 | 2014=The number of connections reached 100, unable to connect! | 47 | 2014=The number of connections reached 100, unable to connect! |
| 44 | 48 | ||
| 45 | -2015=The function/stored does not exist! | 49 | +2015=The function/procedure does not exist! |
| 50 | + | ||
| 51 | +2016=This feature does not exist in the database! | ||
| 52 | + | ||
| 53 | +2017=If there is no primary key, create a primary key! | ||
| 54 | + | ||
| 55 | +3001=Execute Statement | ||
| 56 | + | ||
| 57 | +3002=Serial Number | ||
| 58 | + | ||
| 59 | +3003=Total Rows | ||
| 60 | + | ||
| 61 | +3004=Execution Rows | ||
| 62 | + | ||
| 63 | +3005=Total Coverage | ||
| 64 | + | ||
| 65 | +3006=All Line Number | ||
| 66 | + | ||
| 67 | +3007=Execution Line Number | ||
| 68 | + | ||
| 69 | +3008=Execution Coverage | ||
| 70 | + | ||
| 71 | +3009=Input Params | ||
| 72 | + | ||
| 73 | +3010=Update Time | ||
| 74 | + | ||
| 75 | +1=OID | ||
| 76 | + | ||
| 77 | +2=Table name | ||
| 78 | + | ||
| 79 | +3=Tablespace | ||
| 80 | + | ||
| 81 | +4=Temporary or not table | ||
| 82 | + | ||
| 83 | +5=Type | ||
| 84 | + | ||
| 85 | +6=Owner | ||
| 86 | + | ||
| 87 | +7=Number of pages | ||
| 88 | + | ||
| 89 | +8=Number of rows (estimated) | ||
| 90 | + | ||
| 91 | +9=Index included or not | ||
| 92 | + | ||
| 93 | +10=Share or not | ||
| 94 | + | ||
| 95 | +11=Storage mode | ||
| 96 | + | ||
| 97 | +12=Compression or not | ||
| 98 | + | ||
| 99 | +13=Whether there is OID | ||
| 100 | + | ||
| 101 | +14=Description | ||
| 102 | + | ||
| 103 | +15=Partition | ||
| @@ -6,13 +6,17 @@ | |||
| 6 | 6 | ||
| 7 | 1004=\u5f53\u524d\u8fde\u63a5\u4e0d\u5b58\u5728\uff01 | 7 | 1004=\u5f53\u524d\u8fde\u63a5\u4e0d\u5b58\u5728\uff01 |
| 8 | 8 | ||
| 9 | -1005=\u51fd\u6570/\u8fc7\u7a0b\u5df2\u66f4\u6539\uff0c\u8bf7\u5148\u7f16\u8bd1\uff01 | 9 | +1005=\u65b0\u51fd\u6570/\u8fc7\u7a0b\u5df2\u6253\u5f00\uff0c\u8bf7\u5237\u65b0\uff01 |
| 10 | 10 | ||
| 11 | -1006=\u51fd\u6570/\u8fc7\u7a0b\u4e0d\u5b58\u5728\uff01 | 11 | +1006=\u6e90\u7801\u5df2\u88ab\u66f4\u6539\uff0c\u662f\u5426\u7ee7\u7eed\u6267\u884c\uff01 |
| 12 | 12 | ||
| 13 | -1007=\u8c03\u8bd5\u7ed3\u675f\uff0c\u8bf7\u68c0\u67e5\u53f3\u4fa7\u7684\u7ed3\u679c\u96c6\uff01 | 13 | +1007=\u51fd\u6570/\u8fc7\u7a0b\u5df2\u66f4\u6539\uff0c\u8bf7\u5148\u7f16\u8bd1\uff01 |
| 14 | 14 | ||
| 15 | -1008=\u6682\u4e0d\u652f\u6301\u5b50\u51fd\u6570\u8fdb\u5165\u5b50\u51fd\u6570\uff0c\u8bf7\u70b9\u51fb\u505c\u6b62\u8c03\u8bd5 | 15 | +1008=\u8c03\u8bd5\u7ed3\u675f\uff0c\u8bf7\u68c0\u67e5\u53f3\u4fa7\u7684\u7ed3\u679c\u96c6\uff01 |
| 16 | + | ||
| 17 | +1009=\u5f53\u524d\u7a97\u53e3\u8fde\u63a5\u5df2\u5173\u95ed\uff0c\u8bf7\u5237\u65b0\u6570\u636e\u521b\u5efa\u65b0\u8fde\u63a5\uff01 | ||
| 18 | + | ||
| 19 | +1010=\u751f\u6210\u8986\u76d6\u7387\u62a5\u544a\u9700\u8981\u7b49\u5f85\u8f83\u957f\u65f6\u95f4\uff0c\u662f\u5426\u7ee7\u7eed\uff1f | ||
| 16 | 20 | ||
| 17 | 2001=\u5f00\u59cb\u6267\u884c\uff01 | 21 | 2001=\u5f00\u59cb\u6267\u884c\uff01 |
| 18 | 22 | ||
| @@ -43,3 +47,57 @@ | |||
| 43 | 2014=\u8fde\u63a5\u6570\u8fbe\u5230100\uff0c\u65e0\u6cd5\u8fde\u63a5\uff01 | 47 | 2014=\u8fde\u63a5\u6570\u8fbe\u5230100\uff0c\u65e0\u6cd5\u8fde\u63a5\uff01 |
| 44 | 48 | ||
| 45 | 2015=\u8fd9\u4e2a\u51fd\u6570/\u5b58\u50a8\u8fc7\u7a0b\u4e0d\u5b58\u5728\uff01 | 49 | 2015=\u8fd9\u4e2a\u51fd\u6570/\u5b58\u50a8\u8fc7\u7a0b\u4e0d\u5b58\u5728\uff01 |
| 50 | + | ||
| 51 | +2016=\u8be5\u6570\u636e\u5e93\u4e0d\u5b58\u5728\u6b64\u529f\u80fd\uff01 | ||
| 52 | + | ||
| 53 | +2017=\u65e0\u4e3b\u952e\uff0c\u521b\u5efa\u4e3b\u952e\uff01 | ||
| 54 | + | ||
| 55 | +3001=\u6267\u884c\u8bed\u53e5 | ||
| 56 | + | ||
| 57 | +3002=\u5e8f\u53f7 | ||
| 58 | + | ||
| 59 | +3003=\u603b\u884c\u6570 | ||
| 60 | + | ||
| 61 | +3004=\u6267\u884c\u884c\u6570 | ||
| 62 | + | ||
| 63 | +3005=\u603b\u8986\u76d6\u7387 | ||
| 64 | + | ||
| 65 | +3006=\u6240\u6709\u884c\u53f7 | ||
| 66 | + | ||
| 67 | +3007=\u6267\u884c\u884c\u53f7 | ||
| 68 | + | ||
| 69 | +3008=\u6267\u884c\u8986\u76d6\u7387 | ||
| 70 | + | ||
| 71 | +3009=\u5165\u53c2 | ||
| 72 | + | ||
| 73 | +3010=\u66f4\u65b0\u65f6\u95f4 | ||
| 74 | + | ||
| 75 | +1=OID | ||
| 76 | + | ||
| 77 | +2=\u8868\u540d | ||
| 78 | + | ||
| 79 | +3=\u8868\u7a7a\u95f4 | ||
| 80 | + | ||
| 81 | +4=\u662f\u5426\u4e34\u65f6\u8868 | ||
| 82 | + | ||
| 83 | +5=\u7c7b\u578b | ||
| 84 | + | ||
| 85 | +6=\u6240\u6709\u8005 | ||
| 86 | + | ||
| 87 | +7=\u9875\u6570 | ||
| 88 | + | ||
| 89 | +8=\u884c\u6570(\u5df2\u4f30\u7b97) | ||
| 90 | + | ||
| 91 | +9=\u662f\u5426\u5305\u542b\u7d22\u5f15 | ||
| 92 | + | ||
| 93 | +10=\u662f\u5426\u5171\u4eab | ||
| 94 | + | ||
| 95 | +11=\u5b58\u50a8\u65b9\u5f0f | ||
| 96 | + | ||
| 97 | +12=\u662f\u5426\u538b\u7f29 | ||
| 98 | + | ||
| 99 | +13=\u662f\u5426\u6709OID | ||
| 100 | + | ||
| 101 | +14=\u63cf\u8ff0 | ||
| 102 | + | ||
| 103 | +15=\u5206\u533a | ||
Dplugins/data-studio/src/main/resources/private.pem+0-1
| @@ -1 +0,0 @@ | |||
| 1 | -MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJao72KRZCY_2ysTV_udtJrdYA6A6PKD9ruXn3I9apx0zq04QMmNM443pDox4sWfplkdtx_7BVzOGi5iHOmPQGUAG8rCw01gjFJl-QhScYwu7s7Rz97RZdKhgMuO4OVct5JU_3T0pdjnzqgpbnOE7Jwbsw0CjNt3iz7z5aKxgGYbAgMBAAECgYAhQCeVGYGA75bvatWAMs4pX7JTgR_oZjeOL2iBTgy5ew4iLMgfs4otWRplvZzPAO01vdkstbn5QYOFuSGoanVLfoZqHsl_jgMkDInBHEHstOuQgl46micy4JHgxQmN-od5nCxvR-41Fd_SDyzAEF0EcrjYbC1-w5b9r_zALxMQAQJBAMg9cjCd7J6fNkgB1hZ-kgqYvDpHGjhroU0vHzbiZvYt3-7v1acuJpK3Kq8XYx9ZPxqwDoOWozrlVRYcM98wpNECQQDAnQ9quBj6hALrUHD-ui5pAQVRnBQGQVMslr8x3U7AxxMvBBeUTvh9gCDk1stZu8YSDP3XNgapAaSlP4SzYwcrAkAqfCcLO6alrSAmPQWAdlBkIS3mq4lbqTJrHvFfgr_Xwbn-hzJsqzUR8f0Dc1Hbp-LktbAOqVput5PLAibbVwXRAkA7cz7C7ben-v77qoR12vlgJ5SAr-_uTlNhu9WfinM4RTnClTzB5e4Ernt4pmN1euOTxrbCqkY7--nZp1VKGRKpAkBXgB1OV5dffJRqXjqhciaIWTWqMFWsOFIigiPsE88AYw5nJ0YxDzpf25XctDGEv5gvY2TgEbJTP3_cpBB0bB0W | ||
Dplugins/data-studio/src/main/resources/public.pem+0-1
| @@ -1 +0,0 @@ | |||
| 1 | -MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCWqO9ikWQmP9srE1f7nbSa3WAOgOjyg_a7l59yPWqcdM6tOEDJjTOON6Q6MeLFn6ZZHbcf-wVczhouYhzpj0BlABvKwsNNYIxSZfkIUnGMLu7O0c_e0WXSoYDLjuDlXLeSVP909KXY586oKW5zhOycG7MNAozbd4s-8-WisYBmGwIDAQAB | ||
| @@ -1,3 +1,7 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) GBA-NCTI-ISDC. 2022-2023. All rights reserved. | ||
| 3 | + */ | ||
| 4 | + | ||
| 1 | package com.nctigba.datastudio; | 5 | package com.nctigba.datastudio; |
| 2 | 6 | ||
| 3 | import org.junit.jupiter.api.Test; | 7 | import org.junit.jupiter.api.Test; |
| @@ -3,15 +3,6 @@ | |||
| 3 | 3 | ||
| 4 | NODE_ENV = 'development' | 4 | NODE_ENV = 'development' |
| 5 | VITE_PLUGIN_NAME = 'webds-plugin' | 5 | VITE_PLUGIN_NAME = 'webds-plugin' |
| 6 | -VITE_LOAD_VERSION_TIME = '1678204800' | ||
| 7 | 6 | ||
| 8 | -# VITE_API_HOST = '127.0.0.1:8080' | 7 | +VITE_API_HOST = 'localhost:9494/plugins/webds-plugin' |
| 9 | -# VITE_WS_BASE_URL='ws://127.0.0.1:8080' | 8 | +VITE_WS_BASE_URL = 'ws://localhost:9494' |
| 10 | -# VITE_API_HOST = '127.0.0.1:9494/plugins/webds-plugin' | ||
| 11 | -# VITE_WS_BASE_URL='ws://127.0.0.1:9494' | ||
| 12 | -VITE_API_HOST = '127.0.0.1:9494/plugins/webds-plugin' | ||
| 13 | -VITE_WS_BASE_URL='ws://127.0.0.1:9494' | ||
| 14 | -# VITE_API_HOST = '127.0.0.1:9494/plugins/webds-plugin' | ||
| 15 | -# VITE_WS_BASE_URL='ws://127.0.0.1:9494' | ||
| 16 | -# VITE_API_HOST = '127.0.0.1/plugins/webds-plugin2' | ||
| 17 | -# VITE_WS_BASE_URL='ws://127.0.0.1' | ||
| @@ -3,4 +3,3 @@ | |||
| 3 | 3 | ||
| 4 | NODE_ENV = "production" | 4 | NODE_ENV = "production" |
| 5 | VITE_PLUGIN_NAME = 'webds-plugin' | 5 | VITE_PLUGIN_NAME = 'webds-plugin' |
| 6 | -VITE_LOAD_VERSION_TIME = '1678204800' | ||
| @@ -0,0 +1,55 @@ | |||
| 1 | +{ | ||
| 2 | + "globals": { | ||
| 3 | + "EffectScope": true, | ||
| 4 | + "computed": true, | ||
| 5 | + "createApp": true, | ||
| 6 | + "customRef": true, | ||
| 7 | + "defineAsyncComponent": true, | ||
| 8 | + "defineComponent": true, | ||
| 9 | + "effectScope": true, | ||
| 10 | + "getCurrentInstance": true, | ||
| 11 | + "getCurrentScope": true, | ||
| 12 | + "h": true, | ||
| 13 | + "inject": true, | ||
| 14 | + "isProxy": true, | ||
| 15 | + "isReactive": true, | ||
| 16 | + "isReadonly": true, | ||
| 17 | + "isRef": true, | ||
| 18 | + "markRaw": true, | ||
| 19 | + "nextTick": true, | ||
| 20 | + "onActivated": true, | ||
| 21 | + "onBeforeMount": true, | ||
| 22 | + "onBeforeUnmount": true, | ||
| 23 | + "onBeforeUpdate": true, | ||
| 24 | + "onDeactivated": true, | ||
| 25 | + "onErrorCaptured": true, | ||
| 26 | + "onMounted": true, | ||
| 27 | + "onRenderTracked": true, | ||
| 28 | + "onRenderTriggered": true, | ||
| 29 | + "onScopeDispose": true, | ||
| 30 | + "onServerPrefetch": true, | ||
| 31 | + "onUnmounted": true, | ||
| 32 | + "onUpdated": true, | ||
| 33 | + "provide": true, | ||
| 34 | + "reactive": true, | ||
| 35 | + "readonly": true, | ||
| 36 | + "ref": true, | ||
| 37 | + "resolveComponent": true, | ||
| 38 | + "shallowReactive": true, | ||
| 39 | + "shallowReadonly": true, | ||
| 40 | + "shallowRef": true, | ||
| 41 | + "toRaw": true, | ||
| 42 | + "toRef": true, | ||
| 43 | + "toRefs": true, | ||
| 44 | + "triggerRef": true, | ||
| 45 | + "unref": true, | ||
| 46 | + "useAttrs": true, | ||
| 47 | + "useCssModule": true, | ||
| 48 | + "useCssVars": true, | ||
| 49 | + "useSlots": true, | ||
| 50 | + "watch": true, | ||
| 51 | + "watchEffect": true, | ||
| 52 | + "watchPostEffect": true, | ||
| 53 | + "watchSyncEffect": true | ||
| 54 | + } | ||
| 55 | +} | ||
| @@ -9,6 +9,7 @@ module.exports = { | |||
| 9 | 'plugin:vue/vue3-essential', | 9 | 'plugin:vue/vue3-essential', |
| 10 | 'plugin:@typescript-eslint/recommended', | 10 | 'plugin:@typescript-eslint/recommended', |
| 11 | 'plugin:prettier/recommended', | 11 | 'plugin:prettier/recommended', |
| 12 | + './.eslintrc-auto-import.json', | ||
| 12 | ], | 13 | ], |
| 13 | parser: 'vue-eslint-parser', | 14 | parser: 'vue-eslint-parser', |
| 14 | parserOptions: { | 15 | parserOptions: { |
| @@ -46,11 +46,15 @@ | |||
| 46 | "eslint-plugin-vue": "^9.3.0", | 46 | "eslint-plugin-vue": "^9.3.0", |
| 47 | "prettier": "^2.7.1", | 47 | "prettier": "^2.7.1", |
| 48 | "typescript": "^4.6.4", | 48 | "typescript": "^4.6.4", |
| 49 | + "unplugin-auto-import": "^0.16.4", | ||
| 49 | "vite": "^3.1.4", | 50 | "vite": "^3.1.4", |
| 50 | "vite-plugin-compression": "^0.5.1", | 51 | "vite-plugin-compression": "^0.5.1", |
| 51 | "vite-plugin-style-import": "^2.0.0", | 52 | "vite-plugin-style-import": "^2.0.0", |
| 52 | "vite-plugin-svg-icons": "^2.0.1", | 53 | "vite-plugin-svg-icons": "^2.0.1", |
| 53 | "vite-plugin-vue-setup-extend": "^0.4.0", | 54 | "vite-plugin-vue-setup-extend": "^0.4.0", |
| 54 | "vue-tsc": "^1.0.0" | 55 | "vue-tsc": "^1.0.0" |
| 56 | + }, | ||
| 57 | + "engines": { | ||
| 58 | + "node": ">= 16" | ||
| 55 | } | 59 | } |
| 56 | } | 60 | } |
| @@ -22,7 +22,6 @@ | |||
| 22 | import ConnectDialog from '@/views/connect/index.vue'; | 22 | import ConnectDialog from '@/views/connect/index.vue'; |
| 23 | import ConnectInfoDialog from '@/views/connect/Info.vue'; | 23 | import ConnectInfoDialog from '@/views/connect/Info.vue'; |
| 24 | import EventBus, { EventTypeName } from '@/utils/event-bus'; | 24 | import EventBus, { EventTypeName } from '@/utils/event-bus'; |
| 25 | - import { computed, onMounted, onUnmounted, reactive, ref } from 'vue'; | ||
| 26 | import { useAppStore } from '@/store/modules/app'; | 25 | import { useAppStore } from '@/store/modules/app'; |
| 27 | import { useUserStore } from '@/store/modules/user'; | 26 | import { useUserStore } from '@/store/modules/user'; |
| 28 | import { useTagsViewStore } from '@/store/modules/tagsView'; | 27 | import { useTagsViewStore } from '@/store/modules/tagsView'; |
| @@ -1,4 +1,5 @@ | |||
| 1 | import request from './request'; | 1 | import request from './request'; |
| 2 | +import requestBlob from './requestBlob'; | ||
| 2 | 3 | ||
| 3 | // dropFunctionSP | 4 | // dropFunctionSP |
| 4 | export function dropFunctionSP(data) { | 5 | export function dropFunctionSP(data) { |
| @@ -8,3 +9,36 @@ export function dropFunctionSP(data) { | |||
| 8 | data, | 9 | data, |
| 9 | }); | 10 | }); |
| 10 | } | 11 | } |
| 12 | + | ||
| 13 | +export function getCoverageRateList(data) { | ||
| 14 | + return request({ | ||
| 15 | + url: '/dataStudio/web/v1/coverageRate/query', | ||
| 16 | + method: 'post', | ||
| 17 | + data, | ||
| 18 | + }); | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +export function deleteCoverageRate(data) { | ||
| 22 | + return request({ | ||
| 23 | + url: '/dataStudio/web/v1/coverageRate/delete', | ||
| 24 | + method: 'post', | ||
| 25 | + data, | ||
| 26 | + }); | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +export function exportCoverageRate(data) { | ||
| 30 | + return requestBlob({ | ||
| 31 | + url: '/dataStudio/web/v1/coverageRate/export', | ||
| 32 | + method: 'post', | ||
| 33 | + data, | ||
| 34 | + }); | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +// export ddl of function | ||
| 38 | +export function exportFunctionDdl(data) { | ||
| 39 | + return requestBlob({ | ||
| 40 | + url: '/dataStudio/web/v1/export/function/ddl', | ||
| 41 | + method: 'post', | ||
| 42 | + data, | ||
| 43 | + }); | ||
| 44 | +} | ||
| @@ -34,3 +34,19 @@ export function getSchemaObjectList(data) { | |||
| 34 | params: data, | 34 | params: data, |
| 35 | }); | 35 | }); |
| 36 | } | 36 | } |
| 37 | + | ||
| 38 | +// get tablespace list | ||
| 39 | +export function getTablespaceList(uuid) { | ||
| 40 | + return request({ | ||
| 41 | + url: `/dataStudio/web/v1/metaData/tablespace/${uuid}`, | ||
| 42 | + method: 'get', | ||
| 43 | + }); | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +// get dataType list | ||
| 47 | +export function getDataTypeList(uuid) { | ||
| 48 | + return request({ | ||
| 49 | + url: `/dataStudio/web/v1/metaData/typeList/${uuid}`, | ||
| 50 | + method: 'get', | ||
| 51 | + }); | ||
| 52 | +} | ||
| @@ -6,6 +6,7 @@ declare module 'axios' { | |||
| 6 | interface AxiosResponse { | 6 | interface AxiosResponse { |
| 7 | message: string; | 7 | message: string; |
| 8 | code: number; | 8 | code: number; |
| 9 | + [key: string]: any; | ||
| 9 | } | 10 | } |
| 10 | } | 11 | } |
| 11 | 12 | ||
| @@ -0,0 +1,69 @@ | |||
| 1 | +import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'; | ||
| 2 | +import { ElMessage } from 'element-plus'; | ||
| 3 | +import { i18n } from '@/i18n/index'; | ||
| 4 | + | ||
| 5 | +declare module 'axios' { | ||
| 6 | + interface AxiosResponse { | ||
| 7 | + name: string; | ||
| 8 | + } | ||
| 9 | +} | ||
| 10 | + | ||
| 11 | +const t = i18n.global.t; | ||
| 12 | +const service = axios.create({ | ||
| 13 | + baseURL: | ||
| 14 | + import.meta.env.MODE === 'production' ? `/plugins/${import.meta.env.VITE_PLUGIN_NAME}` : '/', | ||
| 15 | + timeout: 3000000, | ||
| 16 | + withCredentials: true, | ||
| 17 | +}); | ||
| 18 | + | ||
| 19 | +service.interceptors.request.use( | ||
| 20 | + (config: AxiosRequestConfig) => { | ||
| 21 | + const token: string = localStorage.getItem('opengauss-token'); | ||
| 22 | + if (token) { | ||
| 23 | + config.headers['Authorization'] = `Bearer ${token}`; | ||
| 24 | + config.headers['Accept-Language'] = i18n.global.locale.value; | ||
| 25 | + config.headers['Responsetype'] = 'blob'; | ||
| 26 | + } | ||
| 27 | + return config; | ||
| 28 | + }, | ||
| 29 | + (error: AxiosError) => { | ||
| 30 | + return Promise.reject(error); | ||
| 31 | + }, | ||
| 32 | +); | ||
| 33 | + | ||
| 34 | +service.interceptors.response.use( | ||
| 35 | + (response: AxiosResponse) => { | ||
| 36 | + if (response.data?.code == 500) { | ||
| 37 | + ElMessage({ | ||
| 38 | + message: response.data.msg, | ||
| 39 | + type: 'error', | ||
| 40 | + duration: 5000, | ||
| 41 | + }); | ||
| 42 | + return Promise.reject(response.data.msg); | ||
| 43 | + } | ||
| 44 | + return { | ||
| 45 | + name: decodeURIComponent(response.headers['content-disposition']), | ||
| 46 | + data: response.data, | ||
| 47 | + }; | ||
| 48 | + }, | ||
| 49 | + (error: AxiosError) => { | ||
| 50 | + showErrMessage(error.message); | ||
| 51 | + return Promise.reject(error); | ||
| 52 | + }, | ||
| 53 | +); | ||
| 54 | + | ||
| 55 | +/** | ||
| 56 | + * showErrMessage | ||
| 57 | + * message error message | ||
| 58 | + * type message type | ||
| 59 | + * duration Message duration | ||
| 60 | + */ | ||
| 61 | +function showErrMessage(message: string, type: any = 'error', duration = 5000) { | ||
| 62 | + ElMessage({ | ||
| 63 | + message: message, | ||
| 64 | + type: type, | ||
| 65 | + duration: duration, | ||
| 66 | + }); | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | +export default service; | ||
| @@ -0,0 +1,51 @@ | |||
| 1 | +import request from './request'; | ||
| 2 | +import requestBlob from './requestBlob'; | ||
| 3 | + | ||
| 4 | +export function getSchemaUsers(data) { | ||
| 5 | + return request({ | ||
| 6 | + url: `/dataStudio/web/v1/schema/query/users`, | ||
| 7 | + method: 'post', | ||
| 8 | + data, | ||
| 9 | + }); | ||
| 10 | +} | ||
| 11 | + | ||
| 12 | +export function createSchema(data) { | ||
| 13 | + return request({ | ||
| 14 | + url: `/dataStudio/web/v1/schema/create`, | ||
| 15 | + method: 'post', | ||
| 16 | + data, | ||
| 17 | + }); | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +export function getSchema(data) { | ||
| 21 | + return request({ | ||
| 22 | + url: `/dataStudio/web/v1/schema/query`, | ||
| 23 | + method: 'post', | ||
| 24 | + data, | ||
| 25 | + }); | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +export function updateSchema(data) { | ||
| 29 | + return request({ | ||
| 30 | + url: `/dataStudio/web/v1/schema/update`, | ||
| 31 | + method: 'post', | ||
| 32 | + data, | ||
| 33 | + }); | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +export function deleteSchema(data) { | ||
| 37 | + return request({ | ||
| 38 | + url: `/dataStudio/web/v1/schema/delete`, | ||
| 39 | + method: 'post', | ||
| 40 | + data, | ||
| 41 | + }); | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +// export ddl of schema | ||
| 45 | +export function exportSchemaDdl(data) { | ||
| 46 | + return requestBlob({ | ||
| 47 | + url: `/dataStudio/web/v1/export/schema/ddl`, | ||
| 48 | + method: 'post', | ||
| 49 | + data, | ||
| 50 | + }); | ||
| 51 | +} | ||
| @@ -1,4 +1,5 @@ | |||
| 1 | import request from './request'; | 1 | import request from './request'; |
| 2 | +import requestBlob from './requestBlob'; | ||
| 2 | 3 | ||
| 3 | // getColumnList | 4 | // getColumnList |
| 4 | export function getColumnList(data) { | 5 | export function getColumnList(data) { |
| @@ -44,3 +45,12 @@ export function getSequenceDdls(data) { | |||
| 44 | data, | 45 | data, |
| 45 | }); | 46 | }); |
| 46 | } | 47 | } |
| 48 | + | ||
| 49 | +// export ddl of sequence | ||
| 50 | +export function exportSequenceDdl(data) { | ||
| 51 | + return requestBlob({ | ||
| 52 | + url: '/dataStudio/web/v1/export/sequence/ddl', | ||
| 53 | + method: 'post', | ||
| 54 | + data, | ||
| 55 | + }); | ||
| 56 | +} | ||
| @@ -1,4 +1,5 @@ | |||
| 1 | import request from './request'; | 1 | import request from './request'; |
| 2 | +import requestBlob from './requestBlob'; | ||
| 2 | 3 | ||
| 3 | export const getTableDdl = async (data) => { | 4 | export const getTableDdl = async (data) => { |
| 4 | return await request({ | 5 | return await request({ |
| @@ -16,6 +17,14 @@ export const getTableColumn = async (data) => { | |||
| 16 | }); | 17 | }); |
| 17 | }; | 18 | }; |
| 18 | 19 | ||
| 20 | +export const updateTableColumn = async (data) => { | ||
| 21 | + return await request({ | ||
| 22 | + url: `/dataStudio/web/v1/tableColumns/edit`, | ||
| 23 | + method: 'post', | ||
| 24 | + data, | ||
| 25 | + }); | ||
| 26 | +}; | ||
| 27 | + | ||
| 19 | export const getTableConstraint = async (data) => { | 28 | export const getTableConstraint = async (data) => { |
| 20 | return await request({ | 29 | return await request({ |
| 21 | url: `/dataStudio/web/v1/tableConstraints`, | 30 | url: `/dataStudio/web/v1/tableConstraints`, |
| @@ -24,6 +33,22 @@ export const getTableConstraint = async (data) => { | |||
| 24 | }); | 33 | }); |
| 25 | }; | 34 | }; |
| 26 | 35 | ||
| 36 | +export const updateTableConstraint = async (data) => { | ||
| 37 | + return await request({ | ||
| 38 | + url: `/dataStudio/web/v1/constraint`, | ||
| 39 | + method: 'post', | ||
| 40 | + data, | ||
| 41 | + }); | ||
| 42 | +}; | ||
| 43 | + | ||
| 44 | +export const setConstraintPk = async (data) => { | ||
| 45 | + return await request({ | ||
| 46 | + url: `/dataStudio/web/v1/constraint/pk`, | ||
| 47 | + method: 'post', | ||
| 48 | + data, | ||
| 49 | + }); | ||
| 50 | +}; | ||
| 51 | + | ||
| 27 | export const getTableIndex = async (data) => { | 52 | export const getTableIndex = async (data) => { |
| 28 | return await request({ | 53 | return await request({ |
| 29 | url: `/dataStudio/web/v1/tableIndexs`, | 54 | url: `/dataStudio/web/v1/tableIndexs`, |
| @@ -32,6 +57,14 @@ export const getTableIndex = async (data) => { | |||
| 32 | }); | 57 | }); |
| 33 | }; | 58 | }; |
| 34 | 59 | ||
| 60 | +export const updateTableIndex = async (data) => { | ||
| 61 | + return await request({ | ||
| 62 | + url: `/dataStudio/web/v1/index`, | ||
| 63 | + method: 'post', | ||
| 64 | + data, | ||
| 65 | + }); | ||
| 66 | +}; | ||
| 67 | + | ||
| 35 | export const getTableData = async (data) => { | 68 | export const getTableData = async (data) => { |
| 36 | return await request({ | 69 | return await request({ |
| 37 | url: `/dataStudio/web/v1/tableDatas`, | 70 | url: `/dataStudio/web/v1/tableDatas`, |
| @@ -39,3 +72,133 @@ export const getTableData = async (data) => { | |||
| 39 | params: data, | 72 | params: data, |
| 40 | }); | 73 | }); |
| 41 | }; | 74 | }; |
| 75 | + | ||
| 76 | +export const updateTableData = async (data) => { | ||
| 77 | + return await request({ | ||
| 78 | + url: `/dataStudio/web/v1/tableDatas/edit`, | ||
| 79 | + method: 'post', | ||
| 80 | + data, | ||
| 81 | + }); | ||
| 82 | +}; | ||
| 83 | + | ||
| 84 | +export const getCreateTableDdl = async (data) => { | ||
| 85 | + return await request({ | ||
| 86 | + url: `/dataStudio/web/v1/table/ddl`, | ||
| 87 | + method: 'post', | ||
| 88 | + data, | ||
| 89 | + }); | ||
| 90 | +}; | ||
| 91 | + | ||
| 92 | +export const createTable = async (data) => { | ||
| 93 | + return await request({ | ||
| 94 | + url: `/dataStudio/web/v1/table`, | ||
| 95 | + method: 'post', | ||
| 96 | + data, | ||
| 97 | + }); | ||
| 98 | +}; | ||
| 99 | + | ||
| 100 | +export const setTableReindex = async (data) => { | ||
| 101 | + return await request({ | ||
| 102 | + url: `/dataStudio/web/v1/table/reindex`, | ||
| 103 | + method: 'post', | ||
| 104 | + data, | ||
| 105 | + }); | ||
| 106 | +}; | ||
| 107 | + | ||
| 108 | +export const setTableTruncate = async (data) => { | ||
| 109 | + return await request({ | ||
| 110 | + url: `/dataStudio/web/v1/table/truncate`, | ||
| 111 | + method: 'post', | ||
| 112 | + data, | ||
| 113 | + }); | ||
| 114 | +}; | ||
| 115 | + | ||
| 116 | +export const setTableVacuum = async (data) => { | ||
| 117 | + return await request({ | ||
| 118 | + url: `/dataStudio/web/v1/table/vacuum`, | ||
| 119 | + method: 'post', | ||
| 120 | + data, | ||
| 121 | + }); | ||
| 122 | +}; | ||
| 123 | + | ||
| 124 | +export const dropTable = async (data) => { | ||
| 125 | + return await request({ | ||
| 126 | + url: `/dataStudio/web/v1/table/drop`, | ||
| 127 | + method: 'delete', | ||
| 128 | + data, | ||
| 129 | + }); | ||
| 130 | +}; | ||
| 131 | + | ||
| 132 | +export const tableRelatedSequence = async (data) => { | ||
| 133 | + return await request({ | ||
| 134 | + url: `/dataStudio/web/v1/table/sequence`, | ||
| 135 | + method: 'post', | ||
| 136 | + data, | ||
| 137 | + }); | ||
| 138 | +}; | ||
| 139 | + | ||
| 140 | +export const getTableAttribute = async (data) => { | ||
| 141 | + return await request({ | ||
| 142 | + url: `/dataStudio/web/v1/table/attribute`, | ||
| 143 | + method: 'post', | ||
| 144 | + data, | ||
| 145 | + }); | ||
| 146 | +}; | ||
| 147 | + | ||
| 148 | +export const renameTable = async (data) => { | ||
| 149 | + return await request({ | ||
| 150 | + url: `/dataStudio/web/v1/table/rename`, | ||
| 151 | + method: 'post', | ||
| 152 | + data, | ||
| 153 | + }); | ||
| 154 | +}; | ||
| 155 | + | ||
| 156 | +export const setTableComment = async (data) => { | ||
| 157 | + return await request({ | ||
| 158 | + url: `/dataStudio/web/v1/table/comment`, | ||
| 159 | + method: 'post', | ||
| 160 | + data, | ||
| 161 | + }); | ||
| 162 | +}; | ||
| 163 | + | ||
| 164 | +export const setTablespace = async (data) => { | ||
| 165 | + return await request({ | ||
| 166 | + url: `/dataStudio/web/v1/table/retablespace`, | ||
| 167 | + method: 'post', | ||
| 168 | + data, | ||
| 169 | + }); | ||
| 170 | +}; | ||
| 171 | + | ||
| 172 | +export const setTableSchema = async (data) => { | ||
| 173 | + return await request({ | ||
| 174 | + url: `/dataStudio/web/v1/table/reschema`, | ||
| 175 | + method: 'post', | ||
| 176 | + data, | ||
| 177 | + }); | ||
| 178 | +}; | ||
| 179 | + | ||
| 180 | +// export [data, ddl] of table | ||
| 181 | +export const exportTableDdl = async (data) => { | ||
| 182 | + return await requestBlob({ | ||
| 183 | + url: `/dataStudio/web/v1/export/table/ddl`, | ||
| 184 | + method: 'post', | ||
| 185 | + data, | ||
| 186 | + }); | ||
| 187 | +}; | ||
| 188 | + | ||
| 189 | +// export data of table | ||
| 190 | +export const exportTableData = async (data) => { | ||
| 191 | + return await requestBlob({ | ||
| 192 | + url: `/dataStudio/web/v1/export/table/data`, | ||
| 193 | + method: 'post', | ||
| 194 | + responseType: 'blob', | ||
| 195 | + data, | ||
| 196 | + }); | ||
| 197 | +}; | ||
| 198 | + | ||
| 199 | +export const closeTableDatas = async (winId) => { | ||
| 200 | + return await request({ | ||
| 201 | + url: `/dataStudio/web/v1/tableDatas/close/${winId}`, | ||
| 202 | + method: 'get', | ||
| 203 | + }); | ||
| 204 | +}; | ||
| @@ -1,4 +1,5 @@ | |||
| 1 | import request from './request'; | 1 | import request from './request'; |
| 2 | +import requestBlob from './requestBlob'; | ||
| 2 | 3 | ||
| 3 | // createView | 4 | // createView |
| 4 | export function createView(data) { | 5 | export function createView(data) { |
| @@ -44,3 +45,12 @@ export function getViewDatas(data) { | |||
| 44 | params: data, | 45 | params: data, |
| 45 | }); | 46 | }); |
| 46 | } | 47 | } |
| 48 | + | ||
| 49 | +// export ddl of view | ||
| 50 | +export function exportViewDdl(data) { | ||
| 51 | + return requestBlob({ | ||
| 52 | + url: '/dataStudio/web/v1/export/view/ddl', | ||
| 53 | + method: 'post', | ||
| 54 | + data, | ||
| 55 | + }); | ||
| 56 | +} | ||
| @@ -1,3 +1,4 @@ | |||
| 1 | + | ||
| 1 | @font-face { | 2 | @font-face { |
| 2 | font-family: "iconfont logo"; | 3 | font-family: "iconfont logo"; |
| 3 | src: url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834'); | 4 | src: url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834'); |
| @@ -8,7 +9,7 @@ | |||
| 8 | } | 9 | } |
| 9 | 10 | ||
| 10 | .logo { | 11 | .logo { |
| 11 | - font-family: "iconfont logo"; | 12 | + font-family: "iconfont logo", sans-serif; |
| 12 | font-size: 160px; | 13 | font-size: 160px; |
| 13 | font-style: normal; | 14 | font-style: normal; |
| 14 | -webkit-font-smoothing: antialiased; | 15 | -webkit-font-smoothing: antialiased; |
| @@ -57,7 +58,6 @@ | |||
| 57 | display: none; | 58 | display: none; |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | - | ||
| 61 | .main { | 61 | .main { |
| 62 | padding: 30px 100px; | 62 | padding: 30px 100px; |
| 63 | width: 960px; | 63 | width: 960px; |
| @@ -72,7 +72,7 @@ | |||
| 72 | height: 110px; | 72 | height: 110px; |
| 73 | margin-top: -50px; | 73 | margin-top: -50px; |
| 74 | overflow: hidden; | 74 | overflow: hidden; |
| 75 | - *zoom: 1; | 75 | + zoom: 1; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | .main .logo a { | 78 | .main .logo a { |
| @@ -95,7 +95,7 @@ | |||
| 95 | .icon_lists { | 95 | .icon_lists { |
| 96 | width: 100% ; | 96 | width: 100% ; |
| 97 | overflow: hidden; | 97 | overflow: hidden; |
| 98 | - *zoom: 1; | 98 | + zoom: 1; |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | .icon_lists li { | 101 | .icon_lists li { |
| @@ -396,7 +396,7 @@ pre[class*="language-"] { | |||
| 396 | color: black; | 396 | color: black; |
| 397 | background: none; | 397 | background: none; |
| 398 | text-shadow: 0 1px white; | 398 | text-shadow: 0 1px white; |
| 399 | - font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; | 399 | + font-family: 'Consolas', 'Monaco', 'Andale Mono', 'Ubuntu Mono', monospace; |
| 400 | text-align: left; | 400 | text-align: left; |
| 401 | white-space: pre; | 401 | white-space: pre; |
| 402 | word-spacing: normal; | 402 | word-spacing: normal; |
| @@ -414,14 +414,6 @@ pre[class*="language-"] { | |||
| 414 | hyphens: none; | 414 | hyphens: none; |
| 415 | } | 415 | } |
| 416 | 416 | ||
| 417 | -pre[class*="language-"]::-moz-selection, | ||
| 418 | -pre[class*="language-"] ::-moz-selection, | ||
| 419 | -code[class*="language-"]::-moz-selection, | ||
| 420 | -code[class*="language-"] ::-moz-selection { | ||
| 421 | - text-shadow: none; | ||
| 422 | - background: #b3d4fc; | ||
| 423 | -} | ||
| 424 | - | ||
| 425 | pre[class*="language-"]::selection, | 417 | pre[class*="language-"]::selection, |
| 426 | pre[class*="language-"] ::selection, | 418 | pre[class*="language-"] ::selection, |
| 427 | code[class*="language-"]::selection, | 419 | code[class*="language-"]::selection, |
| @@ -9,6 +9,7 @@ | |||
| 9 | <link rel="stylesheet" href="demo.css"> | 9 | <link rel="stylesheet" href="demo.css"> |
| 10 | <link rel="stylesheet" href="iconfont.css"> | 10 | <link rel="stylesheet" href="iconfont.css"> |
| 11 | <script src="iconfont.js"></script> | 11 | <script src="iconfont.js"></script> |
| 12 | + <!-- jQuery --> | ||
| 12 | <script src="https://a1.alicdn.com/oss/uploads/2018/12/26/7bfddb60-08e8-11e9-9b04-53e73bb6408b.js"></script> | 13 | <script src="https://a1.alicdn.com/oss/uploads/2018/12/26/7bfddb60-08e8-11e9-9b04-53e73bb6408b.js"></script> |
| 13 | <script src="https://a1.alicdn.com/oss/uploads/2018/12/26/a3f714d0-08e6-11e9-8a15-ebf944d7534c.js"></script> | 14 | <script src="https://a1.alicdn.com/oss/uploads/2018/12/26/a3f714d0-08e6-11e9-8a15-ebf944d7534c.js"></script> |
| 14 | <style> | 15 | <style> |
| @@ -34,7 +35,7 @@ | |||
| 34 | </head> | 35 | </head> |
| 35 | <body> | 36 | <body> |
| 36 | <div class="main"> | 37 | <div class="main"> |
| 37 | - <h1 class="logo"><a href="https://www.iconfont.cn/" title="iconfont 首页" target="_blank"> | 38 | + <h1 class="logo"><a href="https://www.iconfont.cn/" title="iconfont" target="_blank"> |
| 38 | <img width="200" src="https://img.alicdn.com/imgextra/i3/O1CN01Mn65HV1FfSEzR6DKv_!!6000000000514-55-tps-228-59.svg"> | 39 | <img width="200" src="https://img.alicdn.com/imgextra/i3/O1CN01Mn65HV1FfSEzR6DKv_!!6000000000514-55-tps-228-59.svg"> |
| 39 | 40 | ||
| 40 | </a></h1> | 41 | </a></h1> |
| @@ -44,14 +45,143 @@ | |||
| 44 | <li class="dib"><span>Font class</span></li> | 45 | <li class="dib"><span>Font class</span></li> |
| 45 | <li class="dib"><span>Symbol</span></li> | 46 | <li class="dib"><span>Symbol</span></li> |
| 46 | </ul> | 47 | </ul> |
| 47 | - | ||
| 48 | - <a href="https://www.iconfont.cn/manage/index?manage_type=myprojects&projectId=3692346" target="_blank" class="nav-more">show project</a> | ||
| 49 | - | ||
| 50 | </div> | 48 | </div> |
| 51 | <div class="tab-container"> | 49 | <div class="tab-container"> |
| 52 | <div class="content unicode" style="display: block;"> | 50 | <div class="content unicode" style="display: block;"> |
| 53 | <ul class="icon_lists dib-box"> | 51 | <ul class="icon_lists dib-box"> |
| 54 | 52 | ||
| 53 | + <li class="dib"> | ||
| 54 | + <span class="icon iconfont"></span> | ||
| 55 | + <div class="name">文件管理-copy</div> | ||
| 56 | + <div class="code-name">&#xec6a;</div> | ||
| 57 | + </li> | ||
| 58 | + | ||
| 59 | + <li class="dib"> | ||
| 60 | + <span class="icon iconfont"></span> | ||
| 61 | + <div class="name">文件管理</div> | ||
| 62 | + <div class="code-name">&#xe615;</div> | ||
| 63 | + </li> | ||
| 64 | + | ||
| 65 | + <li class="dib"> | ||
| 66 | + <span class="icon iconfont"></span> | ||
| 67 | + <div class="name">jia</div> | ||
| 68 | + <div class="code-name">&#xe7e8;</div> | ||
| 69 | + </li> | ||
| 70 | + | ||
| 71 | + <li class="dib"> | ||
| 72 | + <span class="icon iconfont"></span> | ||
| 73 | + <div class="name">jian</div> | ||
| 74 | + <div class="code-name">&#xe7e9;</div> | ||
| 75 | + </li> | ||
| 76 | + | ||
| 77 | + <li class="dib"> | ||
| 78 | + <span class="icon iconfont"></span> | ||
| 79 | + <div class="name">加</div> | ||
| 80 | + <div class="code-name">&#xe600;</div> | ||
| 81 | + </li> | ||
| 82 | + | ||
| 83 | + <li class="dib"> | ||
| 84 | + <span class="icon iconfont"></span> | ||
| 85 | + <div class="name">减</div> | ||
| 86 | + <div class="code-name">&#xe601;</div> | ||
| 87 | + </li> | ||
| 88 | + | ||
| 89 | + <li class="dib"> | ||
| 90 | + <span class="icon iconfont"></span> | ||
| 91 | + <div class="name">gou</div> | ||
| 92 | + <div class="code-name">&#xe662;</div> | ||
| 93 | + </li> | ||
| 94 | + | ||
| 95 | + <li class="dib"> | ||
| 96 | + <span class="icon iconfont"></span> | ||
| 97 | + <div class="name">加</div> | ||
| 98 | + <div class="code-name">&#xe66f;</div> | ||
| 99 | + </li> | ||
| 100 | + | ||
| 101 | + <li class="dib"> | ||
| 102 | + <span class="icon iconfont"></span> | ||
| 103 | + <div class="name">错</div> | ||
| 104 | + <div class="code-name">&#xe635;</div> | ||
| 105 | + </li> | ||
| 106 | + | ||
| 107 | + <li class="dib"> | ||
| 108 | + <span class="icon iconfont"></span> | ||
| 109 | + <div class="name">page-last</div> | ||
| 110 | + <div class="code-name">&#xe607;</div> | ||
| 111 | + </li> | ||
| 112 | + | ||
| 113 | + <li class="dib"> | ||
| 114 | + <span class="icon iconfont"></span> | ||
| 115 | + <div class="name">page-first</div> | ||
| 116 | + <div class="code-name">&#xe608;</div> | ||
| 117 | + </li> | ||
| 118 | + | ||
| 119 | + <li class="dib"> | ||
| 120 | + <span class="icon iconfont"></span> | ||
| 121 | + <div class="name">page-previous</div> | ||
| 122 | + <div class="code-name">&#xe60a;</div> | ||
| 123 | + </li> | ||
| 124 | + | ||
| 125 | + <li class="dib"> | ||
| 126 | + <span class="icon iconfont"></span> | ||
| 127 | + <div class="name">page-next</div> | ||
| 128 | + <div class="code-name">&#xe66c;</div> | ||
| 129 | + </li> | ||
| 130 | + | ||
| 131 | + <li class="dib"> | ||
| 132 | + <span class="icon iconfont"></span> | ||
| 133 | + <div class="name">page-last-line</div> | ||
| 134 | + <div class="code-name">&#xe622;</div> | ||
| 135 | + </li> | ||
| 136 | + | ||
| 137 | + <li class="dib"> | ||
| 138 | + <span class="icon iconfont"></span> | ||
| 139 | + <div class="name">page-first-line</div> | ||
| 140 | + <div class="code-name">&#xe683;</div> | ||
| 141 | + </li> | ||
| 142 | + | ||
| 143 | + <li class="dib"> | ||
| 144 | + <span class="icon iconfont"></span> | ||
| 145 | + <div class="name">编译</div> | ||
| 146 | + <div class="code-name">&#xe634;</div> | ||
| 147 | + </li> | ||
| 148 | + | ||
| 149 | + <li class="dib"> | ||
| 150 | + <span class="icon iconfont"></span> | ||
| 151 | + <div class="name">编译-copy</div> | ||
| 152 | + <div class="code-name">&#xec69;</div> | ||
| 153 | + </li> | ||
| 154 | + | ||
| 155 | + <li class="dib"> | ||
| 156 | + <span class="icon iconfont"></span> | ||
| 157 | + <div class="name">编辑</div> | ||
| 158 | + <div class="code-name">&#xe631;</div> | ||
| 159 | + </li> | ||
| 160 | + | ||
| 161 | + <li class="dib"> | ||
| 162 | + <span class="icon iconfont"></span> | ||
| 163 | + <div class="name">删除行</div> | ||
| 164 | + <div class="code-name">&#xec67;</div> | ||
| 165 | + </li> | ||
| 166 | + | ||
| 167 | + <li class="dib"> | ||
| 168 | + <span class="icon iconfont"></span> | ||
| 169 | + <div class="name">添加行</div> | ||
| 170 | + <div class="code-name">&#xec68;</div> | ||
| 171 | + </li> | ||
| 172 | + | ||
| 173 | + <li class="dib"> | ||
| 174 | + <span class="icon iconfont"></span> | ||
| 175 | + <div class="name">clear</div> | ||
| 176 | + <div class="code-name">&#xe900;</div> | ||
| 177 | + </li> | ||
| 178 | + | ||
| 179 | + <li class="dib"> | ||
| 180 | + <span class="icon iconfont"></span> | ||
| 181 | + <div class="name">导出</div> | ||
| 182 | + <div class="code-name">&#xe611;</div> | ||
| 183 | + </li> | ||
| 184 | + | ||
| 55 | <li class="dib"> | 185 | <li class="dib"> |
| 56 | <span class="icon iconfont"></span> | 186 | <span class="icon iconfont"></span> |
| 57 | <div class="name">debugsinglestep-disabled</div> | 187 | <div class="name">debugsinglestep-disabled</div> |
| @@ -64,6 +194,18 @@ | |||
| 64 | <div class="code-name">&#xe606;</div> | 194 | <div class="code-name">&#xe606;</div> |
| 65 | </li> | 195 | </li> |
| 66 | 196 | ||
| 197 | + <li class="dib"> | ||
| 198 | + <span class="icon iconfont"></span> | ||
| 199 | + <div class="name">database-connected-copy</div> | ||
| 200 | + <div class="code-name">&#xe884;</div> | ||
| 201 | + </li> | ||
| 202 | + | ||
| 203 | + <li class="dib"> | ||
| 204 | + <span class="icon iconfont"></span> | ||
| 205 | + <div class="name">database-disconnect-copy</div> | ||
| 206 | + <div class="code-name">&#xe885;</div> | ||
| 207 | + </li> | ||
| 208 | + | ||
| 67 | <li class="dib"> | 209 | <li class="dib"> |
| 68 | <span class="icon iconfont"></span> | 210 | <span class="icon iconfont"></span> |
| 69 | <div class="name">database-connected</div> | 211 | <div class="name">database-connected</div> |
| @@ -78,19 +220,19 @@ | |||
| 78 | 220 | ||
| 79 | <li class="dib"> | 221 | <li class="dib"> |
| 80 | <span class="icon iconfont"></span> | 222 | <span class="icon iconfont"></span> |
| 81 | - <div class="name">database</div> | 223 | + <div class="name">数据库</div> |
| 82 | <div class="code-name">&#xe603;</div> | 224 | <div class="code-name">&#xe603;</div> |
| 83 | </li> | 225 | </li> |
| 84 | 226 | ||
| 85 | <li class="dib"> | 227 | <li class="dib"> |
| 86 | <span class="icon iconfont"></span> | 228 | <span class="icon iconfont"></span> |
| 87 | - <div class="name">m-format</div> | 229 | + <div class="name">m-格式化文字</div> |
| 88 | <div class="code-name">&#xe7f8;</div> | 230 | <div class="code-name">&#xe7f8;</div> |
| 89 | </li> | 231 | </li> |
| 90 | 232 | ||
| 91 | <li class="dib"> | 233 | <li class="dib"> |
| 92 | <span class="icon iconfont"></span> | 234 | <span class="icon iconfont"></span> |
| 93 | - <div class="name">line_pointer</div> | 235 | + <div class="name">line_手势</div> |
| 94 | <div class="code-name">&#xe675;</div> | 236 | <div class="code-name">&#xe675;</div> |
| 95 | </li> | 237 | </li> |
| 96 | 238 | ||
| @@ -144,13 +286,13 @@ | |||
| 144 | 286 | ||
| 145 | <li class="dib"> | 287 | <li class="dib"> |
| 146 | <span class="icon iconfont"></span> | 288 | <span class="icon iconfont"></span> |
| 147 | - <div class="name">play</div> | 289 | + <div class="name">继续播放</div> |
| 148 | <div class="code-name">&#xe624;</div> | 290 | <div class="code-name">&#xe624;</div> |
| 149 | </li> | 291 | </li> |
| 150 | 292 | ||
| 151 | <li class="dib"> | 293 | <li class="dib"> |
| 152 | <span class="icon iconfont"></span> | 294 | <span class="icon iconfont"></span> |
| 153 | - <div class="name">play-copy</div> | 295 | + <div class="name">继续播放-copy</div> |
| 154 | <div class="code-name">&#xe7bb;</div> | 296 | <div class="code-name">&#xe7bb;</div> |
| 155 | </li> | 297 | </li> |
| 156 | 298 | ||
| @@ -230,13 +372,14 @@ | |||
| 230 | <div class="article markdown"> | 372 | <div class="article markdown"> |
| 231 | <h2 id="unicode-">Unicode</h2> | 373 | <h2 id="unicode-">Unicode</h2> |
| 232 | <hr> | 374 | <hr> |
| 375 | + <p>Unicode</p> | ||
| 233 | <h3 id="-font-face">Step 1: Copy the generated files under the project <code>@font-face</code></h3> | 376 | <h3 id="-font-face">Step 1: Copy the generated files under the project <code>@font-face</code></h3> |
| 234 | <pre><code class="language-css" | 377 | <pre><code class="language-css" |
| 235 | >@font-face { | 378 | >@font-face { |
| 236 | font-family: 'iconfont'; | 379 | font-family: 'iconfont'; |
| 237 | - src: url('iconfont.woff2?t=1675671470686') format('woff2'), | 380 | + src: url('iconfont.woff2?t=1683169505473') format('woff2'), |
| 238 | - url('iconfont.woff?t=1675671470686') format('woff'), | 381 | + url('iconfont.woff?t=1683169505473') format('woff'), |
| 239 | - url('iconfont.ttf?t=1675671470686') format('truetype'); | 382 | + url('iconfont.ttf?t=1683169505473') format('truetype'); |
| 240 | } | 383 | } |
| 241 | </code></pre> | 384 | </code></pre> |
| 242 | <h3 id="-iconfont-">Step 2: Define the style of using iconfont</h3> | 385 | <h3 id="-iconfont-">Step 2: Define the style of using iconfont</h3> |
| @@ -259,6 +402,204 @@ | |||
| 259 | <div class="content font-class"> | 402 | <div class="content font-class"> |
| 260 | <ul class="icon_lists dib-box"> | 403 | <ul class="icon_lists dib-box"> |
| 261 | 404 | ||
| 405 | + <li class="dib"> | ||
| 406 | + <span class="icon iconfont icon-report-disabled"></span> | ||
| 407 | + <div class="name"> | ||
| 408 | + 文件管理-copy | ||
| 409 | + </div> | ||
| 410 | + <div class="code-name">.icon-report-disabled | ||
| 411 | + </div> | ||
| 412 | + </li> | ||
| 413 | + | ||
| 414 | + <li class="dib"> | ||
| 415 | + <span class="icon iconfont icon-report"></span> | ||
| 416 | + <div class="name"> | ||
| 417 | + 文件管理 | ||
| 418 | + </div> | ||
| 419 | + <div class="code-name">.icon-report | ||
| 420 | + </div> | ||
| 421 | + </li> | ||
| 422 | + | ||
| 423 | + <li class="dib"> | ||
| 424 | + <span class="icon iconfont icon-jia1"></span> | ||
| 425 | + <div class="name"> | ||
| 426 | + jia | ||
| 427 | + </div> | ||
| 428 | + <div class="code-name">.icon-jia1 | ||
| 429 | + </div> | ||
| 430 | + </li> | ||
| 431 | + | ||
| 432 | + <li class="dib"> | ||
| 433 | + <span class="icon iconfont icon-jian1"></span> | ||
| 434 | + <div class="name"> | ||
| 435 | + jian | ||
| 436 | + </div> | ||
| 437 | + <div class="code-name">.icon-jian1 | ||
| 438 | + </div> | ||
| 439 | + </li> | ||
| 440 | + | ||
| 441 | + <li class="dib"> | ||
| 442 | + <span class="icon iconfont icon-jia"></span> | ||
| 443 | + <div class="name"> | ||
| 444 | + 加 | ||
| 445 | + </div> | ||
| 446 | + <div class="code-name">.icon-jia | ||
| 447 | + </div> | ||
| 448 | + </li> | ||
| 449 | + | ||
| 450 | + <li class="dib"> | ||
| 451 | + <span class="icon iconfont icon-jian"></span> | ||
| 452 | + <div class="name"> | ||
| 453 | + 减 | ||
| 454 | + </div> | ||
| 455 | + <div class="code-name">.icon-jian | ||
| 456 | + </div> | ||
| 457 | + </li> | ||
| 458 | + | ||
| 459 | + <li class="dib"> | ||
| 460 | + <span class="icon iconfont icon-gou"></span> | ||
| 461 | + <div class="name"> | ||
| 462 | + gou | ||
| 463 | + </div> | ||
| 464 | + <div class="code-name">.icon-gou | ||
| 465 | + </div> | ||
| 466 | + </li> | ||
| 467 | + | ||
| 468 | + <li class="dib"> | ||
| 469 | + <span class="icon iconfont icon-copy-add"></span> | ||
| 470 | + <div class="name"> | ||
| 471 | + 加 | ||
| 472 | + </div> | ||
| 473 | + <div class="code-name">.icon-copy-add | ||
| 474 | + </div> | ||
| 475 | + </li> | ||
| 476 | + | ||
| 477 | + <li class="dib"> | ||
| 478 | + <span class="icon iconfont icon-cuo"></span> | ||
| 479 | + <div class="name"> | ||
| 480 | + 错 | ||
| 481 | + </div> | ||
| 482 | + <div class="code-name">.icon-cuo | ||
| 483 | + </div> | ||
| 484 | + </li> | ||
| 485 | + | ||
| 486 | + <li class="dib"> | ||
| 487 | + <span class="icon iconfont icon-page-last"></span> | ||
| 488 | + <div class="name"> | ||
| 489 | + page-last | ||
| 490 | + </div> | ||
| 491 | + <div class="code-name">.icon-page-last | ||
| 492 | + </div> | ||
| 493 | + </li> | ||
| 494 | + | ||
| 495 | + <li class="dib"> | ||
| 496 | + <span class="icon iconfont icon-page-first"></span> | ||
| 497 | + <div class="name"> | ||
| 498 | + page-first | ||
| 499 | + </div> | ||
| 500 | + <div class="code-name">.icon-page-first | ||
| 501 | + </div> | ||
| 502 | + </li> | ||
| 503 | + | ||
| 504 | + <li class="dib"> | ||
| 505 | + <span class="icon iconfont icon-page-previous"></span> | ||
| 506 | + <div class="name"> | ||
| 507 | + page-previous | ||
| 508 | + </div> | ||
| 509 | + <div class="code-name">.icon-page-previous | ||
| 510 | + </div> | ||
| 511 | + </li> | ||
| 512 | + | ||
| 513 | + <li class="dib"> | ||
| 514 | + <span class="icon iconfont icon-page-next"></span> | ||
| 515 | + <div class="name"> | ||
| 516 | + page-next | ||
| 517 | + </div> | ||
| 518 | + <div class="code-name">.icon-page-next | ||
| 519 | + </div> | ||
| 520 | + </li> | ||
| 521 | + | ||
| 522 | + <li class="dib"> | ||
| 523 | + <span class="icon iconfont icon-page-last-line"></span> | ||
| 524 | + <div class="name"> | ||
| 525 | + page-last-line | ||
| 526 | + </div> | ||
| 527 | + <div class="code-name">.icon-page-last-line | ||
| 528 | + </div> | ||
| 529 | + </li> | ||
| 530 | + | ||
| 531 | + <li class="dib"> | ||
| 532 | + <span class="icon iconfont icon-page-first-line"></span> | ||
| 533 | + <div class="name"> | ||
| 534 | + page-first-line | ||
| 535 | + </div> | ||
| 536 | + <div class="code-name">.icon-page-first-line | ||
| 537 | + </div> | ||
| 538 | + </li> | ||
| 539 | + | ||
| 540 | + <li class="dib"> | ||
| 541 | + <span class="icon iconfont icon-compile"></span> | ||
| 542 | + <div class="name"> | ||
| 543 | + 编译 | ||
| 544 | + </div> | ||
| 545 | + <div class="code-name">.icon-compile | ||
| 546 | + </div> | ||
| 547 | + </li> | ||
| 548 | + | ||
| 549 | + <li class="dib"> | ||
| 550 | + <span class="icon iconfont icon-compile-disabled"></span> | ||
| 551 | + <div class="name"> | ||
| 552 | + 编译-copy | ||
| 553 | + </div> | ||
| 554 | + <div class="code-name">.icon-compile-disabled | ||
| 555 | + </div> | ||
| 556 | + </li> | ||
| 557 | + | ||
| 558 | + <li class="dib"> | ||
| 559 | + <span class="icon iconfont icon-bianji"></span> | ||
| 560 | + <div class="name"> | ||
| 561 | + 编辑 | ||
| 562 | + </div> | ||
| 563 | + <div class="code-name">.icon-bianji | ||
| 564 | + </div> | ||
| 565 | + </li> | ||
| 566 | + | ||
| 567 | + <li class="dib"> | ||
| 568 | + <span class="icon iconfont icon-shanchuhang"></span> | ||
| 569 | + <div class="name"> | ||
| 570 | + 删除行 | ||
| 571 | + </div> | ||
| 572 | + <div class="code-name">.icon-shanchuhang | ||
| 573 | + </div> | ||
| 574 | + </li> | ||
| 575 | + | ||
| 576 | + <li class="dib"> | ||
| 577 | + <span class="icon iconfont icon-tianjiahang"></span> | ||
| 578 | + <div class="name"> | ||
| 579 | + 添加行 | ||
| 580 | + </div> | ||
| 581 | + <div class="code-name">.icon-tianjiahang | ||
| 582 | + </div> | ||
| 583 | + </li> | ||
| 584 | + | ||
| 585 | + <li class="dib"> | ||
| 586 | + <span class="icon iconfont icon-clear"></span> | ||
| 587 | + <div class="name"> | ||
| 588 | + clear | ||
| 589 | + </div> | ||
| 590 | + <div class="code-name">.icon-clear | ||
| 591 | + </div> | ||
| 592 | + </li> | ||
| 593 | + | ||
| 594 | + <li class="dib"> | ||
| 595 | + <span class="icon iconfont icon-daochu"></span> | ||
| 596 | + <div class="name"> | ||
| 597 | + 导出 | ||
| 598 | + </div> | ||
| 599 | + <div class="code-name">.icon-daochu | ||
| 600 | + </div> | ||
| 601 | + </li> | ||
| 602 | + | ||
| 262 | <li class="dib"> | 603 | <li class="dib"> |
| 263 | <span class="icon iconfont icon-debugsinglestep-disabled"></span> | 604 | <span class="icon iconfont icon-debugsinglestep-disabled"></span> |
| 264 | <div class="name"> | 605 | <div class="name"> |
| @@ -277,6 +618,24 @@ | |||
| 277 | </div> | 618 | </div> |
| 278 | </li> | 619 | </li> |
| 279 | 620 | ||
| 621 | + <li class="dib"> | ||
| 622 | + <span class="icon iconfont icon-database-connected-copy"></span> | ||
| 623 | + <div class="name"> | ||
| 624 | + database-connected-copy | ||
| 625 | + </div> | ||
| 626 | + <div class="code-name">.icon-database-connected-copy | ||
| 627 | + </div> | ||
| 628 | + </li> | ||
| 629 | + | ||
| 630 | + <li class="dib"> | ||
| 631 | + <span class="icon iconfont icon-database-disconnect-copy"></span> | ||
| 632 | + <div class="name"> | ||
| 633 | + database-disconnect-copy | ||
| 634 | + </div> | ||
| 635 | + <div class="code-name">.icon-database-disconnect-copy | ||
| 636 | + </div> | ||
| 637 | + </li> | ||
| 638 | + | ||
| 280 | <li class="dib"> | 639 | <li class="dib"> |
| 281 | <span class="icon iconfont icon-database-connected"></span> | 640 | <span class="icon iconfont icon-database-connected"></span> |
| 282 | <div class="name"> | 641 | <div class="name"> |
| @@ -298,7 +657,7 @@ | |||
| 298 | <li class="dib"> | 657 | <li class="dib"> |
| 299 | <span class="icon iconfont icon-shujuku"></span> | 658 | <span class="icon iconfont icon-shujuku"></span> |
| 300 | <div class="name"> | 659 | <div class="name"> |
| 301 | - database | 660 | + 数据库 |
| 302 | </div> | 661 | </div> |
| 303 | <div class="code-name">.icon-shujuku | 662 | <div class="code-name">.icon-shujuku |
| 304 | </div> | 663 | </div> |
| @@ -307,7 +666,7 @@ | |||
| 307 | <li class="dib"> | 666 | <li class="dib"> |
| 308 | <span class="icon iconfont icon-m-geshihuawenzi"></span> | 667 | <span class="icon iconfont icon-m-geshihuawenzi"></span> |
| 309 | <div class="name"> | 668 | <div class="name"> |
| 310 | - m-format | 669 | + m-格式化文字 |
| 311 | </div> | 670 | </div> |
| 312 | <div class="code-name">.icon-m-geshihuawenzi | 671 | <div class="code-name">.icon-m-geshihuawenzi |
| 313 | </div> | 672 | </div> |
| @@ -316,7 +675,7 @@ | |||
| 316 | <li class="dib"> | 675 | <li class="dib"> |
| 317 | <span class="icon iconfont icon-line_shoushi"></span> | 676 | <span class="icon iconfont icon-line_shoushi"></span> |
| 318 | <div class="name"> | 677 | <div class="name"> |
| 319 | - line_pointer | 678 | + line_手势 |
| 320 | </div> | 679 | </div> |
| 321 | <div class="code-name">.icon-line_shoushi | 680 | <div class="code-name">.icon-line_shoushi |
| 322 | </div> | 681 | </div> |
| @@ -397,7 +756,7 @@ | |||
| 397 | <li class="dib"> | 756 | <li class="dib"> |
| 398 | <span class="icon iconfont icon-debugstep"></span> | 757 | <span class="icon iconfont icon-debugstep"></span> |
| 399 | <div class="name"> | 758 | <div class="name"> |
| 400 | - play | 759 | + 继续播放 |
| 401 | </div> | 760 | </div> |
| 402 | <div class="code-name">.icon-debugstep | 761 | <div class="code-name">.icon-debugstep |
| 403 | </div> | 762 | </div> |
| @@ -406,7 +765,7 @@ | |||
| 406 | <li class="dib"> | 765 | <li class="dib"> |
| 407 | <span class="icon iconfont icon-debugstep-disabled"></span> | 766 | <span class="icon iconfont icon-debugstep-disabled"></span> |
| 408 | <div class="name"> | 767 | <div class="name"> |
| 409 | - play-copy | 768 | + 继续播放-copy |
| 410 | </div> | 769 | </div> |
| 411 | <div class="code-name">.icon-debugstep-disabled | 770 | <div class="code-name">.icon-debugstep-disabled |
| 412 | </div> | 771 | </div> |
| @@ -535,6 +894,182 @@ | |||
| 535 | <div class="content symbol"> | 894 | <div class="content symbol"> |
| 536 | <ul class="icon_lists dib-box"> | 895 | <ul class="icon_lists dib-box"> |
| 537 | 896 | ||
| 897 | + <li class="dib"> | ||
| 898 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 899 | + <use xlink:href="#icon-report-disabled"></use> | ||
| 900 | + </svg> | ||
| 901 | + <div class="name">文件管理-copy</div> | ||
| 902 | + <div class="code-name">#icon-report-disabled</div> | ||
| 903 | + </li> | ||
| 904 | + | ||
| 905 | + <li class="dib"> | ||
| 906 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 907 | + <use xlink:href="#icon-report"></use> | ||
| 908 | + </svg> | ||
| 909 | + <div class="name">文件管理</div> | ||
| 910 | + <div class="code-name">#icon-report</div> | ||
| 911 | + </li> | ||
| 912 | + | ||
| 913 | + <li class="dib"> | ||
| 914 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 915 | + <use xlink:href="#icon-jia1"></use> | ||
| 916 | + </svg> | ||
| 917 | + <div class="name">jia</div> | ||
| 918 | + <div class="code-name">#icon-jia1</div> | ||
| 919 | + </li> | ||
| 920 | + | ||
| 921 | + <li class="dib"> | ||
| 922 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 923 | + <use xlink:href="#icon-jian1"></use> | ||
| 924 | + </svg> | ||
| 925 | + <div class="name">jian</div> | ||
| 926 | + <div class="code-name">#icon-jian1</div> | ||
| 927 | + </li> | ||
| 928 | + | ||
| 929 | + <li class="dib"> | ||
| 930 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 931 | + <use xlink:href="#icon-jia"></use> | ||
| 932 | + </svg> | ||
| 933 | + <div class="name">加</div> | ||
| 934 | + <div class="code-name">#icon-jia</div> | ||
| 935 | + </li> | ||
| 936 | + | ||
| 937 | + <li class="dib"> | ||
| 938 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 939 | + <use xlink:href="#icon-jian"></use> | ||
| 940 | + </svg> | ||
| 941 | + <div class="name">减</div> | ||
| 942 | + <div class="code-name">#icon-jian</div> | ||
| 943 | + </li> | ||
| 944 | + | ||
| 945 | + <li class="dib"> | ||
| 946 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 947 | + <use xlink:href="#icon-gou"></use> | ||
| 948 | + </svg> | ||
| 949 | + <div class="name">gou</div> | ||
| 950 | + <div class="code-name">#icon-gou</div> | ||
| 951 | + </li> | ||
| 952 | + | ||
| 953 | + <li class="dib"> | ||
| 954 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 955 | + <use xlink:href="#icon-copy-add"></use> | ||
| 956 | + </svg> | ||
| 957 | + <div class="name">加</div> | ||
| 958 | + <div class="code-name">#icon-copy-add</div> | ||
| 959 | + </li> | ||
| 960 | + | ||
| 961 | + <li class="dib"> | ||
| 962 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 963 | + <use xlink:href="#icon-cuo"></use> | ||
| 964 | + </svg> | ||
| 965 | + <div class="name">错</div> | ||
| 966 | + <div class="code-name">#icon-cuo</div> | ||
| 967 | + </li> | ||
| 968 | + | ||
| 969 | + <li class="dib"> | ||
| 970 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 971 | + <use xlink:href="#icon-page-last"></use> | ||
| 972 | + </svg> | ||
| 973 | + <div class="name">page-last</div> | ||
| 974 | + <div class="code-name">#icon-page-last</div> | ||
| 975 | + </li> | ||
| 976 | + | ||
| 977 | + <li class="dib"> | ||
| 978 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 979 | + <use xlink:href="#icon-page-first"></use> | ||
| 980 | + </svg> | ||
| 981 | + <div class="name">page-first</div> | ||
| 982 | + <div class="code-name">#icon-page-first</div> | ||
| 983 | + </li> | ||
| 984 | + | ||
| 985 | + <li class="dib"> | ||
| 986 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 987 | + <use xlink:href="#icon-page-previous"></use> | ||
| 988 | + </svg> | ||
| 989 | + <div class="name">page-previous</div> | ||
| 990 | + <div class="code-name">#icon-page-previous</div> | ||
| 991 | + </li> | ||
| 992 | + | ||
| 993 | + <li class="dib"> | ||
| 994 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 995 | + <use xlink:href="#icon-page-next"></use> | ||
| 996 | + </svg> | ||
| 997 | + <div class="name">page-next</div> | ||
| 998 | + <div class="code-name">#icon-page-next</div> | ||
| 999 | + </li> | ||
| 1000 | + | ||
| 1001 | + <li class="dib"> | ||
| 1002 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 1003 | + <use xlink:href="#icon-page-last-line"></use> | ||
| 1004 | + </svg> | ||
| 1005 | + <div class="name">page-last-line</div> | ||
| 1006 | + <div class="code-name">#icon-page-last-line</div> | ||
| 1007 | + </li> | ||
| 1008 | + | ||
| 1009 | + <li class="dib"> | ||
| 1010 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 1011 | + <use xlink:href="#icon-page-first-line"></use> | ||
| 1012 | + </svg> | ||
| 1013 | + <div class="name">page-first-line</div> | ||
| 1014 | + <div class="code-name">#icon-page-first-line</div> | ||
| 1015 | + </li> | ||
| 1016 | + | ||
| 1017 | + <li class="dib"> | ||
| 1018 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 1019 | + <use xlink:href="#icon-compile"></use> | ||
| 1020 | + </svg> | ||
| 1021 | + <div class="name">编译</div> | ||
| 1022 | + <div class="code-name">#icon-compile</div> | ||
| 1023 | + </li> | ||
| 1024 | + | ||
| 1025 | + <li class="dib"> | ||
| 1026 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 1027 | + <use xlink:href="#icon-compile-disabled"></use> | ||
| 1028 | + </svg> | ||
| 1029 | + <div class="name">编译-copy</div> | ||
| 1030 | + <div class="code-name">#icon-compile-disabled</div> | ||
| 1031 | + </li> | ||
| 1032 | + | ||
| 1033 | + <li class="dib"> | ||
| 1034 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 1035 | + <use xlink:href="#icon-bianji"></use> | ||
| 1036 | + </svg> | ||
| 1037 | + <div class="name">编辑</div> | ||
| 1038 | + <div class="code-name">#icon-bianji</div> | ||
| 1039 | + </li> | ||
| 1040 | + | ||
| 1041 | + <li class="dib"> | ||
| 1042 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 1043 | + <use xlink:href="#icon-shanchuhang"></use> | ||
| 1044 | + </svg> | ||
| 1045 | + <div class="name">删除行</div> | ||
| 1046 | + <div class="code-name">#icon-shanchuhang</div> | ||
| 1047 | + </li> | ||
| 1048 | + | ||
| 1049 | + <li class="dib"> | ||
| 1050 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 1051 | + <use xlink:href="#icon-tianjiahang"></use> | ||
| 1052 | + </svg> | ||
| 1053 | + <div class="name">添加行</div> | ||
| 1054 | + <div class="code-name">#icon-tianjiahang</div> | ||
| 1055 | + </li> | ||
| 1056 | + | ||
| 1057 | + <li class="dib"> | ||
| 1058 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 1059 | + <use xlink:href="#icon-clear"></use> | ||
| 1060 | + </svg> | ||
| 1061 | + <div class="name">clear</div> | ||
| 1062 | + <div class="code-name">#icon-clear</div> | ||
| 1063 | + </li> | ||
| 1064 | + | ||
| 1065 | + <li class="dib"> | ||
| 1066 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 1067 | + <use xlink:href="#icon-daochu"></use> | ||
| 1068 | + </svg> | ||
| 1069 | + <div class="name">导出</div> | ||
| 1070 | + <div class="code-name">#icon-daochu</div> | ||
| 1071 | + </li> | ||
| 1072 | + | ||
| 538 | <li class="dib"> | 1073 | <li class="dib"> |
| 539 | <svg class="icon svg-icon" aria-hidden="true"> | 1074 | <svg class="icon svg-icon" aria-hidden="true"> |
| 540 | <use xlink:href="#icon-debugsinglestep-disabled"></use> | 1075 | <use xlink:href="#icon-debugsinglestep-disabled"></use> |
| @@ -551,6 +1086,22 @@ | |||
| 551 | <div class="code-name">#icon-debugsinglestep</div> | 1086 | <div class="code-name">#icon-debugsinglestep</div> |
| 552 | </li> | 1087 | </li> |
| 553 | 1088 | ||
| 1089 | + <li class="dib"> | ||
| 1090 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 1091 | + <use xlink:href="#icon-database-connected-copy"></use> | ||
| 1092 | + </svg> | ||
| 1093 | + <div class="name">database-connected-copy</div> | ||
| 1094 | + <div class="code-name">#icon-database-connected-copy</div> | ||
| 1095 | + </li> | ||
| 1096 | + | ||
| 1097 | + <li class="dib"> | ||
| 1098 | + <svg class="icon svg-icon" aria-hidden="true"> | ||
| 1099 | + <use xlink:href="#icon-database-disconnect-copy"></use> | ||
| 1100 | + </svg> | ||
| 1101 | + <div class="name">database-disconnect-copy</div> | ||
| 1102 | + <div class="code-name">#icon-database-disconnect-copy</div> | ||
| 1103 | + </li> | ||
| 1104 | + | ||
| 554 | <li class="dib"> | 1105 | <li class="dib"> |
| 555 | <svg class="icon svg-icon" aria-hidden="true"> | 1106 | <svg class="icon svg-icon" aria-hidden="true"> |
| 556 | <use xlink:href="#icon-database-connected"></use> | 1107 | <use xlink:href="#icon-database-connected"></use> |
| @@ -571,7 +1122,7 @@ | |||
| 571 | <svg class="icon svg-icon" aria-hidden="true"> | 1122 | <svg class="icon svg-icon" aria-hidden="true"> |
| 572 | <use xlink:href="#icon-shujuku"></use> | 1123 | <use xlink:href="#icon-shujuku"></use> |
| 573 | </svg> | 1124 | </svg> |
| 574 | - <div class="name">database</div> | 1125 | + <div class="name">数据库</div> |
| 575 | <div class="code-name">#icon-shujuku</div> | 1126 | <div class="code-name">#icon-shujuku</div> |
| 576 | </li> | 1127 | </li> |
| 577 | 1128 | ||
| @@ -579,7 +1130,7 @@ | |||
| 579 | <svg class="icon svg-icon" aria-hidden="true"> | 1130 | <svg class="icon svg-icon" aria-hidden="true"> |
| 580 | <use xlink:href="#icon-m-geshihuawenzi"></use> | 1131 | <use xlink:href="#icon-m-geshihuawenzi"></use> |
| 581 | </svg> | 1132 | </svg> |
| 582 | - <div class="name">m-format</div> | 1133 | + <div class="name">m-格式化文字</div> |
| 583 | <div class="code-name">#icon-m-geshihuawenzi</div> | 1134 | <div class="code-name">#icon-m-geshihuawenzi</div> |
| 584 | </li> | 1135 | </li> |
| 585 | 1136 | ||
| @@ -587,7 +1138,7 @@ | |||
| 587 | <svg class="icon svg-icon" aria-hidden="true"> | 1138 | <svg class="icon svg-icon" aria-hidden="true"> |
| 588 | <use xlink:href="#icon-line_shoushi"></use> | 1139 | <use xlink:href="#icon-line_shoushi"></use> |
| 589 | </svg> | 1140 | </svg> |
| 590 | - <div class="name">line_pointer</div> | 1141 | + <div class="name">line_手势</div> |
| 591 | <div class="code-name">#icon-line_shoushi</div> | 1142 | <div class="code-name">#icon-line_shoushi</div> |
| 592 | </li> | 1143 | </li> |
| 593 | 1144 | ||
| @@ -659,7 +1210,7 @@ | |||
| 659 | <svg class="icon svg-icon" aria-hidden="true"> | 1210 | <svg class="icon svg-icon" aria-hidden="true"> |
| 660 | <use xlink:href="#icon-debugstep"></use> | 1211 | <use xlink:href="#icon-debugstep"></use> |
| 661 | </svg> | 1212 | </svg> |
| 662 | - <div class="name">play</div> | 1213 | + <div class="name">继续播放</div> |
| 663 | <div class="code-name">#icon-debugstep</div> | 1214 | <div class="code-name">#icon-debugstep</div> |
| 664 | </li> | 1215 | </li> |
| 665 | 1216 | ||
| @@ -667,7 +1218,7 @@ | |||
| 667 | <svg class="icon svg-icon" aria-hidden="true"> | 1218 | <svg class="icon svg-icon" aria-hidden="true"> |
| 668 | <use xlink:href="#icon-debugstep-disabled"></use> | 1219 | <use xlink:href="#icon-debugstep-disabled"></use> |
| 669 | </svg> | 1220 | </svg> |
| 670 | - <div class="name">play-copy</div> | 1221 | + <div class="name">继续播放-copy</div> |
| 671 | <div class="code-name">#icon-debugstep-disabled</div> | 1222 | <div class="code-name">#icon-debugstep-disabled</div> |
| 672 | </li> | 1223 | </li> |
| 673 | 1224 | ||
| @@ -1,18 +1,106 @@ | |||
| 1 | @font-face { | 1 | @font-face { |
| 2 | font-family: "iconfont"; /* Project id 3692346 */ | 2 | font-family: "iconfont"; /* Project id 3692346 */ |
| 3 | - src: url('iconfont.woff2?t=1675671470686') format('woff2'), | 3 | + src: url('iconfont.woff2?t=1683169505473') format('woff2'), |
| 4 | - url('iconfont.woff?t=1675671470686') format('woff'), | 4 | + url('iconfont.woff?t=1683169505473') format('woff'), |
| 5 | - url('iconfont.ttf?t=1675671470686') format('truetype'); | 5 | + url('iconfont.ttf?t=1683169505473') format('truetype'); |
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | .iconfont { | 8 | .iconfont { |
| 9 | - font-family: "iconfont" !important; | 9 | + font-family: "iconfont", sans-serif !important; |
| 10 | font-size: 16px; | 10 | font-size: 16px; |
| 11 | font-style: normal; | 11 | font-style: normal; |
| 12 | -webkit-font-smoothing: antialiased; | 12 | -webkit-font-smoothing: antialiased; |
| 13 | -moz-osx-font-smoothing: grayscale; | 13 | -moz-osx-font-smoothing: grayscale; |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | +.icon-report-disabled:before { | ||
| 17 | + content: "\ec6a"; | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +.icon-report:before { | ||
| 21 | + content: "\e615"; | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +.icon-jia1:before { | ||
| 25 | + content: "\e7e8"; | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +.icon-jian1:before { | ||
| 29 | + content: "\e7e9"; | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +.icon-jia:before { | ||
| 33 | + content: "\e600"; | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +.icon-jian:before { | ||
| 37 | + content: "\e601"; | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +.icon-gou:before { | ||
| 41 | + content: "\e662"; | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +.icon-copy-add:before { | ||
| 45 | + content: "\e66f"; | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +.icon-cuo:before { | ||
| 49 | + content: "\e635"; | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +.icon-page-last:before { | ||
| 53 | + content: "\e607"; | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +.icon-page-first:before { | ||
| 57 | + content: "\e608"; | ||
| 58 | +} | ||
| 59 | + | ||
| 60 | +.icon-page-previous:before { | ||
| 61 | + content: "\e60a"; | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +.icon-page-next:before { | ||
| 65 | + content: "\e66c"; | ||
| 66 | +} | ||
| 67 | + | ||
| 68 | +.icon-page-last-line:before { | ||
| 69 | + content: "\e622"; | ||
| 70 | +} | ||
| 71 | + | ||
| 72 | +.icon-page-first-line:before { | ||
| 73 | + content: "\e683"; | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +.icon-compile:before { | ||
| 77 | + content: "\e634"; | ||
| 78 | +} | ||
| 79 | + | ||
| 80 | +.icon-compile-disabled:before { | ||
| 81 | + content: "\ec69"; | ||
| 82 | +} | ||
| 83 | + | ||
| 84 | +.icon-bianji:before { | ||
| 85 | + content: "\e631"; | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +.icon-shanchuhang:before { | ||
| 89 | + content: "\ec67"; | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | +.icon-tianjiahang:before { | ||
| 93 | + content: "\ec68"; | ||
| 94 | +} | ||
| 95 | + | ||
| 96 | +.icon-clear:before { | ||
| 97 | + content: "\e900"; | ||
| 98 | +} | ||
| 99 | + | ||
| 100 | +.icon-daochu:before { | ||
| 101 | + content: "\e611"; | ||
| 102 | +} | ||
| 103 | + | ||
| 16 | .icon-debugsinglestep-disabled:before { | 104 | .icon-debugsinglestep-disabled:before { |
| 17 | content: "\e605"; | 105 | content: "\e605"; |
| 18 | } | 106 | } |
| @@ -21,6 +109,14 @@ | |||
| 21 | content: "\e606"; | 109 | content: "\e606"; |
| 22 | } | 110 | } |
| 23 | 111 | ||
| 112 | +.icon-database-connected-copy:before { | ||
| 113 | + content: "\e884"; | ||
| 114 | +} | ||
| 115 | + | ||
| 116 | +.icon-database-disconnect-copy:before { | ||
| 117 | + content: "\e885"; | ||
| 118 | +} | ||
| 119 | + | ||
| 24 | .icon-database-connected:before { | 120 | .icon-database-connected:before { |
| 25 | content: "\e602"; | 121 | content: "\e602"; |
| 26 | } | 122 | } |
| @@ -5,6 +5,160 @@ | |||
| 5 | "css_prefix_text": "icon-", | 5 | "css_prefix_text": "icon-", |
| 6 | "description": "", | 6 | "description": "", |
| 7 | "glyphs": [ | 7 | "glyphs": [ |
| 8 | + { | ||
| 9 | + "icon_id": "35321985", | ||
| 10 | + "name": "文件管理-copy", | ||
| 11 | + "font_class": "report-disabled", | ||
| 12 | + "unicode": "ec6a", | ||
| 13 | + "unicode_decimal": 60522 | ||
| 14 | + }, | ||
| 15 | + { | ||
| 16 | + "icon_id": "2199033", | ||
| 17 | + "name": "文件管理", | ||
| 18 | + "font_class": "report", | ||
| 19 | + "unicode": "e615", | ||
| 20 | + "unicode_decimal": 58901 | ||
| 21 | + }, | ||
| 22 | + { | ||
| 23 | + "icon_id": "7770141", | ||
| 24 | + "name": "jia", | ||
| 25 | + "font_class": "jia1", | ||
| 26 | + "unicode": "e7e8", | ||
| 27 | + "unicode_decimal": 59368 | ||
| 28 | + }, | ||
| 29 | + { | ||
| 30 | + "icon_id": "7770142", | ||
| 31 | + "name": "jian", | ||
| 32 | + "font_class": "jian1", | ||
| 33 | + "unicode": "e7e9", | ||
| 34 | + "unicode_decimal": 59369 | ||
| 35 | + }, | ||
| 36 | + { | ||
| 37 | + "icon_id": "162780", | ||
| 38 | + "name": "加", | ||
| 39 | + "font_class": "jia", | ||
| 40 | + "unicode": "e600", | ||
| 41 | + "unicode_decimal": 58880 | ||
| 42 | + }, | ||
| 43 | + { | ||
| 44 | + "icon_id": "162781", | ||
| 45 | + "name": "减", | ||
| 46 | + "font_class": "jian", | ||
| 47 | + "unicode": "e601", | ||
| 48 | + "unicode_decimal": 58881 | ||
| 49 | + }, | ||
| 50 | + { | ||
| 51 | + "icon_id": "742038", | ||
| 52 | + "name": "gou", | ||
| 53 | + "font_class": "gou", | ||
| 54 | + "unicode": "e662", | ||
| 55 | + "unicode_decimal": 58978 | ||
| 56 | + }, | ||
| 57 | + { | ||
| 58 | + "icon_id": "6056155", | ||
| 59 | + "name": "加", | ||
| 60 | + "font_class": "copy-add", | ||
| 61 | + "unicode": "e66f", | ||
| 62 | + "unicode_decimal": 58991 | ||
| 63 | + }, | ||
| 64 | + { | ||
| 65 | + "icon_id": "11391490", | ||
| 66 | + "name": "错", | ||
| 67 | + "font_class": "cuo", | ||
| 68 | + "unicode": "e635", | ||
| 69 | + "unicode_decimal": 58933 | ||
| 70 | + }, | ||
| 71 | + { | ||
| 72 | + "icon_id": "18309139", | ||
| 73 | + "name": "page-last", | ||
| 74 | + "font_class": "page-last", | ||
| 75 | + "unicode": "e607", | ||
| 76 | + "unicode_decimal": 58887 | ||
| 77 | + }, | ||
| 78 | + { | ||
| 79 | + "icon_id": "18309143", | ||
| 80 | + "name": "page-first", | ||
| 81 | + "font_class": "page-first", | ||
| 82 | + "unicode": "e608", | ||
| 83 | + "unicode_decimal": 58888 | ||
| 84 | + }, | ||
| 85 | + { | ||
| 86 | + "icon_id": "18309144", | ||
| 87 | + "name": "page-previous", | ||
| 88 | + "font_class": "page-previous", | ||
| 89 | + "unicode": "e60a", | ||
| 90 | + "unicode_decimal": 58890 | ||
| 91 | + }, | ||
| 92 | + { | ||
| 93 | + "icon_id": "18365403", | ||
| 94 | + "name": "page-next", | ||
| 95 | + "font_class": "page-next", | ||
| 96 | + "unicode": "e66c", | ||
| 97 | + "unicode_decimal": 58988 | ||
| 98 | + }, | ||
| 99 | + { | ||
| 100 | + "icon_id": "23656305", | ||
| 101 | + "name": "page-last-line", | ||
| 102 | + "font_class": "page-last-line", | ||
| 103 | + "unicode": "e622", | ||
| 104 | + "unicode_decimal": 58914 | ||
| 105 | + }, | ||
| 106 | + { | ||
| 107 | + "icon_id": "27533500", | ||
| 108 | + "name": "page-first-line", | ||
| 109 | + "font_class": "page-first-line", | ||
| 110 | + "unicode": "e683", | ||
| 111 | + "unicode_decimal": 59011 | ||
| 112 | + }, | ||
| 113 | + { | ||
| 114 | + "icon_id": "22787828", | ||
| 115 | + "name": "编译", | ||
| 116 | + "font_class": "compile", | ||
| 117 | + "unicode": "e634", | ||
| 118 | + "unicode_decimal": 58932 | ||
| 119 | + }, | ||
| 120 | + { | ||
| 121 | + "icon_id": "34712334", | ||
| 122 | + "name": "编译-copy", | ||
| 123 | + "font_class": "compile-disabled", | ||
| 124 | + "unicode": "ec69", | ||
| 125 | + "unicode_decimal": 60521 | ||
| 126 | + }, | ||
| 127 | + { | ||
| 128 | + "icon_id": "16364316", | ||
| 129 | + "name": "编辑", | ||
| 130 | + "font_class": "bianji", | ||
| 131 | + "unicode": "e631", | ||
| 132 | + "unicode_decimal": 58929 | ||
| 133 | + }, | ||
| 134 | + { | ||
| 135 | + "icon_id": "17581737", | ||
| 136 | + "name": "删除行", | ||
| 137 | + "font_class": "shanchuhang", | ||
| 138 | + "unicode": "ec67", | ||
| 139 | + "unicode_decimal": 60519 | ||
| 140 | + }, | ||
| 141 | + { | ||
| 142 | + "icon_id": "17581740", | ||
| 143 | + "name": "添加行", | ||
| 144 | + "font_class": "tianjiahang", | ||
| 145 | + "unicode": "ec68", | ||
| 146 | + "unicode_decimal": 60520 | ||
| 147 | + }, | ||
| 148 | + { | ||
| 149 | + "icon_id": "8094805", | ||
| 150 | + "name": "clear", | ||
| 151 | + "font_class": "clear", | ||
| 152 | + "unicode": "e900", | ||
| 153 | + "unicode_decimal": 59648 | ||
| 154 | + }, | ||
| 155 | + { | ||
| 156 | + "icon_id": "4736293", | ||
| 157 | + "name": "导出", | ||
| 158 | + "font_class": "daochu", | ||
| 159 | + "unicode": "e611", | ||
| 160 | + "unicode_decimal": 58897 | ||
| 161 | + }, | ||
| 8 | { | 162 | { |
| 9 | "icon_id": "33979523", | 163 | "icon_id": "33979523", |
| 10 | "name": "debugsinglestep-disabled", | 164 | "name": "debugsinglestep-disabled", |
| @@ -19,6 +173,20 @@ | |||
| 19 | "unicode": "e606", | 173 | "unicode": "e606", |
| 20 | "unicode_decimal": 58886 | 174 | "unicode_decimal": 58886 |
| 21 | }, | 175 | }, |
| 176 | + { | ||
| 177 | + "icon_id": "34125424", | ||
| 178 | + "name": "database-connected-copy", | ||
| 179 | + "font_class": "database-connected-copy", | ||
| 180 | + "unicode": "e884", | ||
| 181 | + "unicode_decimal": 59524 | ||
| 182 | + }, | ||
| 183 | + { | ||
| 184 | + "icon_id": "34125437", | ||
| 185 | + "name": "database-disconnect-copy", | ||
| 186 | + "font_class": "database-disconnect-copy", | ||
| 187 | + "unicode": "e885", | ||
| 188 | + "unicode_decimal": 59525 | ||
| 189 | + }, | ||
| 22 | { | 190 | { |
| 23 | "icon_id": "33846229", | 191 | "icon_id": "33846229", |
| 24 | "name": "database-connected", | 192 | "name": "database-connected", |
Binary files do not support preview
Binary files do not support preview
| @@ -0,0 +1,64 @@ | |||
| 1 | +/* eslint-disable */ | ||
| 2 | +/* prettier-ignore */ | ||
| 3 | +// @ts-nocheck | ||
| 4 | +// Generated by unplugin-auto-import | ||
| 5 | +export {} | ||
| 6 | +declare global { | ||
| 7 | + const EffectScope: typeof import('vue')['EffectScope'] | ||
| 8 | + const computed: typeof import('vue')['computed'] | ||
| 9 | + const createApp: typeof import('vue')['createApp'] | ||
| 10 | + const customRef: typeof import('vue')['customRef'] | ||
| 11 | + const defineAsyncComponent: typeof import('vue')['defineAsyncComponent'] | ||
| 12 | + const defineComponent: typeof import('vue')['defineComponent'] | ||
| 13 | + const effectScope: typeof import('vue')['effectScope'] | ||
| 14 | + const getCurrentInstance: typeof import('vue')['getCurrentInstance'] | ||
| 15 | + const getCurrentScope: typeof import('vue')['getCurrentScope'] | ||
| 16 | + const h: typeof import('vue')['h'] | ||
| 17 | + const inject: typeof import('vue')['inject'] | ||
| 18 | + const isProxy: typeof import('vue')['isProxy'] | ||
| 19 | + const isReactive: typeof import('vue')['isReactive'] | ||
| 20 | + const isReadonly: typeof import('vue')['isReadonly'] | ||
| 21 | + const isRef: typeof import('vue')['isRef'] | ||
| 22 | + const markRaw: typeof import('vue')['markRaw'] | ||
| 23 | + const nextTick: typeof import('vue')['nextTick'] | ||
| 24 | + const onActivated: typeof import('vue')['onActivated'] | ||
| 25 | + const onBeforeMount: typeof import('vue')['onBeforeMount'] | ||
| 26 | + const onBeforeUnmount: typeof import('vue')['onBeforeUnmount'] | ||
| 27 | + const onBeforeUpdate: typeof import('vue')['onBeforeUpdate'] | ||
| 28 | + const onDeactivated: typeof import('vue')['onDeactivated'] | ||
| 29 | + const onErrorCaptured: typeof import('vue')['onErrorCaptured'] | ||
| 30 | + const onMounted: typeof import('vue')['onMounted'] | ||
| 31 | + const onRenderTracked: typeof import('vue')['onRenderTracked'] | ||
| 32 | + const onRenderTriggered: typeof import('vue')['onRenderTriggered'] | ||
| 33 | + const onScopeDispose: typeof import('vue')['onScopeDispose'] | ||
| 34 | + const onServerPrefetch: typeof import('vue')['onServerPrefetch'] | ||
| 35 | + const onUnmounted: typeof import('vue')['onUnmounted'] | ||
| 36 | + const onUpdated: typeof import('vue')['onUpdated'] | ||
| 37 | + const provide: typeof import('vue')['provide'] | ||
| 38 | + const reactive: typeof import('vue')['reactive'] | ||
| 39 | + const readonly: typeof import('vue')['readonly'] | ||
| 40 | + const ref: typeof import('vue')['ref'] | ||
| 41 | + const resolveComponent: typeof import('vue')['resolveComponent'] | ||
| 42 | + const shallowReactive: typeof import('vue')['shallowReactive'] | ||
| 43 | + const shallowReadonly: typeof import('vue')['shallowReadonly'] | ||
| 44 | + const shallowRef: typeof import('vue')['shallowRef'] | ||
| 45 | + const toRaw: typeof import('vue')['toRaw'] | ||
| 46 | + const toRef: typeof import('vue')['toRef'] | ||
| 47 | + const toRefs: typeof import('vue')['toRefs'] | ||
| 48 | + const toValue: typeof import('vue')['toValue'] | ||
| 49 | + const triggerRef: typeof import('vue')['triggerRef'] | ||
| 50 | + const unref: typeof import('vue')['unref'] | ||
| 51 | + const useAttrs: typeof import('vue')['useAttrs'] | ||
| 52 | + const useCssModule: typeof import('vue')['useCssModule'] | ||
| 53 | + const useCssVars: typeof import('vue')['useCssVars'] | ||
| 54 | + const useSlots: typeof import('vue')['useSlots'] | ||
| 55 | + const watch: typeof import('vue')['watch'] | ||
| 56 | + const watchEffect: typeof import('vue')['watchEffect'] | ||
| 57 | + const watchPostEffect: typeof import('vue')['watchPostEffect'] | ||
| 58 | + const watchSyncEffect: typeof import('vue')['watchSyncEffect'] | ||
| 59 | +} | ||
| 60 | +// for type re-export | ||
| 61 | +declare global { | ||
| 62 | + // @ts-ignore | ||
| 63 | + export type { Component, ComponentPublicInstance, ComputedRef, InjectionKey, PropType, Ref, VNode } from 'vue' | ||
| 64 | +} | ||
| @@ -4,7 +4,6 @@ | |||
| 4 | </template> | 4 | </template> |
| 5 | 5 | ||
| 6 | <script lang="ts" setup> | 6 | <script lang="ts" setup> |
| 7 | - import { reactive, ref, onMounted, nextTick, watch, markRaw, onUnmounted } from 'vue'; | ||
| 8 | import ace from 'ace-builds'; | 7 | import ace from 'ace-builds'; |
| 9 | import 'ace-builds/src-noconflict/theme-chrome'; | 8 | import 'ace-builds/src-noconflict/theme-chrome'; |
| 10 | import 'ace-builds/src-noconflict/theme-monokai'; | 9 | import 'ace-builds/src-noconflict/theme-monokai'; |
| @@ -183,7 +182,7 @@ | |||
| 183 | if (target.className.indexOf('ace_gutter-cell') == -1) { | 182 | if (target.className.indexOf('ace_gutter-cell') == -1) { |
| 184 | return; | 183 | return; |
| 185 | } | 184 | } |
| 186 | - if (e.clientX > 20 + target.getBoundingClientRect().left) { | 185 | + if (e.clientX > 32 + target.getBoundingClientRect().left) { |
| 187 | return; | 186 | return; |
| 188 | } | 187 | } |
| 189 | const line = e.getDocumentPosition().row; | 188 | const line = e.getDocumentPosition().row; |
| @@ -15,7 +15,6 @@ | |||
| 15 | </template> | 15 | </template> |
| 16 | 16 | ||
| 17 | <script lang="ts" setup> | 17 | <script lang="ts" setup> |
| 18 | - import { computed } from 'vue'; | ||
| 19 | import { useI18n } from 'vue-i18n'; | 18 | import { useI18n } from 'vue-i18n'; |
| 20 | 19 | ||
| 21 | const { t } = useI18n(); | 20 | const { t } = useI18n(); |
| @@ -35,22 +34,28 @@ | |||
| 35 | stop: false, | 34 | stop: false, |
| 36 | startDebug: false, | 35 | startDebug: false, |
| 37 | stopDebug: false, | 36 | stopDebug: false, |
| 38 | - breakPointStep: false, | 37 | + continueStep: false, |
| 39 | singleStep: false, | 38 | singleStep: false, |
| 40 | */ | 39 | */ |
| 41 | const emit = defineEmits<{ | 40 | const emit = defineEmits<{ |
| 41 | + (e: 'compile'): void; | ||
| 42 | (e: 'execute'): void; | 42 | (e: 'execute'): void; |
| 43 | (e: 'stopRun'): void; | 43 | (e: 'stopRun'): void; |
| 44 | (e: 'clear'): void; | 44 | (e: 'clear'): void; |
| 45 | (e: 'startDebug'): void; | 45 | (e: 'startDebug'): void; |
| 46 | (e: 'stopDebug'): void; | 46 | (e: 'stopDebug'): void; |
| 47 | - (e: 'breakPointStep'): void; | 47 | + (e: 'continueStep'): void; |
| 48 | (e: 'singleStep'): void; | 48 | (e: 'singleStep'): void; |
| 49 | (e: 'stepIn'): void; | 49 | (e: 'stepIn'): void; |
| 50 | (e: 'stepOut'): void; | 50 | (e: 'stepOut'): void; |
| 51 | (e: 'format'): void; | 51 | (e: 'format'): void; |
| 52 | + (e: 'coverageRate'): void; | ||
| 52 | }>(); | 53 | }>(); |
| 53 | 54 | ||
| 55 | + const handleCompile = () => { | ||
| 56 | + emit('compile'); | ||
| 57 | + }; | ||
| 58 | + | ||
| 54 | const handleExecute = () => { | 59 | const handleExecute = () => { |
| 55 | emit('execute'); | 60 | emit('execute'); |
| 56 | }; | 61 | }; |
| @@ -71,8 +76,8 @@ | |||
| 71 | emit('stopDebug'); | 76 | emit('stopDebug'); |
| 72 | }; | 77 | }; |
| 73 | 78 | ||
| 74 | - const handleBreakPointStep = () => { | 79 | + const handleContinueStep = () => { |
| 75 | - emit('breakPointStep'); | 80 | + emit('continueStep'); |
| 76 | }; | 81 | }; |
| 77 | 82 | ||
| 78 | const handleSingleStep = () => { | 83 | const handleSingleStep = () => { |
| @@ -88,9 +93,20 @@ | |||
| 88 | const handleFormat = () => { | 93 | const handleFormat = () => { |
| 89 | emit('format'); | 94 | emit('format'); |
| 90 | }; | 95 | }; |
| 96 | + const handleCoverageRate = () => { | ||
| 97 | + emit('coverageRate'); | ||
| 98 | + }; | ||
| 91 | 99 | ||
| 92 | const displayButton = computed(() => { | 100 | const displayButton = computed(() => { |
| 93 | return { | 101 | return { |
| 102 | + compile: { | ||
| 103 | + name: t('functionBar.compile'), | ||
| 104 | + show: ['debug'].includes(props.type), | ||
| 105 | + enabled: props.isGlobalEnable && props.status.compile, | ||
| 106 | + on: handleCompile, | ||
| 107 | + icon: 'compile', | ||
| 108 | + disabledIcon: 'compile-disabled', | ||
| 109 | + }, | ||
| 94 | execute: { | 110 | execute: { |
| 95 | name: t('functionBar.execute'), | 111 | name: t('functionBar.execute'), |
| 96 | show: ['sql', 'debug'].includes(props.type), | 112 | show: ['sql', 'debug'].includes(props.type), |
| @@ -131,11 +147,11 @@ | |||
| 131 | icon: 'debugclose', | 147 | icon: 'debugclose', |
| 132 | disabledIcon: 'debugclose-disabled', | 148 | disabledIcon: 'debugclose-disabled', |
| 133 | }, | 149 | }, |
| 134 | - breakPointStep: { | 150 | + continueStep: { |
| 135 | - name: t('functionBar.breakPointStep'), | 151 | + name: t('functionBar.continueStep'), |
| 136 | show: ['debug', 'debugChild'].includes(props.type), | 152 | show: ['debug', 'debugChild'].includes(props.type), |
| 137 | - enabled: props.isGlobalEnable && props.status.breakPointStep, | 153 | + enabled: props.isGlobalEnable && props.status.continueStep, |
| 138 | - on: handleBreakPointStep, | 154 | + on: handleContinueStep, |
| 139 | icon: 'debugstep', | 155 | icon: 'debugstep', |
| 140 | disabledIcon: 'debugstep-disabled', | 156 | disabledIcon: 'debugstep-disabled', |
| 141 | }, | 157 | }, |
| @@ -171,6 +187,14 @@ | |||
| 171 | icon: 'formatter', | 187 | icon: 'formatter', |
| 172 | disabledIcon: 'formatter-disabled', | 188 | disabledIcon: 'formatter-disabled', |
| 173 | }, | 189 | }, |
| 190 | + coverageRate: { | ||
| 191 | + name: t('functionBar.coverageRate'), | ||
| 192 | + show: ['debug'].includes(props.type), | ||
| 193 | + enabled: props.isGlobalEnable && props.status.coverageRate, | ||
| 194 | + on: handleCoverageRate, | ||
| 195 | + icon: 'report', | ||
| 196 | + disabledIcon: 'report-disabled', | ||
| 197 | + }, | ||
| 174 | }; | 198 | }; |
| 175 | }); | 199 | }); |
| 176 | </script> | 200 | </script> |
| @@ -64,7 +64,6 @@ | |||
| 64 | </el-tabs> | 64 | </el-tabs> |
| 65 | </template> | 65 | </template> |
| 66 | <script lang="ts" setup> | 66 | <script lang="ts" setup> |
| 67 | - import { computed, ref } from 'vue'; | ||
| 68 | interface messageType { | 67 | interface messageType { |
| 69 | id: number | string; | 68 | id: number | string; |
| 70 | label: string; | 69 | label: string; |
| @@ -6,7 +6,6 @@ | |||
| 6 | </template> | 6 | </template> |
| 7 | 7 | ||
| 8 | <script lang="ts"> | 8 | <script lang="ts"> |
| 9 | - import { computed } from 'vue'; | ||
| 10 | export default { | 9 | export default { |
| 11 | name: 'baseSvgIcon', | 10 | name: 'baseSvgIcon', |
| 12 | props: { | 11 | props: { |
| @@ -0,0 +1,200 @@ | |||
| 1 | +<template> | ||
| 2 | + <div class="coverage-rate-dialog"> | ||
| 3 | + <el-dialog | ||
| 4 | + v-model="visible" | ||
| 5 | + :title="title" | ||
| 6 | + :width="1100" | ||
| 7 | + align-center | ||
| 8 | + :close-on-click-modal="false" | ||
| 9 | + @opened="handleOpen" | ||
| 10 | + @closed="handleClose" | ||
| 11 | + > | ||
| 12 | + <div class="dialog_body" v-loading="loading"> | ||
| 13 | + <div class="buttons"> | ||
| 14 | + <el-button type="primary" @click="handleExport"> | ||
| 15 | + {{ $t('button.export') }} | ||
| 16 | + </el-button> | ||
| 17 | + <el-button plain @click="handleDelete">{{ $t('button.delete') }}</el-button> | ||
| 18 | + </div> | ||
| 19 | + <el-table | ||
| 20 | + ref="tableRef" | ||
| 21 | + :data="tableData" | ||
| 22 | + style="width: 100%" | ||
| 23 | + @selection-change="handleSelectionChange" | ||
| 24 | + max-height="300" | ||
| 25 | + border | ||
| 26 | + > | ||
| 27 | + <el-table-column type="selection" width="55" align="center" /> | ||
| 28 | + <el-table-column | ||
| 29 | + property="serialNumber" | ||
| 30 | + :label="t('coverageDialog.serialNumber')" | ||
| 31 | + width="100" | ||
| 32 | + align="center" | ||
| 33 | + /> | ||
| 34 | + <el-table-column | ||
| 35 | + property="totalRows" | ||
| 36 | + :label="t('coverageDialog.totalRows')" | ||
| 37 | + width="100" | ||
| 38 | + align="center" | ||
| 39 | + /> | ||
| 40 | + <el-table-column | ||
| 41 | + property="executionRows" | ||
| 42 | + :label="t('coverageDialog.executionRows')" | ||
| 43 | + width="100" | ||
| 44 | + align="center" | ||
| 45 | + /> | ||
| 46 | + <el-table-column | ||
| 47 | + property="totalCoverage" | ||
| 48 | + :label="t('coverageDialog.totalCoverage')" | ||
| 49 | + width="100" | ||
| 50 | + align="center" | ||
| 51 | + /> | ||
| 52 | + <el-table-column | ||
| 53 | + property="allLineNumber" | ||
| 54 | + :label="t('coverageDialog.allLineNumber')" | ||
| 55 | + width="170" | ||
| 56 | + align="center" | ||
| 57 | + /> | ||
| 58 | + <el-table-column | ||
| 59 | + property="executionLineNumber" | ||
| 60 | + :label="t('coverageDialog.executionLineNumber')" | ||
| 61 | + width="170" | ||
| 62 | + align="center" | ||
| 63 | + /> | ||
| 64 | + <el-table-column | ||
| 65 | + property="executionCoverage" | ||
| 66 | + :label="t('coverageDialog.executionCoverage')" | ||
| 67 | + width="120" | ||
| 68 | + align="center" | ||
| 69 | + /> | ||
| 70 | + <el-table-column | ||
| 71 | + property="inputParams" | ||
| 72 | + :label="t('coverageDialog.inputParams')" | ||
| 73 | + width="120" | ||
| 74 | + align="center" | ||
| 75 | + /> | ||
| 76 | + <el-table-column | ||
| 77 | + property="updateTime" | ||
| 78 | + :label="t('coverageDialog.updateTime')" | ||
| 79 | + width="170" | ||
| 80 | + align="center" | ||
| 81 | + /> | ||
| 82 | + </el-table> | ||
| 83 | + </div> | ||
| 84 | + </el-dialog> | ||
| 85 | + </div> | ||
| 86 | +</template> | ||
| 87 | + | ||
| 88 | +<script lang="ts" setup> | ||
| 89 | + import { ElMessage, ElMessageBox, ElTable } from 'element-plus'; | ||
| 90 | + import { useI18n } from 'vue-i18n'; | ||
| 91 | + import { toSpacePascalCase, downLoadMyBlobType } from '@/utils'; | ||
| 92 | + import { getCoverageRateList, deleteCoverageRate, exportCoverageRate } from '@/api/functionSP'; | ||
| 93 | + const props = withDefaults( | ||
| 94 | + defineProps<{ | ||
| 95 | + modelValue: boolean; | ||
| 96 | + connectionName: string; | ||
| 97 | + uuid: string; | ||
| 98 | + oid: string; | ||
| 99 | + fileName: string; | ||
| 100 | + }>(), | ||
| 101 | + { | ||
| 102 | + modelValue: false, | ||
| 103 | + connectionName: '', | ||
| 104 | + uuid: '', | ||
| 105 | + oid: '', | ||
| 106 | + fileName: '', | ||
| 107 | + }, | ||
| 108 | + ); | ||
| 109 | + const myEmit = defineEmits<{ | ||
| 110 | + (event: 'update:modelValue', text: boolean): void; | ||
| 111 | + }>(); | ||
| 112 | + interface CoverageList { | ||
| 113 | + cid: number; | ||
| 114 | + serialNumber: number; | ||
| 115 | + totalRows: number; | ||
| 116 | + executionRows: number; | ||
| 117 | + totalCoverage: string; | ||
| 118 | + allLineNumber: string; | ||
| 119 | + executionLineNumber: string; | ||
| 120 | + executionCoverage: string; | ||
| 121 | + inputParams: string; | ||
| 122 | + updateTime: string; | ||
| 123 | + } | ||
| 124 | + const { t } = useI18n(); | ||
| 125 | + const loading = ref(false); | ||
| 126 | + const tableData = ref<CoverageList[]>([]); | ||
| 127 | + const tableRef = ref<InstanceType<typeof ElTable>>(); | ||
| 128 | + const multipleSelection = ref<CoverageList[]>([]); | ||
| 129 | + const visible = computed({ | ||
| 130 | + get: () => props.modelValue, | ||
| 131 | + set: (val) => myEmit('update:modelValue', val), | ||
| 132 | + }); | ||
| 133 | + const title = computed(() => { | ||
| 134 | + return `${toSpacePascalCase(t('functionBar.coverageRate'))} - ${props.fileName}@${ | ||
| 135 | + props.connectionName | ||
| 136 | + }`; | ||
| 137 | + }); | ||
| 138 | + const handleSelectionChange = (val) => { | ||
| 139 | + multipleSelection.value = val; | ||
| 140 | + }; | ||
| 141 | + const getList = async () => { | ||
| 142 | + loading.value = true; | ||
| 143 | + try { | ||
| 144 | + const res = (await getCoverageRateList({ | ||
| 145 | + uuid: props.uuid, | ||
| 146 | + oid: props.oid, | ||
| 147 | + })) as unknown as CoverageList[]; | ||
| 148 | + tableData.value = res; | ||
| 149 | + } finally { | ||
| 150 | + loading.value = false; | ||
| 151 | + } | ||
| 152 | + }; | ||
| 153 | + const handleOpen = async () => { | ||
| 154 | + getList(); | ||
| 155 | + }; | ||
| 156 | + const handleClose = () => { | ||
| 157 | + visible.value = false; | ||
| 158 | + resetForm(); | ||
| 159 | + }; | ||
| 160 | + const resetForm = () => { | ||
| 161 | + tableData.value = []; | ||
| 162 | + tableRef.value!.clearSelection(); | ||
| 163 | + }; | ||
| 164 | + const noChooseData = () => { | ||
| 165 | + ElMessage.warning(t('message.selectedData')); | ||
| 166 | + }; | ||
| 167 | + const handleExport = async () => { | ||
| 168 | + if (!multipleSelection.value.length) return noChooseData(); | ||
| 169 | + const res = await exportCoverageRate({ | ||
| 170 | + uuid: props.uuid, | ||
| 171 | + oid: props.oid, | ||
| 172 | + cidList: multipleSelection.value.map((item) => item.cid), | ||
| 173 | + }); | ||
| 174 | + downLoadMyBlobType(res.name, res.data); | ||
| 175 | + }; | ||
| 176 | + const handleDelete = async () => { | ||
| 177 | + if (!multipleSelection.value.length) return noChooseData(); | ||
| 178 | + ElMessageBox.confirm(t('coverageDialog.deleteMsg')).then(async () => { | ||
| 179 | + await deleteCoverageRate({ | ||
| 180 | + uuid: props.uuid, | ||
| 181 | + cidList: multipleSelection.value.map((item) => item.cid), | ||
| 182 | + }); | ||
| 183 | + ElMessage.success(t('message.deleteSuccess')); | ||
| 184 | + getList(); | ||
| 185 | + }); | ||
| 186 | + }; | ||
| 187 | +</script> | ||
| 188 | + | ||
| 189 | +<style lang="scss" scoped> | ||
| 190 | + .coverage-rate-dialog { | ||
| 191 | + :deep(.el-dialog__body) { | ||
| 192 | + padding-top: 5px; | ||
| 193 | + padding-bottom: 25px; | ||
| 194 | + } | ||
| 195 | + } | ||
| 196 | + .buttons { | ||
| 197 | + text-align: right; | ||
| 198 | + margin-bottom: 10px; | ||
| 199 | + } | ||
| 200 | +</style> | ||
| @@ -137,7 +137,6 @@ | |||
| 137 | </div> | 137 | </div> |
| 138 | </template> | 138 | </template> |
| 139 | <script lang="ts" setup> | 139 | <script lang="ts" setup> |
| 140 | - import { computed, ref, watch } from 'vue'; | ||
| 141 | import { ElTable } from 'element-plus'; | 140 | import { ElTable } from 'element-plus'; |
| 142 | import { Search } from '@element-plus/icons-vue'; | 141 | import { Search } from '@element-plus/icons-vue'; |
| 143 | 142 | ||
| @@ -47,8 +47,6 @@ | |||
| 47 | </template> | 47 | </template> |
| 48 | 48 | ||
| 49 | <script lang="ts" setup> | 49 | <script lang="ts" setup> |
| 50 | - import { computed, ref, watch } from 'vue'; | ||
| 51 | - | ||
| 52 | interface Data { | 50 | interface Data { |
| 53 | name: string; | 51 | name: string; |
| 54 | type: string; | 52 | type: string; |
| @@ -7,16 +7,18 @@ | |||
| 7 | :status="sqlData.barStatus" | 7 | :status="sqlData.barStatus" |
| 8 | :editorReadOnly="sqlData.readOnly" | 8 | :editorReadOnly="sqlData.readOnly" |
| 9 | :isGlobalEnable="isGlobalEnable" | 9 | :isGlobalEnable="isGlobalEnable" |
| 10 | - @execute="handleExecute" | 10 | + @compile="handleCompile" |
| 11 | + @execute="handleExecute(false)" | ||
| 11 | @stopRun="handleStop" | 12 | @stopRun="handleStop" |
| 12 | @clear="handleClear" | 13 | @clear="handleClear" |
| 13 | @startDebug="handleStartDebug" | 14 | @startDebug="handleStartDebug" |
| 14 | @stopDebug="handleStopDebug" | 15 | @stopDebug="handleStopDebug" |
| 15 | - @breakPointStep="handleBreakPointStep" | 16 | + @continueStep="handleContinueStep" |
| 16 | @singleStep="handleSingleStep" | 17 | @singleStep="handleSingleStep" |
| 17 | @stepIn="handleStepIn" | 18 | @stepIn="handleStepIn" |
| 18 | @stepOut="handleStepOut(false)" | 19 | @stepOut="handleStepOut(false)" |
| 19 | @format="handleFormat" | 20 | @format="handleFormat" |
| 21 | + @coverageRate="showCoverageRateDialog = true" | ||
| 20 | /> | 22 | /> |
| 21 | <div class="monaco-wrapper" ref="monacoWrapper"> | 23 | <div class="monaco-wrapper" ref="monacoWrapper"> |
| 22 | <AceEditor | 24 | <AceEditor |
| @@ -50,6 +52,13 @@ | |||
| 50 | @confirm="paramsConfirm" | 52 | @confirm="paramsConfirm" |
| 51 | @cancel="paramsCancel" | 53 | @cancel="paramsCancel" |
| 52 | /> | 54 | /> |
| 55 | + <CoverageRateDialog | ||
| 56 | + v-model="showCoverageRateDialog" | ||
| 57 | + :connectionName="ws.connectionName" | ||
| 58 | + :uuid="ws.uuid" | ||
| 59 | + :oid="ws.oid" | ||
| 60 | + :fileName="ws.fileName" | ||
| 61 | + /> | ||
| 53 | </div> | 62 | </div> |
| 54 | </template> | 63 | </template> |
| 55 | 64 | ||
| @@ -59,8 +68,8 @@ | |||
| 59 | import DebugPane from './DebugPane.vue'; | 68 | import DebugPane from './DebugPane.vue'; |
| 60 | import ResultTabs from '@/components/ResultTabs.vue'; | 69 | import ResultTabs from '@/components/ResultTabs.vue'; |
| 61 | import EnterParamsDialog from './EnterParamsDialog.vue'; | 70 | import EnterParamsDialog from './EnterParamsDialog.vue'; |
| 62 | - import { ElMessageBox } from 'element-plus'; | 71 | + import CoverageRateDialog from './CoverageRateDialog.vue'; |
| 63 | - import { computed, onActivated, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'; | 72 | + import { ElMessage, ElMessageBox } from 'element-plus'; |
| 64 | import createTemplate from './createTemplate'; | 73 | import createTemplate from './createTemplate'; |
| 65 | import { useRoute, useRouter } from 'vue-router'; | 74 | import { useRoute, useRouter } from 'vue-router'; |
| 66 | import WebSocketClass from '@/utils/websocket'; | 75 | import WebSocketClass from '@/utils/websocket'; |
| @@ -69,7 +78,7 @@ | |||
| 69 | import { useUserStore } from '@/store/modules/user'; | 78 | import { useUserStore } from '@/store/modules/user'; |
| 70 | import { useTagsViewStore } from '@/store/modules/tagsView'; | 79 | import { useTagsViewStore } from '@/store/modules/tagsView'; |
| 71 | import { useI18n } from 'vue-i18n'; | 80 | import { useI18n } from 'vue-i18n'; |
| 72 | - import EventBus, { EventTypeName } from '@/utils/event-bus'; | 81 | + import { changeRunningTagStatus } from '@/hooks/tagRunning'; |
| 73 | 82 | ||
| 74 | const route = useRoute(); | 83 | const route = useRoute(); |
| 75 | const router = useRouter(); | 84 | const router = useRouter(); |
| @@ -94,16 +103,18 @@ | |||
| 94 | clear: true, | 103 | clear: true, |
| 95 | }, | 104 | }, |
| 96 | debug: { | 105 | debug: { |
| 97 | - execute: true, | 106 | + compile: true, |
| 107 | + execute: false, | ||
| 98 | startDebug: false, | 108 | startDebug: false, |
| 99 | stopDebug: false, | 109 | stopDebug: false, |
| 100 | - breakPointStep: false, | 110 | + continueStep: false, |
| 101 | singleStep: false, | 111 | singleStep: false, |
| 102 | stepIn: false, | 112 | stepIn: false, |
| 103 | stepOut: false, | 113 | stepOut: false, |
| 114 | + coverageRate: false, | ||
| 104 | }, | 115 | }, |
| 105 | debugChild: { | 116 | debugChild: { |
| 106 | - breakPointStep: true, | 117 | + continueStep: true, |
| 107 | singleStep: true, | 118 | singleStep: true, |
| 108 | stepIn: true, | 119 | stepIn: true, |
| 109 | stepOut: true, | 120 | stepOut: true, |
| @@ -131,37 +142,43 @@ | |||
| 131 | name: '', | 142 | name: '', |
| 132 | webUser: '', | 143 | webUser: '', |
| 133 | rootId: '', | 144 | rootId: '', |
| 134 | - parentId: '', | 145 | + parentTagId: '', |
| 135 | connectionName: '', | 146 | connectionName: '', |
| 136 | uuid: '', | 147 | uuid: '', |
| 137 | sessionId: '', | 148 | sessionId: '', |
| 138 | dbname: '', | 149 | dbname: '', |
| 139 | schema: '', | 150 | schema: '', |
| 151 | + fileName: '', | ||
| 152 | + oid: '', | ||
| 140 | instance: null, | 153 | instance: null, |
| 154 | + parentWindowName: '', | ||
| 141 | rootWindowName: '', | 155 | rootWindowName: '', |
| 142 | }); | 156 | }); |
| 143 | const tagId = TagsViewStore.getViewByRoute(route)?.id; | 157 | const tagId = TagsViewStore.getViewByRoute(route)?.id; |
| 144 | const commonWsParams = computed(() => { | 158 | const commonWsParams = computed(() => { |
| 145 | return { | 159 | return { |
| 146 | - webUser: ws.webUser, | 160 | + rootWindowName: ws.rootWindowName, |
| 147 | - uuid: ws.uuid, | ||
| 148 | windowName: ws.sessionId, | 161 | windowName: ws.sessionId, |
| 162 | + uuid: ws.uuid, | ||
| 163 | + oid: ws.oid, | ||
| 149 | }; | 164 | }; |
| 150 | }); | 165 | }); |
| 151 | const isGlobalEnable = computed(() => { | 166 | const isGlobalEnable = computed(() => { |
| 152 | return AppStore.connectedDatabase.findIndex((item) => item.uuid == ws.uuid) > -1; | 167 | return AppStore.connectedDatabase.findIndex((item) => item.uuid == ws.uuid) > -1; |
| 153 | }); | 168 | }); |
| 154 | - const isStepIntoChild = computed(() => { | ||
| 155 | - return TagsViewStore.getViewByRoute(route)?.isStepIntoChild; | ||
| 156 | - }); | ||
| 157 | const loading = ref(null); | 169 | const loading = ref(null); |
| 158 | const refreshCounter = reactive({ | 170 | const refreshCounter = reactive({ |
| 159 | counter: null, | 171 | counter: null, |
| 160 | times: 0, | 172 | times: 0, |
| 161 | }); | 173 | }); |
| 162 | const isSaving = ref(false); | 174 | const isSaving = ref(false); |
| 163 | - const saveFileTitle = ref(''); | 175 | + const saveFile = reactive({ |
| 176 | + name: '', | ||
| 177 | + oid: '', | ||
| 178 | + }); | ||
| 164 | const alreadyCloseWindow = ref(false); | 179 | const alreadyCloseWindow = ref(false); |
| 180 | + const showCoverageRateDialog = ref(false); | ||
| 181 | + const preInputParams = ref([]); | ||
| 165 | 182 | ||
| 166 | // set editor height | 183 | // set editor height |
| 167 | watch( | 184 | watch( |
| @@ -211,11 +228,12 @@ | |||
| 211 | data: [], | 228 | data: [], |
| 212 | }); | 229 | }); |
| 213 | const paramsConfirm = () => { | 230 | const paramsConfirm = () => { |
| 231 | + preInputParams.value = enterParams.data.map((item) => ({ [item.type]: item.value })); | ||
| 214 | ws.instance.send({ | 232 | ws.instance.send({ |
| 215 | operation: 'inputParam', | 233 | operation: 'inputParam', |
| 216 | ...commonWsParams.value, | 234 | ...commonWsParams.value, |
| 217 | sql: editorRef.value.getValue(), | 235 | sql: editorRef.value.getValue(), |
| 218 | - inputParams: enterParams.data.map((item) => ({ [item.type]: item.value })), | 236 | + inputParams: preInputParams.value, |
| 219 | breakPoints: editorRef.value.getAllLineDecorations(), | 237 | breakPoints: editorRef.value.getAllLineDecorations(), |
| 220 | }); | 238 | }); |
| 221 | getButtonStatus(); | 239 | getButtonStatus(); |
| @@ -279,15 +297,10 @@ | |||
| 279 | type: string; | 297 | type: string; |
| 280 | } | 298 | } |
| 281 | const onWebSocketMessage = (data: string) => { | 299 | const onWebSocketMessage = (data: string) => { |
| 282 | - if (!isGlobalEnable.value) return; | 300 | + if (!isGlobalEnable.value) return loading.value?.close(); |
| 283 | let res: Message = JSON.parse(data); | 301 | let res: Message = JSON.parse(data); |
| 284 | if (res.code == '200') { | 302 | if (res.code == '200') { |
| 285 | - if ( | 303 | + if (['debug', 'debugChild'].includes(props.editorType) && res.type != 'operateStatus') { |
| 286 | - props.editorType == 'debug' && | ||
| 287 | - res.type != 'operateStatus' && | ||
| 288 | - res.type != 'newWindow' && | ||
| 289 | - !isStepIntoChild.value | ||
| 290 | - ) { | ||
| 291 | getButtonStatus(); | 304 | getButtonStatus(); |
| 292 | } | 305 | } |
| 293 | const result = res.data?.result; | 306 | const result = res.data?.result; |
| @@ -321,12 +334,30 @@ | |||
| 321 | } else { | 334 | } else { |
| 322 | sqlData.barStatus = result; | 335 | sqlData.barStatus = result; |
| 323 | sqlData.readOnly = !result?.execute; | 336 | sqlData.readOnly = !result?.execute; |
| 337 | + changeRunningTagStatus(tagId, !result?.execute); | ||
| 324 | } | 338 | } |
| 325 | // can use 'startDebug' button = not isDebugging | 339 | // can use 'startDebug' button = not isDebugging |
| 326 | if (props.editorType == 'debug') { | 340 | if (props.editorType == 'debug') { |
| 327 | debug.isDebugging = !(result.startDebug || result.execute); | 341 | debug.isDebugging = !(result.startDebug || result.execute); |
| 328 | } | 342 | } |
| 329 | } | 343 | } |
| 344 | + if (res.type == 'message') { | ||
| 345 | + res.msg == 'success' && ElMessage.success(result); | ||
| 346 | + } | ||
| 347 | + if (res.type == 'confirm') { | ||
| 348 | + ElMessageBox.confirm(result).then(() => { | ||
| 349 | + handleExecute(true); | ||
| 350 | + }); | ||
| 351 | + } | ||
| 352 | + if (res.type == 'createCoverageRate') { | ||
| 353 | + ElMessageBox.confirm(result) | ||
| 354 | + .then(() => { | ||
| 355 | + handleCreateCoverageRate(true); | ||
| 356 | + }) | ||
| 357 | + .catch(() => { | ||
| 358 | + handleCreateCoverageRate(false); | ||
| 359 | + }); | ||
| 360 | + } | ||
| 330 | if (res.type == 'paramWindow') { | 361 | if (res.type == 'paramWindow') { |
| 331 | const arr = result.map((item) => { | 362 | const arr = result.map((item) => { |
| 332 | return { | 363 | return { |
| @@ -365,18 +396,19 @@ | |||
| 365 | clearInterval(refreshCounter.counter); | 396 | clearInterval(refreshCounter.counter); |
| 366 | loading.value.close(); | 397 | loading.value.close(); |
| 367 | TagsViewStore.delCurrentView(route); | 398 | TagsViewStore.delCurrentView(route); |
| 368 | - const title = saveFileTitle.value; | 399 | + const title = saveFile.name; |
| 369 | router.push({ | 400 | router.push({ |
| 370 | // eslint-disable-next-line prettier/prettier | 401 | // eslint-disable-next-line prettier/prettier |
| 371 | path: `/debug/${encodeURIComponent(route.query.connectInfoId as string)}_${route.query.schema}_fun_pro_${title}`, | 402 | path: `/debug/${encodeURIComponent(route.query.connectInfoId as string)}_${route.query.schema}_fun_pro_${title}`, |
| 372 | query: { | 403 | query: { |
| 373 | title: `${title}@${route.query.connectInfoName}`, | 404 | title: `${title}@${route.query.connectInfoName}`, |
| 374 | - funcname: title, | 405 | + fileName: title, |
| 375 | dbname: route.query.dbname, | 406 | dbname: route.query.dbname, |
| 376 | connectInfoName: route.query.connectInfoName, | 407 | connectInfoName: route.query.connectInfoName, |
| 377 | terminalNum: TagsViewStore.maxTerminalNum + 1, | 408 | terminalNum: TagsViewStore.maxTerminalNum + 1, |
| 378 | schema: route.query.schema, | 409 | schema: route.query.schema, |
| 379 | uuid: ws.uuid, | 410 | uuid: ws.uuid, |
| 411 | + oid: saveFile.oid, | ||
| 380 | time: Date.now(), | 412 | time: Date.now(), |
| 381 | }, | 413 | }, |
| 382 | }); | 414 | }); |
| @@ -393,57 +425,68 @@ | |||
| 393 | }); | 425 | }); |
| 394 | } | 426 | } |
| 395 | } | 427 | } |
| 396 | - if (res.type == 'refresh') { | 428 | + if (res.type == 'newFile') { |
| 397 | - if (['createTerminal', 'createDebug'].includes(route.name as string)) { | 429 | + saveFile.name = result.name; |
| 398 | - saveFileTitle.value = res.data.result; | 430 | + saveFile.oid = result.oid; |
| 399 | - if (isSaving.value) { | 431 | + const title = result.name; |
| 400 | - loading.value = loadingInstance(); | 432 | + const oid = result.oid; |
| 401 | - refreshCounter.counter = setInterval(() => { | 433 | + TagsViewStore.delViewById(tagId); |
| 402 | - refreshCounter.times++; | 434 | + router.push({ |
| 403 | - if (refreshCounter.times > 6) { | 435 | + // eslint-disable-next-line prettier/prettier |
| 404 | - clearInterval(refreshCounter.counter); | 436 | + path: `/debug/${encodeURIComponent(route.query.connectInfoId as string)}_${route.query.schema}_fun_pro_${oid}`, |
| 405 | - loading.value.close(); | 437 | + query: { |
| 406 | - isSaving.value = false; | 438 | + title: `${title}@${route.query.connectInfoName}`, |
| 407 | - EventBus.notify(EventTypeName.CLOSE_SELECTED_TAB, route); | 439 | + fileName: title, |
| 408 | - } else { | 440 | + dbname: route.query.dbname, |
| 409 | - ws.instance.send({ | 441 | + connectInfoName: route.query.connectInfoName, |
| 410 | - operation: 'funcProcedure', | 442 | + terminalNum: TagsViewStore.maxTerminalNum + 1, |
| 411 | - fullName: saveFileTitle.value, | 443 | + schema: route.query.schema, |
| 412 | - schema: route.query.schema, | 444 | + uuid: ws.uuid, |
| 413 | - ...commonWsParams.value, | 445 | + oid, |
| 414 | - }); | 446 | + time: Date.now(), |
| 415 | - } | 447 | + }, |
| 416 | - }, 6000); | 448 | + }); |
| 417 | - } | ||
| 418 | - } | ||
| 419 | } | 449 | } |
| 420 | if (res.type == 'variableHighLight') { | 450 | if (res.type == 'variableHighLight') { |
| 421 | debug.variableHighLight = result; | 451 | debug.variableHighLight = result; |
| 422 | } | 452 | } |
| 423 | if (res.type == 'newWindow') { | 453 | if (res.type == 'newWindow') { |
| 424 | - setStepIntoChildStatus(tagId, true); | 454 | + const { name, oid } = result; |
| 425 | - const path = encodeURIComponent(route.query.dbname + '_' + result); | 455 | + const path = `/debugChild/${encodeURIComponent(route.query.dbname + '_' + oid)}`; |
| 426 | - router.push({ | 456 | + const visitedViews = TagsViewStore.visitedViews; |
| 427 | - path: `/debugChild/${path}`, | 457 | + const eventView = visitedViews.find((item) => item.path == path); |
| 428 | - query: { | 458 | + if (eventView) { |
| 429 | - title: `${result}@${ws.connectionName}`, | 459 | + router.push(eventView.fullPath); |
| 430 | - funcname: result, | 460 | + } else { |
| 431 | - dbname: route.query.dbname, | 461 | + router.push({ |
| 432 | - connectInfoName: ws.connectionName, | 462 | + path, |
| 433 | - uuid: ws.uuid, | 463 | + query: { |
| 434 | - schema: route.query.schema, | 464 | + title: `${name}@${ws.connectionName}`, |
| 435 | - parentTagId: TagsViewStore.getViewByRoute(route)?.id, | 465 | + fileName: name, |
| 436 | - rootTagId: | 466 | + dbname: route.query.dbname, |
| 437 | - route.name == 'debug' | 467 | + connectInfoName: ws.connectionName, |
| 438 | - ? TagsViewStore.getViewByRoute(route)?.id | 468 | + uuid: ws.uuid, |
| 439 | - : route.query.rootTagId, | 469 | + schema: route.query.schema, |
| 440 | - rootWindowName: ws.sessionId, | 470 | + parentTagId: tagId, |
| 441 | - time: Date.now(), | 471 | + rootTagId: route.name == 'debug' ? tagId : route.query.rootTagId, |
| 442 | - }, | 472 | + parentWindowName: ws.sessionId, |
| 443 | - }); | 473 | + rootWindowName: ws.rootWindowName, |
| 474 | + oid, | ||
| 475 | + time: Date.now(), | ||
| 476 | + }, | ||
| 477 | + }); | ||
| 478 | + } | ||
| 479 | + } | ||
| 480 | + if (res.type == 'switchWindow') { | ||
| 481 | + const targetView = TagsViewStore.getViewByOid(result); | ||
| 482 | + if (targetView?.fullPath) { | ||
| 483 | + loading.value = loadingInstance(); | ||
| 484 | + router.push(targetView.fullPath); | ||
| 485 | + loading.value.close(); | ||
| 486 | + } | ||
| 444 | } | 487 | } |
| 445 | if (res.type == 'closeWindow') { | 488 | if (res.type == 'closeWindow') { |
| 446 | - const parentView = TagsViewStore.getViewById(route.query.parentTagId); | 489 | + const parentView = TagsViewStore.getViewById(ws.parentTagId); |
| 447 | if (parentView?.fullPath) { | 490 | if (parentView?.fullPath) { |
| 448 | alreadyCloseWindow.value = true; | 491 | alreadyCloseWindow.value = true; |
| 449 | loading.value = loadingInstance(); | 492 | loading.value = loadingInstance(); |
| @@ -462,10 +505,12 @@ | |||
| 462 | }; | 505 | }; |
| 463 | 506 | ||
| 464 | const getButtonStatus = () => { | 507 | const getButtonStatus = () => { |
| 465 | - ws.instance.send({ | 508 | + if (route.name != 'createDebug') { |
| 466 | - operation: 'operateStatus', | 509 | + ws.instance.send({ |
| 467 | - ...commonWsParams.value, | 510 | + operation: 'operateStatus', |
| 468 | - }); | 511 | + ...commonWsParams.value, |
| 512 | + }); | ||
| 513 | + } | ||
| 469 | }; | 514 | }; |
| 470 | 515 | ||
| 471 | const changeServerLanguage = (language) => { | 516 | const changeServerLanguage = (language) => { |
| @@ -475,7 +520,19 @@ | |||
| 475 | }); | 520 | }); |
| 476 | }; | 521 | }; |
| 477 | 522 | ||
| 478 | - const handleExecute = () => { | 523 | + const handleCompile = () => { |
| 524 | + tabList.value = []; | ||
| 525 | + tabValue.value = 'home'; | ||
| 526 | + ws.instance.send({ | ||
| 527 | + operation: 'compile', | ||
| 528 | + ...commonWsParams.value, | ||
| 529 | + sql: editorRef.value.getValue(), | ||
| 530 | + schema: ws.schema, | ||
| 531 | + }); | ||
| 532 | + getButtonStatus(); | ||
| 533 | + }; | ||
| 534 | + | ||
| 535 | + const handleExecute = (isContinue) => { | ||
| 479 | tabList.value = []; | 536 | tabList.value = []; |
| 480 | tabValue.value = 'home'; | 537 | tabValue.value = 'home'; |
| 481 | if (props.editorType == 'sql') { | 538 | if (props.editorType == 'sql') { |
| @@ -487,12 +544,11 @@ | |||
| 487 | }); | 544 | }); |
| 488 | } | 545 | } |
| 489 | if (props.editorType == 'debug') { | 546 | if (props.editorType == 'debug') { |
| 490 | - isSaving.value = true; | ||
| 491 | ws.instance.send({ | 547 | ws.instance.send({ |
| 492 | operation: 'execute', | 548 | operation: 'execute', |
| 493 | ...commonWsParams.value, | 549 | ...commonWsParams.value, |
| 494 | sql: editorRef.value.getValue(), | 550 | sql: editorRef.value.getValue(), |
| 495 | - isDebug: false, | 551 | + isContinue, |
| 496 | }); | 552 | }); |
| 497 | getButtonStatus(); | 553 | getButtonStatus(); |
| 498 | } | 554 | } |
| @@ -519,8 +575,6 @@ | |||
| 519 | operation: 'startDebug', | 575 | operation: 'startDebug', |
| 520 | ...commonWsParams.value, | 576 | ...commonWsParams.value, |
| 521 | sql: editorRef.value.getValue(), | 577 | sql: editorRef.value.getValue(), |
| 522 | - breakPoints: editorRef.value.getAllLineDecorations(), | ||
| 523 | - isDebug: true, | ||
| 524 | }); | 578 | }); |
| 525 | }; | 579 | }; |
| 526 | 580 | ||
| @@ -537,11 +591,11 @@ | |||
| 537 | } | 591 | } |
| 538 | }; | 592 | }; |
| 539 | 593 | ||
| 540 | - const handleBreakPointStep = () => { | 594 | + const handleContinueStep = () => { |
| 541 | ws.instance.send({ | 595 | ws.instance.send({ |
| 542 | - operation: 'breakPointStep', | 596 | + operation: 'continueStep', |
| 543 | ...commonWsParams.value, | 597 | ...commonWsParams.value, |
| 544 | - oldWindowName: ws.rootWindowName, | 598 | + oldWindowName: ws.parentWindowName, |
| 545 | sql: editorRef.value.getValue(), | 599 | sql: editorRef.value.getValue(), |
| 546 | }); | 600 | }); |
| 547 | }; | 601 | }; |
| @@ -550,7 +604,7 @@ | |||
| 550 | ws.instance.send({ | 604 | ws.instance.send({ |
| 551 | operation: 'singleStep', | 605 | operation: 'singleStep', |
| 552 | ...commonWsParams.value, | 606 | ...commonWsParams.value, |
| 553 | - oldWindowName: ws.rootWindowName, | 607 | + oldWindowName: ws.parentWindowName, |
| 554 | sql: editorRef.value.getValue(), | 608 | sql: editorRef.value.getValue(), |
| 555 | }); | 609 | }); |
| 556 | }; | 610 | }; |
| @@ -559,7 +613,7 @@ | |||
| 559 | ws.instance.send({ | 613 | ws.instance.send({ |
| 560 | operation: 'stepIn', | 614 | operation: 'stepIn', |
| 561 | ...commonWsParams.value, | 615 | ...commonWsParams.value, |
| 562 | - oldWindowName: ws.rootWindowName, | 616 | + oldWindowName: ws.parentWindowName, |
| 563 | sql: editorRef.value.getValue(), | 617 | sql: editorRef.value.getValue(), |
| 564 | }); | 618 | }); |
| 565 | }; | 619 | }; |
| @@ -568,7 +622,7 @@ | |||
| 568 | ws.instance.send({ | 622 | ws.instance.send({ |
| 569 | operation: 'stepOut', | 623 | operation: 'stepOut', |
| 570 | ...commonWsParams.value, | 624 | ...commonWsParams.value, |
| 571 | - oldWindowName: ws.rootWindowName, | 625 | + oldWindowName: ws.parentWindowName, |
| 572 | isCloseWindow: isUnMount, | 626 | isCloseWindow: isUnMount, |
| 573 | sql: editorRef.value.getValue(), | 627 | sql: editorRef.value.getValue(), |
| 574 | }); | 628 | }); |
| @@ -589,34 +643,19 @@ | |||
| 589 | operation: operation, | 643 | operation: operation, |
| 590 | ...commonWsParams.value, | 644 | ...commonWsParams.value, |
| 591 | line: line + 1, | 645 | line: line + 1, |
| 592 | - oldWindowName: ws.rootWindowName, | 646 | + oldWindowName: ws.parentWindowName, |
| 593 | }); | 647 | }); |
| 594 | }; | 648 | }; |
| 595 | 649 | ||
| 596 | - const getStepIntoChildStatus = (tag) => { | 650 | + const handleCreateCoverageRate = (status) => { |
| 597 | - return ['number', 'string'].includes(typeof tag) | 651 | + ws.instance.send({ |
| 598 | - ? !!TagsViewStore.getViewById(tag)?.isStepIntoChild | 652 | + operation: 'createCoverageRate', |
| 599 | - : !!TagsViewStore.getViewByRoute(tag)?.isStepIntoChild; | 653 | + ...commonWsParams.value, |
| 654 | + sql: editorRef.value.getValue(), | ||
| 655 | + inputParams: preInputParams.value, | ||
| 656 | + isCoverage: status, | ||
| 657 | + }); | ||
| 600 | }; | 658 | }; |
| 601 | - const setStepIntoChildStatus = (tag, status) => { | ||
| 602 | - ['number', 'string'].includes(typeof tag) | ||
| 603 | - ? TagsViewStore.updateStepIntoChildStatusById(tag, status) | ||
| 604 | - : TagsViewStore.updateStepIntoChildStatusByRoute(tag, status); | ||
| 605 | - if (['debug', 'debugChild'].includes(props.editorType)) { | ||
| 606 | - Object.assign(sqlData.barStatus, { | ||
| 607 | - breakPointStep: !status, | ||
| 608 | - singleStep: !status, | ||
| 609 | - stepIn: !status, | ||
| 610 | - stepOut: !status, | ||
| 611 | - }); | ||
| 612 | - } | ||
| 613 | - }; | ||
| 614 | - onActivated(() => { | ||
| 615 | - if (['debug'].includes(route.name as string)) { | ||
| 616 | - const status = getStepIntoChildStatus(tagId); | ||
| 617 | - status ? setStepIntoChildStatus(tagId, true) : getButtonStatus(); | ||
| 618 | - } | ||
| 619 | - }); | ||
| 620 | 659 | ||
| 621 | // is create? and return default tempalate | 660 | // is create? and return default tempalate |
| 622 | onMounted(async () => { | 661 | onMounted(async () => { |
| @@ -629,18 +668,21 @@ | |||
| 629 | debug.isDebugging = true; | 668 | debug.isDebugging = true; |
| 630 | sqlData.readOnly = true; | 669 | sqlData.readOnly = true; |
| 631 | } | 670 | } |
| 632 | - | 671 | + const sessionId = route.query.connectInfoName + '_' + route.query.time; |
| 633 | Object.assign(ws, { | 672 | Object.assign(ws, { |
| 634 | name: route.query.connectInfoName, | 673 | name: route.query.connectInfoName, |
| 635 | webUser: UserStore.userId, | 674 | webUser: UserStore.userId, |
| 636 | rootId: route.query.rootId, | 675 | rootId: route.query.rootId, |
| 637 | - parentId: route.query.parentTagId, | 676 | + parentTagId: route.query.parentTagId, |
| 638 | connectionName: route.query.connectInfoName, | 677 | connectionName: route.query.connectInfoName, |
| 639 | uuid: route.query.uuid, | 678 | uuid: route.query.uuid, |
| 640 | - sessionId: route.query.connectInfoName + '_' + route.query.time, | 679 | + sessionId, |
| 641 | dbname: route.query.dbname, | 680 | dbname: route.query.dbname, |
| 642 | schema: route.query.schema, | 681 | schema: route.query.schema, |
| 643 | - rootWindowName: route.query.rootWindowName, | 682 | + fileName: route.query.fileName, |
| 683 | + oid: route.query.oid, | ||
| 684 | + parentWindowName: route.query.parentWindowName, | ||
| 685 | + rootWindowName: route.query.rootWindowName || sessionId, | ||
| 644 | }); | 686 | }); |
| 645 | ws.instance = new WebSocketClass(ws.name, ws.sessionId, onWebSocketMessage); | 687 | ws.instance = new WebSocketClass(ws.name, ws.sessionId, onWebSocketMessage); |
| 646 | 688 | ||
| @@ -651,13 +693,11 @@ | |||
| 651 | }); | 693 | }); |
| 652 | 694 | ||
| 653 | if (['debug', 'debugChild'].includes(route.name as string)) { | 695 | if (['debug', 'debugChild'].includes(route.name as string)) { |
| 654 | - const { funcname } = route.query; | ||
| 655 | loading.value = loadingInstance(); | 696 | loading.value = loadingInstance(); |
| 656 | try { | 697 | try { |
| 657 | ws.instance.send({ | 698 | ws.instance.send({ |
| 658 | operation: 'funcProcedure', | 699 | operation: 'funcProcedure', |
| 659 | - fullName: funcname, | 700 | + oldWindowName: route.name == 'debugChild' ? ws.parentWindowName : undefined, |
| 660 | - schema: ws.schema, | ||
| 661 | ...commonWsParams.value, | 701 | ...commonWsParams.value, |
| 662 | }); | 702 | }); |
| 663 | } catch (error) { | 703 | } catch (error) { |
| @@ -670,14 +710,10 @@ | |||
| 670 | if (!ws.instance) return; | 710 | if (!ws.instance) return; |
| 671 | ['debug'].includes(props.editorType) && handleStopDebug(false); | 711 | ['debug'].includes(props.editorType) && handleStopDebug(false); |
| 672 | ['debugChild'].includes(props.editorType) && !alreadyCloseWindow.value && handleStepOut(true); | 712 | ['debugChild'].includes(props.editorType) && !alreadyCloseWindow.value && handleStepOut(true); |
| 673 | - if (['debugChild'].includes(props.editorType)) { | 713 | + ws.instance.send({ |
| 674 | - TagsViewStore.updateStepIntoChildStatusById(ws.parentId, false); | 714 | + operation: 'close', |
| 675 | - } else { | 715 | + windowName: ws.sessionId, |
| 676 | - ws.instance.send({ | 716 | + }); |
| 677 | - operation: 'close', | ||
| 678 | - windowName: ws.sessionId, | ||
| 679 | - }); | ||
| 680 | - } | ||
| 681 | ws.instance.close(); | 717 | ws.instance.close(); |
| 682 | Object.assign(ws, { | 718 | Object.assign(ws, { |
| 683 | name: '', | 719 | name: '', |
| @@ -26,5 +26,5 @@ export const prevTokenPersist = { | |||
| 26 | storage: localStorage, | 26 | storage: localStorage, |
| 27 | }; | 27 | }; |
| 28 | 28 | ||
| 29 | -export const wsHeartbeatTime = 1000 * 30; | 29 | +export const wsHeartbeatTime = 1000 * 60 * 5; |
| 30 | -export const httpHeartbeatTime = 1000 * 30; | 30 | +export const httpHeartbeatTime = 1000 * 60 * 5; |
| @@ -1,9 +1,24 @@ | |||
| 1 | +function isBody(node) { | ||
| 2 | + return node && node.nodeType == 1 && node.tagName.toLowerCase() == 'body'; | ||
| 3 | +} | ||
| 4 | + | ||
| 5 | +function canFindParent(el, selectorClassName) { | ||
| 6 | + if (!el) return false; | ||
| 7 | + if (isBody(el)) return false; | ||
| 8 | + if (el.classList.contains(selectorClassName)) return true; | ||
| 9 | + return canFindParent(el.parentNode, selectorClassName); | ||
| 10 | +} | ||
| 11 | + | ||
| 1 | export default { | 12 | export default { |
| 2 | mounted(el, binding) { | 13 | mounted(el, binding) { |
| 3 | function documentHandler(e: Event) { | 14 | function documentHandler(e: Event) { |
| 4 | if (el.contains(e.target)) { | 15 | if (el.contains(e.target)) { |
| 5 | return false; | 16 | return false; |
| 6 | } | 17 | } |
| 18 | + const extraClass = Object.keys(binding.modifiers); | ||
| 19 | + for (const item of extraClass) { | ||
| 20 | + if (canFindParent(e.target, item)) return false; | ||
| 21 | + } | ||
| 7 | if (binding.value && typeof binding.value == 'function') { | 22 | if (binding.value && typeof binding.value == 'function') { |
| 8 | binding.value(e); | 23 | binding.value(e); |
| 9 | } | 24 | } |
| @@ -0,0 +1,53 @@ | |||
| 1 | +import { ElMessageBox } from 'element-plus'; | ||
| 2 | +import type { Action } from 'element-plus'; | ||
| 3 | +import router from '@/router/index'; | ||
| 4 | +import { i18n } from '@/i18n/index'; | ||
| 5 | +import pinia from '@/store/index'; | ||
| 6 | +import { useAppStore } from '@/store/modules/app'; | ||
| 7 | +import { useTagsViewStore } from '@/store/modules/tagsView'; | ||
| 8 | + | ||
| 9 | +const t = i18n.global.t; | ||
| 10 | +export const eventQueue = {}; | ||
| 11 | + | ||
| 12 | +export const updateEventQueue = () => { | ||
| 13 | + const TagsViewStore = useTagsViewStore(pinia); | ||
| 14 | + Object.keys(eventQueue).forEach((key) => { | ||
| 15 | + if (!TagsViewStore.visitedViews.find((item) => item.id == key)) { | ||
| 16 | + delete eventQueue[key]; | ||
| 17 | + } | ||
| 18 | + }); | ||
| 19 | +}; | ||
| 20 | + | ||
| 21 | +const checkAvailableTag = (tag) => { | ||
| 22 | + const AppStore = useAppStore(pinia); | ||
| 23 | + const tagUuid = tag.query.uuid; | ||
| 24 | + return !!AppStore.connectedDatabase.find((item) => item.uuid == tagUuid); | ||
| 25 | +}; | ||
| 26 | + | ||
| 27 | +export const handleEventQueueProcedure = async (tag) => { | ||
| 28 | + const key = tag.id; | ||
| 29 | + if (tag.name == 'table' && eventQueue[key] && checkAvailableTag(tag)) { | ||
| 30 | + router.push(tag.fullPath); | ||
| 31 | + return await ElMessageBox.confirm( | ||
| 32 | + t('message.saveData', { name: tag.query.fileName }), | ||
| 33 | + 'Warning', | ||
| 34 | + { | ||
| 35 | + confirmButtonText: t('common.save'), | ||
| 36 | + cancelButtonText: t('common.notSave'), | ||
| 37 | + type: 'warning', | ||
| 38 | + distinguishCancelAndClose: true, | ||
| 39 | + }, | ||
| 40 | + ) | ||
| 41 | + .then(async () => { | ||
| 42 | + await eventQueue[key](); | ||
| 43 | + return Promise.resolve(); | ||
| 44 | + }) | ||
| 45 | + .catch((action: Action) => { | ||
| 46 | + if (action === 'cancel') { | ||
| 47 | + return Promise.resolve(); | ||
| 48 | + } else { | ||
| 49 | + return Promise.reject(); | ||
| 50 | + } | ||
| 51 | + }); | ||
| 52 | + } | ||
| 53 | +}; | ||
| @@ -0,0 +1,38 @@ | |||
| 1 | +import { ElMessage } from 'element-plus'; | ||
| 2 | +import { i18n } from '@/i18n/index'; | ||
| 3 | +import pinia from '@/store/index'; | ||
| 4 | +import { useTagsViewStore } from '@/store/modules/tagsView'; | ||
| 5 | + | ||
| 6 | +const t = i18n.global.t; | ||
| 7 | +export const queue = new Set(); | ||
| 8 | + | ||
| 9 | +export const refreshRunningTags = () => { | ||
| 10 | + const TagsViewStore = useTagsViewStore(pinia); | ||
| 11 | + for (const key of queue) { | ||
| 12 | + if (!TagsViewStore.visitedViews.find((item) => item.id == key)) { | ||
| 13 | + queue.delete(key); | ||
| 14 | + } | ||
| 15 | + } | ||
| 16 | +}; | ||
| 17 | + | ||
| 18 | +export const changeRunningTagStatus = (tagId: string | number, isRunning: boolean): void => { | ||
| 19 | + if (isRunning) { | ||
| 20 | + !queue.has(tagId) && queue.add(tagId); | ||
| 21 | + } else { | ||
| 22 | + queue.delete(tagId); | ||
| 23 | + } | ||
| 24 | +}; | ||
| 25 | + | ||
| 26 | +export const hasRunningTagStatus = (tagId: string | number): boolean => { | ||
| 27 | + return queue.has(tagId); | ||
| 28 | +}; | ||
| 29 | + | ||
| 30 | +export const deleteRunningTag = (tagId: string | number): boolean => { | ||
| 31 | + if (queue.has(tagId)) { | ||
| 32 | + ElMessage.error(t('message.debugCannotFinish')); | ||
| 33 | + return false; | ||
| 34 | + } else { | ||
| 35 | + changeRunningTagStatus(tagId, false); | ||
| 36 | + return true; | ||
| 37 | + } | ||
| 38 | +}; | ||
| @@ -0,0 +1,44 @@ | |||
| 1 | +import { reactive, toRefs } from 'vue'; | ||
| 2 | +export const useEditTable = ( | ||
| 3 | + options = { | ||
| 4 | + editingSuffix: '', | ||
| 5 | + editedSuffix: '', | ||
| 6 | + rowStatusKey: '', | ||
| 7 | + }, | ||
| 8 | +) => { | ||
| 9 | + const state = reactive({ | ||
| 10 | + globalEditing: false, | ||
| 11 | + editingElement: null, | ||
| 12 | + editingData: { | ||
| 13 | + row: {}, | ||
| 14 | + column: {} as any, | ||
| 15 | + }, | ||
| 16 | + }); | ||
| 17 | + const cellClassFn = ({ row, column }) => { | ||
| 18 | + if (options.rowStatusKey && row[options.rowStatusKey] == 'add') return 'add'; | ||
| 19 | + if (options.rowStatusKey && row[options.rowStatusKey] == 'delete') return 'delete'; | ||
| 20 | + if (row[column.property + options.editedSuffix]) return 'edited'; | ||
| 21 | + }; | ||
| 22 | + const clickOutsideTable = () => { | ||
| 23 | + if (state.globalEditing) { | ||
| 24 | + state.globalEditing = false; | ||
| 25 | + state.editingElement = null; | ||
| 26 | + state.editingData.row[state.editingData.column.property + options.editingSuffix] = false; | ||
| 27 | + } | ||
| 28 | + }; | ||
| 29 | + const handleTableClick = (event) => { | ||
| 30 | + if ( | ||
| 31 | + state.globalEditing && | ||
| 32 | + state.editingElement && | ||
| 33 | + !state.editingElement.contains(event.target) | ||
| 34 | + ) { | ||
| 35 | + clickOutsideTable(); | ||
| 36 | + } | ||
| 37 | + }; | ||
| 38 | + return { | ||
| 39 | + ...toRefs(state), | ||
| 40 | + cellClassFn, | ||
| 41 | + clickOutsideTable, | ||
| 42 | + handleTableClick, | ||
| 43 | + }; | ||
| 44 | +}; | ||
| @@ -0,0 +1 @@ | |||
| 1 | +export const useSiderbar = () => {}; | ||
| @@ -1,5 +1,6 @@ | |||
| 1 | export default { | 1 | export default { |
| 2 | common: { | 2 | common: { |
| 3 | + name: 'name', | ||
| 3 | error: 'error', | 4 | error: 'error', |
| 4 | loadData: 'Loading data, please wait...', | 5 | loadData: 'Loading data, please wait...', |
| 5 | sorry: 'SORRY', | 6 | sorry: 'SORRY', |
| @@ -13,24 +14,47 @@ export default { | |||
| 13 | loginExpired: 'Login status has expired, please log in again', | 14 | loginExpired: 'Login status has expired, please log in again', |
| 14 | signInAgain: 'Sign in again', | 15 | signInAgain: 'Sign in again', |
| 15 | all: 'all', | 16 | all: 'all', |
| 17 | + save: 'save', | ||
| 18 | + notSave: 'not save', | ||
| 19 | + page: 'page', | ||
| 20 | + serialNumber: 'Serial No', | ||
| 21 | + attribute: 'attribute', | ||
| 22 | + value: 'value', | ||
| 16 | if: '?', | 23 | if: '?', |
| 17 | colon: ':', | 24 | colon: ':', |
| 18 | }, | 25 | }, |
| 26 | + success: 'success', | ||
| 27 | + button: { | ||
| 28 | + confirm: 'confirm', | ||
| 29 | + clear: 'clear', | ||
| 30 | + reset: 'reset', | ||
| 31 | + cancel: 'cancel', | ||
| 32 | + save: 'save', | ||
| 33 | + enabled: 'enabled', | ||
| 34 | + disabled: 'disabled', | ||
| 35 | + status: 'status', | ||
| 36 | + export: 'export', | ||
| 37 | + delete: 'delete', | ||
| 38 | + }, | ||
| 19 | utils: { | 39 | utils: { |
| 20 | colorError: 'Wrong {name} color value', | 40 | colorError: 'Wrong {name} color value', |
| 21 | }, | 41 | }, |
| 22 | rules: { | 42 | rules: { |
| 23 | empty: '{0} is required', | 43 | empty: '{0} is required', |
| 44 | + enter: '请输入{0}', | ||
| 24 | charLength: 'The length cannot exceed {count} characters', | 45 | charLength: 'The length cannot exceed {count} characters', |
| 25 | integer: '{0} must be integer', | 46 | integer: '{0} must be integer', |
| 26 | }, | 47 | }, |
| 27 | message: { | 48 | message: { |
| 49 | + success: 'success', | ||
| 50 | + fail: 'fail', | ||
| 28 | deleteFile: 'Successfully deleted, please refresh the connection list!', | 51 | deleteFile: 'Successfully deleted, please refresh the connection list!', |
| 29 | connectSuccess: 'Connection succeeded!', | 52 | connectSuccess: 'Connection succeeded!', |
| 30 | createSuccess: 'created successfully!', | 53 | createSuccess: 'created successfully!', |
| 31 | disconnectSuccess: 'Disconnected successfully!', | 54 | disconnectSuccess: 'Disconnected successfully!', |
| 32 | editSuccess: 'Edit successfully', | 55 | editSuccess: 'Edit successfully', |
| 33 | deleteSuccess: 'Remove successfully!', | 56 | deleteSuccess: 'Remove successfully!', |
| 57 | + setSuccess: 'Setting successfully!', | ||
| 34 | noConnectionAvailable: 'No connection available', | 58 | noConnectionAvailable: 'No connection available', |
| 35 | deleteConnectInfo0: 'The current connection has been established and cannot be deleted!', | 59 | deleteConnectInfo0: 'The current connection has been established and cannot be deleted!', |
| 36 | deleteConnectInfo1: 'Are you sure you want to remove the connection information?', | 60 | deleteConnectInfo1: 'Are you sure you want to remove the connection information?', |
| @@ -40,6 +64,23 @@ export default { | |||
| 40 | 'All databases will be disconnected before deleting the connection. Are you sure you want to delete the {name} server?', | 64 | 'All databases will be disconnected before deleting the connection. Are you sure you want to delete the {name} server?', |
| 41 | deleteDatabase: | 65 | deleteDatabase: |
| 42 | 'The connection will be disconnected before deleting the database. Are you sure you want to delete the {name} database?', | 66 | 'The connection will be disconnected before deleting the database. Are you sure you want to delete the {name} database?', |
| 67 | + deleteMode: 'Are you sure you want to delete the {name} mode?', | ||
| 68 | + saveData: 'There is unsaved data in table {name}. Do you need to save the changes?', | ||
| 69 | + selectedData: 'Please select data', | ||
| 70 | + editTableGuide: | ||
| 71 | + 'The table does not define a unique physical key: {name},<br/>To continue, please define a unique key!', | ||
| 72 | + enterValue: 'Please enter the corresponding value!', | ||
| 73 | + leastOneColumn: 'Must have at least one column!', | ||
| 74 | + reindexTable: 'Whether to reindex:{name}?', | ||
| 75 | + truncateTable: 'Whether to truncate table: {name}?', | ||
| 76 | + vacuumTable: 'Whether to vacuum table: {name}, and free up space?', | ||
| 77 | + dropTable: 'Whether to drop table: {name}?', | ||
| 78 | + renameTableTips: 'Enter a new name for the {name} table', | ||
| 79 | + setTableDescription: 'Enter new description for table {name}', | ||
| 80 | + setTablespace: 'Select a new tablespace for table {name}', | ||
| 81 | + setTableSchema: 'Select a new schema name for table {name}', | ||
| 82 | + debugCannotFinish: | ||
| 83 | + 'There is a running debugging program, please end or interrupt debugging first!', | ||
| 43 | }, | 84 | }, |
| 44 | week: { | 85 | week: { |
| 45 | Sunday: 'Sun', | 86 | Sunday: 'Sun', |
| @@ -50,8 +91,20 @@ export default { | |||
| 50 | Friday: 'Fri', | 91 | Friday: 'Fri', |
| 51 | Saturday: 'Sat', | 92 | Saturday: 'Sat', |
| 52 | }, | 93 | }, |
| 53 | - siderbar: {}, | 94 | + siderbar: { |
| 95 | + properties: 'properties', | ||
| 96 | + table: { | ||
| 97 | + showRelatedSequence: 'show related sequence', | ||
| 98 | + reindex: 'reindex table', | ||
| 99 | + truncate: 'truncate table', | ||
| 100 | + vacuum: 'vacuum table', | ||
| 101 | + setDescription: 'set table description', | ||
| 102 | + setTablespace: 'set tablespace', | ||
| 103 | + setSchema: 'set schema', | ||
| 104 | + }, | ||
| 105 | + }, | ||
| 54 | database: { | 106 | database: { |
| 107 | + database: 'database', | ||
| 55 | open: 'open connection', | 108 | open: 'open connection', |
| 56 | close: 'disconnect', | 109 | close: 'disconnect', |
| 57 | create: 'create database', | 110 | create: 'create database', |
| @@ -126,6 +179,8 @@ export default { | |||
| 126 | }, | 179 | }, |
| 127 | }, | 180 | }, |
| 128 | create: { | 181 | create: { |
| 182 | + mode: 'create mode', | ||
| 183 | + table: 'create table', | ||
| 129 | function: 'create function', | 184 | function: 'create function', |
| 130 | process: 'create process', | 185 | process: 'create process', |
| 131 | sql: 'create sql', | 186 | sql: 'create sql', |
| @@ -135,12 +190,26 @@ export default { | |||
| 135 | terminal: 'create terminal', | 190 | terminal: 'create terminal', |
| 136 | openNewTerminal: 'open new terminal', | 191 | openNewTerminal: 'open new terminal', |
| 137 | }, | 192 | }, |
| 193 | + edit: { | ||
| 194 | + mode: 'edit mode', | ||
| 195 | + }, | ||
| 138 | delete: { | 196 | delete: { |
| 197 | + mode: 'delete mode', | ||
| 198 | + table: 'drop table', | ||
| 139 | functionSP: 'delete function/process', | 199 | functionSP: 'delete function/process', |
| 140 | view: 'delete view', | 200 | view: 'delete view', |
| 141 | synonym: 'delete synonym', | 201 | synonym: 'delete synonym', |
| 142 | sequence: 'delete sequence', | 202 | sequence: 'delete sequence', |
| 143 | }, | 203 | }, |
| 204 | + rename: { | ||
| 205 | + mode: 'rename mode', | ||
| 206 | + table: 'rename table', | ||
| 207 | + }, | ||
| 208 | + export: { | ||
| 209 | + ddl: 'export DDL', | ||
| 210 | + ddlData: 'export DDL and data', | ||
| 211 | + tableData: 'export table data', | ||
| 212 | + }, | ||
| 144 | windows: { | 213 | windows: { |
| 145 | list: 'windows', | 214 | list: 'windows', |
| 146 | placeholder: 'Please enter a window name', | 215 | placeholder: 'Please enter a window name', |
| @@ -151,16 +220,18 @@ export default { | |||
| 151 | home: 'Operation/Display', | 220 | home: 'Operation/Display', |
| 152 | }, | 221 | }, |
| 153 | functionBar: { | 222 | functionBar: { |
| 154 | - execute: 'compile / execute', | 223 | + compile: 'compile', |
| 224 | + execute: 'execute', | ||
| 155 | stopRun: 'stop', | 225 | stopRun: 'stop', |
| 156 | clear: 'clear', | 226 | clear: 'clear', |
| 157 | startDebug: 'startDebug', | 227 | startDebug: 'startDebug', |
| 158 | stopDebug: 'stopDebug', | 228 | stopDebug: 'stopDebug', |
| 159 | - breakPointStep: 'continue', | 229 | + continueStep: 'continue', |
| 160 | singleStep: 'singleStep', | 230 | singleStep: 'singleStep', |
| 161 | stepIn: 'stepInto', | 231 | stepIn: 'stepInto', |
| 162 | stepOut: 'stepOut', | 232 | stepOut: 'stepOut', |
| 163 | format: 'format', | 233 | format: 'format', |
| 234 | + coverageRate: 'historicalCoverage', | ||
| 164 | }, | 235 | }, |
| 165 | resultTab: { | 236 | resultTab: { |
| 166 | message: 'Message', | 237 | message: 'Message', |
| @@ -169,15 +240,6 @@ export default { | |||
| 169 | closeOtherTab: 'close other tabs', | 240 | closeOtherTab: 'close other tabs', |
| 170 | closeAllTab: 'close all tabs', | 241 | closeAllTab: 'close all tabs', |
| 171 | }, | 242 | }, |
| 172 | - button: { | ||
| 173 | - confirm: 'confirm', | ||
| 174 | - clear: 'clear', | ||
| 175 | - reset: 'reset', | ||
| 176 | - cancel: 'cancel', | ||
| 177 | - enabled: 'enabled', | ||
| 178 | - disabled: 'disabled', | ||
| 179 | - status: 'Status', | ||
| 180 | - }, | ||
| 181 | paramsDialog: { | 243 | paramsDialog: { |
| 182 | title: 'Function execution input parameter', | 244 | title: 'Function execution input parameter', |
| 183 | column: { | 245 | column: { |
| @@ -187,6 +249,18 @@ export default { | |||
| 187 | value: 'Value', | 249 | value: 'Value', |
| 188 | }, | 250 | }, |
| 189 | }, | 251 | }, |
| 252 | + coverageDialog: { | ||
| 253 | + serialNumber: 'Serial Number', | ||
| 254 | + totalRows: 'Total Rows', | ||
| 255 | + executionRows: 'Execution Rows', | ||
| 256 | + totalCoverage: 'Total Coverage', | ||
| 257 | + allLineNumber: 'All Line Number', | ||
| 258 | + executionLineNumber: 'Execution Line Number', | ||
| 259 | + executionCoverage: 'Execution Coverage', | ||
| 260 | + inputParams: 'Input Params', | ||
| 261 | + updateTime: 'Update Time', | ||
| 262 | + deleteMsg: 'Are you sure you want to delete the selected stored procedure query history?', | ||
| 263 | + }, | ||
| 190 | debugPane: { | 264 | debugPane: { |
| 191 | callStack: 'CallStack', | 265 | callStack: 'CallStack', |
| 192 | callHierarchy: 'CallHierarchy', | 266 | callHierarchy: 'CallHierarchy', |
| @@ -203,35 +277,100 @@ export default { | |||
| 203 | variable: 'Please enter variable name', | 277 | variable: 'Please enter variable name', |
| 204 | }, | 278 | }, |
| 205 | }, | 279 | }, |
| 280 | + mode: { | ||
| 281 | + name: 'mode name', | ||
| 282 | + owner: 'owner', | ||
| 283 | + description: 'description', | ||
| 284 | + }, | ||
| 285 | + createTable: { | ||
| 286 | + tabs: ['General', 'Column', 'Constraint', 'Indexes', 'Parition', 'DDL Preview'], | ||
| 287 | + normal: 'NORMAL', | ||
| 288 | + column: 'Column', | ||
| 289 | + value: 'Value', | ||
| 290 | + isPartition: 'is Partition Table', | ||
| 291 | + general: { | ||
| 292 | + name: 'tableName', | ||
| 293 | + ifNotExists: 'IF Not EXISTS', | ||
| 294 | + tableType: 'Table Type', | ||
| 295 | + withOIDS: 'WITH OIDS', | ||
| 296 | + tablespace: 'Tablespace', | ||
| 297 | + fillFactor: 'Fill Factor', | ||
| 298 | + storage: 'Table Orientation', | ||
| 299 | + description: 'Description', | ||
| 300 | + }, | ||
| 301 | + partition: { | ||
| 302 | + partitionType: 'Partition Type', | ||
| 303 | + intervalValue: 'Interval Value', | ||
| 304 | + partitionDefinition: 'Partition Definition', | ||
| 305 | + partitionColumn: 'Partition Column', | ||
| 306 | + partitionName: 'Partition Name', | ||
| 307 | + partitionValue: 'Partition Value', | ||
| 308 | + definePartitionValue: 'Define Partition Value', | ||
| 309 | + tablespace: 'Tablespace', | ||
| 310 | + }, | ||
| 311 | + }, | ||
| 206 | table: { | 312 | table: { |
| 313 | + title: 'Table', | ||
| 314 | + description: 'Description', | ||
| 315 | + customUniqueKey: 'Custom Unique Key', | ||
| 316 | + editTableGuide: 'Edit Table Data Wizard', | ||
| 317 | + tablespace: 'tablespace', | ||
| 318 | + general: { | ||
| 319 | + title: 'General', | ||
| 320 | + }, | ||
| 207 | column: { | 321 | column: { |
| 208 | title: 'Column', | 322 | title: 'Column', |
| 209 | columnName: 'ColumnName', | 323 | columnName: 'ColumnName', |
| 210 | dataType: 'DataType', | 324 | dataType: 'DataType', |
| 211 | canBeNull: 'CanBeNull', | 325 | canBeNull: 'CanBeNull', |
| 212 | - remark: 'Remark', | 326 | + defaultValue: 'Default', |
| 327 | + isUnique: 'IsUnique', | ||
| 328 | + arrayDimensions: 'ArrayDimensions', | ||
| 329 | + precisionSize: 'Precision/Size', | ||
| 330 | + range: 'Range', | ||
| 331 | + description: 'Description', | ||
| 213 | }, | 332 | }, |
| 214 | constraint: { | 333 | constraint: { |
| 215 | title: 'Constraint', | 334 | title: 'Constraint', |
| 216 | - columnName: 'ColumnName', | ||
| 217 | constrainColumn: 'ConstrainColumn', | 335 | constrainColumn: 'ConstrainColumn', |
| 336 | + constrainName: 'ConstrainName', | ||
| 337 | + columnName: 'ColumnName', | ||
| 218 | constrainType: 'ConstrainType', | 338 | constrainType: 'ConstrainType', |
| 219 | expression: 'Expression', | 339 | expression: 'Expression', |
| 220 | - whetherToDelay: 'WhetherDelay', | 340 | + isDeffered: 'IsDeffered', |
| 221 | - pattern: 'Pattern', | 341 | + schema: 'Schema', |
| 222 | tablespace: 'Tablespace', | 342 | tablespace: 'Tablespace', |
| 343 | + description: 'Description', | ||
| 223 | }, | 344 | }, |
| 224 | indexes: { | 345 | indexes: { |
| 225 | title: 'Indexes', | 346 | title: 'Indexes', |
| 226 | - indexName: 'IndexName', | ||
| 227 | indexColumn: 'IndexColumn', | 347 | indexColumn: 'IndexColumn', |
| 348 | + indexName: 'IndexName', | ||
| 349 | + columnName: 'ColumnName', | ||
| 228 | isUnique: 'IsUnique', | 350 | isUnique: 'IsUnique', |
| 351 | + accessMethod: 'AccessMethod', | ||
| 229 | expression: 'Expression', | 352 | expression: 'Expression', |
| 230 | tablespace: 'Tablespace', | 353 | tablespace: 'Tablespace', |
| 354 | + description: 'Description', | ||
| 231 | }, | 355 | }, |
| 232 | data: { | 356 | data: { |
| 233 | title: 'Data', | 357 | title: 'Data', |
| 234 | }, | 358 | }, |
| 359 | + export: { | ||
| 360 | + selectColumns: 'Select Columns', | ||
| 361 | + format: 'Format', | ||
| 362 | + quotes: 'Quotes', | ||
| 363 | + escape: 'Escape', | ||
| 364 | + replaceNullWith: 'Replace NULL With', | ||
| 365 | + encoding: 'Encoding', | ||
| 366 | + includeHeader: 'Include Header', | ||
| 367 | + delimiter: 'Delimiter', | ||
| 368 | + comma: 'Comma', | ||
| 369 | + tab: 'Tab', | ||
| 370 | + pipe: 'Pipe', | ||
| 371 | + semicolon: 'Semicolon', | ||
| 372 | + other: 'Other', | ||
| 373 | + }, | ||
| 235 | }, | 374 | }, |
| 236 | view: { | 375 | view: { |
| 237 | base: 'base', | 376 | base: 'base', |
| @@ -271,5 +410,4 @@ export default { | |||
| 271 | attr: 'Attribute', | 410 | attr: 'Attribute', |
| 272 | }, | 411 | }, |
| 273 | }, | 412 | }, |
| 274 | - success: 'success', | ||
| 275 | }; | 413 | }; |
| @@ -1,5 +1,6 @@ | |||
| 1 | export default { | 1 | export default { |
| 2 | common: { | 2 | common: { |
| 3 | + name: '名称', | ||
| 3 | error: '错误', | 4 | error: '错误', |
| 4 | loadData: '正在加载数据,请稍候...', | 5 | loadData: '正在加载数据,请稍候...', |
| 5 | sorry: '抱歉', | 6 | sorry: '抱歉', |
| @@ -12,30 +13,68 @@ export default { | |||
| 12 | loginExpired: '登录状态已过期,请重新登录', | 13 | loginExpired: '登录状态已过期,请重新登录', |
| 13 | signInAgain: '重新登录', | 14 | signInAgain: '重新登录', |
| 14 | all: '全部', | 15 | all: '全部', |
| 16 | + save: '保存', | ||
| 17 | + notSave: '不保存', | ||
| 18 | + page: '页', | ||
| 19 | + serialNumber: '序号', | ||
| 20 | + attribute: '属性', | ||
| 21 | + value: '值', | ||
| 15 | if: '?', | 22 | if: '?', |
| 16 | colon: ':', | 23 | colon: ':', |
| 17 | }, | 24 | }, |
| 25 | + success: '成功', | ||
| 26 | + button: { | ||
| 27 | + confirm: '确定', | ||
| 28 | + clear: '清空', | ||
| 29 | + reset: '重置', | ||
| 30 | + cancel: '取消', | ||
| 31 | + save: '保存', | ||
| 32 | + enabled: '启用', | ||
| 33 | + disabled: '禁用', | ||
| 34 | + status: '状态', | ||
| 35 | + export: '导出', | ||
| 36 | + delete: '删除', | ||
| 37 | + }, | ||
| 18 | utils: { | 38 | utils: { |
| 19 | colorError: '输入错误的{name}颜色值', | 39 | colorError: '输入错误的{name}颜色值', |
| 20 | }, | 40 | }, |
| 21 | rules: { | 41 | rules: { |
| 22 | empty: '{0}不能为空', | 42 | empty: '{0}不能为空', |
| 43 | + enter: '请输入{0}', | ||
| 23 | charLength: '长度不可超过{count}个字符', | 44 | charLength: '长度不可超过{count}个字符', |
| 24 | integer: '{0}必须为整数', | 45 | integer: '{0}必须为整数', |
| 25 | }, | 46 | }, |
| 26 | message: { | 47 | message: { |
| 48 | + success: '成功', | ||
| 49 | + fail: '失败', | ||
| 27 | deleteFile: '删除成功,请刷新连接列表!', | 50 | deleteFile: '删除成功,请刷新连接列表!', |
| 28 | connectSuccess: '连接成功!', | 51 | connectSuccess: '连接成功!', |
| 29 | createSuccess: '创建成功!', | 52 | createSuccess: '创建成功!', |
| 30 | disconnectSuccess: '断开成功!', | 53 | disconnectSuccess: '断开成功!', |
| 31 | editSuccess: '修改成功!', | 54 | editSuccess: '修改成功!', |
| 32 | deleteSuccess: '删除成功!', | 55 | deleteSuccess: '删除成功!', |
| 56 | + setSuccess: '设置成功!', | ||
| 33 | noConnectionAvailable: '没有可用的连接', | 57 | noConnectionAvailable: '没有可用的连接', |
| 34 | deleteConnectInfo0: '当前连接已建立,不可删除!', | 58 | deleteConnectInfo0: '当前连接已建立,不可删除!', |
| 35 | deleteConnectInfo1: '您确定要删除连接信息吗?', | 59 | deleteConnectInfo1: '您确定要删除连接信息吗?', |
| 36 | disConnect: '断开数据库连接可能会取消所有正在进行的数据库操作,确定要断开{name}吗?', | 60 | disConnect: '断开数据库连接可能会取消所有正在进行的数据库操作,确定要断开{name}吗?', |
| 37 | deleteConnect: '在删除连接之前所有数据库将被断开,确定要删除{name}服务器吗?', | 61 | deleteConnect: '在删除连接之前所有数据库将被断开,确定要删除{name}服务器吗?', |
| 38 | deleteDatabase: '删除数据库前将会断开连接,确定要删除{name}数据库吗?', | 62 | deleteDatabase: '删除数据库前将会断开连接,确定要删除{name}数据库吗?', |
| 63 | + deleteMode: '您确定要删除{name}模式吗?', | ||
| 64 | + saveData: '{name}表存在未保存的数据,是否需要保存更改?', | ||
| 65 | + selectedData: '请选择数据', | ||
| 66 | + editTableGuide: '该表未定义唯一物理键:{name},<br/>若要继续操作,请定义唯一键!', | ||
| 67 | + enterValue: '请输入对应的值!', | ||
| 68 | + leastOneColumn: '必须至少有一列!', | ||
| 69 | + reindexTable: '是否重建索引:{name}?', | ||
| 70 | + truncateTable: '是否清空{name}表?', | ||
| 71 | + vacuumTable: '是否清理{name}表,释放空间吗?', | ||
| 72 | + dropTable: '是否删除{name}表?', | ||
| 73 | + renameTableTips: '请为{name}表输入新的名称', | ||
| 74 | + setTableDescription: '请为表{name}设置新的描述', | ||
| 75 | + setTablespace: '请为表{name}选择一个新的表空间', | ||
| 76 | + setTableSchema: '请为表{name}选择一个新的模式', | ||
| 77 | + debugCannotFinish: '存在正在运行的调试程序,请先结束或中断调试!', | ||
| 39 | }, | 78 | }, |
| 40 | week: { | 79 | week: { |
| 41 | Sunday: '日', | 80 | Sunday: '日', |
| @@ -46,8 +85,20 @@ export default { | |||
| 46 | Friday: '五', | 85 | Friday: '五', |
| 47 | Saturday: '六', | 86 | Saturday: '六', |
| 48 | }, | 87 | }, |
| 49 | - siderbar: {}, | 88 | + siderbar: { |
| 89 | + properties: '属性', | ||
| 90 | + table: { | ||
| 91 | + showRelatedSequence: '查询相关序列', | ||
| 92 | + reindex: '重建索引', | ||
| 93 | + truncate: '截断表', | ||
| 94 | + vacuum: '清理表', | ||
| 95 | + setDescription: '设置表描述', | ||
| 96 | + setTablespace: '设置表空间', | ||
| 97 | + setSchema: '设置表模式', | ||
| 98 | + }, | ||
| 99 | + }, | ||
| 50 | database: { | 100 | database: { |
| 101 | + database: '数据库', | ||
| 51 | open: '打开连接', | 102 | open: '打开连接', |
| 52 | close: '断开连接', | 103 | close: '断开连接', |
| 53 | create: '创建数据库', | 104 | create: '创建数据库', |
| @@ -122,6 +173,8 @@ export default { | |||
| 122 | }, | 173 | }, |
| 123 | }, | 174 | }, |
| 124 | create: { | 175 | create: { |
| 176 | + mode: '创建模式', | ||
| 177 | + table: '创建表', | ||
| 125 | function: '创建函数', | 178 | function: '创建函数', |
| 126 | process: '创建过程', | 179 | process: '创建过程', |
| 127 | sql: '创建SQL函数', | 180 | sql: '创建SQL函数', |
| @@ -131,12 +184,26 @@ export default { | |||
| 131 | terminal: '新建终端', | 184 | terminal: '新建终端', |
| 132 | openNewTerminal: '打开新终端', | 185 | openNewTerminal: '打开新终端', |
| 133 | }, | 186 | }, |
| 187 | + edit: { | ||
| 188 | + mode: '编辑模式', | ||
| 189 | + }, | ||
| 134 | delete: { | 190 | delete: { |
| 191 | + mode: '删除模式', | ||
| 192 | + table: '删除表', | ||
| 135 | functionSP: '删除函数/过程', | 193 | functionSP: '删除函数/过程', |
| 136 | view: '删除视图', | 194 | view: '删除视图', |
| 137 | synonym: '删除同义词', | 195 | synonym: '删除同义词', |
| 138 | sequence: '删除序列', | 196 | sequence: '删除序列', |
| 139 | }, | 197 | }, |
| 198 | + rename: { | ||
| 199 | + mode: '重命名模式', | ||
| 200 | + table: '重命名表', | ||
| 201 | + }, | ||
| 202 | + export: { | ||
| 203 | + ddl: '导出DDL', | ||
| 204 | + ddlData: '导出DDL和数据', | ||
| 205 | + tableData: '导出表数据', | ||
| 206 | + }, | ||
| 140 | windows: { | 207 | windows: { |
| 141 | list: '窗口列表', | 208 | list: '窗口列表', |
| 142 | placeholder: '请输入窗口名称', | 209 | placeholder: '请输入窗口名称', |
| @@ -147,16 +214,18 @@ export default { | |||
| 147 | home: '运行及展示', | 214 | home: '运行及展示', |
| 148 | }, | 215 | }, |
| 149 | functionBar: { | 216 | functionBar: { |
| 150 | - execute: '编译/执行', | 217 | + compile: '编译', |
| 218 | + execute: '执行', | ||
| 151 | stopRun: '停止', | 219 | stopRun: '停止', |
| 152 | clear: '清空', | 220 | clear: '清空', |
| 153 | startDebug: '开始调试', | 221 | startDebug: '开始调试', |
| 154 | stopDebug: '停止调试', | 222 | stopDebug: '停止调试', |
| 155 | - breakPointStep: '继续执行', | 223 | + continueStep: '继续执行', |
| 156 | singleStep: '单步执行', | 224 | singleStep: '单步执行', |
| 157 | stepIn: '函数步入', | 225 | stepIn: '函数步入', |
| 158 | stepOut: '函数退出', | 226 | stepOut: '函数退出', |
| 159 | format: '格式化', | 227 | format: '格式化', |
| 228 | + coverageRate: '历史覆盖率', | ||
| 160 | }, | 229 | }, |
| 161 | resultTab: { | 230 | resultTab: { |
| 162 | message: '消息', | 231 | message: '消息', |
| @@ -165,15 +234,6 @@ export default { | |||
| 165 | closeOtherTab: '关闭其他', | 234 | closeOtherTab: '关闭其他', |
| 166 | closeAllTab: '关闭全部', | 235 | closeAllTab: '关闭全部', |
| 167 | }, | 236 | }, |
| 168 | - button: { | ||
| 169 | - confirm: '确定', | ||
| 170 | - clear: '清空', | ||
| 171 | - reset: '重置', | ||
| 172 | - cancel: '取消', | ||
| 173 | - enabled: '启用', | ||
| 174 | - disabled: '禁用', | ||
| 175 | - status: '状态', | ||
| 176 | - }, | ||
| 177 | paramsDialog: { | 237 | paramsDialog: { |
| 178 | title: '函数执行入参', | 238 | title: '函数执行入参', |
| 179 | column: { | 239 | column: { |
| @@ -183,6 +243,18 @@ export default { | |||
| 183 | value: '值', | 243 | value: '值', |
| 184 | }, | 244 | }, |
| 185 | }, | 245 | }, |
| 246 | + coverageDialog: { | ||
| 247 | + serialNumber: '序号', | ||
| 248 | + totalRows: '总行数', | ||
| 249 | + executionRows: '执行行数', | ||
| 250 | + totalCoverage: '总覆盖率', | ||
| 251 | + allLineNumber: '所有行号', | ||
| 252 | + executionLineNumber: '执行行号', | ||
| 253 | + executionCoverage: '执行覆盖率', | ||
| 254 | + inputParams: '入参', | ||
| 255 | + updateTime: '更新时间', | ||
| 256 | + deleteMsg: '确定要删除选定的存储过程查询历史记录吗?', | ||
| 257 | + }, | ||
| 186 | debugPane: { | 258 | debugPane: { |
| 187 | callStack: '调用堆栈', | 259 | callStack: '调用堆栈', |
| 188 | callHierarchy: '调用层级', | 260 | callHierarchy: '调用层级', |
| @@ -199,35 +271,97 @@ export default { | |||
| 199 | variable: '请输入变量名称', | 271 | variable: '请输入变量名称', |
| 200 | }, | 272 | }, |
| 201 | }, | 273 | }, |
| 274 | + mode: { | ||
| 275 | + name: '模式名称', | ||
| 276 | + owner: '所有者', | ||
| 277 | + description: '描述', | ||
| 278 | + }, | ||
| 279 | + createTable: { | ||
| 280 | + tabs: ['常规', '列', '约束', '索引', '分区', 'DDL预览'], | ||
| 281 | + normal: '正常', | ||
| 282 | + column: '列', | ||
| 283 | + value: '值', | ||
| 284 | + isPartition: '是否分区表', | ||
| 285 | + general: { | ||
| 286 | + name: '表名', | ||
| 287 | + ifNotExists: '如果不存在', | ||
| 288 | + tableType: '表类型', | ||
| 289 | + withOIDS: '带OIDS', | ||
| 290 | + tablespace: '表空间', | ||
| 291 | + fillFactor: '填充因子', | ||
| 292 | + storage: '存储方式', | ||
| 293 | + description: '描述', | ||
| 294 | + }, | ||
| 295 | + partition: { | ||
| 296 | + partitionType: '分区类型', | ||
| 297 | + intervalValue: '间隔值', | ||
| 298 | + partitionDefinition: '分区定义', | ||
| 299 | + partitionColumn: '分区列', | ||
| 300 | + partitionName: '分区名称', | ||
| 301 | + partitionValue: '分区值', | ||
| 302 | + definePartitionValue: '设置分区值', | ||
| 303 | + tablespace: '表空间', | ||
| 304 | + }, | ||
| 305 | + }, | ||
| 202 | table: { | 306 | table: { |
| 307 | + title: '表', | ||
| 308 | + description: '描述', | ||
| 309 | + customUniqueKey: '自定义唯一键', | ||
| 310 | + editTableGuide: '编辑表数据向导', | ||
| 311 | + tablespace: '表空间', | ||
| 312 | + general: { | ||
| 313 | + title: '一般', | ||
| 314 | + }, | ||
| 203 | column: { | 315 | column: { |
| 204 | title: '列', | 316 | title: '列', |
| 205 | columnName: '列名称', | 317 | columnName: '列名称', |
| 206 | dataType: '数据类型', | 318 | dataType: '数据类型', |
| 207 | canBeNull: '能否为NULL', | 319 | canBeNull: '能否为NULL', |
| 208 | - remark: '备注', | 320 | + defaultValue: '默认值', |
| 321 | + isUnique: '是否唯一', | ||
| 322 | + arrayDimensions: '阵列维度', | ||
| 323 | + precisionSize: '精度/大小', | ||
| 324 | + range: '范围', | ||
| 209 | }, | 325 | }, |
| 210 | constraint: { | 326 | constraint: { |
| 211 | title: '约束', | 327 | title: '约束', |
| 212 | - columnName: '列名称', | ||
| 213 | constrainColumn: '约束列', | 328 | constrainColumn: '约束列', |
| 329 | + constrainName: '约束名称', | ||
| 330 | + columnName: '列名称', | ||
| 214 | constrainType: '约束类型', | 331 | constrainType: '约束类型', |
| 215 | expression: '表达式', | 332 | expression: '表达式', |
| 216 | - whetherToDelay: '能否延迟', | 333 | + isDeffered: '能否延迟', |
| 217 | - pattern: '模式', | 334 | + schema: '模式', |
| 218 | tablespace: '表空间', | 335 | tablespace: '表空间', |
| 219 | }, | 336 | }, |
| 220 | indexes: { | 337 | indexes: { |
| 221 | title: '索引', | 338 | title: '索引', |
| 222 | - indexName: '索引名称', | ||
| 223 | indexColumn: '索引列', | 339 | indexColumn: '索引列', |
| 340 | + indexName: '索引名称', | ||
| 341 | + columnName: '列名称', | ||
| 224 | isUnique: '是否唯一', | 342 | isUnique: '是否唯一', |
| 343 | + accessMethod: '访问方式', | ||
| 225 | expression: '表达式', | 344 | expression: '表达式', |
| 226 | tablespace: '表空间', | 345 | tablespace: '表空间', |
| 227 | }, | 346 | }, |
| 228 | data: { | 347 | data: { |
| 229 | title: '数据', | 348 | title: '数据', |
| 230 | }, | 349 | }, |
| 350 | + export: { | ||
| 351 | + selectColumns: '选择列', | ||
| 352 | + format: '格式', | ||
| 353 | + quotes: '引号', | ||
| 354 | + escape: '转义符', | ||
| 355 | + replaceNullWith: '将NULL替换为', | ||
| 356 | + encoding: '编码', | ||
| 357 | + includeHeader: '包含标题', | ||
| 358 | + delimiter: '分隔符', | ||
| 359 | + comma: '逗号', | ||
| 360 | + tab: 'Tab键', | ||
| 361 | + pipe: '竖线符号', | ||
| 362 | + semicolon: '分号', | ||
| 363 | + other: '其他', | ||
| 364 | + }, | ||
| 231 | }, | 365 | }, |
| 232 | view: { | 366 | view: { |
| 233 | base: '基本', | 367 | base: '基本', |
| @@ -267,5 +401,4 @@ export default { | |||
| 267 | attr: '属性', | 401 | attr: '属性', |
| 268 | }, | 402 | }, |
| 269 | }, | 403 | }, |
| 270 | - success: '成功', | ||
| 271 | }; | 404 | }; |
| @@ -16,7 +16,6 @@ | |||
| 16 | </template> | 16 | </template> |
| 17 | 17 | ||
| 18 | <script lang="ts" setup name="mainVue"> | 18 | <script lang="ts" setup name="mainVue"> |
| 19 | - import { computed, h } from 'vue'; | ||
| 20 | import { useSettingStore } from '@/store/modules/setting'; | 19 | import { useSettingStore } from '@/store/modules/setting'; |
| 21 | import { useTagsViewStore } from '@/store/modules/tagsView'; | 20 | import { useTagsViewStore } from '@/store/modules/tagsView'; |
| 22 | const SettingStore = useSettingStore(); | 21 | const SettingStore = useSettingStore(); |
| @@ -0,0 +1,257 @@ | |||
| 1 | +<template> | ||
| 2 | + <div class="export-dialog"> | ||
| 3 | + <el-dialog | ||
| 4 | + v-model="visible" | ||
| 5 | + :title="title" | ||
| 6 | + :width="750" | ||
| 7 | + align-center | ||
| 8 | + :close-on-click-modal="false" | ||
| 9 | + @opened="handleOpen" | ||
| 10 | + @close="handleClose" | ||
| 11 | + > | ||
| 12 | + <div class="dialog_body"> | ||
| 13 | + <el-form :model="form" ref="ruleFormRef" :rules="rules" label-width="140px"> | ||
| 14 | + <el-form-item prop="columnList" :label="$t('table.export.selectColumns')"> | ||
| 15 | + <el-table | ||
| 16 | + ref="multipleTableRef" | ||
| 17 | + :data="tableData" | ||
| 18 | + @selection-change="handleSelectionChange" | ||
| 19 | + max-height="300" | ||
| 20 | + border | ||
| 21 | + > | ||
| 22 | + <el-table-column type="selection" width="55" align="center" /> | ||
| 23 | + <el-table-column | ||
| 24 | + property="columnName" | ||
| 25 | + :label="t('table.column.columnName')" | ||
| 26 | + align="center" | ||
| 27 | + /> | ||
| 28 | + </el-table> | ||
| 29 | + </el-form-item> | ||
| 30 | + <el-row :gutter="10"> | ||
| 31 | + <el-col :span="13"> | ||
| 32 | + <el-form-item prop="fileType" :label="$t('table.export.format')"> | ||
| 33 | + <el-select v-model="form.fileType" @change="handleChangeFormat"> | ||
| 34 | + <el-option v-for="item in formatList" :key="item" :label="item" :value="item" /> | ||
| 35 | + </el-select> | ||
| 36 | + </el-form-item> | ||
| 37 | + <el-form-item prop="quote" :label="$t('table.export.quotes')"> | ||
| 38 | + <el-input v-model="form.quote" :disabled="form.fileType != 'Text'" /> | ||
| 39 | + </el-form-item> | ||
| 40 | + <el-form-item prop="escape" :label="$t('table.export.escape')"> | ||
| 41 | + <el-input v-model="form.escape" :disabled="form.fileType != 'Text'" /> | ||
| 42 | + </el-form-item> | ||
| 43 | + <el-form-item prop="replaceNull" :label="$t('table.export.replaceNullWith')"> | ||
| 44 | + <el-input v-model="form.replaceNull" :disabled="form.fileType != 'Text'" /> | ||
| 45 | + </el-form-item> | ||
| 46 | + <el-form-item prop="encoding" :label="$t('table.export.encoding')"> | ||
| 47 | + <el-select v-model="form.encoding"> | ||
| 48 | + <el-option v-for="item in encodingList" :key="item" :label="item" :value="item" /> | ||
| 49 | + </el-select> | ||
| 50 | + </el-form-item> | ||
| 51 | + </el-col> | ||
| 52 | + <el-col :span="11"> | ||
| 53 | + <el-form-item prop="includeHeader" :label="$t('table.export.includeHeader')"> | ||
| 54 | + <el-checkbox v-model="form.includeHeader" :disabled="form.fileType != 'Text'" /> | ||
| 55 | + </el-form-item> | ||
| 56 | + <el-form-item prop="delimiter" :label="$t('table.export.delimiter')"> | ||
| 57 | + <el-radio-group | ||
| 58 | + v-model="form.delimiter" | ||
| 59 | + :disabled="form.fileType != 'Text'" | ||
| 60 | + @change="handleChangeDelimiter" | ||
| 61 | + > | ||
| 62 | + <el-radio label="comma">{{ t('table.export.comma') }}(,)</el-radio> | ||
| 63 | + <el-radio label="tab">{{ t('table.export.tab') }}</el-radio> | ||
| 64 | + <el-radio label="pipe">{{ t('table.export.pipe') }}(|)</el-radio> | ||
| 65 | + <el-radio label="semicolon">{{ t('table.export.semicolon') }}(;)</el-radio> | ||
| 66 | + <el-radio label="other"> | ||
| 67 | + {{ t('table.export.other') }}{{ t('common.colon') }} | ||
| 68 | + </el-radio> | ||
| 69 | + <el-input v-model="form.delimiterOther" :disabled="form.delimiter != 'other'" /> | ||
| 70 | + </el-radio-group> | ||
| 71 | + </el-form-item> | ||
| 72 | + </el-col> | ||
| 73 | + </el-row> | ||
| 74 | + </el-form> | ||
| 75 | + </div> | ||
| 76 | + <template #footer> | ||
| 77 | + <span class="dialog-footer"> | ||
| 78 | + <el-button @click="handleClose">{{ $t('button.cancel') }}</el-button> | ||
| 79 | + <el-button type="primary" @click="confirmForm"> | ||
| 80 | + {{ $t('button.confirm') }} | ||
| 81 | + </el-button> | ||
| 82 | + </span> | ||
| 83 | + </template> | ||
| 84 | + </el-dialog> | ||
| 85 | + </div> | ||
| 86 | +</template> | ||
| 87 | +<script lang="ts" setup> | ||
| 88 | + import { ElMessage, ElTable, FormInstance, FormRules } from 'element-plus'; | ||
| 89 | + import { useI18n } from 'vue-i18n'; | ||
| 90 | + import type { NodeData } from './types'; | ||
| 91 | + import { getTableColumn } from '@/api/table'; | ||
| 92 | + import { loadingInstance, downLoadMyBlobType } from '@/utils'; | ||
| 93 | + import { exportTableData } from '@/api/table'; | ||
| 94 | + | ||
| 95 | + const { t } = useI18n(); | ||
| 96 | + const props = withDefaults( | ||
| 97 | + defineProps<{ | ||
| 98 | + modelValue: boolean; | ||
| 99 | + nodeData: Partial<NodeData>; | ||
| 100 | + }>(), | ||
| 101 | + { | ||
| 102 | + modelValue: false, | ||
| 103 | + nodeData: () => ({}), | ||
| 104 | + }, | ||
| 105 | + ); | ||
| 106 | + const myEmit = defineEmits<{ | ||
| 107 | + (event: 'update:modelValue', text: boolean): void; | ||
| 108 | + (event: 'success', data: any): void; | ||
| 109 | + }>(); | ||
| 110 | + | ||
| 111 | + const loading = ref(null); | ||
| 112 | + const ruleFormRef = ref<FormInstance>(); | ||
| 113 | + const tableData = ref([]); | ||
| 114 | + const multipleTableRef = ref<InstanceType<typeof ElTable>>(); | ||
| 115 | + const formatList = reactive(['Excel(xlsx)', 'Excel(xls)', 'Text', 'Binary']); | ||
| 116 | + const encodingList = reactive(['UTF-8', 'GBK', 'LATIN1']); | ||
| 117 | + const form = reactive({ | ||
| 118 | + columnList: [], | ||
| 119 | + fileType: 'Excel(xlsx)', | ||
| 120 | + quote: '', | ||
| 121 | + escape: '', | ||
| 122 | + replaceNull: '', | ||
| 123 | + encoding: 'UTF-8', | ||
| 124 | + includeHeader: true, | ||
| 125 | + delimiter: '', | ||
| 126 | + delimiterOther: '', | ||
| 127 | + }); | ||
| 128 | + const rules = reactive<FormRules>({ | ||
| 129 | + columnList: [ | ||
| 130 | + { | ||
| 131 | + required: true, | ||
| 132 | + type: 'array', | ||
| 133 | + message: t('rules.empty', [t('table.export.selectColumns')]), | ||
| 134 | + trigger: 'change', | ||
| 135 | + }, | ||
| 136 | + ], | ||
| 137 | + }); | ||
| 138 | + const visible = computed({ | ||
| 139 | + get: () => props.modelValue, | ||
| 140 | + set: (val) => myEmit('update:modelValue', val), | ||
| 141 | + }); | ||
| 142 | + const uuid = computed(() => { | ||
| 143 | + return props.nodeData?.uuid; | ||
| 144 | + }); | ||
| 145 | + const schema = computed(() => { | ||
| 146 | + return props.nodeData?.schemaName; | ||
| 147 | + }); | ||
| 148 | + const tableName = computed(() => { | ||
| 149 | + return props.nodeData?.name; | ||
| 150 | + }); | ||
| 151 | + const oid = computed(() => { | ||
| 152 | + return props.nodeData?.oid; | ||
| 153 | + }); | ||
| 154 | + const title = computed(() => { | ||
| 155 | + return `${t('export.tableData')}${t('common.colon')} ${schema.value}.${tableName.value}`; | ||
| 156 | + }); | ||
| 157 | + | ||
| 158 | + const handleSelectionChange = (val) => { | ||
| 159 | + form.columnList = val; | ||
| 160 | + }; | ||
| 161 | + const handleChangeFormat = (val) => { | ||
| 162 | + Object.assign(form, { | ||
| 163 | + quote: '', | ||
| 164 | + escape: '', | ||
| 165 | + replaceNull: '', | ||
| 166 | + includeHeader: true, | ||
| 167 | + delimiter: val == 'Text' ? 'comma' : '', | ||
| 168 | + delimiterOther: '', | ||
| 169 | + }); | ||
| 170 | + }; | ||
| 171 | + const handleChangeDelimiter = () => { | ||
| 172 | + form.delimiterOther = ''; | ||
| 173 | + }; | ||
| 174 | + | ||
| 175 | + const handleOpen = async () => { | ||
| 176 | + loading.value = loadingInstance(); | ||
| 177 | + try { | ||
| 178 | + const res = await getTableColumn({ | ||
| 179 | + uuid: uuid.value, | ||
| 180 | + schema: schema.value, | ||
| 181 | + tableName: tableName.value, | ||
| 182 | + oid: oid.value, | ||
| 183 | + }); | ||
| 184 | + tableData.value = res.result.map((row) => { | ||
| 185 | + return { | ||
| 186 | + columnName: row[0], | ||
| 187 | + dataType: row[1], | ||
| 188 | + }; | ||
| 189 | + }); | ||
| 190 | + nextTick(() => { | ||
| 191 | + multipleTableRef.value!.toggleAllSelection(); | ||
| 192 | + }); | ||
| 193 | + } finally { | ||
| 194 | + loading.value.close(); | ||
| 195 | + } | ||
| 196 | + }; | ||
| 197 | + const handleClose = () => { | ||
| 198 | + myEmit('update:modelValue', false); | ||
| 199 | + ruleFormRef.value.resetFields(); | ||
| 200 | + }; | ||
| 201 | + const confirmForm = async () => { | ||
| 202 | + if (form.delimiter == 'other' && !form.delimiterOther) { | ||
| 203 | + return ElMessage.error(t('rules.enter', [t('table.export.delimiter')])); | ||
| 204 | + } | ||
| 205 | + ruleFormRef.value.validate(async (valid) => { | ||
| 206 | + if (valid) { | ||
| 207 | + loading.value = loadingInstance(); | ||
| 208 | + const delimiterMap = { | ||
| 209 | + comma: ',', | ||
| 210 | + tab: ' ', | ||
| 211 | + pipe: '|', | ||
| 212 | + semicolon: ';', | ||
| 213 | + }; | ||
| 214 | + const params = { | ||
| 215 | + columnList: form.columnList.map((item) => item.columnName), | ||
| 216 | + fileType: form.fileType, | ||
| 217 | + titleFlag: form.includeHeader, | ||
| 218 | + quote: form.quote, | ||
| 219 | + escape: form.escape, | ||
| 220 | + replaceNull: form.replaceNull, | ||
| 221 | + delimiter: form.delimiter == 'other' ? form.delimiterOther : delimiterMap[form.delimiter], | ||
| 222 | + encoding: form.encoding, | ||
| 223 | + uuid: uuid.value, | ||
| 224 | + schema: schema.value, | ||
| 225 | + tableName: tableName.value, | ||
| 226 | + }; | ||
| 227 | + try { | ||
| 228 | + const res = await exportTableData(params); | ||
| 229 | + downLoadMyBlobType(res.name, res.data); | ||
| 230 | + visible.value = false; | ||
| 231 | + } finally { | ||
| 232 | + loading.value.close(); | ||
| 233 | + } | ||
| 234 | + } | ||
| 235 | + }); | ||
| 236 | + }; | ||
| 237 | +</script> | ||
| 238 | + | ||
| 239 | +<style lang="scss" scoped> | ||
| 240 | + .export-dialog { | ||
| 241 | + :deep(.el-dialog__body) { | ||
| 242 | + padding-top: 5px; | ||
| 243 | + padding-bottom: 5px; | ||
| 244 | + } | ||
| 245 | + :deep(.el-select) { | ||
| 246 | + width: 100%; | ||
| 247 | + } | ||
| 248 | + :deep(.el-input-number .el-input__inner) { | ||
| 249 | + text-align: left; | ||
| 250 | + } | ||
| 251 | + :deep(.el-radio-group) { | ||
| 252 | + display: flex; | ||
| 253 | + flex-direction: column; | ||
| 254 | + align-items: flex-start; | ||
| 255 | + } | ||
| 256 | + } | ||
| 257 | +</style> | ||
Rplugins/data-studio/web-ui/src/layout/Sidebar/CreateDbDialog.vue→plugins/data-studio/web-ui/src/layout/Sidebar/components/CreateDbDialog.vue+0-1
| @@ -81,7 +81,6 @@ | |||
| 81 | </div> | 81 | </div> |
| 82 | </template> | 82 | </template> |
| 83 | <script lang="ts" setup> | 83 | <script lang="ts" setup> |
| 84 | - import { computed, ref, reactive } from 'vue'; | ||
| 85 | import { ElMessage, FormInstance, FormRules } from 'element-plus'; | 84 | import { ElMessage, FormInstance, FormRules } from 'element-plus'; |
| 86 | import { useI18n } from 'vue-i18n'; | 85 | import { useI18n } from 'vue-i18n'; |
| 87 | import { useUserStore } from '@/store/modules/user'; | 86 | import { useUserStore } from '@/store/modules/user'; |
| @@ -0,0 +1,154 @@ | |||
| 1 | +<template> | ||
| 2 | + <div class="schema-dialog"> | ||
| 3 | + <el-dialog | ||
| 4 | + v-model="visible" | ||
| 5 | + :title="props.type == 'create' ? $t('create.mode') : $t('edit.mode')" | ||
| 6 | + :width="500" | ||
| 7 | + align-center | ||
| 8 | + :close-on-click-modal="false" | ||
| 9 | + @opened="handleOpen" | ||
| 10 | + @close="handleClose" | ||
| 11 | + > | ||
| 12 | + <div class="dialog_body"> | ||
| 13 | + <el-form :model="form" ref="ruleFormRef" :rules="rules" label-width="125px"> | ||
| 14 | + <el-form-item prop="schemaName" :label="$t('mode.name')"> | ||
| 15 | + <el-input v-model="form.schemaName" /> | ||
| 16 | + </el-form-item> | ||
| 17 | + <el-form-item :label="$t('database.database')"> | ||
| 18 | + {{ form.databaseName }} | ||
| 19 | + </el-form-item> | ||
| 20 | + <el-form-item prop="owner" :label="$t('mode.owner')"> | ||
| 21 | + <el-select v-model="form.owner" :disabled="props.type == 'edit'"> | ||
| 22 | + <el-option v-for="item in ownerList" :key="item" :label="item" :value="item" /> | ||
| 23 | + </el-select> | ||
| 24 | + </el-form-item> | ||
| 25 | + <el-form-item prop="description" :label="$t('mode.description')"> | ||
| 26 | + <el-input v-model="form.description" type="textarea" :rows="2" resize="none" /> | ||
| 27 | + </el-form-item> | ||
| 28 | + </el-form> | ||
| 29 | + </div> | ||
| 30 | + <template #footer> | ||
| 31 | + <span class="dialog-footer"> | ||
| 32 | + <el-button @click="handleClose">{{ $t('button.cancel') }}</el-button> | ||
| 33 | + <el-button type="primary" @click="confirmForm"> | ||
| 34 | + {{ $t('button.confirm') }} | ||
| 35 | + </el-button> | ||
| 36 | + </span> | ||
| 37 | + </template> | ||
| 38 | + </el-dialog> | ||
| 39 | + </div> | ||
| 40 | +</template> | ||
| 41 | +<script lang="ts" setup> | ||
| 42 | + import { ElMessage, FormInstance, FormRules } from 'element-plus'; | ||
| 43 | + import { useI18n } from 'vue-i18n'; | ||
| 44 | + import { getSchemaUsers, createSchema, getSchema, updateSchema } from '@/api/schema'; | ||
| 45 | + | ||
| 46 | + const props = withDefaults( | ||
| 47 | + defineProps<{ | ||
| 48 | + modelValue: boolean; | ||
| 49 | + type: 'create' | 'edit'; | ||
| 50 | + uuid: string; | ||
| 51 | + databaseName: string; | ||
| 52 | + oid: string; | ||
| 53 | + owner: string; | ||
| 54 | + }>(), | ||
| 55 | + { | ||
| 56 | + modelValue: false, | ||
| 57 | + type: 'create', | ||
| 58 | + uuid: '', | ||
| 59 | + databaseName: '', | ||
| 60 | + oid: '', | ||
| 61 | + owner: '', | ||
| 62 | + }, | ||
| 63 | + ); | ||
| 64 | + const myEmit = defineEmits<{ | ||
| 65 | + (event: 'update:modelValue', text: boolean): void; | ||
| 66 | + (event: 'success', data: any): void; | ||
| 67 | + }>(); | ||
| 68 | + const visible = computed({ | ||
| 69 | + get: () => props.modelValue, | ||
| 70 | + set: (val) => myEmit('update:modelValue', val), | ||
| 71 | + }); | ||
| 72 | + | ||
| 73 | + const { t } = useI18n(); | ||
| 74 | + const ruleFormRef = ref<FormInstance>(); | ||
| 75 | + const form = reactive({ | ||
| 76 | + oid: '', | ||
| 77 | + schemaName: '', | ||
| 78 | + databaseName: '', | ||
| 79 | + owner: '', | ||
| 80 | + description: '', | ||
| 81 | + }); | ||
| 82 | + const rules = reactive<FormRules>({ | ||
| 83 | + schemaName: [{ required: true, message: t('rules.empty', [t('mode.name')]), trigger: 'blur' }], | ||
| 84 | + owner: [{ required: true, message: t('rules.empty', [t('mode.owner')]), trigger: 'change' }], | ||
| 85 | + }); | ||
| 86 | + | ||
| 87 | + const ownerList = ref<string[]>([]); | ||
| 88 | + | ||
| 89 | + const getOwnerList = async () => { | ||
| 90 | + ownerList.value = (await getSchemaUsers({ uuid: props.uuid })) as unknown as string[]; | ||
| 91 | + }; | ||
| 92 | + const handleOpen = async () => { | ||
| 93 | + if (props.type == 'create') { | ||
| 94 | + getOwnerList(); | ||
| 95 | + form.databaseName = props.databaseName; | ||
| 96 | + form.owner = props.owner; | ||
| 97 | + } else if (props.type == 'edit') { | ||
| 98 | + const res = (await getSchema({ | ||
| 99 | + uuid: props.uuid, | ||
| 100 | + oid: props.oid, | ||
| 101 | + })) as unknown as typeof form; | ||
| 102 | + Object.assign(form, { | ||
| 103 | + oid: props.oid, | ||
| 104 | + schemaName: res.schemaName, | ||
| 105 | + databaseName: props.databaseName, | ||
| 106 | + owner: res.owner, | ||
| 107 | + description: res.description, | ||
| 108 | + }); | ||
| 109 | + } | ||
| 110 | + }; | ||
| 111 | + const handleClose = () => { | ||
| 112 | + myEmit('update:modelValue', false); | ||
| 113 | + ruleFormRef.value.resetFields(); | ||
| 114 | + ownerList.value = []; | ||
| 115 | + }; | ||
| 116 | + const confirmForm = async () => { | ||
| 117 | + ruleFormRef.value.validate(async (valid) => { | ||
| 118 | + if (valid) { | ||
| 119 | + const params = { | ||
| 120 | + uuid: props.uuid, | ||
| 121 | + schemaName: form.schemaName, | ||
| 122 | + owner: form.owner, | ||
| 123 | + description: form.description, | ||
| 124 | + }; | ||
| 125 | + if (props.type == 'create') { | ||
| 126 | + await createSchema({ ...params }); | ||
| 127 | + ElMessage.success(t('message.createSuccess')); | ||
| 128 | + } else { | ||
| 129 | + await updateSchema({ | ||
| 130 | + ...params, | ||
| 131 | + oid: form.oid, | ||
| 132 | + }); | ||
| 133 | + ElMessage.success(t('message.editSuccess')); | ||
| 134 | + } | ||
| 135 | + myEmit('success', { schemaName: form.schemaName }); | ||
| 136 | + } | ||
| 137 | + }); | ||
| 138 | + }; | ||
| 139 | +</script> | ||
| 140 | + | ||
| 141 | +<style lang="scss" scoped> | ||
| 142 | + .schema-dialog { | ||
| 143 | + :deep(.el-dialog__body) { | ||
| 144 | + padding-top: 5px; | ||
| 145 | + padding-bottom: 5px; | ||
| 146 | + } | ||
| 147 | + :deep(.el-select) { | ||
| 148 | + width: 100%; | ||
| 149 | + } | ||
| 150 | + :deep(.el-input-number .el-input__inner) { | ||
| 151 | + text-align: left; | ||
| 152 | + } | ||
| 153 | + } | ||
| 154 | +</style> | ||
Rplugins/data-studio/web-ui/src/layout/Sidebar/DbInfoDialog.vue→plugins/data-studio/web-ui/src/layout/Sidebar/components/DbInfoDialog.vue+0-1
| @@ -19,7 +19,6 @@ | |||
| 19 | </div> | 19 | </div> |
| 20 | </template> | 20 | </template> |
| 21 | <script lang="ts" setup> | 21 | <script lang="ts" setup> |
| 22 | - import { computed, ref } from 'vue'; | ||
| 23 | import { useI18n } from 'vue-i18n'; | 22 | import { useI18n } from 'vue-i18n'; |
| 24 | import { getDatabaseAttribute } from '@/api/database'; | 23 | import { getDatabaseAttribute } from '@/api/database'; |
| 25 | 24 | ||
| @@ -0,0 +1,261 @@ | |||
| 1 | +<template> | ||
| 2 | + <div class="export-dialog"> | ||
| 3 | + <el-dialog | ||
| 4 | + v-model="visible" | ||
| 5 | + :title="title" | ||
| 6 | + :width="750" | ||
| 7 | + align-center | ||
| 8 | + :close-on-click-modal="false" | ||
| 9 | + @opened="handleOpen" | ||
| 10 | + @close="handleClose" | ||
| 11 | + > | ||
| 12 | + <div class="dialog_body"> | ||
| 13 | + <el-form :model="form" ref="ruleFormRef" :rules="rules" label-width="140px"> | ||
| 14 | + <el-form-item prop="columnList" :label="$t('table.export.selectColumns')"> | ||
| 15 | + <el-table | ||
| 16 | + ref="multipleTableRef" | ||
| 17 | + :data="tableData" | ||
| 18 | + @selection-change="handleSelectionChange" | ||
| 19 | + max-height="300" | ||
| 20 | + border | ||
| 21 | + > | ||
| 22 | + <el-table-column type="selection" width="55" align="center" /> | ||
| 23 | + <el-table-column | ||
| 24 | + property="columnName" | ||
| 25 | + :label="t('table.column.columnName')" | ||
| 26 | + align="center" | ||
| 27 | + /> | ||
| 28 | + </el-table> | ||
| 29 | + </el-form-item> | ||
| 30 | + <el-row :gutter="10"> | ||
| 31 | + <el-col :span="13"> | ||
| 32 | + <el-form-item prop="fileType" :label="$t('table.export.format')"> | ||
| 33 | + <el-select v-model="form.fileType" @change="handleChangeFormat"> | ||
| 34 | + <el-option v-for="item in formatList" :key="item" :label="item" :value="item" /> | ||
| 35 | + </el-select> | ||
| 36 | + </el-form-item> | ||
| 37 | + <el-form-item prop="quote" :label="$t('table.export.quotes')"> | ||
| 38 | + <el-input v-model="form.quote" :disabled="form.fileType != 'Text'" /> | ||
| 39 | + </el-form-item> | ||
| 40 | + <el-form-item prop="escape" :label="$t('table.export.escape')"> | ||
| 41 | + <el-input v-model="form.escape" :disabled="form.fileType != 'Text'" /> | ||
| 42 | + </el-form-item> | ||
| 43 | + <el-form-item prop="replaceNull" :label="$t('table.export.replaceNullWith')"> | ||
| 44 | + <el-input v-model="form.replaceNull" :disabled="form.fileType != 'Text'" /> | ||
| 45 | + </el-form-item> | ||
| 46 | + <el-form-item prop="encoding" :label="$t('table.export.encoding')"> | ||
| 47 | + <el-select v-model="form.encoding" placement="top"> | ||
| 48 | + <el-option v-for="item in encodingList" :key="item" :label="item" :value="item" /> | ||
| 49 | + </el-select> | ||
| 50 | + </el-form-item> | ||
| 51 | + </el-col> | ||
| 52 | + <el-col :span="11"> | ||
| 53 | + <el-form-item prop="includeHeader" :label="$t('table.export.includeHeader')"> | ||
| 54 | + <el-checkbox v-model="form.includeHeader" :disabled="form.fileType != 'Text'" /> | ||
| 55 | + </el-form-item> | ||
| 56 | + <el-form-item prop="delimiter" :label="$t('table.export.delimiter')"> | ||
| 57 | + <el-radio-group | ||
| 58 | + v-model="form.delimiter" | ||
| 59 | + :disabled="form.fileType != 'Text'" | ||
| 60 | + @change="handleChangeDelimiter" | ||
| 61 | + > | ||
| 62 | + <el-radio label="comma">{{ t('table.export.comma') }}(,)</el-radio> | ||
| 63 | + <el-radio label="tab">{{ t('table.export.tab') }}</el-radio> | ||
| 64 | + <el-radio label="pipe">{{ t('table.export.pipe') }}(|)</el-radio> | ||
| 65 | + <el-radio label="semicolon">{{ t('table.export.semicolon') }}(;)</el-radio> | ||
| 66 | + <el-radio label="other"> | ||
| 67 | + {{ t('table.export.other') }}{{ t('common.colon') }} | ||
| 68 | + </el-radio> | ||
| 69 | + <el-input | ||
| 70 | + v-model="form.delimiterOther" | ||
| 71 | + :disabled="form.delimiter != 'other'" | ||
| 72 | + maxlength="10" | ||
| 73 | + /> | ||
| 74 | + </el-radio-group> | ||
| 75 | + </el-form-item> | ||
| 76 | + </el-col> | ||
| 77 | + </el-row> | ||
| 78 | + </el-form> | ||
| 79 | + </div> | ||
| 80 | + <template #footer> | ||
| 81 | + <span class="dialog-footer"> | ||
| 82 | + <el-button @click="handleClose">{{ $t('button.cancel') }}</el-button> | ||
| 83 | + <el-button type="primary" @click="confirmForm"> | ||
| 84 | + {{ $t('button.confirm') }} | ||
| 85 | + </el-button> | ||
| 86 | + </span> | ||
| 87 | + </template> | ||
| 88 | + </el-dialog> | ||
| 89 | + </div> | ||
| 90 | +</template> | ||
| 91 | +<script lang="ts" setup> | ||
| 92 | + import { ElMessage, ElTable, FormInstance, FormRules } from 'element-plus'; | ||
| 93 | + import { useI18n } from 'vue-i18n'; | ||
| 94 | + import type { NodeData } from '../types'; | ||
| 95 | + import { getTableColumn } from '@/api/table'; | ||
| 96 | + import { loadingInstance, downLoadMyBlobType } from '@/utils'; | ||
| 97 | + import { exportTableData } from '@/api/table'; | ||
| 98 | + | ||
| 99 | + const { t } = useI18n(); | ||
| 100 | + const props = withDefaults( | ||
| 101 | + defineProps<{ | ||
| 102 | + modelValue: boolean; | ||
| 103 | + nodeData: Partial<NodeData>; | ||
| 104 | + }>(), | ||
| 105 | + { | ||
| 106 | + modelValue: false, | ||
| 107 | + nodeData: () => ({}), | ||
| 108 | + }, | ||
| 109 | + ); | ||
| 110 | + const myEmit = defineEmits<{ | ||
| 111 | + (event: 'update:modelValue', text: boolean): void; | ||
| 112 | + (event: 'success', data: any): void; | ||
| 113 | + }>(); | ||
| 114 | + | ||
| 115 | + const loading = ref(null); | ||
| 116 | + const ruleFormRef = ref<FormInstance>(); | ||
| 117 | + const tableData = ref([]); | ||
| 118 | + const multipleTableRef = ref<InstanceType<typeof ElTable>>(); | ||
| 119 | + const formatList = reactive(['Excel(xlsx)', 'Excel(xls)', 'Text', 'Binary']); | ||
| 120 | + const encodingList = reactive(['UTF-8', 'GBK', 'LATIN1']); | ||
| 121 | + const form = reactive({ | ||
| 122 | + columnList: [], | ||
| 123 | + fileType: 'Excel(xlsx)', | ||
| 124 | + quote: '', | ||
| 125 | + escape: '', | ||
| 126 | + replaceNull: '', | ||
| 127 | + encoding: 'UTF-8', | ||
| 128 | + includeHeader: true, | ||
| 129 | + delimiter: '', | ||
| 130 | + delimiterOther: '', | ||
| 131 | + }); | ||
| 132 | + const rules = reactive<FormRules>({ | ||
| 133 | + columnList: [ | ||
| 134 | + { | ||
| 135 | + required: true, | ||
| 136 | + type: 'array', | ||
| 137 | + message: t('rules.empty', [t('table.export.selectColumns')]), | ||
| 138 | + trigger: 'change', | ||
| 139 | + }, | ||
| 140 | + ], | ||
| 141 | + }); | ||
| 142 | + const visible = computed({ | ||
| 143 | + get: () => props.modelValue, | ||
| 144 | + set: (val) => myEmit('update:modelValue', val), | ||
| 145 | + }); | ||
| 146 | + const uuid = computed(() => { | ||
| 147 | + return props.nodeData?.uuid; | ||
| 148 | + }); | ||
| 149 | + const schema = computed(() => { | ||
| 150 | + return props.nodeData?.schemaName; | ||
| 151 | + }); | ||
| 152 | + const tableName = computed(() => { | ||
| 153 | + return props.nodeData?.name; | ||
| 154 | + }); | ||
| 155 | + const oid = computed(() => { | ||
| 156 | + return props.nodeData?.oid; | ||
| 157 | + }); | ||
| 158 | + const title = computed(() => { | ||
| 159 | + return `${t('export.tableData')}${t('common.colon')} ${schema.value}.${tableName.value}`; | ||
| 160 | + }); | ||
| 161 | + | ||
| 162 | + const handleSelectionChange = (val) => { | ||
| 163 | + form.columnList = val; | ||
| 164 | + }; | ||
| 165 | + const handleChangeFormat = (val) => { | ||
| 166 | + Object.assign(form, { | ||
| 167 | + quote: '', | ||
| 168 | + escape: '', | ||
| 169 | + replaceNull: '', | ||
| 170 | + includeHeader: true, | ||
| 171 | + delimiter: val == 'Text' ? 'comma' : '', | ||
| 172 | + delimiterOther: '', | ||
| 173 | + }); | ||
| 174 | + }; | ||
| 175 | + const handleChangeDelimiter = () => { | ||
| 176 | + form.delimiterOther = ''; | ||
| 177 | + }; | ||
| 178 | + | ||
| 179 | + const handleOpen = async () => { | ||
| 180 | + loading.value = loadingInstance(); | ||
| 181 | + try { | ||
| 182 | + const res = await getTableColumn({ | ||
| 183 | + uuid: uuid.value, | ||
| 184 | + schema: schema.value, | ||
| 185 | + tableName: tableName.value, | ||
| 186 | + oid: oid.value, | ||
| 187 | + }); | ||
| 188 | + tableData.value = res.result.map((row) => { | ||
| 189 | + return { | ||
| 190 | + columnName: row[0], | ||
| 191 | + dataType: row[1], | ||
| 192 | + }; | ||
| 193 | + }); | ||
| 194 | + nextTick(() => { | ||
| 195 | + multipleTableRef.value!.toggleAllSelection(); | ||
| 196 | + }); | ||
| 197 | + } finally { | ||
| 198 | + loading.value.close(); | ||
| 199 | + } | ||
| 200 | + }; | ||
| 201 | + const handleClose = () => { | ||
| 202 | + myEmit('update:modelValue', false); | ||
| 203 | + ruleFormRef.value.resetFields(); | ||
| 204 | + }; | ||
| 205 | + const confirmForm = async () => { | ||
| 206 | + if (form.delimiter == 'other' && !form.delimiterOther) { | ||
| 207 | + return ElMessage.error(t('rules.enter', [t('table.export.delimiter')])); | ||
| 208 | + } | ||
| 209 | + ruleFormRef.value.validate(async (valid) => { | ||
| 210 | + if (valid) { | ||
| 211 | + loading.value = loadingInstance(); | ||
| 212 | + const delimiterMap = { | ||
| 213 | + comma: ',', | ||
| 214 | + tab: ' ', | ||
| 215 | + pipe: '|', | ||
| 216 | + semicolon: ';', | ||
| 217 | + }; | ||
| 218 | + const params = { | ||
| 219 | + columnList: form.columnList.map((item) => item.columnName), | ||
| 220 | + fileType: form.fileType, | ||
| 221 | + titleFlag: form.includeHeader, | ||
| 222 | + quote: form.quote, | ||
| 223 | + escape: form.escape, | ||
| 224 | + replaceNull: form.replaceNull, | ||
| 225 | + delimiter: form.delimiter == 'other' ? form.delimiterOther : delimiterMap[form.delimiter], | ||
| 226 | + encoding: form.encoding, | ||
| 227 | + uuid: uuid.value, | ||
| 228 | + schema: schema.value, | ||
| 229 | + tableName: tableName.value, | ||
| 230 | + }; | ||
| 231 | + try { | ||
| 232 | + const res = await exportTableData(params); | ||
| 233 | + downLoadMyBlobType(res.name, res.data); | ||
| 234 | + visible.value = false; | ||
| 235 | + } finally { | ||
| 236 | + loading.value.close(); | ||
| 237 | + } | ||
| 238 | + } | ||
| 239 | + }); | ||
| 240 | + }; | ||
| 241 | +</script> | ||
| 242 | + | ||
| 243 | +<style lang="scss" scoped> | ||
| 244 | + .export-dialog { | ||
| 245 | + :deep(.el-dialog__body) { | ||
| 246 | + padding-top: 5px; | ||
| 247 | + padding-bottom: 5px; | ||
| 248 | + } | ||
| 249 | + :deep(.el-select) { | ||
| 250 | + width: 100%; | ||
| 251 | + } | ||
| 252 | + :deep(.el-input-number .el-input__inner) { | ||
| 253 | + text-align: left; | ||
| 254 | + } | ||
| 255 | + :deep(.el-radio-group) { | ||
| 256 | + display: flex; | ||
| 257 | + flex-direction: column; | ||
| 258 | + align-items: flex-start; | ||
| 259 | + } | ||
| 260 | + } | ||
| 261 | +</style> | ||
| @@ -0,0 +1,122 @@ | |||
| 1 | +<template> | ||
| 2 | + <div class="dialog"> | ||
| 3 | + <el-dialog | ||
| 4 | + v-model="visible" | ||
| 5 | + :title="toSpacePascalCase($t('rename.table'))" | ||
| 6 | + :width="500" | ||
| 7 | + align-center | ||
| 8 | + :close-on-click-modal="false" | ||
| 9 | + @close="handleClose" | ||
| 10 | + > | ||
| 11 | + <div class="dialog_body"> | ||
| 12 | + <div class="tips">{{ | ||
| 13 | + $t('message.renameTableTips', { | ||
| 14 | + name: `${commonParams.schema}.${commonParams.tableName}`, | ||
| 15 | + }) | ||
| 16 | + }}</div> | ||
| 17 | + <el-form :model="form" ref="ruleFormRef" :rules="rules" label-width="0px"> | ||
| 18 | + <el-form-item prop="name"> | ||
| 19 | + <el-input v-model="form.name" /> | ||
| 20 | + </el-form-item> | ||
| 21 | + </el-form> | ||
| 22 | + </div> | ||
| 23 | + <template #footer> | ||
| 24 | + <span class="dialog-footer"> | ||
| 25 | + <el-button @click="handleClose">{{ $t('button.cancel') }}</el-button> | ||
| 26 | + <el-button type="primary" @click="confirmForm" :loading="loading"> | ||
| 27 | + {{ $t('button.confirm') }} | ||
| 28 | + </el-button> | ||
| 29 | + </span> | ||
| 30 | + </template> | ||
| 31 | + </el-dialog> | ||
| 32 | + </div> | ||
| 33 | +</template> | ||
| 34 | +<script lang="ts" setup> | ||
| 35 | + import { ElMessage, FormInstance, FormRules } from 'element-plus'; | ||
| 36 | + import { useI18n } from 'vue-i18n'; | ||
| 37 | + import { renameTable } from '@/api/table'; | ||
| 38 | + import { toSpacePascalCase } from '@/utils'; | ||
| 39 | + import EventBus, { EventTypeName } from '@/utils/event-bus'; | ||
| 40 | + import type { NodeData } from '../types'; | ||
| 41 | + | ||
| 42 | + const props = withDefaults( | ||
| 43 | + defineProps<{ | ||
| 44 | + modelValue: boolean; | ||
| 45 | + nodeData: Partial<NodeData>; | ||
| 46 | + }>(), | ||
| 47 | + { | ||
| 48 | + modelValue: false, | ||
| 49 | + nodeData: () => ({}), | ||
| 50 | + }, | ||
| 51 | + ); | ||
| 52 | + const myEmit = defineEmits<{ | ||
| 53 | + (event: 'update:modelValue', text: boolean): void; | ||
| 54 | + }>(); | ||
| 55 | + const visible = computed({ | ||
| 56 | + get: () => props.modelValue, | ||
| 57 | + set: (val) => myEmit('update:modelValue', val), | ||
| 58 | + }); | ||
| 59 | + const commonParams = computed(() => { | ||
| 60 | + return { | ||
| 61 | + uuid: props.nodeData?.uuid, | ||
| 62 | + schema: props.nodeData?.schemaName, | ||
| 63 | + tableName: props.nodeData?.name, | ||
| 64 | + }; | ||
| 65 | + }); | ||
| 66 | + | ||
| 67 | + const { t } = useI18n(); | ||
| 68 | + const loading = ref(false); | ||
| 69 | + const ruleFormRef = ref<FormInstance>(); | ||
| 70 | + const form = reactive({ | ||
| 71 | + name: '', | ||
| 72 | + }); | ||
| 73 | + const rules = reactive<FormRules>({ | ||
| 74 | + name: [{ required: true, message: t('rules.empty', [t('common.name')]), trigger: 'blur' }], | ||
| 75 | + }); | ||
| 76 | + | ||
| 77 | + const handleClose = () => { | ||
| 78 | + myEmit('update:modelValue', false); | ||
| 79 | + resetForm(); | ||
| 80 | + }; | ||
| 81 | + const confirmForm = () => { | ||
| 82 | + ruleFormRef.value.validate(async (valid) => { | ||
| 83 | + if (valid) { | ||
| 84 | + loading.value = true; | ||
| 85 | + renameTable({ | ||
| 86 | + generalPurpose: form.name, | ||
| 87 | + ...commonParams.value, | ||
| 88 | + }) | ||
| 89 | + .then(() => { | ||
| 90 | + ElMessage.success(`${t('message.editSuccess')}`); | ||
| 91 | + EventBus.notify(EventTypeName.REFRESH_ASIDER, 'mode', { | ||
| 92 | + rootId: props.nodeData.rootId, | ||
| 93 | + databaseId: props.nodeData.databaseId, | ||
| 94 | + schemaId: props.nodeData.schemaId, | ||
| 95 | + }); | ||
| 96 | + handleClose(); | ||
| 97 | + }) | ||
| 98 | + .finally(() => { | ||
| 99 | + loading.value = false; | ||
| 100 | + }); | ||
| 101 | + } | ||
| 102 | + }); | ||
| 103 | + }; | ||
| 104 | + const resetForm = () => { | ||
| 105 | + form.name = ''; | ||
| 106 | + }; | ||
| 107 | +</script> | ||
| 108 | + | ||
| 109 | +<style lang="scss" scoped> | ||
| 110 | + .dialog { | ||
| 111 | + :deep(.el-dialog__body) { | ||
| 112 | + padding-top: 5px; | ||
| 113 | + padding-bottom: 5px; | ||
| 114 | + } | ||
| 115 | + :deep(.el-select) { | ||
| 116 | + width: 100%; | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + .tips { | ||
| 120 | + margin-bottom: 5px; | ||
| 121 | + } | ||
| 122 | +</style> | ||
| @@ -0,0 +1,150 @@ | |||
| 1 | +<template> | ||
| 2 | + <div class="dialog"> | ||
| 3 | + <el-dialog | ||
| 4 | + v-model="visible" | ||
| 5 | + :title="toSpacePascalCase($t('siderbar.table.setSchema'))" | ||
| 6 | + :width="500" | ||
| 7 | + align-center | ||
| 8 | + :close-on-click-modal="false" | ||
| 9 | + @opened="handleOpen" | ||
| 10 | + @close="handleClose" | ||
| 11 | + > | ||
| 12 | + <div class="dialog_body"> | ||
| 13 | + <div class="tips">{{ | ||
| 14 | + $t('message.setTableSchema', { | ||
| 15 | + name: `${commonParams.schema}.${commonParams.tableName}`, | ||
| 16 | + }) | ||
| 17 | + }}</div> | ||
| 18 | + <el-form :model="form" ref="ruleFormRef" :rules="rules" label-width="0px"> | ||
| 19 | + <el-form-item prop="input"> | ||
| 20 | + <el-select v-model="form.input"> | ||
| 21 | + <el-option | ||
| 22 | + v-for="item in optionList" | ||
| 23 | + :key="item" | ||
| 24 | + :value="item" | ||
| 25 | + :label="item" | ||
| 26 | + ></el-option> | ||
| 27 | + </el-select> | ||
| 28 | + </el-form-item> | ||
| 29 | + </el-form> | ||
| 30 | + </div> | ||
| 31 | + <template #footer> | ||
| 32 | + <span class="dialog-footer"> | ||
| 33 | + <el-button @click="handleClose">{{ $t('button.cancel') }}</el-button> | ||
| 34 | + <el-button type="primary" @click="confirmForm" :loading="loading"> | ||
| 35 | + {{ $t('button.confirm') }} | ||
| 36 | + </el-button> | ||
| 37 | + </span> | ||
| 38 | + </template> | ||
| 39 | + </el-dialog> | ||
| 40 | + </div> | ||
| 41 | +</template> | ||
| 42 | +<script lang="ts" setup> | ||
| 43 | + import { ElMessage, FormInstance, FormRules } from 'element-plus'; | ||
| 44 | + import { useI18n } from 'vue-i18n'; | ||
| 45 | + import { toSpacePascalCase } from '@/utils'; | ||
| 46 | + import EventBus, { EventTypeName } from '@/utils/event-bus'; | ||
| 47 | + import { setTableSchema } from '@/api/table'; | ||
| 48 | + import { getSchemaList } from '@/api/metaData'; | ||
| 49 | + import type { NodeData } from '../types'; | ||
| 50 | + | ||
| 51 | + const props = withDefaults( | ||
| 52 | + defineProps<{ | ||
| 53 | + modelValue: boolean; | ||
| 54 | + nodeData: Partial<NodeData>; | ||
| 55 | + }>(), | ||
| 56 | + { | ||
| 57 | + modelValue: false, | ||
| 58 | + nodeData: () => ({}), | ||
| 59 | + }, | ||
| 60 | + ); | ||
| 61 | + const myEmit = defineEmits<{ | ||
| 62 | + (event: 'update:modelValue', text: boolean): void; | ||
| 63 | + }>(); | ||
| 64 | + const visible = computed({ | ||
| 65 | + get: () => props.modelValue, | ||
| 66 | + set: (val) => myEmit('update:modelValue', val), | ||
| 67 | + }); | ||
| 68 | + const commonParams = computed(() => { | ||
| 69 | + return { | ||
| 70 | + uuid: props.nodeData?.uuid, | ||
| 71 | + schema: props.nodeData?.schemaName, | ||
| 72 | + tableName: props.nodeData?.name, | ||
| 73 | + }; | ||
| 74 | + }); | ||
| 75 | + | ||
| 76 | + const { t } = useI18n(); | ||
| 77 | + const loading = ref(false); | ||
| 78 | + const optionList = ref([]); | ||
| 79 | + const ruleFormRef = ref<FormInstance>(); | ||
| 80 | + const form = reactive({ | ||
| 81 | + input: '', | ||
| 82 | + }); | ||
| 83 | + const rules = reactive<FormRules>({ | ||
| 84 | + input: [ | ||
| 85 | + { required: true, message: t('rules.empty', [t('table.tablespace')]), trigger: 'change' }, | ||
| 86 | + ], | ||
| 87 | + }); | ||
| 88 | + | ||
| 89 | + interface schemaObject { | ||
| 90 | + name: string; | ||
| 91 | + oid: string; | ||
| 92 | + } | ||
| 93 | + const fetchSchemaList = async () => { | ||
| 94 | + const res = (await getSchemaList({ | ||
| 95 | + uuid: commonParams.value.uuid, | ||
| 96 | + })) as unknown as schemaObject[]; | ||
| 97 | + optionList.value = res.map((item) => { | ||
| 98 | + return item.name; | ||
| 99 | + }); | ||
| 100 | + }; | ||
| 101 | + | ||
| 102 | + const handleOpen = async () => { | ||
| 103 | + fetchSchemaList(); | ||
| 104 | + }; | ||
| 105 | + | ||
| 106 | + const handleClose = () => { | ||
| 107 | + myEmit('update:modelValue', false); | ||
| 108 | + resetForm(); | ||
| 109 | + }; | ||
| 110 | + const confirmForm = () => { | ||
| 111 | + ruleFormRef.value.validate(async (valid) => { | ||
| 112 | + if (valid) { | ||
| 113 | + loading.value = true; | ||
| 114 | + setTableSchema({ | ||
| 115 | + generalPurpose: form.input, | ||
| 116 | + ...commonParams.value, | ||
| 117 | + }) | ||
| 118 | + .then(() => { | ||
| 119 | + ElMessage.success(`${t('message.editSuccess')}`); | ||
| 120 | + EventBus.notify(EventTypeName.REFRESH_ASIDER, 'database', { | ||
| 121 | + rootId: props.nodeData.rootId, | ||
| 122 | + databaseId: props.nodeData.databaseId, | ||
| 123 | + }); | ||
| 124 | + handleClose(); | ||
| 125 | + }) | ||
| 126 | + .finally(() => { | ||
| 127 | + loading.value = false; | ||
| 128 | + }); | ||
| 129 | + } | ||
| 130 | + }); | ||
| 131 | + }; | ||
| 132 | + const resetForm = () => { | ||
| 133 | + form.input = ''; | ||
| 134 | + }; | ||
| 135 | +</script> | ||
| 136 | + | ||
| 137 | +<style lang="scss" scoped> | ||
| 138 | + .dialog { | ||
| 139 | + :deep(.el-dialog__body) { | ||
| 140 | + padding-top: 5px; | ||
| 141 | + padding-bottom: 5px; | ||
| 142 | + } | ||
| 143 | + :deep(.el-select) { | ||
| 144 | + width: 100%; | ||
| 145 | + } | ||
| 146 | + } | ||
| 147 | + .tips { | ||
| 148 | + margin-bottom: 5px; | ||
| 149 | + } | ||
| 150 | +</style> | ||
| @@ -0,0 +1,143 @@ | |||
| 1 | +<template> | ||
| 2 | + <div class="dialog"> | ||
| 3 | + <el-dialog | ||
| 4 | + v-model="visible" | ||
| 5 | + :title="toSpacePascalCase($t('siderbar.table.setTablespace'))" | ||
| 6 | + :width="500" | ||
| 7 | + align-center | ||
| 8 | + :close-on-click-modal="false" | ||
| 9 | + @opened="handleOpen" | ||
| 10 | + @close="handleClose" | ||
| 11 | + > | ||
| 12 | + <div class="dialog_body"> | ||
| 13 | + <div class="tips">{{ | ||
| 14 | + $t('message.setTablespace', { | ||
| 15 | + name: `${commonParams.schema}.${commonParams.tableName}`, | ||
| 16 | + }) | ||
| 17 | + }}</div> | ||
| 18 | + <el-form :model="form" ref="ruleFormRef" :rules="rules" label-width="0px"> | ||
| 19 | + <el-form-item prop="input"> | ||
| 20 | + <el-select v-model="form.input"> | ||
| 21 | + <el-option | ||
| 22 | + v-for="item in optionList" | ||
| 23 | + :key="item" | ||
| 24 | + :value="item" | ||
| 25 | + :label="item" | ||
| 26 | + ></el-option> | ||
| 27 | + </el-select> | ||
| 28 | + </el-form-item> | ||
| 29 | + </el-form> | ||
| 30 | + </div> | ||
| 31 | + <template #footer> | ||
| 32 | + <span class="dialog-footer"> | ||
| 33 | + <el-button @click="handleClose">{{ $t('button.cancel') }}</el-button> | ||
| 34 | + <el-button type="primary" @click="confirmForm" :loading="loading"> | ||
| 35 | + {{ $t('button.confirm') }} | ||
| 36 | + </el-button> | ||
| 37 | + </span> | ||
| 38 | + </template> | ||
| 39 | + </el-dialog> | ||
| 40 | + </div> | ||
| 41 | +</template> | ||
| 42 | +<script lang="ts" setup> | ||
| 43 | + import { ElMessage, FormInstance, FormRules } from 'element-plus'; | ||
| 44 | + import { useI18n } from 'vue-i18n'; | ||
| 45 | + import { toSpacePascalCase } from '@/utils'; | ||
| 46 | + import EventBus, { EventTypeName } from '@/utils/event-bus'; | ||
| 47 | + import { getTablespaceList } from '@/api/metaData'; | ||
| 48 | + import { setTablespace } from '@/api/table'; | ||
| 49 | + import type { NodeData } from '../types'; | ||
| 50 | + | ||
| 51 | + const props = withDefaults( | ||
| 52 | + defineProps<{ | ||
| 53 | + modelValue: boolean; | ||
| 54 | + nodeData: Partial<NodeData>; | ||
| 55 | + }>(), | ||
| 56 | + { | ||
| 57 | + modelValue: false, | ||
| 58 | + nodeData: () => ({}), | ||
| 59 | + }, | ||
| 60 | + ); | ||
| 61 | + const myEmit = defineEmits<{ | ||
| 62 | + (event: 'update:modelValue', text: boolean): void; | ||
| 63 | + }>(); | ||
| 64 | + const visible = computed({ | ||
| 65 | + get: () => props.modelValue, | ||
| 66 | + set: (val) => myEmit('update:modelValue', val), | ||
| 67 | + }); | ||
| 68 | + const commonParams = computed(() => { | ||
| 69 | + return { | ||
| 70 | + uuid: props.nodeData?.uuid, | ||
| 71 | + schema: props.nodeData?.schemaName, | ||
| 72 | + tableName: props.nodeData?.name, | ||
| 73 | + }; | ||
| 74 | + }); | ||
| 75 | + | ||
| 76 | + const { t } = useI18n(); | ||
| 77 | + const loading = ref(false); | ||
| 78 | + const optionList = ref([]); | ||
| 79 | + const ruleFormRef = ref<FormInstance>(); | ||
| 80 | + const form = reactive({ | ||
| 81 | + input: '', | ||
| 82 | + }); | ||
| 83 | + const rules = reactive<FormRules>({ | ||
| 84 | + input: [ | ||
| 85 | + { required: true, message: t('rules.empty', [t('table.tablespace')]), trigger: 'change' }, | ||
| 86 | + ], | ||
| 87 | + }); | ||
| 88 | + | ||
| 89 | + const fetchTablespaceList = async () => { | ||
| 90 | + const res = (await getTablespaceList(commonParams.value.uuid)) as unknown as string[]; | ||
| 91 | + optionList.value = res; | ||
| 92 | + }; | ||
| 93 | + | ||
| 94 | + const handleOpen = async () => { | ||
| 95 | + fetchTablespaceList(); | ||
| 96 | + }; | ||
| 97 | + | ||
| 98 | + const handleClose = () => { | ||
| 99 | + myEmit('update:modelValue', false); | ||
| 100 | + resetForm(); | ||
| 101 | + }; | ||
| 102 | + const confirmForm = () => { | ||
| 103 | + ruleFormRef.value.validate(async (valid) => { | ||
| 104 | + if (valid) { | ||
| 105 | + loading.value = true; | ||
| 106 | + setTablespace({ | ||
| 107 | + generalPurpose: form.input, | ||
| 108 | + ...commonParams.value, | ||
| 109 | + }) | ||
| 110 | + .then(() => { | ||
| 111 | + ElMessage.success(`${t('message.editSuccess')}`); | ||
| 112 | + EventBus.notify(EventTypeName.REFRESH_ASIDER, 'mode', { | ||
| 113 | + rootId: props.nodeData.rootId, | ||
| 114 | + databaseId: props.nodeData.databaseId, | ||
| 115 | + schemaId: props.nodeData.schemaId, | ||
| 116 | + }); | ||
| 117 | + handleClose(); | ||
| 118 | + }) | ||
| 119 | + .finally(() => { | ||
| 120 | + loading.value = false; | ||
| 121 | + }); | ||
| 122 | + } | ||
| 123 | + }); | ||
| 124 | + }; | ||
| 125 | + const resetForm = () => { | ||
| 126 | + form.input = ''; | ||
| 127 | + }; | ||
| 128 | +</script> | ||
| 129 | + | ||
| 130 | +<style lang="scss" scoped> | ||
| 131 | + .dialog { | ||
| 132 | + :deep(.el-dialog__body) { | ||
| 133 | + padding-top: 5px; | ||
| 134 | + padding-bottom: 5px; | ||
| 135 | + } | ||
| 136 | + :deep(.el-select) { | ||
| 137 | + width: 100%; | ||
| 138 | + } | ||
| 139 | + } | ||
| 140 | + .tips { | ||
| 141 | + margin-bottom: 5px; | ||
| 142 | + } | ||
| 143 | +</style> | ||
| @@ -0,0 +1,124 @@ | |||
| 1 | +<template> | ||
| 2 | + <div class="dialog"> | ||
| 3 | + <el-dialog | ||
| 4 | + v-model="visible" | ||
| 5 | + :title="toSpacePascalCase($t('siderbar.table.setDescription'))" | ||
| 6 | + :width="500" | ||
| 7 | + align-center | ||
| 8 | + :close-on-click-modal="false" | ||
| 9 | + @close="handleClose" | ||
| 10 | + > | ||
| 11 | + <div class="dialog_body"> | ||
| 12 | + <div class="tips">{{ | ||
| 13 | + $t('message.setTableDescription', { | ||
| 14 | + name: `${commonParams.schema}.${commonParams.tableName}`, | ||
| 15 | + }) | ||
| 16 | + }}</div> | ||
| 17 | + <el-form :model="form" ref="ruleFormRef" :rules="rules" label-width="0px"> | ||
| 18 | + <el-form-item prop="description"> | ||
| 19 | + <el-input v-model="form.description" /> | ||
| 20 | + </el-form-item> | ||
| 21 | + </el-form> | ||
| 22 | + </div> | ||
| 23 | + <template #footer> | ||
| 24 | + <span class="dialog-footer"> | ||
| 25 | + <el-button @click="handleClose">{{ $t('button.cancel') }}</el-button> | ||
| 26 | + <el-button type="primary" @click="confirmForm" :loading="loading"> | ||
| 27 | + {{ $t('button.confirm') }} | ||
| 28 | + </el-button> | ||
| 29 | + </span> | ||
| 30 | + </template> | ||
| 31 | + </el-dialog> | ||
| 32 | + </div> | ||
| 33 | +</template> | ||
| 34 | +<script lang="ts" setup> | ||
| 35 | + import { ElMessage, FormInstance, FormRules } from 'element-plus'; | ||
| 36 | + import { useI18n } from 'vue-i18n'; | ||
| 37 | + import { setTableComment } from '@/api/table'; | ||
| 38 | + import { toSpacePascalCase } from '@/utils'; | ||
| 39 | + import EventBus, { EventTypeName } from '@/utils/event-bus'; | ||
| 40 | + import type { NodeData } from '../types'; | ||
| 41 | + | ||
| 42 | + const props = withDefaults( | ||
| 43 | + defineProps<{ | ||
| 44 | + modelValue: boolean; | ||
| 45 | + nodeData: Partial<NodeData>; | ||
| 46 | + }>(), | ||
| 47 | + { | ||
| 48 | + modelValue: false, | ||
| 49 | + nodeData: () => ({}), | ||
| 50 | + }, | ||
| 51 | + ); | ||
| 52 | + const myEmit = defineEmits<{ | ||
| 53 | + (event: 'update:modelValue', text: boolean): void; | ||
| 54 | + }>(); | ||
| 55 | + const visible = computed({ | ||
| 56 | + get: () => props.modelValue, | ||
| 57 | + set: (val) => myEmit('update:modelValue', val), | ||
| 58 | + }); | ||
| 59 | + const commonParams = computed(() => { | ||
| 60 | + return { | ||
| 61 | + uuid: props.nodeData?.uuid, | ||
| 62 | + schema: props.nodeData?.schemaName, | ||
| 63 | + tableName: props.nodeData?.name, | ||
| 64 | + }; | ||
| 65 | + }); | ||
| 66 | + | ||
| 67 | + const { t } = useI18n(); | ||
| 68 | + const loading = ref(false); | ||
| 69 | + const ruleFormRef = ref<FormInstance>(); | ||
| 70 | + const form = reactive({ | ||
| 71 | + description: '', | ||
| 72 | + }); | ||
| 73 | + const rules = reactive<FormRules>({ | ||
| 74 | + description: [ | ||
| 75 | + { required: true, message: t('rules.empty', [t('table.description')]), trigger: 'blur' }, | ||
| 76 | + ], | ||
| 77 | + }); | ||
| 78 | + | ||
| 79 | + const handleClose = () => { | ||
| 80 | + myEmit('update:modelValue', false); | ||
| 81 | + resetForm(); | ||
| 82 | + }; | ||
| 83 | + const confirmForm = () => { | ||
| 84 | + ruleFormRef.value.validate(async (valid) => { | ||
| 85 | + if (valid) { | ||
| 86 | + loading.value = true; | ||
| 87 | + setTableComment({ | ||
| 88 | + generalPurpose: form.description, | ||
| 89 | + ...commonParams.value, | ||
| 90 | + }) | ||
| 91 | + .then(() => { | ||
| 92 | + ElMessage.success(`${t('message.editSuccess')}`); | ||
| 93 | + EventBus.notify(EventTypeName.REFRESH_ASIDER, 'mode', { | ||
| 94 | + rootId: props.nodeData.rootId, | ||
| 95 | + databaseId: props.nodeData.databaseId, | ||
| 96 | + schemaId: props.nodeData.schemaId, | ||
| 97 | + }); | ||
| 98 | + handleClose(); | ||
| 99 | + }) | ||
| 100 | + .finally(() => { | ||
| 101 | + loading.value = false; | ||
| 102 | + }); | ||
| 103 | + } | ||
| 104 | + }); | ||
| 105 | + }; | ||
| 106 | + const resetForm = () => { | ||
| 107 | + form.description = ''; | ||
| 108 | + }; | ||
| 109 | +</script> | ||
| 110 | + | ||
| 111 | +<style lang="scss" scoped> | ||
| 112 | + .dialog { | ||
| 113 | + :deep(.el-dialog__body) { | ||
| 114 | + padding-top: 5px; | ||
| 115 | + padding-bottom: 5px; | ||
| 116 | + } | ||
| 117 | + :deep(.el-select) { | ||
| 118 | + width: 100%; | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + .tips { | ||
| 122 | + margin-bottom: 5px; | ||
| 123 | + } | ||
| 124 | +</style> | ||
Dplugins/data-studio/web-ui/src/layout/Sidebar/index.d.ts+0-0
The file is empty
| @@ -149,6 +149,12 @@ | |||
| 149 | > | 149 | > |
| 150 | {{ $t('database.property') }} | 150 | {{ $t('database.property') }} |
| 151 | </li> | 151 | </li> |
| 152 | + <li | ||
| 153 | + :class="{ disabled: !treeContextDbStatus }" | ||
| 154 | + @click="treeContextDbStatus && handleSchema('create')" | ||
| 155 | + > | ||
| 156 | + {{ $t('create.mode') }} | ||
| 157 | + </li> | ||
| 152 | <li | 158 | <li |
| 153 | :class="{ disabled: !treeContextDbStatus }" | 159 | :class="{ disabled: !treeContextDbStatus }" |
| 154 | @click=" | 160 | @click=" |
| @@ -181,6 +187,20 @@ | |||
| 181 | > | 187 | > |
| 182 | {{ $t('connection.refresh') }} | 188 | {{ $t('connection.refresh') }} |
| 183 | </li> | 189 | </li> |
| 190 | + <li | ||
| 191 | + @click="!systemSchema.includes(currentContextNodeData.name) && handleSchema('edit')" | ||
| 192 | + :class="{ disabled: systemSchema.includes(currentContextNodeData.name) }" | ||
| 193 | + > | ||
| 194 | + {{ $t('edit.mode') }} | ||
| 195 | + </li> | ||
| 196 | + <li | ||
| 197 | + @click="!systemSchema.includes(currentContextNodeData.name) && handleSchema('delete')" | ||
| 198 | + :class="{ disabled: systemSchema.includes(currentContextNodeData.name) }" | ||
| 199 | + > | ||
| 200 | + {{ $t('delete.mode') }} | ||
| 201 | + </li> | ||
| 202 | + <li @click="handleExport('modeDDL')"> {{ $t('export.ddl') }}</li> | ||
| 203 | + <li @click="handleExport('modeDDLData')"> {{ $t('export.ddlData') }}</li> | ||
| 184 | </ul> | 204 | </ul> |
| 185 | <ul | 205 | <ul |
| 186 | v-if="treeContext.terminalCollectVisible" | 206 | v-if="treeContext.terminalCollectVisible" |
| @@ -195,14 +215,14 @@ | |||
| 195 | <li @click="hanldeCreate('sql')"> {{ $t('create.sql') }}</li> | 215 | <li @click="hanldeCreate('sql')"> {{ $t('create.sql') }}</li> |
| 196 | </ul> | 216 | </ul> |
| 197 | <ul | 217 | <ul |
| 198 | - v-if="treeContext.functionSPVisible" | 218 | + v-if="treeContext.tableCollectVisible" |
| 199 | v-click-outside=" | 219 | v-click-outside=" |
| 200 | () => { | 220 | () => { |
| 201 | - treeContext.functionSPVisible = false; | 221 | + treeContext.tableCollectVisible = false; |
| 202 | } | 222 | } |
| 203 | " | 223 | " |
| 204 | > | 224 | > |
| 205 | - <li @click="deleteConfirm('functionSP')"> {{ $t('delete.functionSP') }}</li> | 225 | + <li @click="hanldeCreateTable"> {{ $t('create.table') }}</li> |
| 206 | </ul> | 226 | </ul> |
| 207 | <ul | 227 | <ul |
| 208 | v-if="treeContext.viewCollectVisible" | 228 | v-if="treeContext.viewCollectVisible" |
| @@ -234,6 +254,40 @@ | |||
| 234 | > | 254 | > |
| 235 | <li @click="showCreatDialog('synonym')"> {{ $t('create.synonym') }}</li> | 255 | <li @click="showCreatDialog('synonym')"> {{ $t('create.synonym') }}</li> |
| 236 | </ul> | 256 | </ul> |
| 257 | + <ul | ||
| 258 | + v-if="treeContext.functionSPVisible" | ||
| 259 | + v-click-outside=" | ||
| 260 | + () => { | ||
| 261 | + treeContext.functionSPVisible = false; | ||
| 262 | + } | ||
| 263 | + " | ||
| 264 | + > | ||
| 265 | + <li @click="deleteConfirm('functionSP')"> {{ $t('delete.functionSP') }}</li> | ||
| 266 | + <li @click="handleExport('functionDDL')"> {{ $t('export.ddl') }}</li> | ||
| 267 | + </ul> | ||
| 268 | + <ul | ||
| 269 | + v-if="treeContext.tableVisible" | ||
| 270 | + v-click-outside=" | ||
| 271 | + () => { | ||
| 272 | + treeContext.tableVisible = false; | ||
| 273 | + } | ||
| 274 | + " | ||
| 275 | + > | ||
| 276 | + <li @click="handleRelatedSequence"> {{ $t('siderbar.table.showRelatedSequence') }}</li> | ||
| 277 | + <li @click="handleReindex"> {{ $t('siderbar.table.reindex') }}</li> | ||
| 278 | + <li @click="handleVacuum"> {{ $t('siderbar.table.vacuum') }}</li> | ||
| 279 | + <li @click="handleTruncate"> {{ $t('siderbar.table.truncate') }}</li> | ||
| 280 | + <li @click="handleSetTableSchema"> {{ $t('siderbar.table.setSchema') }}</li> | ||
| 281 | + <li @click="handleSetTablespace"> {{ $t('siderbar.table.setTablespace') }}</li> | ||
| 282 | + <li @click="handleUpdateTableDescription"> | ||
| 283 | + {{ $t('siderbar.table.setDescription') }} | ||
| 284 | + </li> | ||
| 285 | + <li @click="handleExport('tableDDL')"> {{ $t('export.ddl') }}</li> | ||
| 286 | + <li @click="handleExport('tableData')"> {{ $t('export.tableData') }}</li> | ||
| 287 | + <li @click="handleExport('tableDDLData')"> {{ $t('export.ddlData') }}</li> | ||
| 288 | + <li @click="handleTableRename"> {{ $t('rename.table') }}</li> | ||
| 289 | + <li @click="handleDropTable"> {{ $t('delete.table') }}</li> | ||
| 290 | + </ul> | ||
| 237 | <ul | 291 | <ul |
| 238 | v-if="treeContext.viewVisible" | 292 | v-if="treeContext.viewVisible" |
| 239 | v-click-outside=" | 293 | v-click-outside=" |
| @@ -243,6 +297,7 @@ | |||
| 243 | " | 297 | " |
| 244 | > | 298 | > |
| 245 | <li @click="deleteConfirm('view')"> {{ $t('delete.view') }}</li> | 299 | <li @click="deleteConfirm('view')"> {{ $t('delete.view') }}</li> |
| 300 | + <li @click="handleExport('viewDDL')"> {{ $t('export.ddl') }}</li> | ||
| 246 | </ul> | 301 | </ul> |
| 247 | <ul | 302 | <ul |
| 248 | v-if="treeContext.sequenceVisible" | 303 | v-if="treeContext.sequenceVisible" |
| @@ -253,6 +308,8 @@ | |||
| 253 | " | 308 | " |
| 254 | > | 309 | > |
| 255 | <li @click="deleteConfirm('sequence')"> {{ $t('delete.sequence') }}</li> | 310 | <li @click="deleteConfirm('sequence')"> {{ $t('delete.sequence') }}</li> |
| 311 | + <li @click="handleExport('sequenceDDL')"> {{ $t('export.ddl') }}</li> | ||
| 312 | + <li @click="handleExport('sequenceDDLData')"> {{ $t('export.ddlData') }}</li> | ||
| 256 | </ul> | 313 | </ul> |
| 257 | <ul | 314 | <ul |
| 258 | v-if="treeContext.synonymVisible" | 315 | v-if="treeContext.synonymVisible" |
| @@ -294,7 +351,7 @@ | |||
| 294 | </div> | 351 | </div> |
| 295 | <div v-else class="windows-item" :class="isActive(tag) ? 'active' : ''"> | 352 | <div v-else class="windows-item" :class="isActive(tag) ? 'active' : ''"> |
| 296 | <svg-icon :icon-class="tag.meta.icon" class-name="icon" /> | 353 | <svg-icon :icon-class="tag.meta.icon" class-name="icon" /> |
| 297 | - <span class="name">{{ tag.title }}</span> | 354 | + <span class="name" :title="tag.title">{{ tag.query.fileName }}</span> |
| 298 | </div> | 355 | </div> |
| 299 | </div> | 356 | </div> |
| 300 | </div> | 357 | </div> |
| @@ -314,10 +371,21 @@ | |||
| 314 | :uuid="currentContextNodeData.uuid" | 371 | :uuid="currentContextNodeData.uuid" |
| 315 | :databaseName="currentContextNodeData.label" | 372 | :databaseName="currentContextNodeData.label" |
| 316 | /> | 373 | /> |
| 374 | + <CreateSchemaDialog | ||
| 375 | + v-if="showCreateSchemaDialog" | ||
| 376 | + v-model="showCreateSchemaDialog" | ||
| 377 | + :uuid="currentContextNodeData.uuid" | ||
| 378 | + :databaseName="createSchemaData.databaseName" | ||
| 379 | + :oid="createSchemaData.oid" | ||
| 380 | + :owner="createSchemaData.owner" | ||
| 381 | + :type="createSchemaType" | ||
| 382 | + @success="createSchemaSuccess" | ||
| 383 | + /> | ||
| 317 | <CreateViewDialog | 384 | <CreateViewDialog |
| 385 | + v-if="viewDialog" | ||
| 386 | + v-model="viewDialog" | ||
| 318 | type="create" | 387 | type="create" |
| 319 | :connectData="currentContextNodeData" | 388 | :connectData="currentContextNodeData" |
| 320 | - v-model="viewDialog" | ||
| 321 | @success="refreshModeByContext" | 389 | @success="refreshModeByContext" |
| 322 | /> | 390 | /> |
| 323 | <CreateSynonymDialog | 391 | <CreateSynonymDialog |
| @@ -334,34 +402,68 @@ | |||
| 334 | :connectData="currentContextNodeData" | 402 | :connectData="currentContextNodeData" |
| 335 | @success="refreshModeByContext" | 403 | @success="refreshModeByContext" |
| 336 | /> | 404 | /> |
| 405 | + <ExportTableDataDialog | ||
| 406 | + v-if="exportTableDialog" | ||
| 407 | + v-model="exportTableDialog" | ||
| 408 | + :nodeData="currentContextNodeData" | ||
| 409 | + /> | ||
| 410 | + <RenameTable | ||
| 411 | + v-if="renameTableDialog" | ||
| 412 | + v-model="renameTableDialog" | ||
| 413 | + :nodeData="currentContextNodeData" | ||
| 414 | + /> | ||
| 415 | + <UpdateTableDescription | ||
| 416 | + v-if="updateTableDescriptionDialog" | ||
| 417 | + v-model="updateTableDescriptionDialog" | ||
| 418 | + :nodeData="currentContextNodeData" | ||
| 419 | + /> | ||
| 420 | + <SetTablespace | ||
| 421 | + v-if="setTablespaceDialog" | ||
| 422 | + v-model="setTablespaceDialog" | ||
| 423 | + :nodeData="currentContextNodeData" | ||
| 424 | + /> | ||
| 425 | + <SetTableSchema | ||
| 426 | + v-if="setTableSchemaDialog" | ||
| 427 | + v-model="setTableSchemaDialog" | ||
| 428 | + :nodeData="currentContextNodeData" | ||
| 429 | + /> | ||
| 337 | </div> | 430 | </div> |
| 338 | </template> | 431 | </template> |
| 339 | 432 | ||
| 340 | <script lang="ts" setup name="Siderbar"> | 433 | <script lang="ts" setup name="Siderbar"> |
| 341 | import { Search } from '@element-plus/icons-vue'; | 434 | import { Search } from '@element-plus/icons-vue'; |
| 342 | import { ElMessage, ElMessageBox, ElTree } from 'element-plus'; | 435 | import { ElMessage, ElMessageBox, ElTree } from 'element-plus'; |
| 343 | - import CreateDbDialog from './CreateDbDialog.vue'; | 436 | + import CreateDbDialog from './components/CreateDbDialog.vue'; |
| 344 | - import DbInfoDialog from './DbInfoDialog.vue'; | 437 | + import DbInfoDialog from './components/DbInfoDialog.vue'; |
| 438 | + import CreateSchemaDialog from './components/CreateSchemaDialog.vue'; | ||
| 345 | import CreateViewDialog from '@/views/view/CreateViewDialog.vue'; | 439 | import CreateViewDialog from '@/views/view/CreateViewDialog.vue'; |
| 346 | import CreateSynonymDialog from '@/views/synonym/CreateSynonymDialog.vue'; | 440 | import CreateSynonymDialog from '@/views/synonym/CreateSynonymDialog.vue'; |
| 347 | import CreateSequenceDialog from '@/views/sequence/CreateSequenceDialog.vue'; | 441 | import CreateSequenceDialog from '@/views/sequence/CreateSequenceDialog.vue'; |
| 348 | - import { computed, nextTick, onMounted, reactive, ref, onUnmounted, watch } from 'vue'; | 442 | + import ExportTableDataDialog from './components/ExportTableDataDialog.vue'; |
| 443 | + import RenameTable from './components/RenameTable.vue'; | ||
| 444 | + import UpdateTableDescription from './components/UpdateTableDescription.vue'; | ||
| 445 | + import SetTablespace from './components/SetTablespace.vue'; | ||
| 446 | + import SetTableSchema from './components/SetTableSchema.vue'; | ||
| 349 | import { useRoute, useRouter } from 'vue-router'; | 447 | import { useRoute, useRouter } from 'vue-router'; |
| 350 | import { useAppStore } from '@/store/modules/app'; | 448 | import { useAppStore } from '@/store/modules/app'; |
| 351 | import { useTagsViewStore } from '@/store/modules/tagsView'; | 449 | import { useTagsViewStore } from '@/store/modules/tagsView'; |
| 352 | import vClickOutside from '@/directives/clickOutside'; | 450 | import vClickOutside from '@/directives/clickOutside'; |
| 353 | import EventBus, { EventTypeName } from '@/utils/event-bus'; | 451 | import EventBus, { EventTypeName } from '@/utils/event-bus'; |
| 354 | import { getSchemaList, getSchemaObjectList } from '@/api/metaData'; | 452 | import { getSchemaList, getSchemaObjectList } from '@/api/metaData'; |
| 355 | - import { loadingInstance } from '@/utils'; | 453 | + import { loadingInstance, downLoadMyBlobType } from '@/utils'; |
| 356 | import { useI18n } from 'vue-i18n'; | 454 | import { useI18n } from 'vue-i18n'; |
| 357 | import { closeConnections } from '@/api/connect'; | 455 | import { closeConnections } from '@/api/connect'; |
| 358 | - import { dropFunctionSP } from '@/api/functionSP'; | ||
| 359 | - import { dropView } from '@/api/view'; | ||
| 360 | - import { dropSequence } from '@/api/sequence'; | ||
| 361 | - import { dropSynonym } from '@/api/synonym'; | ||
| 362 | import { getDatabaseList, openDatabaseConnection, deleteDatabase } from '@/api/database'; | 456 | import { getDatabaseList, openDatabaseConnection, deleteDatabase } from '@/api/database'; |
| 457 | + import { deleteSchema, exportSchemaDdl } from '@/api/schema'; | ||
| 458 | + import { exportTableDdl } from '@/api/table'; | ||
| 459 | + import { dropFunctionSP, exportFunctionDdl } from '@/api/functionSP'; | ||
| 460 | + import { dropView, exportViewDdl } from '@/api/view'; | ||
| 461 | + import { dropSequence, exportSequenceDdl } from '@/api/sequence'; | ||
| 462 | + import { dropSynonym } from '@/api/synonym'; | ||
| 363 | import { useUserStore } from '@/store/modules/user'; | 463 | import { useUserStore } from '@/store/modules/user'; |
| 364 | import { connectListPersist } from '@/config'; | 464 | import { connectListPersist } from '@/config'; |
| 465 | + import { useSidebarContext } from '../hooks/useSidebarContext'; | ||
| 466 | + import type { Tree, FetchNode, ConnectInfo, RefreshOptions, NodeData } from './types'; | ||
| 365 | 467 | ||
| 366 | const AppStore = useAppStore(); | 468 | const AppStore = useAppStore(); |
| 367 | const TagsViewStore = useTagsViewStore(); | 469 | const TagsViewStore = useTagsViewStore(); |
| @@ -380,7 +482,7 @@ | |||
| 380 | person = 'person', // schema | 482 | person = 'person', // schema |
| 381 | tableCollect = 'tableCollect', | 483 | tableCollect = 'tableCollect', |
| 382 | table = 'table', | 484 | table = 'table', |
| 383 | - terminalCollect = 'codeCollect', | 485 | + terminalCollect = 'terminalCollect', |
| 384 | terminal = 'terminal', | 486 | terminal = 'terminal', |
| 385 | viewCollect = 'viewCollect', | 487 | viewCollect = 'viewCollect', |
| 386 | view = 'view', | 488 | view = 'view', |
| @@ -390,38 +492,18 @@ | |||
| 390 | sequence = 'sequence', | 492 | sequence = 'sequence', |
| 391 | } */ | 493 | } */ |
| 392 | 494 | ||
| 393 | - interface Tree { | ||
| 394 | - id: string; | ||
| 395 | - parentId: string; | ||
| 396 | - label: string; | ||
| 397 | - name: string; | ||
| 398 | - isLeaf?: boolean; | ||
| 399 | - type?: string; | ||
| 400 | - isConnect?: boolean; | ||
| 401 | - connectTime: null | number; | ||
| 402 | - uuid?: string; | ||
| 403 | - children?: Tree[]; | ||
| 404 | - connectInfo: ConnectInfo; | ||
| 405 | - } | ||
| 406 | - interface ConnectInfo { | ||
| 407 | - name: string; | ||
| 408 | - id: string; | ||
| 409 | - ip: string; | ||
| 410 | - port: string; | ||
| 411 | - userName: string; | ||
| 412 | - uuid?: string; | ||
| 413 | - type?: string; | ||
| 414 | - driver?: ''; | ||
| 415 | - password?: string; | ||
| 416 | - webUser: string; | ||
| 417 | - } | ||
| 418 | - | ||
| 419 | const treeClass = ref('no-tree'); | 495 | const treeClass = ref('no-tree'); |
| 420 | const showCreateDbDialog = ref(false); | 496 | const showCreateDbDialog = ref(false); |
| 421 | const showDbInfoDialog = ref(false); | 497 | const showDbInfoDialog = ref(false); |
| 498 | + const showCreateSchemaDialog = ref(false); | ||
| 422 | const viewDialog = ref(false); | 499 | const viewDialog = ref(false); |
| 423 | const synonymDialog = ref(false); | 500 | const synonymDialog = ref(false); |
| 424 | const sequenceDialog = ref(false); | 501 | const sequenceDialog = ref(false); |
| 502 | + const exportTableDialog = ref(false); | ||
| 503 | + const renameTableDialog = ref(false); | ||
| 504 | + const updateTableDescriptionDialog = ref(false); | ||
| 505 | + const setTablespaceDialog = ref(false); | ||
| 506 | + const setTableSchemaDialog = ref(false); | ||
| 425 | const UserStore = useUserStore(); | 507 | const UserStore = useUserStore(); |
| 426 | const connectInfo: ConnectInfo = reactive({ | 508 | const connectInfo: ConnectInfo = reactive({ |
| 427 | name: '', | 509 | name: '', |
| @@ -440,20 +522,46 @@ | |||
| 440 | isLeaf: 'isLeaf', | 522 | isLeaf: 'isLeaf', |
| 441 | }; | 523 | }; |
| 442 | const connectionList = ref<Array<Tree>>([]); | 524 | const connectionList = ref<Array<Tree>>([]); |
| 443 | - const currentContextNodeData = reactive({ | 525 | + const currentContextNodeData = reactive<NodeData>({ |
| 444 | id: '', | 526 | id: '', |
| 527 | + type: '', | ||
| 445 | uuid: '', | 528 | uuid: '', |
| 446 | connectInfo: { id: '', name: '' } as ConnectInfo, | 529 | connectInfo: { id: '', name: '' } as ConnectInfo, |
| 530 | + rootId: '', | ||
| 531 | + parentId: '', | ||
| 447 | databaseId: '', | 532 | databaseId: '', |
| 448 | databaseName: '', | 533 | databaseName: '', |
| 449 | schemaId: '', | 534 | schemaId: '', |
| 450 | schemaName: '', | 535 | schemaName: '', |
| 536 | + oid: '', | ||
| 451 | label: '', | 537 | label: '', |
| 452 | name: '', | 538 | name: '', |
| 453 | children: [], | 539 | children: [], |
| 454 | }); | 540 | }); |
| 455 | let loading = ref(null); | 541 | let loading = ref(null); |
| 456 | const createDbType = ref<'create' | 'edit'>('create'); | 542 | const createDbType = ref<'create' | 'edit'>('create'); |
| 543 | + const createSchemaType = ref<'create' | 'edit'>('create'); | ||
| 544 | + const createSchemaData = reactive({ | ||
| 545 | + databaseName: '', | ||
| 546 | + databaseId: '', | ||
| 547 | + oid: '', | ||
| 548 | + owner: '', | ||
| 549 | + }); | ||
| 550 | + | ||
| 551 | + const systemSchema = ref([ | ||
| 552 | + 'blockchain', | ||
| 553 | + 'snapshot', | ||
| 554 | + 'dbe_perf', | ||
| 555 | + 'pkg_service', | ||
| 556 | + 'cstore', | ||
| 557 | + 'pg_toast', | ||
| 558 | + 'pg_catalog', | ||
| 559 | + 'sqladvisor', | ||
| 560 | + 'dbe_pldebugger', | ||
| 561 | + 'dbe_pldeveloper', | ||
| 562 | + 'information_schema', | ||
| 563 | + 'db4ai', | ||
| 564 | + ]); | ||
| 457 | 565 | ||
| 458 | const isActive = (rou) => { | 566 | const isActive = (rou) => { |
| 459 | return rou.path === route.path; | 567 | return rou.path === route.path; |
| @@ -490,12 +598,18 @@ | |||
| 490 | } | 598 | } |
| 491 | } | 599 | } |
| 492 | }; | 600 | }; |
| 601 | + | ||
| 602 | + const getConnectInfoByRootId = (rootId) => { | ||
| 603 | + return connectionList.value.find((item) => item.id == rootId); | ||
| 604 | + }; | ||
| 605 | + | ||
| 493 | const loadNode = async (node, resolve) => { | 606 | const loadNode = async (node, resolve) => { |
| 494 | if (node.data.children && node.data.children.length) { | 607 | if (node.data.children && node.data.children.length) { |
| 495 | return resolve(node.data.children); | 608 | return resolve(node.data.children); |
| 496 | } else if (node.data?.type == 'database' && node.data?.isConnect) { | 609 | } else if (node.data?.type == 'database' && node.data?.isConnect) { |
| 497 | try { | 610 | try { |
| 498 | const data = await fetchSchemaList( | 611 | const data = await fetchSchemaList( |
| 612 | + node.data.rootId, | ||
| 499 | node.data.id, | 613 | node.data.id, |
| 500 | node.data.id, | 614 | node.data.id, |
| 501 | node.data.label, | 615 | node.data.label, |
| @@ -509,6 +623,7 @@ | |||
| 509 | } else if (['public', 'person'].includes(node.data?.type)) { | 623 | } else if (['public', 'person'].includes(node.data?.type)) { |
| 510 | try { | 624 | try { |
| 511 | const data = await fetchSchemaContentList( | 625 | const data = await fetchSchemaContentList( |
| 626 | + node.data.rootId, | ||
| 512 | node.data.id, | 627 | node.data.id, |
| 513 | node.data.uuid, | 628 | node.data.uuid, |
| 514 | node.data.databaseId, | 629 | node.data.databaseId, |
| @@ -554,6 +669,7 @@ | |||
| 554 | const isConnect = !!hasConnectDb; | 669 | const isConnect = !!hasConnectDb; |
| 555 | return { | 670 | return { |
| 556 | id: `${id}_${dbName}`, | 671 | id: `${id}_${dbName}`, |
| 672 | + rootId: id, | ||
| 557 | parentId: id, | 673 | parentId: id, |
| 558 | uuid: hasConnectDb?.uuid || '', | 674 | uuid: hasConnectDb?.uuid || '', |
| 559 | label: dbName, | 675 | label: dbName, |
| @@ -582,6 +698,7 @@ | |||
| 582 | if (list.id == rootId) { | 698 | if (list.id == rootId) { |
| 583 | list.children.push({ | 699 | list.children.push({ |
| 584 | id: databaseId, | 700 | id: databaseId, |
| 701 | + rootId, | ||
| 585 | parentId: rootId, | 702 | parentId: rootId, |
| 586 | uuid: '', | 703 | uuid: '', |
| 587 | label: databaseName, | 704 | label: databaseName, |
| @@ -620,28 +737,30 @@ | |||
| 620 | refreshConnectListMap(); | 737 | refreshConnectListMap(); |
| 621 | }; | 738 | }; |
| 622 | 739 | ||
| 623 | - const fetchSchemaList = async (parentId, databaseId, databaseName, uuid, connectInfo) => { | 740 | + const fetchSchemaList = async (rootId, parentId, databaseId, databaseName, uuid, connectInfo) => { |
| 624 | const data = (await getSchemaList({ | 741 | const data = (await getSchemaList({ |
| 625 | uuid, | 742 | uuid, |
| 626 | connectionName: connectInfo.name, | 743 | connectionName: connectInfo.name, |
| 627 | webUser: UserStore.userId, | 744 | webUser: UserStore.userId, |
| 628 | - })) as unknown as string[]; | 745 | + })) as unknown as FetchNode[]; |
| 629 | const schemaList = []; | 746 | const schemaList = []; |
| 630 | - data.forEach((schemaName) => { | 747 | + data.forEach((item) => { |
| 631 | const obj = { | 748 | const obj = { |
| 632 | - id: `${parentId}_${schemaName}`, | 749 | + id: `${parentId}_${item.oid}`, |
| 750 | + oid: item.oid, | ||
| 751 | + rootId, | ||
| 633 | parentId, | 752 | parentId, |
| 634 | - label: schemaName, | 753 | + label: item.name, |
| 635 | - name: schemaName, | 754 | + name: item.name, |
| 636 | connectInfo, | 755 | connectInfo, |
| 637 | databaseName, | 756 | databaseName, |
| 638 | databaseId, | 757 | databaseId, |
| 639 | uuid, | 758 | uuid, |
| 640 | - type: schemaName === 'public' ? 'public' : 'person', | 759 | + type: item.name === 'public' ? 'public' : 'person', |
| 641 | isLeaf: false, | 760 | isLeaf: false, |
| 642 | children: [], | 761 | children: [], |
| 643 | }; | 762 | }; |
| 644 | - schemaName === 'public' ? schemaList.unshift(obj) : schemaList.push(obj); | 763 | + item.name === 'public' ? schemaList.unshift(obj) : schemaList.push(obj); |
| 645 | }); | 764 | }); |
| 646 | const dbNode = findNode({ rootId: connectInfo.id, databaseId }); | 765 | const dbNode = findNode({ rootId: connectInfo.id, databaseId }); |
| 647 | dbNode.children = schemaList; | 766 | dbNode.children = schemaList; |
| @@ -650,6 +769,7 @@ | |||
| 650 | }; | 769 | }; |
| 651 | 770 | ||
| 652 | const fetchSchemaContentList = async ( | 771 | const fetchSchemaContentList = async ( |
| 772 | + rootId, | ||
| 653 | parentId, | 773 | parentId, |
| 654 | uuid, | 774 | uuid, |
| 655 | databaseId, | 775 | databaseId, |
| @@ -668,6 +788,7 @@ | |||
| 668 | if (data.length) { | 788 | if (data.length) { |
| 669 | arr = handleSchemaList( | 789 | arr = handleSchemaList( |
| 670 | data[0], | 790 | data[0], |
| 791 | + rootId, | ||
| 671 | parentId, | 792 | parentId, |
| 672 | uuid, | 793 | uuid, |
| 673 | databaseId, | 794 | databaseId, |
| @@ -682,6 +803,7 @@ | |||
| 682 | // User Mode - public/no public | 803 | // User Mode - public/no public |
| 683 | const handleSchemaList = ( | 804 | const handleSchemaList = ( |
| 684 | obj, | 805 | obj, |
| 806 | + rootId, | ||
| 685 | parentId, | 807 | parentId, |
| 686 | uuid, | 808 | uuid, |
| 687 | databaseId, | 809 | databaseId, |
| @@ -702,6 +824,7 @@ | |||
| 702 | const keyId = `${parentId}_${key}`; | 824 | const keyId = `${parentId}_${key}`; |
| 703 | array.push({ | 825 | array.push({ |
| 704 | id: keyId, | 826 | id: keyId, |
| 827 | + rootId, | ||
| 705 | parentId, | 828 | parentId, |
| 706 | uuid, | 829 | uuid, |
| 707 | label: `${label} (${obj[key].length})`, | 830 | label: `${label} (${obj[key].length})`, |
| @@ -716,6 +839,7 @@ | |||
| 716 | children: handleTypeList( | 839 | children: handleTypeList( |
| 717 | obj[key], | 840 | obj[key], |
| 718 | childType, | 841 | childType, |
| 842 | + rootId, | ||
| 719 | keyId, | 843 | keyId, |
| 720 | uuid, | 844 | uuid, |
| 721 | databaseId, | 845 | databaseId, |
| @@ -765,6 +889,7 @@ | |||
| 765 | const handleTypeList = ( | 889 | const handleTypeList = ( |
| 766 | array, | 890 | array, |
| 767 | childType, | 891 | childType, |
| 892 | + rootId, | ||
| 768 | parentId, | 893 | parentId, |
| 769 | uuid, | 894 | uuid, |
| 770 | databaseId, | 895 | databaseId, |
| @@ -773,12 +898,15 @@ | |||
| 773 | schemaName, | 898 | schemaName, |
| 774 | connectInfo, | 899 | connectInfo, |
| 775 | ) => { | 900 | ) => { |
| 776 | - return array.map((item) => ({ | 901 | + return array.map((item: FetchNode) => ({ |
| 777 | - id: `${parentId}_${item}`, | 902 | + id: `${parentId}_${item.oid}`, |
| 903 | + oid: item.oid, | ||
| 904 | + parttype: item.parttype, | ||
| 905 | + rootId, | ||
| 778 | parentId, | 906 | parentId, |
| 779 | uuid, | 907 | uuid, |
| 780 | - label: item, | 908 | + label: item.name, |
| 781 | - name: item, | 909 | + name: item.name, |
| 782 | type: childType, | 910 | type: childType, |
| 783 | databaseId, | 911 | databaseId, |
| 784 | databaseName, | 912 | databaseName, |
| @@ -845,13 +973,10 @@ | |||
| 845 | const db = currentContextNodeData.children[i]; | 973 | const db = currentContextNodeData.children[i]; |
| 846 | db.isConnect && (await closeConnections(db.uuid)); | 974 | db.isConnect && (await closeConnections(db.uuid)); |
| 847 | } | 975 | } |
| 848 | - // const index = connectionList.value.findIndex((item) => item.id == currentContextNodeData.id); | ||
| 849 | treeRef.value.remove(treeRef.value.getNode(currentContextNodeData.id)); | 976 | treeRef.value.remove(treeRef.value.getNode(currentContextNodeData.id)); |
| 850 | - // index > -1 && connectionList.value.splice(index, 1); | ||
| 851 | updateConnectListPersist(); | 977 | updateConnectListPersist(); |
| 852 | refreshConnectListMap(); | 978 | refreshConnectListMap(); |
| 853 | if (connectionList.value.length == 0) { | 979 | if (connectionList.value.length == 0) { |
| 854 | - // EventBus.notify(EventTypeName.CLOSE_ALL_TAB); | ||
| 855 | router.push('/home'); | 980 | router.push('/home'); |
| 856 | } | 981 | } |
| 857 | AppStore.currentConnectNode = | 982 | AppStore.currentConnectNode = |
| @@ -933,6 +1058,7 @@ | |||
| 933 | path: '/createTerminal/' + time, | 1058 | path: '/createTerminal/' + time, |
| 934 | query: { | 1059 | query: { |
| 935 | title, | 1060 | title, |
| 1061 | + fileName: title, | ||
| 936 | rootId, | 1062 | rootId, |
| 937 | connectInfoName, | 1063 | connectInfoName, |
| 938 | uuid: currentContextNodeData.uuid, | 1064 | uuid: currentContextNodeData.uuid, |
| @@ -1002,14 +1128,42 @@ | |||
| 1002 | treeContext.databaseVisible = false; | 1128 | treeContext.databaseVisible = false; |
| 1003 | showDbInfoDialog.value = true; | 1129 | showDbInfoDialog.value = true; |
| 1004 | }; | 1130 | }; |
| 1005 | - interface RefreshOptions { | 1131 | + const handleSchema = (type: 'create' | 'edit' | 'delete') => { |
| 1006 | - connectInfo: ConnectInfo | undefined; | 1132 | + treeContext.databaseVisible = false; |
| 1007 | - rootId: string; | 1133 | + treeContext.modeVisible = false; |
| 1008 | - uuid: string; | 1134 | + if (type == 'create') { |
| 1009 | - databaseId: string; | 1135 | + createSchemaType.value = 'create'; |
| 1010 | - schemaId: string; | 1136 | + Object.assign(createSchemaData, { |
| 1011 | - nodeId: string; | 1137 | + databaseName: currentContextNodeData.label, |
| 1012 | - } | 1138 | + databaseId: currentContextNodeData.id, |
| 1139 | + oid: '', | ||
| 1140 | + owner: currentContextNodeData.connectInfo.userName, | ||
| 1141 | + }); | ||
| 1142 | + showCreateSchemaDialog.value = true; | ||
| 1143 | + } else if (type == 'edit') { | ||
| 1144 | + createSchemaType.value = 'edit'; | ||
| 1145 | + Object.assign(createSchemaData, { | ||
| 1146 | + databaseName: currentContextNodeData.databaseName, | ||
| 1147 | + databaseId: currentContextNodeData.databaseId, | ||
| 1148 | + oid: currentContextNodeData.oid, | ||
| 1149 | + owner: currentContextNodeData.connectInfo.userName, | ||
| 1150 | + }); | ||
| 1151 | + showCreateSchemaDialog.value = true; | ||
| 1152 | + } else { | ||
| 1153 | + ElMessageBox.confirm(t('message.deleteMode', { name: currentContextNodeData.label })).then( | ||
| 1154 | + async () => { | ||
| 1155 | + await deleteSchema({ | ||
| 1156 | + uuid: currentContextNodeData.uuid, | ||
| 1157 | + schemaName: currentContextNodeData.name, | ||
| 1158 | + }); | ||
| 1159 | + ElMessage.success(t('message.deleteSuccess')); | ||
| 1160 | + const rootId = currentContextNodeData.connectInfo.id; | ||
| 1161 | + refresh('database', { rootId, databaseId: currentContextNodeData.databaseId }); | ||
| 1162 | + }, | ||
| 1163 | + ); | ||
| 1164 | + } | ||
| 1165 | + }; | ||
| 1166 | + | ||
| 1013 | const refresh = async ( | 1167 | const refresh = async ( |
| 1014 | mode: 'connection' | 'database' | 'mode', | 1168 | mode: 'connection' | 'database' | 'mode', |
| 1015 | options: Partial<RefreshOptions> = { | 1169 | options: Partial<RefreshOptions> = { |
| @@ -1059,6 +1213,12 @@ | |||
| 1059 | }); | 1213 | }); |
| 1060 | }; | 1214 | }; |
| 1061 | 1215 | ||
| 1216 | + const createSchemaSuccess = () => { | ||
| 1217 | + showCreateSchemaDialog.value = false; | ||
| 1218 | + const rootId = currentContextNodeData.connectInfo.id; | ||
| 1219 | + refresh('database', { rootId, databaseId: createSchemaData.databaseId }); | ||
| 1220 | + }; | ||
| 1221 | + | ||
| 1062 | const filterNode = (value: string, data: Tree) => { | 1222 | const filterNode = (value: string, data: Tree) => { |
| 1063 | if (!value) return true; | 1223 | if (!value) return true; |
| 1064 | if (!data.label) return false; | 1224 | if (!data.label) return false; |
| @@ -1079,23 +1239,28 @@ | |||
| 1079 | uuid, | 1239 | uuid, |
| 1080 | dbname: databaseName, | 1240 | dbname: databaseName, |
| 1081 | schema: schemaName, | 1241 | schema: schemaName, |
| 1242 | + fileName: target.label.slice( | ||
| 1243 | + 0, | ||
| 1244 | + target.label.indexOf('(') > -1 ? target.label.indexOf('(') : target.label.length, | ||
| 1245 | + ), | ||
| 1246 | + oid: target.oid, | ||
| 1082 | }; | 1247 | }; |
| 1083 | if (target.type == 'table') { | 1248 | if (target.type == 'table') { |
| 1084 | router.push({ | 1249 | router.push({ |
| 1085 | path: `/table/${target.id}`, | 1250 | path: `/table/${target.id}`, |
| 1086 | query: { | 1251 | query: { |
| 1087 | - tableName: target.label, | ||
| 1088 | ...commonParams, | 1252 | ...commonParams, |
| 1253 | + parttype: target.parttype, | ||
| 1254 | + time: String(Date.now()), | ||
| 1089 | }, | 1255 | }, |
| 1090 | }); | 1256 | }); |
| 1091 | } else if (target.type == 'terminal') { | 1257 | } else if (target.type == 'terminal') { |
| 1092 | setTimeout(() => { | 1258 | setTimeout(() => { |
| 1093 | const terminalNum = TagsViewStore.maxTerminalNum + 1; | 1259 | const terminalNum = TagsViewStore.maxTerminalNum + 1; |
| 1094 | - const time = Date.now(); | 1260 | + const time = String(Date.now()); |
| 1095 | router.push({ | 1261 | router.push({ |
| 1096 | path: `/debug/${encodeURIComponent(target.id)}`, | 1262 | path: `/debug/${encodeURIComponent(target.id)}`, |
| 1097 | query: { | 1263 | query: { |
| 1098 | - funcname: target.label, | ||
| 1099 | terminalNum, | 1264 | terminalNum, |
| 1100 | ...commonParams, | 1265 | ...commonParams, |
| 1101 | time, | 1266 | time, |
| @@ -1144,11 +1309,13 @@ | |||
| 1144 | rootVisible: false, | 1309 | rootVisible: false, |
| 1145 | databaseVisible: false, | 1310 | databaseVisible: false, |
| 1146 | modeVisible: false, | 1311 | modeVisible: false, |
| 1312 | + tableCollectVisible: false, | ||
| 1147 | terminalCollectVisible: false, | 1313 | terminalCollectVisible: false, |
| 1148 | functionSPVisible: false, | 1314 | functionSPVisible: false, |
| 1149 | viewCollectVisible: false, | 1315 | viewCollectVisible: false, |
| 1150 | synonymCollectVisible: false, | 1316 | synonymCollectVisible: false, |
| 1151 | sequenceCollectVisible: false, | 1317 | sequenceCollectVisible: false, |
| 1318 | + tableVisible: false, | ||
| 1152 | viewVisible: false, | 1319 | viewVisible: false, |
| 1153 | sequenceVisible: false, | 1320 | sequenceVisible: false, |
| 1154 | synonymVisible: false, | 1321 | synonymVisible: false, |
| @@ -1165,6 +1332,11 @@ | |||
| 1165 | (listItem) => listItem.id === currentContextNodeData.connectInfo.id, | 1332 | (listItem) => listItem.id === currentContextNodeData.connectInfo.id, |
| 1166 | )?.connectedDatabase[0]?.uuid; | 1333 | )?.connectedDatabase[0]?.uuid; |
| 1167 | }); | 1334 | }); |
| 1335 | + const hideTreeContext = () => { | ||
| 1336 | + Object.keys(treeContext).forEach((key) => { | ||
| 1337 | + if (key.indexOf('Visible') !== -1 && treeContext[key] === true) treeContext[key] = false; | ||
| 1338 | + }); | ||
| 1339 | + }; | ||
| 1168 | const handleContextmenu = (event, data) => { | 1340 | const handleContextmenu = (event, data) => { |
| 1169 | const type = data.type; | 1341 | const type = data.type; |
| 1170 | Object.assign(currentContextNodeData, data); | 1342 | Object.assign(currentContextNodeData, data); |
| @@ -1172,14 +1344,14 @@ | |||
| 1172 | top: event.y + 2 + 'px', | 1344 | top: event.y + 2 + 'px', |
| 1173 | left: event.x + 2 + 'px', | 1345 | left: event.x + 2 + 'px', |
| 1174 | }; | 1346 | }; |
| 1175 | - Object.keys(treeContext).forEach((item) => { | 1347 | + hideTreeContext(); |
| 1176 | - if (item.indexOf('Visible') !== -1) treeContext[item] = false; | ||
| 1177 | - }); | ||
| 1178 | const typeMap = { | 1348 | const typeMap = { |
| 1179 | root: 'rootVisible', | 1349 | root: 'rootVisible', |
| 1180 | database: 'databaseVisible', | 1350 | database: 'databaseVisible', |
| 1181 | public: 'modeVisible', | 1351 | public: 'modeVisible', |
| 1182 | person: 'modeVisible', | 1352 | person: 'modeVisible', |
| 1353 | + tableCollect: 'tableCollectVisible', | ||
| 1354 | + table: 'tableVisible', | ||
| 1183 | terminalCollect: 'terminalCollectVisible', | 1355 | terminalCollect: 'terminalCollectVisible', |
| 1184 | terminal: 'functionSPVisible', | 1356 | terminal: 'functionSPVisible', |
| 1185 | viewCollect: 'viewCollectVisible', | 1357 | viewCollect: 'viewCollectVisible', |
| @@ -1193,6 +1365,27 @@ | |||
| 1193 | treeContext[typeMap[type]] = true; | 1365 | treeContext[typeMap[type]] = true; |
| 1194 | } | 1366 | } |
| 1195 | }; | 1367 | }; |
| 1368 | + const hanldeCreateTable = () => { | ||
| 1369 | + const time = Date.now(); | ||
| 1370 | + const connectInfo: any = currentContextNodeData.connectInfo; | ||
| 1371 | + router.push({ | ||
| 1372 | + path: '/createTable/' + time, | ||
| 1373 | + query: { | ||
| 1374 | + title: 'create_table', | ||
| 1375 | + fileName: 'create_table', | ||
| 1376 | + rootId: connectInfo.id, | ||
| 1377 | + connectInfoName: connectInfo.name, | ||
| 1378 | + connectInfoId: connectInfo.id, | ||
| 1379 | + uuid: currentContextNodeData.uuid, | ||
| 1380 | + databaseName: currentContextNodeData.databaseName, | ||
| 1381 | + databaseId: currentContextNodeData.databaseId, | ||
| 1382 | + schema: currentContextNodeData.schemaName, | ||
| 1383 | + schemaId: currentContextNodeData.schemaId, | ||
| 1384 | + time, | ||
| 1385 | + }, | ||
| 1386 | + }); | ||
| 1387 | + treeContext.tableCollectVisible = false; | ||
| 1388 | + }; | ||
| 1196 | const hanldeCreate = (type: 'function' | 'procedure' | 'sql') => { | 1389 | const hanldeCreate = (type: 'function' | 'procedure' | 'sql') => { |
| 1197 | enum titleMap { | 1390 | enum titleMap { |
| 1198 | function = 'create_F', | 1391 | function = 'create_F', |
| @@ -1206,6 +1399,7 @@ | |||
| 1206 | query: { | 1399 | query: { |
| 1207 | type, | 1400 | type, |
| 1208 | title: titleMap[type], | 1401 | title: titleMap[type], |
| 1402 | + fileName: titleMap[type], | ||
| 1209 | dbname: connectInfo.dataName, | 1403 | dbname: connectInfo.dataName, |
| 1210 | connectInfoName: connectInfo.name, | 1404 | connectInfoName: connectInfo.name, |
| 1211 | connectInfoId: connectInfo.id, | 1405 | connectInfoId: connectInfo.id, |
| @@ -1267,6 +1461,7 @@ | |||
| 1267 | [type + 'Name']: currentContextNodeData.label, | 1461 | [type + 'Name']: currentContextNodeData.label, |
| 1268 | webUser: UserStore.userId, | 1462 | webUser: UserStore.userId, |
| 1269 | uuid: currentContextNodeData.uuid, | 1463 | uuid: currentContextNodeData.uuid, |
| 1464 | + oid: currentContextNodeData.oid, | ||
| 1270 | }; | 1465 | }; |
| 1271 | await api(params); | 1466 | await api(params); |
| 1272 | ElMessage.success(t('message.deleteSuccess')); | 1467 | ElMessage.success(t('message.deleteSuccess')); |
| @@ -1274,6 +1469,139 @@ | |||
| 1274 | }); | 1469 | }); |
| 1275 | }; | 1470 | }; |
| 1276 | 1471 | ||
| 1472 | + const handleExport = async ( | ||
| 1473 | + type: | ||
| 1474 | + | 'modeDDL' | ||
| 1475 | + | 'modeDDLData' | ||
| 1476 | + | 'tableDDL' | ||
| 1477 | + | 'tableData' | ||
| 1478 | + | 'tableDDLData' | ||
| 1479 | + | 'functionDDL' | ||
| 1480 | + | 'viewDDL' | ||
| 1481 | + | 'sequenceDDL' | ||
| 1482 | + | 'sequenceDDLData', | ||
| 1483 | + ) => { | ||
| 1484 | + const visibleString = { | ||
| 1485 | + modeDDL: 'modeVisible', | ||
| 1486 | + modeDDLData: 'modeVisible', | ||
| 1487 | + tableDDL: 'tableVisible', | ||
| 1488 | + tableData: 'tableVisible', | ||
| 1489 | + tableDDLData: 'tableVisible', | ||
| 1490 | + functionDDL: 'functionSPVisible', | ||
| 1491 | + viewDDL: 'viewVisible', | ||
| 1492 | + sequenceDDL: 'sequenceVisible', | ||
| 1493 | + sequenceDDLData: 'sequenceVisible', | ||
| 1494 | + }; | ||
| 1495 | + treeContext[visibleString[type]] = false; | ||
| 1496 | + const { uuid, schemaName: schema, oid, name } = currentContextNodeData; | ||
| 1497 | + if (type == 'tableData') { | ||
| 1498 | + exportTableDialog.value = true; | ||
| 1499 | + } else { | ||
| 1500 | + const obj = { | ||
| 1501 | + modeDDL: { | ||
| 1502 | + api: exportSchemaDdl, | ||
| 1503 | + params: { | ||
| 1504 | + uuid, | ||
| 1505 | + schema: name, | ||
| 1506 | + schemaList: [name], | ||
| 1507 | + }, | ||
| 1508 | + }, | ||
| 1509 | + modeDDLData: { | ||
| 1510 | + api: exportSchemaDdl, | ||
| 1511 | + params: { | ||
| 1512 | + uuid, | ||
| 1513 | + schema: name, | ||
| 1514 | + dataFlag: true, | ||
| 1515 | + schemaList: [name], | ||
| 1516 | + }, | ||
| 1517 | + }, | ||
| 1518 | + tableDDL: { | ||
| 1519 | + api: exportTableDdl, | ||
| 1520 | + params: { | ||
| 1521 | + uuid, | ||
| 1522 | + schema, | ||
| 1523 | + dataFlag: false, | ||
| 1524 | + tableList: [name], | ||
| 1525 | + }, | ||
| 1526 | + }, | ||
| 1527 | + tableDDLData: { | ||
| 1528 | + api: exportTableDdl, | ||
| 1529 | + params: { | ||
| 1530 | + uuid, | ||
| 1531 | + schema, | ||
| 1532 | + dataFlag: true, | ||
| 1533 | + tableList: [name], | ||
| 1534 | + }, | ||
| 1535 | + }, | ||
| 1536 | + functionDDL: { | ||
| 1537 | + api: exportFunctionDdl, | ||
| 1538 | + params: { | ||
| 1539 | + uuid, | ||
| 1540 | + schema, | ||
| 1541 | + functionMap: [oid], | ||
| 1542 | + }, | ||
| 1543 | + }, | ||
| 1544 | + viewDDL: { | ||
| 1545 | + api: exportViewDdl, | ||
| 1546 | + params: { | ||
| 1547 | + uuid, | ||
| 1548 | + schema, | ||
| 1549 | + viewList: [name], | ||
| 1550 | + }, | ||
| 1551 | + }, | ||
| 1552 | + sequenceDDL: { | ||
| 1553 | + api: exportSequenceDdl, | ||
| 1554 | + params: { | ||
| 1555 | + uuid, | ||
| 1556 | + schema, | ||
| 1557 | + sequenceList: [name], | ||
| 1558 | + }, | ||
| 1559 | + }, | ||
| 1560 | + sequenceDDLData: { | ||
| 1561 | + api: exportSequenceDdl, | ||
| 1562 | + params: { | ||
| 1563 | + uuid, | ||
| 1564 | + schema, | ||
| 1565 | + dataFlag: true, | ||
| 1566 | + sequenceList: [name], | ||
| 1567 | + }, | ||
| 1568 | + }, | ||
| 1569 | + }; | ||
| 1570 | + const { api, params } = obj[type]; | ||
| 1571 | + loading.value = loadingInstance(); | ||
| 1572 | + try { | ||
| 1573 | + const res = await api(params); | ||
| 1574 | + downLoadMyBlobType(res.name, res.data); | ||
| 1575 | + } finally { | ||
| 1576 | + loading.value.close(); | ||
| 1577 | + } | ||
| 1578 | + } | ||
| 1579 | + }; | ||
| 1580 | + | ||
| 1581 | + const handleTableRename = () => { | ||
| 1582 | + treeContext.tableVisible = false; | ||
| 1583 | + renameTableDialog.value = true; | ||
| 1584 | + }; | ||
| 1585 | + const handleUpdateTableDescription = () => { | ||
| 1586 | + treeContext.tableVisible = false; | ||
| 1587 | + updateTableDescriptionDialog.value = true; | ||
| 1588 | + }; | ||
| 1589 | + const handleSetTablespace = () => { | ||
| 1590 | + treeContext.tableVisible = false; | ||
| 1591 | + setTablespaceDialog.value = true; | ||
| 1592 | + }; | ||
| 1593 | + const handleSetTableSchema = () => { | ||
| 1594 | + treeContext.tableVisible = false; | ||
| 1595 | + setTableSchemaDialog.value = true; | ||
| 1596 | + }; | ||
| 1597 | + | ||
| 1598 | + const { handleReindex, handleTruncate, handleVacuum, handleDropTable, handleRelatedSequence } = | ||
| 1599 | + useSidebarContext({ | ||
| 1600 | + // treeContext, | ||
| 1601 | + currentContextNodeData, | ||
| 1602 | + hideTreeContext, | ||
| 1603 | + }); | ||
| 1604 | + | ||
| 1277 | const resetExpandNodes = () => { | 1605 | const resetExpandNodes = () => { |
| 1278 | connectionList.value.forEach((level1) => { | 1606 | connectionList.value.forEach((level1) => { |
| 1279 | connectionList.value.length <= 1 | 1607 | connectionList.value.length <= 1 |
| @@ -1329,7 +1657,6 @@ | |||
| 1329 | onMounted(async () => { | 1657 | onMounted(async () => { |
| 1330 | // maybe update database list, and schema, databaseName... so must close all tabs. | 1658 | // maybe update database list, and schema, databaseName... so must close all tabs. |
| 1331 | EventBus.listen(EventTypeName.GET_DATABASE_LIST, async (connectData) => { | 1659 | EventBus.listen(EventTypeName.GET_DATABASE_LIST, async (connectData) => { |
| 1332 | - EventBus.notify(EventTypeName.CLOSE_ALL_TAB_TO_LAST); | ||
| 1333 | connectData && Object.assign(connectInfo, connectData); | 1660 | connectData && Object.assign(connectInfo, connectData); |
| 1334 | const { connectionid, ...info } = connectData; | 1661 | const { connectionid, ...info } = connectData; |
| 1335 | const isRepeatIndex = AppStore.connectListMap.findIndex((item) => item.id == connectData.id); | 1662 | const isRepeatIndex = AppStore.connectListMap.findIndex((item) => item.id == connectData.id); |
| @@ -1349,7 +1676,21 @@ | |||
| 1349 | ? AppStore.connectListMap.splice(isRepeatIndex, 1, connectListMapItem) | 1676 | ? AppStore.connectListMap.splice(isRepeatIndex, 1, connectListMapItem) |
| 1350 | : AppStore.connectListMap.unshift(connectListMapItem); | 1677 | : AppStore.connectListMap.unshift(connectListMapItem); |
| 1351 | await fetchDBList(info, connectionid); | 1678 | await fetchDBList(info, connectionid); |
| 1352 | - parent.location.reload(); | 1679 | + if (!TagsViewStore.visitedViews.find((item) => item.name == 'home' && item.query?.rootId)) { |
| 1680 | + const connectInfoName = AppStore.connectListMap[0].info.name; | ||
| 1681 | + const uuid = AppStore.connectListMap[0].connectedDatabase[0]?.uuid; | ||
| 1682 | + const dbname = AppStore.connectListMap[0].connectedDatabase[0]?.name; | ||
| 1683 | + router.replace({ | ||
| 1684 | + path: '/home', | ||
| 1685 | + query: { | ||
| 1686 | + rootId: AppStore.connectListMap[0].id, | ||
| 1687 | + connectInfoName, | ||
| 1688 | + uuid, | ||
| 1689 | + dbname, | ||
| 1690 | + time: Date.now(), | ||
| 1691 | + }, | ||
| 1692 | + }); | ||
| 1693 | + } | ||
| 1353 | }); | 1694 | }); |
| 1354 | EventBus.listen(EventTypeName.UPDATE_DATABASE_LIST, (connectData) => { | 1695 | EventBus.listen(EventTypeName.UPDATE_DATABASE_LIST, (connectData) => { |
| 1355 | connectData && Object.assign(connectInfo, connectData); | 1696 | connectData && Object.assign(connectInfo, connectData); |
| @@ -1372,11 +1713,15 @@ | |||
| 1372 | : AppStore.connectListMap.unshift(connectListMapItem); | 1713 | : AppStore.connectListMap.unshift(connectListMapItem); |
| 1373 | fetchDBList(info, connectionid); | 1714 | fetchDBList(info, connectionid); |
| 1374 | }); | 1715 | }); |
| 1716 | + EventBus.listen(EventTypeName.REFRESH_ASIDER, async (mode, options) => { | ||
| 1717 | + refresh(mode, options); | ||
| 1718 | + }); | ||
| 1375 | connectionList.value = getAllConnectList(); | 1719 | connectionList.value = getAllConnectList(); |
| 1376 | }); | 1720 | }); |
| 1377 | onUnmounted(() => { | 1721 | onUnmounted(() => { |
| 1378 | EventBus.unListen(EventTypeName.GET_DATABASE_LIST); | 1722 | EventBus.unListen(EventTypeName.GET_DATABASE_LIST); |
| 1379 | EventBus.unListen(EventTypeName.UPDATE_DATABASE_LIST); | 1723 | EventBus.unListen(EventTypeName.UPDATE_DATABASE_LIST); |
| 1724 | + EventBus.unListen(EventTypeName.REFRESH_ASIDER); | ||
| 1380 | }); | 1725 | }); |
| 1381 | </script> | 1726 | </script> |
| 1382 | 1727 | ||
| @@ -1423,124 +1768,5 @@ | |||
| 1423 | } | 1768 | } |
| 1424 | </style> | 1769 | </style> |
| 1425 | <style lang="scss" scoped> | 1770 | <style lang="scss" scoped> |
| 1426 | - @function border-style() { | 1771 | + @import './sidebar.scss'; |
| 1427 | - @return 1px solid #d8d8d8; | ||
| 1428 | - } | ||
| 1429 | - .siderbar { | ||
| 1430 | - display: flex; | ||
| 1431 | - flex-direction: column; | ||
| 1432 | - padding: 8px; | ||
| 1433 | - user-select: none; | ||
| 1434 | - } | ||
| 1435 | - .tree { | ||
| 1436 | - width: fit-content; | ||
| 1437 | - } | ||
| 1438 | - .no-tree { | ||
| 1439 | - width: auto; | ||
| 1440 | - } | ||
| 1441 | - .database-wrapper { | ||
| 1442 | - height: 66%; | ||
| 1443 | - flex-grow: 0; | ||
| 1444 | - } | ||
| 1445 | - | ||
| 1446 | - .windows-wrapper { | ||
| 1447 | - height: calc(34% - 15px); | ||
| 1448 | - margin-top: 15px; | ||
| 1449 | - } | ||
| 1450 | - .group-wrapper { | ||
| 1451 | - border: border-style(); | ||
| 1452 | - display: flex; | ||
| 1453 | - flex-direction: column; | ||
| 1454 | - } | ||
| 1455 | - .icon { | ||
| 1456 | - margin-right: 6px; | ||
| 1457 | - color: #75757e; | ||
| 1458 | - } | ||
| 1459 | - .group-title-contain { | ||
| 1460 | - padding: 3px 5px; | ||
| 1461 | - display: flex; | ||
| 1462 | - justify-content: space-between; | ||
| 1463 | - border-bottom: border-style(); | ||
| 1464 | - .left { | ||
| 1465 | - display: flex; | ||
| 1466 | - align-items: center; | ||
| 1467 | - } | ||
| 1468 | - .icon { | ||
| 1469 | - font-size: 19px; | ||
| 1470 | - } | ||
| 1471 | - .el-icon { | ||
| 1472 | - font-size: 18px; | ||
| 1473 | - color: #75757e; | ||
| 1474 | - cursor: pointer; | ||
| 1475 | - :hover { | ||
| 1476 | - color: var(--el-color-primary); | ||
| 1477 | - } | ||
| 1478 | - } | ||
| 1479 | - } | ||
| 1480 | - .group-search-contain { | ||
| 1481 | - margin: 5px; | ||
| 1482 | - } | ||
| 1483 | - .group-main-contain { | ||
| 1484 | - flex: 1; | ||
| 1485 | - overflow: auto; | ||
| 1486 | - margin: 5px; | ||
| 1487 | - margin-top: 0; | ||
| 1488 | - border: border-style(); | ||
| 1489 | - border-radius: 4px; | ||
| 1490 | - position: relative; | ||
| 1491 | - } | ||
| 1492 | - .windows-list { | ||
| 1493 | - width: fit-content; | ||
| 1494 | - .windows-item { | ||
| 1495 | - white-space: nowrap; | ||
| 1496 | - cursor: pointer; | ||
| 1497 | - margin: 3px; | ||
| 1498 | - padding: 5px; | ||
| 1499 | - &:hover { | ||
| 1500 | - background: var(--el-bg-color-bar); | ||
| 1501 | - } | ||
| 1502 | - &.home, | ||
| 1503 | - &.home .icon { | ||
| 1504 | - color: var(--el-color-primary); | ||
| 1505 | - } | ||
| 1506 | - &.active { | ||
| 1507 | - background-color: var(--normal-color); | ||
| 1508 | - } | ||
| 1509 | - &.active, | ||
| 1510 | - &.active .icon { | ||
| 1511 | - color: var(--color-bg-2); | ||
| 1512 | - } | ||
| 1513 | - } | ||
| 1514 | - } | ||
| 1515 | - | ||
| 1516 | - .context-menu { | ||
| 1517 | - position: fixed; | ||
| 1518 | - z-index: 100; | ||
| 1519 | - box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12); | ||
| 1520 | - ul { | ||
| 1521 | - padding: 3px 0; | ||
| 1522 | - margin: 0; | ||
| 1523 | - list-style-type: none; | ||
| 1524 | - border-radius: 4px; | ||
| 1525 | - background-color: var(--el-bg-color-overlay); | ||
| 1526 | - } | ||
| 1527 | - li { | ||
| 1528 | - padding: 2px 12px; | ||
| 1529 | - line-height: 20px; | ||
| 1530 | - display: flex; | ||
| 1531 | - align-items: center; | ||
| 1532 | - white-space: nowrap; | ||
| 1533 | - list-style: none; | ||
| 1534 | - margin: 0; | ||
| 1535 | - cursor: pointer; | ||
| 1536 | - outline: 0; | ||
| 1537 | - &.disabled { | ||
| 1538 | - color: var(--color-text-4); | ||
| 1539 | - cursor: not-allowed; | ||
| 1540 | - } | ||
| 1541 | - &:not(.disabled):hover { | ||
| 1542 | - background-color: var(--color-fill-2); | ||
| 1543 | - } | ||
| 1544 | - } | ||
| 1545 | - } | ||
| 1546 | </style> | 1772 | </style> |
| @@ -0,0 +1,58 @@ | |||
| 1 | +export interface Tree { | ||
| 2 | + id: string; | ||
| 3 | + rootId: string; | ||
| 4 | + parentId: string; | ||
| 5 | + label: string; | ||
| 6 | + name: string; | ||
| 7 | + isLeaf?: boolean; | ||
| 8 | + children?: Tree[]; | ||
| 9 | + type?: string; | ||
| 10 | + isConnect?: boolean; | ||
| 11 | + connectTime: null | number; | ||
| 12 | + uuid?: string; | ||
| 13 | + connectInfo: ConnectInfo; | ||
| 14 | +} | ||
| 15 | +export interface FetchNode { | ||
| 16 | + name: string; | ||
| 17 | + oid: string; | ||
| 18 | + parttype?: 'n' | 'y' | ''; | ||
| 19 | +} | ||
| 20 | +export interface ConnectInfo { | ||
| 21 | + name: string; | ||
| 22 | + id: string; | ||
| 23 | + ip: string; | ||
| 24 | + port: string; | ||
| 25 | + userName: string; | ||
| 26 | + uuid?: string; | ||
| 27 | + type?: string; | ||
| 28 | + driver?: ''; | ||
| 29 | + password?: string; | ||
| 30 | + webUser: string; | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +export interface NodeData { | ||
| 34 | + id: string; | ||
| 35 | + type: string; | ||
| 36 | + connectInfo: ConnectInfo; | ||
| 37 | + rootId: string; | ||
| 38 | + parentId: string | null; | ||
| 39 | + uuid: string; | ||
| 40 | + databaseId: string; | ||
| 41 | + databaseName: string; | ||
| 42 | + schemaId: string; | ||
| 43 | + schemaName: string; | ||
| 44 | + oid: string; | ||
| 45 | + label: string; | ||
| 46 | + name: string; | ||
| 47 | + children?: NodeData[]; | ||
| 48 | + [key: string]: any; | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +export interface RefreshOptions { | ||
| 52 | + connectInfo: ConnectInfo | undefined; | ||
| 53 | + rootId: string; | ||
| 54 | + uuid: string; | ||
| 55 | + databaseId: string; | ||
| 56 | + schemaId: string; | ||
| 57 | + nodeId: string; | ||
| 58 | +} | ||
| @@ -8,7 +8,6 @@ | |||
| 8 | </template> | 8 | </template> |
| 9 | 9 | ||
| 10 | <script setup lang="ts"> | 10 | <script setup lang="ts"> |
| 11 | - import { ref, watch, onMounted, nextTick } from 'vue'; | ||
| 12 | import { useElementSize } from '@vueuse/core'; | 11 | import { useElementSize } from '@vueuse/core'; |
| 13 | import BScroll from '@better-scroll/core'; | 12 | import BScroll from '@better-scroll/core'; |
| 14 | import type { Options } from '@better-scroll/core'; | 13 | import type { Options } from '@better-scroll/core'; |
| @@ -30,7 +30,7 @@ | |||
| 30 | @contextmenu.prevent="handleContextmenu($event, tag)" | 30 | @contextmenu.prevent="handleContextmenu($event, tag)" |
| 31 | > | 31 | > |
| 32 | <svg-icon :icon-class="tag.meta.icon" class-name="pre-icon" /> | 32 | <svg-icon :icon-class="tag.meta.icon" class-name="pre-icon" /> |
| 33 | - <div class="tags-view-item">{{ tag.title }}</div> | 33 | + <div class="tags-view-item" :title="tag.title">{{ tag.query.fileName }}</div> |
| 34 | <el-icon | 34 | <el-icon |
| 35 | v-if="!isAffix(tag)" | 35 | v-if="!isAffix(tag)" |
| 36 | @click.prevent.stop="closeSelectedTagToLastView(tag)" | 36 | @click.prevent.stop="closeSelectedTagToLastView(tag)" |
| @@ -63,7 +63,6 @@ | |||
| 63 | </template> | 63 | </template> |
| 64 | 64 | ||
| 65 | <script lang="ts" setup name="TagsView"> | 65 | <script lang="ts" setup name="TagsView"> |
| 66 | - import { computed, nextTick, onMounted, onUnmounted, reactive, ref, watch } from 'vue'; | ||
| 67 | import { ElMessage } from 'element-plus'; | 66 | import { ElMessage } from 'element-plus'; |
| 68 | import betterScroll from './betterScroll.vue'; | 67 | import betterScroll from './betterScroll.vue'; |
| 69 | import LangButton from '@/components/LangButton.vue'; | 68 | import LangButton from '@/components/LangButton.vue'; |
| @@ -76,8 +75,10 @@ | |||
| 76 | import { useI18n } from 'vue-i18n'; | 75 | import { useI18n } from 'vue-i18n'; |
| 77 | import vClickOutside from '@/directives/clickOutside'; | 76 | import vClickOutside from '@/directives/clickOutside'; |
| 78 | import EventBus, { EventTypeName } from '@/utils/event-bus'; | 77 | import EventBus, { EventTypeName } from '@/utils/event-bus'; |
| 79 | - | ||
| 80 | import path from 'path-browserify'; | 78 | import path from 'path-browserify'; |
| 79 | + import { handleEventQueueProcedure, updateEventQueue } from '@/hooks/saveData'; | ||
| 80 | + import { refreshRunningTags, deleteRunningTag } from '@/hooks/tagRunning'; | ||
| 81 | + | ||
| 81 | const route = useRoute(); | 82 | const route = useRoute(); |
| 82 | const router = useRouter(); | 83 | const router = useRouter(); |
| 83 | const TagsViewStore = useTagsViewStore(); | 84 | const TagsViewStore = useTagsViewStore(); |
| @@ -207,39 +208,59 @@ | |||
| 207 | TagsViewStore.delViewById(viewId); | 208 | TagsViewStore.delViewById(viewId); |
| 208 | }; | 209 | }; |
| 209 | 210 | ||
| 210 | - const closeSelectedTagToLastView = (view) => { | 211 | + const closeSelectedTagToLastView = async (view) => { |
| 211 | contextMenu.visible = false; | 212 | contextMenu.visible = false; |
| 212 | - closeSelectedTag(view); | 213 | + if (view.name == 'debugChild') { |
| 213 | - if (isActive(view)) { | 214 | + return ElMessage.error(t('message.debugCannotFinish')); |
| 214 | - toLastView(visitedViews.value, view); | 215 | + } |
| 216 | + if (deleteRunningTag(view.id)) { | ||
| 217 | + await handleEventQueueProcedure(view); | ||
| 218 | + closeSelectedTag(view); | ||
| 219 | + updateEventQueue(); | ||
| 220 | + if (isActive(view)) { | ||
| 221 | + toLastView(visitedViews.value, view); | ||
| 222 | + } | ||
| 215 | } | 223 | } |
| 216 | }; | 224 | }; |
| 217 | 225 | ||
| 218 | const closeCurrentTab = () => { | 226 | const closeCurrentTab = () => { |
| 219 | - closeSelectedTagToLastView(contextTag.value); | 227 | + contextMenu.visible = false; |
| 228 | + if (contextTag.value.name == 'debugChild') { | ||
| 229 | + return ElMessage.error(t('message.debugCannotFinish')); | ||
| 230 | + } | ||
| 231 | + if (deleteRunningTag(contextTag.value.id)) { | ||
| 232 | + closeSelectedTagToLastView(contextTag.value); | ||
| 233 | + } | ||
| 220 | }; | 234 | }; |
| 221 | 235 | ||
| 222 | const closeOtherTab = async () => { | 236 | const closeOtherTab = async () => { |
| 223 | contextMenu.visible = false; | 237 | contextMenu.visible = false; |
| 224 | const { path, name } = contextTag.value; | 238 | const { path, name } = contextTag.value; |
| 225 | for (let item of visitedViews.value) { | 239 | for (let item of visitedViews.value) { |
| 226 | - if (item.path !== path) { | 240 | + if (item.path !== path && deleteRunningTag(item.id) && item.name !== 'debugChild') { |
| 241 | + await handleEventQueueProcedure(item); | ||
| 227 | TagsViewStore.delView(item); | 242 | TagsViewStore.delView(item); |
| 228 | } | 243 | } |
| 229 | } | 244 | } |
| 245 | + updateEventQueue(); | ||
| 230 | if (path !== route.path || name == 'debugChild') { | 246 | if (path !== route.path || name == 'debugChild') { |
| 231 | toLastFilterView(visitedViews.value, { name: 'debugChild' }); | 247 | toLastFilterView(visitedViews.value, { name: 'debugChild' }); |
| 232 | } | 248 | } |
| 233 | }; | 249 | }; |
| 234 | 250 | ||
| 235 | const closeAllTab = async () => { | 251 | const closeAllTab = async () => { |
| 236 | - TagsViewStore.delAllViews(); | ||
| 237 | contextMenu.visible = false; | 252 | contextMenu.visible = false; |
| 253 | + for (let item of visitedViews.value) { | ||
| 254 | + if (item.name !== 'debugChild' && deleteRunningTag(item.id)) { | ||
| 255 | + await handleEventQueueProcedure(item); | ||
| 256 | + TagsViewStore.delView(item); | ||
| 257 | + } | ||
| 258 | + } | ||
| 259 | + updateEventQueue(); | ||
| 238 | }; | 260 | }; |
| 239 | const closeAllTabToLast = async () => { | 261 | const closeAllTabToLast = async () => { |
| 240 | - let visitedViews = await TagsViewStore.delAllViews(); | 262 | + await closeAllTab(); |
| 241 | - toLastView(visitedViews, route); | 263 | + toLastView(TagsViewStore.visitedViews, route); |
| 242 | - contextMenu.visible = false; | ||
| 243 | }; | 264 | }; |
| 244 | 265 | ||
| 245 | const routerGo = (tag) => { | 266 | const routerGo = (tag) => { |
| @@ -321,6 +342,7 @@ | |||
| 321 | path: '/createTerminal/' + time, | 342 | path: '/createTerminal/' + time, |
| 322 | query: { | 343 | query: { |
| 323 | title, | 344 | title, |
| 345 | + fileName: title, | ||
| 324 | rootId, | 346 | rootId, |
| 325 | connectInfoName, | 347 | connectInfoName, |
| 326 | uuid, | 348 | uuid, |
| @@ -345,6 +367,7 @@ | |||
| 345 | nextTick(() => { | 367 | nextTick(() => { |
| 346 | setTimeout(() => { | 368 | setTimeout(() => { |
| 347 | moveToCurrentTag(); | 369 | moveToCurrentTag(); |
| 370 | + refreshRunningTags(); | ||
| 348 | }, 100); | 371 | }, 100); |
| 349 | }); | 372 | }); |
| 350 | }); | 373 | }); |
| @@ -356,14 +379,14 @@ | |||
| 356 | } | 379 | } |
| 357 | next(); | 380 | next(); |
| 358 | }); | 381 | }); |
| 359 | - EventBus.listen(EventTypeName.CLOSE_SELECTED_TAB, (view) => { | 382 | + EventBus.listen(EventTypeName.CLOSE_SELECTED_TAB, async (view) => { |
| 360 | - closeSelectedTagToLastView(view); | 383 | + await closeSelectedTagToLastView(view); |
| 361 | }); | 384 | }); |
| 362 | - EventBus.listen(EventTypeName.CLOSE_ALL_TAB_TO_LAST, () => { | 385 | + EventBus.listen(EventTypeName.CLOSE_ALL_TAB_TO_LAST, async () => { |
| 363 | - closeAllTabToLast(); | 386 | + await closeAllTabToLast(); |
| 364 | }); | 387 | }); |
| 365 | - EventBus.listen(EventTypeName.CLOSE_ALL_TAB, () => { | 388 | + EventBus.listen(EventTypeName.CLOSE_ALL_TAB, async () => { |
| 366 | - closeAllTab(); | 389 | + await closeAllTab(); |
| 367 | }); | 390 | }); |
| 368 | }); | 391 | }); |
| 369 | onUnmounted(() => { | 392 | onUnmounted(() => { |
| @@ -0,0 +1,96 @@ | |||
| 1 | +import { ElMessage, ElMessageBox } from 'element-plus'; | ||
| 2 | +import { useI18n } from 'vue-i18n'; | ||
| 3 | +import { useRouter } from 'vue-router'; | ||
| 4 | +import EventBus, { EventTypeName } from '@/utils/event-bus'; | ||
| 5 | +import { setTableReindex, setTableTruncate, setTableVacuum, dropTable } from '@/api/table'; | ||
| 6 | +import type { NodeData } from '../Sidebar/types'; | ||
| 7 | + | ||
| 8 | +export const useSidebarContext = ( | ||
| 9 | + options = { | ||
| 10 | + currentContextNodeData: {} as NodeData, | ||
| 11 | + hideTreeContext: undefined as undefined | (() => void), | ||
| 12 | + }, | ||
| 13 | +) => { | ||
| 14 | + const { t } = useI18n(); | ||
| 15 | + const router = useRouter(); | ||
| 16 | + const getTableCommonParams = () => { | ||
| 17 | + const { uuid, schemaName: schema, oid, name } = options.currentContextNodeData; | ||
| 18 | + return { | ||
| 19 | + uuid, | ||
| 20 | + schema, | ||
| 21 | + oid, | ||
| 22 | + tableName: name, | ||
| 23 | + }; | ||
| 24 | + }; | ||
| 25 | + | ||
| 26 | + const handleReindex = () => { | ||
| 27 | + if (options.hideTreeContext) options.hideTreeContext(); | ||
| 28 | + const params = getTableCommonParams(); | ||
| 29 | + ElMessageBox.confirm( | ||
| 30 | + t('message.reindexTable', { name: `${params.schema}.${params.tableName}` }), | ||
| 31 | + ).then(async () => { | ||
| 32 | + await setTableReindex(params); | ||
| 33 | + ElMessage.success(t('message.success')); | ||
| 34 | + }); | ||
| 35 | + }; | ||
| 36 | + const handleTruncate = () => { | ||
| 37 | + if (options.hideTreeContext) options.hideTreeContext(); | ||
| 38 | + const params = getTableCommonParams(); | ||
| 39 | + ElMessageBox.confirm( | ||
| 40 | + t('message.truncateTable', { name: `${params.schema}.${params.tableName}` }), | ||
| 41 | + ).then(async () => { | ||
| 42 | + await setTableTruncate(params); | ||
| 43 | + ElMessage.success(t('message.success')); | ||
| 44 | + }); | ||
| 45 | + }; | ||
| 46 | + | ||
| 47 | + const handleVacuum = () => { | ||
| 48 | + if (options.hideTreeContext) options.hideTreeContext(); | ||
| 49 | + const params = getTableCommonParams(); | ||
| 50 | + ElMessageBox.confirm( | ||
| 51 | + t('message.vacuumTable', { name: `${params.schema}.${params.tableName}` }), | ||
| 52 | + ).then(async () => { | ||
| 53 | + await setTableVacuum(params); | ||
| 54 | + ElMessage.success(t('message.success')); | ||
| 55 | + }); | ||
| 56 | + }; | ||
| 57 | + | ||
| 58 | + const handleDropTable = () => { | ||
| 59 | + if (options.hideTreeContext) options.hideTreeContext(); | ||
| 60 | + const params = getTableCommonParams(); | ||
| 61 | + ElMessageBox.confirm( | ||
| 62 | + t('message.dropTable', { name: `${params.schema}.${params.tableName}` }), | ||
| 63 | + ).then(async () => { | ||
| 64 | + await dropTable(params); | ||
| 65 | + ElMessage.success(t('message.success')); | ||
| 66 | + EventBus.notify(EventTypeName.REFRESH_ASIDER, 'mode', { | ||
| 67 | + rootId: options.currentContextNodeData.rootId, | ||
| 68 | + databaseId: options.currentContextNodeData.databaseId, | ||
| 69 | + schemaId: options.currentContextNodeData.schemaId, | ||
| 70 | + }); | ||
| 71 | + }); | ||
| 72 | + }; | ||
| 73 | + | ||
| 74 | + const handleRelatedSequence = () => { | ||
| 75 | + if (options.hideTreeContext) options.hideTreeContext(); | ||
| 76 | + const params = getTableCommonParams(); | ||
| 77 | + router.push({ | ||
| 78 | + path: `/tableRelatedSequence/${options.currentContextNodeData.id}`, | ||
| 79 | + query: { | ||
| 80 | + title: `${params.schema}.${params.tableName}.RelatedSequence-options.${options.currentContextNodeData.databaseName}@${options.currentContextNodeData.connectInfo.name}`, | ||
| 81 | + fileName: `${params.tableName}.RelatedSequence`, | ||
| 82 | + ...params, | ||
| 83 | + rootId: options.currentContextNodeData.rootId, | ||
| 84 | + dbname: options.currentContextNodeData.databaseName, | ||
| 85 | + }, | ||
| 86 | + }); | ||
| 87 | + }; | ||
| 88 | + | ||
| 89 | + return { | ||
| 90 | + handleReindex, | ||
| 91 | + handleTruncate, | ||
| 92 | + handleVacuum, | ||
| 93 | + handleDropTable, | ||
| 94 | + handleRelatedSequence, | ||
| 95 | + }; | ||
| 96 | +}; | ||
| @@ -0,0 +1,264 @@ | |||
| 1 | +import { ref } from 'vue'; | ||
| 2 | +import { useAppStore } from '@/store/modules/app'; | ||
| 3 | +import { useUserStore } from '@/store/modules/user'; | ||
| 4 | +import { loadingInstance } from '@/utils'; | ||
| 5 | +import { connectListPersist } from '@/config'; | ||
| 6 | +import { getDatabaseList } from '@/api/database'; | ||
| 7 | +import { getSchemaList, getSchemaObjectList } from '@/api/metaData'; | ||
| 8 | +import type { FetchNode } from '../Sidebar/types'; | ||
| 9 | +import { useI18n } from 'vue-i18n'; | ||
| 10 | + | ||
| 11 | +export const useSidebarFetchData = (connectionList, findNode) => { | ||
| 12 | + const AppStore = useAppStore(); | ||
| 13 | + const UserStore = useUserStore(); | ||
| 14 | + const { t } = useI18n(); | ||
| 15 | + const loading = ref(null); | ||
| 16 | + | ||
| 17 | + const getAllConnectList = (connectObj?: { id: string | number }) => { | ||
| 18 | + let list = JSON.parse(connectListPersist.storage.getItem(connectListPersist.key) || '[]'); | ||
| 19 | + if (list.length && connectObj) { | ||
| 20 | + const repeatList: boolean[] = list.map((item) => item.id === connectObj.id); | ||
| 21 | + repeatList.includes(true) | ||
| 22 | + ? (list = list.map((item) => (item.id === connectObj.id ? connectObj : item))) | ||
| 23 | + : list.unshift(connectObj); | ||
| 24 | + } else if (!list.length && connectObj) { | ||
| 25 | + list = [connectObj]; | ||
| 26 | + } | ||
| 27 | + return list; | ||
| 28 | + }; | ||
| 29 | + const updateConnectListPersist = () => { | ||
| 30 | + connectListPersist.storage.setItem( | ||
| 31 | + connectListPersist.key, | ||
| 32 | + JSON.stringify(connectionList.value), | ||
| 33 | + ); | ||
| 34 | + }; | ||
| 35 | + const fetchDBList = async (connectInfo, uuid) => { | ||
| 36 | + loading.value = loadingInstance(); | ||
| 37 | + try { | ||
| 38 | + const data = (await getDatabaseList(uuid)) as unknown as string[]; | ||
| 39 | + const cloneConnectInfo = JSON.parse(JSON.stringify(connectInfo)); | ||
| 40 | + const { id, name, ip, port } = connectInfo; | ||
| 41 | + const root = { | ||
| 42 | + id, | ||
| 43 | + parentId: null, | ||
| 44 | + label: `${name} (${ip}:${port})`, | ||
| 45 | + name, | ||
| 46 | + type: 'root', | ||
| 47 | + connectInfo: cloneConnectInfo, | ||
| 48 | + isLeaf: false, | ||
| 49 | + children: data.map((dbName) => { | ||
| 50 | + const hasConnectDb = AppStore.connectListMap | ||
| 51 | + .find((item) => item.id === connectInfo.id) | ||
| 52 | + ?.connectedDatabase.find((item) => item.name == dbName); | ||
| 53 | + const isConnect = !!hasConnectDb; | ||
| 54 | + return { | ||
| 55 | + id: `${id}_${dbName}`, | ||
| 56 | + rootId: id, | ||
| 57 | + parentId: id, | ||
| 58 | + uuid: hasConnectDb?.uuid || '', | ||
| 59 | + label: dbName, | ||
| 60 | + name: dbName, | ||
| 61 | + connectInfo: cloneConnectInfo, | ||
| 62 | + type: 'database', | ||
| 63 | + isLeaf: false, | ||
| 64 | + children: [], | ||
| 65 | + isConnect, | ||
| 66 | + connectTime: hasConnectDb?.connectTime || null, | ||
| 67 | + }; | ||
| 68 | + }), | ||
| 69 | + }; | ||
| 70 | + connectionList.value = getAllConnectList(root); | ||
| 71 | + AppStore.updateCurrentNode(root); | ||
| 72 | + updateConnectListPersist(); | ||
| 73 | + } finally { | ||
| 74 | + loading.value.close(); | ||
| 75 | + } | ||
| 76 | + return true; | ||
| 77 | + }; | ||
| 78 | + const fetchSchemaList = async (rootId, parentId, databaseId, databaseName, uuid, connectInfo) => { | ||
| 79 | + const data = (await getSchemaList({ | ||
| 80 | + uuid, | ||
| 81 | + connectionName: connectInfo.name, | ||
| 82 | + webUser: UserStore.userId, | ||
| 83 | + })) as unknown as FetchNode[]; | ||
| 84 | + const schemaList = []; | ||
| 85 | + data.forEach((item) => { | ||
| 86 | + const obj = { | ||
| 87 | + id: `${parentId}_${item.oid}`, | ||
| 88 | + oid: item.oid, | ||
| 89 | + rootId, | ||
| 90 | + parentId, | ||
| 91 | + label: item.name, | ||
| 92 | + name: item.name, | ||
| 93 | + connectInfo, | ||
| 94 | + databaseName, | ||
| 95 | + databaseId, | ||
| 96 | + uuid, | ||
| 97 | + type: item.name === 'public' ? 'public' : 'person', | ||
| 98 | + isLeaf: false, | ||
| 99 | + children: [], | ||
| 100 | + }; | ||
| 101 | + item.name === 'public' ? schemaList.unshift(obj) : schemaList.push(obj); | ||
| 102 | + }); | ||
| 103 | + const dbNode = findNode({ rootId: connectInfo.id, databaseId }); | ||
| 104 | + dbNode.children = schemaList; | ||
| 105 | + updateConnectListPersist(); | ||
| 106 | + return schemaList; | ||
| 107 | + }; | ||
| 108 | + const fetchSchemaContentList = async ( | ||
| 109 | + rootId, | ||
| 110 | + parentId, | ||
| 111 | + uuid, | ||
| 112 | + databaseId, | ||
| 113 | + databaseName, | ||
| 114 | + schemaId, | ||
| 115 | + schemaName, | ||
| 116 | + connectInfo, | ||
| 117 | + ) => { | ||
| 118 | + const data = (await getSchemaObjectList({ | ||
| 119 | + connectionName: connectInfo.name, | ||
| 120 | + webUser: UserStore.userId, | ||
| 121 | + schema: schemaName, | ||
| 122 | + uuid, | ||
| 123 | + })) as unknown as any[]; | ||
| 124 | + let arr = []; | ||
| 125 | + if (data.length) { | ||
| 126 | + arr = handleSchemaList( | ||
| 127 | + data[0], | ||
| 128 | + rootId, | ||
| 129 | + parentId, | ||
| 130 | + uuid, | ||
| 131 | + databaseId, | ||
| 132 | + databaseName, | ||
| 133 | + schemaId, | ||
| 134 | + schemaName, | ||
| 135 | + connectInfo, | ||
| 136 | + ); | ||
| 137 | + } | ||
| 138 | + return arr; | ||
| 139 | + }; | ||
| 140 | + // User Mode - public/no public | ||
| 141 | + const handleSchemaList = ( | ||
| 142 | + obj, | ||
| 143 | + rootId, | ||
| 144 | + parentId, | ||
| 145 | + uuid, | ||
| 146 | + databaseId, | ||
| 147 | + databaseName, | ||
| 148 | + schemaId, | ||
| 149 | + schemaName, | ||
| 150 | + connectInfo, | ||
| 151 | + ) => { | ||
| 152 | + const array = []; | ||
| 153 | + const order = ['table', 'fun_pro', 'sequence', 'view', 'synonym']; | ||
| 154 | + let keys = Object.keys(obj); | ||
| 155 | + keys = keys.sort((a, b) => { | ||
| 156 | + return order.indexOf(a) - order.indexOf(b); | ||
| 157 | + }); | ||
| 158 | + keys.forEach((key) => { | ||
| 159 | + if (!order.includes(key)) return; | ||
| 160 | + const { label, type, childType } = sortType(key); | ||
| 161 | + const keyId = `${parentId}_${key}`; | ||
| 162 | + array.push({ | ||
| 163 | + id: keyId, | ||
| 164 | + rootId, | ||
| 165 | + parentId, | ||
| 166 | + uuid, | ||
| 167 | + label: `${label} (${obj[key].length})`, | ||
| 168 | + name: label, | ||
| 169 | + type, | ||
| 170 | + key, | ||
| 171 | + connectInfo, | ||
| 172 | + databaseId, | ||
| 173 | + databaseName, | ||
| 174 | + schemaId, | ||
| 175 | + schemaName, | ||
| 176 | + children: handleTypeList( | ||
| 177 | + obj[key], | ||
| 178 | + childType, | ||
| 179 | + rootId, | ||
| 180 | + keyId, | ||
| 181 | + uuid, | ||
| 182 | + databaseId, | ||
| 183 | + databaseName, | ||
| 184 | + schemaId, | ||
| 185 | + schemaName, | ||
| 186 | + connectInfo, | ||
| 187 | + ), | ||
| 188 | + isLeaf: false, | ||
| 189 | + }); | ||
| 190 | + }); | ||
| 191 | + return array; | ||
| 192 | + }; | ||
| 193 | + // User Mode-children | ||
| 194 | + const sortType = (key) => { | ||
| 195 | + const obj = { label: '', type: '', childType: '' }; | ||
| 196 | + switch (key) { | ||
| 197 | + case 'table': | ||
| 198 | + obj.label = t('database.regular_table'); | ||
| 199 | + obj.type = 'tableCollect'; | ||
| 200 | + obj.childType = 'table'; | ||
| 201 | + break; | ||
| 202 | + case 'fun_pro': | ||
| 203 | + obj.label = t('database.function_process'); | ||
| 204 | + obj.type = 'terminalCollect'; | ||
| 205 | + obj.childType = 'terminal'; | ||
| 206 | + break; | ||
| 207 | + case 'view': | ||
| 208 | + obj.label = t('database.view'); | ||
| 209 | + obj.type = 'viewCollect'; | ||
| 210 | + obj.childType = 'view'; | ||
| 211 | + break; | ||
| 212 | + case 'synonym': | ||
| 213 | + obj.label = t('database.synonym'); | ||
| 214 | + obj.type = 'synonymCollect'; | ||
| 215 | + obj.childType = 'synonym'; | ||
| 216 | + break; | ||
| 217 | + case 'sequence': | ||
| 218 | + obj.label = t('database.sequence'); | ||
| 219 | + obj.type = 'sequenceCollect'; | ||
| 220 | + obj.childType = 'sequence'; | ||
| 221 | + break; | ||
| 222 | + } | ||
| 223 | + return obj; | ||
| 224 | + }; | ||
| 225 | + // User Mode-children data - [table/func/view]... | ||
| 226 | + const handleTypeList = ( | ||
| 227 | + array, | ||
| 228 | + childType, | ||
| 229 | + rootId, | ||
| 230 | + parentId, | ||
| 231 | + uuid, | ||
| 232 | + databaseId, | ||
| 233 | + databaseName, | ||
| 234 | + schemaId, | ||
| 235 | + schemaName, | ||
| 236 | + connectInfo, | ||
| 237 | + ) => { | ||
| 238 | + return array.map((item: FetchNode) => ({ | ||
| 239 | + id: `${parentId}_${item.oid}`, | ||
| 240 | + oid: item.oid, | ||
| 241 | + rootId, | ||
| 242 | + parentId, | ||
| 243 | + uuid, | ||
| 244 | + label: item.name, | ||
| 245 | + name: item.name, | ||
| 246 | + type: childType, | ||
| 247 | + databaseId, | ||
| 248 | + databaseName, | ||
| 249 | + schemaId, | ||
| 250 | + schemaName, | ||
| 251 | + connectInfo, | ||
| 252 | + isLeaf: true, | ||
| 253 | + })); | ||
| 254 | + }; | ||
| 255 | + return { | ||
| 256 | + getAllConnectList, | ||
| 257 | + updateConnectListPersist, | ||
| 258 | + fetchDBList, | ||
| 259 | + fetchSchemaList, | ||
| 260 | + fetchSchemaContentList, | ||
| 261 | + handleSchemaList, | ||
| 262 | + sortType, | ||
| 263 | + }; | ||
| 264 | +}; | ||
| @@ -12,7 +12,6 @@ | |||
| 12 | </template> | 12 | </template> |
| 13 | 13 | ||
| 14 | <script lang="ts" setup name="layout"> | 14 | <script lang="ts" setup name="layout"> |
| 15 | - import { computed } from 'vue'; | ||
| 16 | import { useSettingStore } from '@/store/modules/setting'; | 15 | import { useSettingStore } from '@/store/modules/setting'; |
| 17 | import Sidebar from './Sidebar/index.vue'; | 16 | import Sidebar from './Sidebar/index.vue'; |
| 18 | import UMain from './Main/index.vue'; | 17 | import UMain from './Main/index.vue'; |
| @@ -35,10 +34,6 @@ | |||
| 35 | box-sizing: border-box; | 34 | box-sizing: border-box; |
| 36 | flex-direction: column; | 35 | flex-direction: column; |
| 37 | } | 36 | } |
| 38 | - .sidebar-container { | ||
| 39 | - display: flex; | ||
| 40 | - flex-direction: column; | ||
| 41 | - } | ||
| 42 | .drawer-bg { | 37 | .drawer-bg { |
| 43 | background: #000; | 38 | background: #000; |
| 44 | opacity: 0.3; | 39 | opacity: 0.3; |
| @@ -19,14 +19,10 @@ router.beforeEach(async (to, from, next) => { | |||
| 19 | const isDSConnect = JSON.parse( | 19 | const isDSConnect = JSON.parse( |
| 20 | connectListPersist.storage.getItem(connectListPersist.key) || '[]', | 20 | connectListPersist.storage.getItem(connectListPersist.key) || '[]', |
| 21 | ); | 21 | ); |
| 22 | - if (isDSConnect.length) { | 22 | + if (isDSConnect.length == 0 && to.name == 'home' && to.fullPath != '/home') { |
| 23 | - next(); | 23 | + next({ path: '/home' }); |
| 24 | } else { | 24 | } else { |
| 25 | - if (to.fullPath == '/home') { | 25 | + next(); |
| 26 | - next(); | ||
| 27 | - } else { | ||
| 28 | - next({ path: '/home' }); | ||
| 29 | - } | ||
| 30 | } | 26 | } |
| 31 | }); | 27 | }); |
| 32 | 28 | ||
| @@ -20,12 +20,24 @@ export const constantRoutes: Array<RouteRecordRaw & extendRoute> = [ | |||
| 20 | name: 'home', | 20 | name: 'home', |
| 21 | meta: { title: '', icon: 'home2', affix: true, role: ['other'], keepAlive: true }, | 21 | meta: { title: '', icon: 'home2', affix: true, role: ['other'], keepAlive: true }, |
| 22 | }, | 22 | }, |
| 23 | + { | ||
| 24 | + path: '/createTable/:id(\\d+)?', | ||
| 25 | + component: () => import('@/views/createTable/index.vue'), | ||
| 26 | + name: 'createTable', | ||
| 27 | + meta: { title: '', icon: 'table', keepAlive: true }, | ||
| 28 | + }, | ||
| 23 | { | 29 | { |
| 24 | path: '/table/:id', | 30 | path: '/table/:id', |
| 25 | component: () => import('@/views/table/index.vue'), | 31 | component: () => import('@/views/table/index.vue'), |
| 26 | name: 'table', | 32 | name: 'table', |
| 27 | meta: { title: '', icon: 'table', keepAlive: true }, | 33 | meta: { title: '', icon: 'table', keepAlive: true }, |
| 28 | }, | 34 | }, |
| 35 | + { | ||
| 36 | + path: '/tableRelatedSequence/:id', | ||
| 37 | + component: () => import('@/views/table/tableRelatedSequence.vue'), | ||
| 38 | + name: 'tableRelatedSequence', | ||
| 39 | + meta: { title: '', icon: 'table', keepAlive: true }, | ||
| 40 | + }, | ||
| 29 | { | 41 | { |
| 30 | path: '/createTerminal/:id(\\d+)?', | 42 | path: '/createTerminal/:id(\\d+)?', |
| 31 | component: () => import('@/views/terminal/index.vue'), | 43 | component: () => import('@/views/terminal/index.vue'), |
| @@ -22,11 +22,9 @@ export const useSettingStore = defineStore({ | |||
| 22 | }), | 22 | }), |
| 23 | getters: {}, | 23 | getters: {}, |
| 24 | actions: { | 24 | actions: { |
| 25 | - // set theme | ||
| 26 | setThemeConfig({ key, val }) { | 25 | setThemeConfig({ key, val }) { |
| 27 | this.themeConfig[key] = val; | 26 | this.themeConfig[key] = val; |
| 28 | }, | 27 | }, |
| 29 | - // toggle Collapse | ||
| 30 | setCollapse(value) { | 28 | setCollapse(value) { |
| 31 | this.isCollapse = value; | 29 | this.isCollapse = value; |
| 32 | this.withoutAnimation = false; | 30 | this.withoutAnimation = false; |
| @@ -1,5 +1,5 @@ | |||
| 1 | :root { | 1 | :root { |
| 2 | - font-family: Inter, Avenir, Helvetica, Arial, sans-serif; | 2 | + font-family: 'Inter', 'Avenir', 'Helvetica', 'Arial', sans-serif; |
| 3 | font-size: 16px; | 3 | font-size: 16px; |
| 4 | line-height: 24px; | 4 | line-height: 24px; |
| 5 | font-weight: 400; | 5 | font-weight: 400; |
| @@ -19,7 +19,7 @@ body { | |||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | .clearfix { | 21 | .clearfix { |
| 22 | - *zoom: 1 | 22 | + zoom: 1 |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | .flex-center { | 25 | .flex-center { |
| @@ -36,6 +36,10 @@ body { | |||
| 36 | display: flex; | 36 | display: flex; |
| 37 | align-items: center; | 37 | align-items: center; |
| 38 | } | 38 | } |
| 39 | +.word-wrap { | ||
| 40 | + word-wrap: break-word; | ||
| 41 | + word-break: break-all; | ||
| 42 | +} | ||
| 39 | 43 | ||
| 40 | ::-webkit-scrollbar { | 44 | ::-webkit-scrollbar { |
| 41 | width: 7px; | 45 | width: 7px; |
| @@ -68,3 +72,17 @@ body { | |||
| 68 | background-color: var(--el-dropdown-menuItem-hover-fill); | 72 | background-color: var(--el-dropdown-menuItem-hover-fill); |
| 69 | } | 73 | } |
| 70 | } | 74 | } |
| 75 | + | ||
| 76 | +.el-table .el-table__cell.add { | ||
| 77 | + background-color: #e4ffb5 ; | ||
| 78 | + color: #606266; | ||
| 79 | + .el-input__inner { | ||
| 80 | + color: #606266 ; | ||
| 81 | + } | ||
| 82 | +} | ||
| 83 | +.el-table .el-table__cell.delete { | ||
| 84 | + background-color: #ff6347 ; | ||
| 85 | +} | ||
| 86 | +.el-table .el-table__cell.edited { | ||
| 87 | + background-color: #f1d4d8 ; | ||
| 88 | +} | ||
| @@ -68,6 +68,7 @@ html.dark { | |||
| 68 | --color-fill-2: rgb(255 255 255 / 8%); | 68 | --color-fill-2: rgb(255 255 255 / 8%); |
| 69 | --color-text-4: rgb(255 255 255 / 30%); | 69 | --color-text-4: rgb(255 255 255 / 30%); |
| 70 | --color-bg-2: #232324; | 70 | --color-bg-2: #232324; |
| 71 | + --table-current-row-bg-color: #6f6f6f; | ||
| 71 | body { | 72 | body { |
| 72 | background: none; | 73 | background: none; |
| 73 | } | 74 | } |
| @@ -20,6 +20,7 @@ | |||
| 20 | --color-fill-2: #f2f3f5; | 20 | --color-fill-2: #f2f3f5; |
| 21 | --color-text-4: #c9cdd4; | 21 | --color-text-4: #c9cdd4; |
| 22 | --color-bg-2: #fff; | 22 | --color-bg-2: #fff; |
| 23 | + --table-current-row-bg-color: #e1e1e1; | ||
| 23 | } | 24 | } |
| 24 | .el-tabs { | 25 | .el-tabs { |
| 25 | --el-tabs-header-height: 28px; | 26 | --el-tabs-header-height: 28px; |
| @@ -99,10 +100,10 @@ html { | |||
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | .el-table__body tr.current-row>td.el-table__cell { | 102 | .el-table__body tr.current-row>td.el-table__cell { |
| 102 | - background-color: var(--el-fill-color-light); | 103 | + background-color: var(--table-current-row-bg-color); |
| 103 | } | 104 | } |
| 104 | .el-table--striped .el-table__body tr.el-table__row--striped.current-row td.el-table__cell { | 105 | .el-table--striped .el-table__body tr.el-table__row--striped.current-row td.el-table__cell { |
| 105 | - background-color: var(--el-fill-color-light); | 106 | + background-color: var(--table-current-row-bg-color); |
| 106 | } | 107 | } |
| 107 | 108 | ||
| 108 | .el-dropdown__popper { | 109 | .el-dropdown__popper { |
| @@ -1,22 +1,19 @@ | |||
| 1 | class EventBus { | 1 | class EventBus { |
| 2 | static list: { [key: string]: any } = {}; | 2 | static list: { [key: string]: any } = {}; |
| 3 | 3 | ||
| 4 | - // subscribe | ||
| 5 | static listen(name: EventTypeName, fn: any) { | 4 | static listen(name: EventTypeName, fn: any) { |
| 6 | this.list[name] = this.list[name] || []; | 5 | this.list[name] = this.list[name] || []; |
| 7 | this.list[name].push(fn); | 6 | this.list[name].push(fn); |
| 8 | } | 7 | } |
| 9 | 8 | ||
| 10 | - // release | 9 | + static async notify(name: EventTypeName, ...params: any[]) { |
| 11 | - static notify(name: EventTypeName, ...params: any[]) { | ||
| 12 | if (this.list[name]) { | 10 | if (this.list[name]) { |
| 13 | - this.list[name].forEach((fn: any) => { | 11 | + for (let i = 0; i < this.list[name].length; i++) { |
| 14 | - fn(...params); | 12 | + await this.list[name][i](...params); |
| 15 | - }); | 13 | + } |
| 16 | } | 14 | } |
| 17 | } | 15 | } |
| 18 | 16 | ||
| 19 | - // cancel subscribe | ||
| 20 | static unListen(name: EventTypeName, fn?: any) { | 17 | static unListen(name: EventTypeName, fn?: any) { |
| 21 | if (this.list[name]) { | 18 | if (this.list[name]) { |
| 22 | if (fn) { | 19 | if (fn) { |
| @@ -40,4 +37,5 @@ export enum EventTypeName { | |||
| 40 | CLOSE_ALL_TAB_TO_LAST, | 37 | CLOSE_ALL_TAB_TO_LAST, |
| 41 | REFRESH_DATABASE_LIST, | 38 | REFRESH_DATABASE_LIST, |
| 42 | UPDATE_DEBUG_BUTTON, | 39 | UPDATE_DEBUG_BUTTON, |
| 40 | + REFRESH_ASIDER, | ||
| 43 | } | 41 | } |
| @@ -1,4 +1,4 @@ | |||
| 1 | -import { ElLoading } from 'element-plus'; | 1 | +import { ElLoading, ElMessage } from 'element-plus'; |
| 2 | import type { Column } from 'element-plus'; | 2 | import type { Column } from 'element-plus'; |
| 3 | import { i18n } from '@/i18n/index'; | 3 | import { i18n } from '@/i18n/index'; |
| 4 | 4 | ||
| @@ -245,7 +245,7 @@ export function debounce(func, wait, immediate) { | |||
| 245 | if (!timeout) timeout = setTimeout(later, wait); | 245 | if (!timeout) timeout = setTimeout(later, wait); |
| 246 | if (callNow) { | 246 | if (callNow) { |
| 247 | result = func.apply(that, args); | 247 | result = func.apply(that, args); |
| 248 | - that = args = null; | 248 | + that = null; |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | return result; | 251 | return result; |
| @@ -396,7 +396,6 @@ export const deepObjClone = function (obj) { | |||
| 396 | } | 396 | } |
| 397 | return clone(obj); | 397 | return clone(obj); |
| 398 | }; | 398 | }; |
| 399 | -import { ElMessage } from 'element-plus'; | ||
| 400 | 399 | ||
| 401 | /** | 400 | /** |
| 402 | * color: hexToRgb | 401 | * color: hexToRgb |
| @@ -584,6 +583,91 @@ export const formatTableData = (columns: string[], data: (string | number)[][]) | |||
| 584 | }); | 583 | }); |
| 585 | }; | 584 | }; |
| 586 | 585 | ||
| 586 | +export const formatEditTableData = (config: { | ||
| 587 | + columns: any[]; | ||
| 588 | + data: (string | number)[][]; | ||
| 589 | + idKey?: string; | ||
| 590 | + rowStatusKey?: string; | ||
| 591 | + editingSuffix?: string; | ||
| 592 | + editedSuffix?: string; | ||
| 593 | +}) => { | ||
| 594 | + const options = { | ||
| 595 | + editingSuffix: '_isEditing', | ||
| 596 | + editedSuffix: '_edited', | ||
| 597 | + ...config, | ||
| 598 | + }; | ||
| 599 | + return options.data.map((rowData, rowIndex) => { | ||
| 600 | + const obj = {}; | ||
| 601 | + options.columns.forEach((col, colIndex) => { | ||
| 602 | + obj[col.name] = rowData[colIndex]; | ||
| 603 | + obj[col.name + options.editingSuffix] = false; | ||
| 604 | + obj[col.name + options.editedSuffix] = false; | ||
| 605 | + if (options.idKey) obj[options.idKey] = rowIndex; | ||
| 606 | + if (options.rowStatusKey) obj[options.rowStatusKey] = ''; | ||
| 607 | + }); | ||
| 608 | + return obj; | ||
| 609 | + }); | ||
| 610 | +}; | ||
| 611 | + | ||
| 612 | +export const getFlexColumnWidth = ( | ||
| 613 | + data: Record<string, any>[], | ||
| 614 | + key: string, | ||
| 615 | + isCalculateCharWidth?: boolean, | ||
| 616 | +) => { | ||
| 617 | + const minWidth = 90; | ||
| 618 | + const maxWidth = 400; | ||
| 619 | + const maxCharLength = 50 * 3; | ||
| 620 | + key = key + ''; | ||
| 621 | + if (!data || !data.length || data.length === 0 || data === undefined) { | ||
| 622 | + return minWidth; | ||
| 623 | + } | ||
| 624 | + if (!key || !key.length || key.length === 0 || key === undefined || typeof key == 'object') { | ||
| 625 | + return minWidth; | ||
| 626 | + } | ||
| 627 | + let index = 0; | ||
| 628 | + for (let i = 0; i < data.length; i++) { | ||
| 629 | + if ([null, undefined, ''].includes(data[i][key])) { | ||
| 630 | + continue; | ||
| 631 | + } | ||
| 632 | + const now_temp = data[i][key] + ''; | ||
| 633 | + const max_temp = data[index][key] + ''; | ||
| 634 | + if (now_temp.length > max_temp.length) { | ||
| 635 | + index = i; | ||
| 636 | + } | ||
| 637 | + if ((data[index][key] + '').length >= maxCharLength) { | ||
| 638 | + return maxWidth; | ||
| 639 | + } | ||
| 640 | + } | ||
| 641 | + let maxColumnContent = data[index][key] ?? ''; | ||
| 642 | + maxColumnContent += ''; | ||
| 643 | + let flexWidth = 0; | ||
| 644 | + if (isCalculateCharWidth) { | ||
| 645 | + for (const char of maxColumnContent) { | ||
| 646 | + if ((char >= 'A' && char <= 'Z') || (char >= 'a' && char <= 'z')) { | ||
| 647 | + flexWidth += 8; | ||
| 648 | + } else if (char >= '\u4e00' && char <= '\u9fa5') { | ||
| 649 | + flexWidth += 15; | ||
| 650 | + } else { | ||
| 651 | + flexWidth += 8; | ||
| 652 | + } | ||
| 653 | + } | ||
| 654 | + } else { | ||
| 655 | + flexWidth = maxColumnContent.length * 8; | ||
| 656 | + } | ||
| 657 | + if (flexWidth <= minWidth) { | ||
| 658 | + flexWidth = minWidth; | ||
| 659 | + } else if (flexWidth <= 200) { | ||
| 660 | + flexWidth = 100; | ||
| 661 | + } else if (flexWidth <= 300) { | ||
| 662 | + flexWidth = 200; | ||
| 663 | + } else if (flexWidth <= 400) { | ||
| 664 | + flexWidth = 300; | ||
| 665 | + } else { | ||
| 666 | + flexWidth = maxWidth; | ||
| 667 | + } | ||
| 668 | + return flexWidth; | ||
| 669 | +}; | ||
| 670 | + | ||
| 587 | export const dispatchEventStorage = () => { | 671 | export const dispatchEventStorage = () => { |
| 588 | const setItemSign = localStorage.setItem; | 672 | const setItemSign = localStorage.setItem; |
| 589 | localStorage.setItem = function (...arg: string[]) { | 673 | localStorage.setItem = function (...arg: string[]) { |
| @@ -610,3 +694,98 @@ export const manualStringify = (value) => { | |||
| 610 | cache = null; | 694 | cache = null; |
| 611 | return str; | 695 | return str; |
| 612 | }; | 696 | }; |
| 697 | + | ||
| 698 | +export const upperSentenceFirstLetter = (str: string) => { | ||
| 699 | + return str.slice(0, 1).toUpperCase() + str.slice(1).toLowerCase(); | ||
| 700 | +}; | ||
| 701 | + | ||
| 702 | +export const upperWordFirstLetter = (str: string) => { | ||
| 703 | + const strArr = str.split(' '); | ||
| 704 | + for (let i = 0; i < strArr.length; i++) { | ||
| 705 | + strArr[i] = strArr[i].substring(0, 1).toUpperCase() + strArr[i].toLowerCase().substring(1); | ||
| 706 | + } | ||
| 707 | + return strArr.join(' '); | ||
| 708 | +}; | ||
| 709 | + | ||
| 710 | +export const isBodyElement = (node: Element) => { | ||
| 711 | + return node && node.nodeType == 1 && node.tagName.toLowerCase() == 'body'; | ||
| 712 | +}; | ||
| 713 | + | ||
| 714 | +export const findParentElement = (el: Element, parentClassName: string) => { | ||
| 715 | + if (!el) return; | ||
| 716 | + if (isBodyElement(el)) return; | ||
| 717 | + if (el.classList.contains(parentClassName)) return el; | ||
| 718 | + return findParentElement(el.parentElement, parentClassName); | ||
| 719 | +}; | ||
| 720 | + | ||
| 721 | +/** | ||
| 722 | + * such as 'abcDef' to 'Abc Def' | ||
| 723 | + * such as ' abc Def' to 'Abc Def' | ||
| 724 | + * str string | ||
| 725 | + * string | ||
| 726 | + */ | ||
| 727 | +export const toSpacePascalCase = (str: string): string => { | ||
| 728 | + const toUppercase = (str) => str.toUpperCase(); | ||
| 729 | + return str | ||
| 730 | + .replace(/\B[A-Z]/g, ' $&') | ||
| 731 | + .trim() | ||
| 732 | + .replace(/^./, toUppercase) | ||
| 733 | + .replace(/\b\w/g, toUppercase); | ||
| 734 | +}; | ||
| 735 | + | ||
| 736 | +export const downloadHtml = (htmlContent, fileName) => { | ||
| 737 | + const blob = new Blob([htmlContent], { type: 'text/html' }); | ||
| 738 | + const url = URL.createObjectURL(blob); | ||
| 739 | + const link = document.createElement('a'); | ||
| 740 | + link.href = url; | ||
| 741 | + link.download = fileName || 'download.html'; | ||
| 742 | + link.click(); | ||
| 743 | + URL.revokeObjectURL(url); | ||
| 744 | +}; | ||
| 745 | + | ||
| 746 | +export const simpleDownloadUrl = async (url, fileName) => { | ||
| 747 | + const link = document.createElement('a'); | ||
| 748 | + link.href = url; | ||
| 749 | + link.download = fileName || ''; | ||
| 750 | + link.click(); | ||
| 751 | +}; | ||
| 752 | + | ||
| 753 | +export const downLoadURL = (href, fileName) => { | ||
| 754 | + const elink = document.createElement('a'); | ||
| 755 | + elink.download = fileName; | ||
| 756 | + elink.style.display = 'none'; | ||
| 757 | + if (href instanceof Blob) { | ||
| 758 | + elink.href = URL.createObjectURL(href); | ||
| 759 | + } else { | ||
| 760 | + elink.href = href; | ||
| 761 | + } | ||
| 762 | + document.body.appendChild(elink); | ||
| 763 | + elink.click(); | ||
| 764 | + URL.revokeObjectURL(elink.href); | ||
| 765 | + document.body.removeChild(elink); | ||
| 766 | +}; | ||
| 767 | + | ||
| 768 | +export const downLoadURLBlob = async (url: string, fileName?: string) => { | ||
| 769 | + if (!fileName) { | ||
| 770 | + const arr = url.split('?')[0].split('/'); | ||
| 771 | + fileName = arr[arr.length - 1]; | ||
| 772 | + } | ||
| 773 | + const resp = await fetch(url); | ||
| 774 | + if (!resp) return; | ||
| 775 | + const eleA = document.createElement('a'); | ||
| 776 | + const blob = await resp.blob(); | ||
| 777 | + if (!blob) return; | ||
| 778 | + eleA.href = URL.createObjectURL(blob); | ||
| 779 | + eleA.download = fileName; | ||
| 780 | + eleA.click(); | ||
| 781 | + URL.revokeObjectURL(eleA.href); | ||
| 782 | +}; | ||
| 783 | + | ||
| 784 | +export const downLoadMyBlobType = async (fileName: string, data: any) => { | ||
| 785 | + const blob = new Blob([data]); | ||
| 786 | + const tag = document.createElement('a'); | ||
| 787 | + tag.href = window.URL.createObjectURL(blob); | ||
| 788 | + tag.download = fileName; | ||
| 789 | + tag.click(); | ||
| 790 | + URL.revokeObjectURL(tag.href); | ||
| 791 | +}; | ||
| @@ -16,7 +16,6 @@ | |||
| 16 | </template> | 16 | </template> |
| 17 | 17 | ||
| 18 | <script lang="ts" setup> | 18 | <script lang="ts" setup> |
| 19 | - import { computed, ref } from 'vue'; | ||
| 20 | import { getDatabaseAttr } from '@/api/connect'; | 19 | import { getDatabaseAttr } from '@/api/connect'; |
| 21 | import { useI18n } from 'vue-i18n'; | 20 | import { useI18n } from 'vue-i18n'; |
| 22 | 21 | ||
| @@ -181,7 +181,6 @@ | |||
| 181 | </template> | 181 | </template> |
| 182 | 182 | ||
| 183 | <script lang="ts" setup name="ConnectDialog"> | 183 | <script lang="ts" setup name="ConnectDialog"> |
| 184 | - import { computed, ref, reactive } from 'vue'; | ||
| 185 | import { | 184 | import { |
| 186 | createConnect, | 185 | createConnect, |
| 187 | updateConnect, | 186 | updateConnect, |
| @@ -0,0 +1,217 @@ | |||
| 1 | +<template> | ||
| 2 | + <div class="table-container"> | ||
| 3 | + <Toolbar :status="barStatus" @addLine="toAddLine" @removeLine="handleRemoveLine(data)" /> | ||
| 4 | + <EditTable2 | ||
| 5 | + :data="props.data" | ||
| 6 | + :columns="tableColumns" | ||
| 7 | + :idKey="idKey" | ||
| 8 | + :rowStatusKey="rowStatusKey" | ||
| 9 | + :editingSuffix="editingSuffix" | ||
| 10 | + :editedSuffix="editedSuffix" | ||
| 11 | + v-model:globalEditing="globalEditing" | ||
| 12 | + @currentChange="handleCurrentChange" | ||
| 13 | + > | ||
| 14 | + <template v-for="item in tableColumns" :key="item.prop" v-slot:[item.prop]="scope"> | ||
| 15 | + <el-input | ||
| 16 | + v-if="globalEditing && scope.row[item.prop + editingSuffix] && item.element == 'input'" | ||
| 17 | + v-model="scope.row[item.prop]" | ||
| 18 | + v-bind="item.attribute" | ||
| 19 | + @change="handleChangeValue(scope.row, scope.column)" | ||
| 20 | + /> | ||
| 21 | + <el-input-number | ||
| 22 | + v-else-if=" | ||
| 23 | + globalEditing && scope.row[item.prop + editingSuffix] && item.element == 'inputNumber' | ||
| 24 | + " | ||
| 25 | + v-model="scope.row[item.prop]" | ||
| 26 | + v-bind="item.attribute" | ||
| 27 | + :controls="false" | ||
| 28 | + @change="handleChangeValue(scope.row, scope.column)" | ||
| 29 | + style="width: 100%" | ||
| 30 | + /> | ||
| 31 | + <el-select | ||
| 32 | + v-else-if=" | ||
| 33 | + globalEditing && scope.row[item.prop + editingSuffix] && item.prop == 'dataType' | ||
| 34 | + " | ||
| 35 | + v-model="scope.row[item.prop]" | ||
| 36 | + v-bind="item.attribute" | ||
| 37 | + @change="handleChangeValue(scope.row, scope.column)" | ||
| 38 | + > | ||
| 39 | + <el-option | ||
| 40 | + v-for="op in dataTypeList" | ||
| 41 | + :key="op.value" | ||
| 42 | + :label="op.label" | ||
| 43 | + :value="op.value" | ||
| 44 | + /> | ||
| 45 | + </el-select> | ||
| 46 | + <el-select | ||
| 47 | + v-else-if=" | ||
| 48 | + globalEditing && scope.row[item.prop + editingSuffix] && item.element == 'select' | ||
| 49 | + " | ||
| 50 | + v-model="scope.row[item.prop]" | ||
| 51 | + v-bind="item.attribute" | ||
| 52 | + @change="handleChangeValue(scope.row, scope.column)" | ||
| 53 | + > | ||
| 54 | + <el-option | ||
| 55 | + v-for="op in item.options" | ||
| 56 | + :key="op.value" | ||
| 57 | + :label="op.label" | ||
| 58 | + :value="op.value" | ||
| 59 | + /> | ||
| 60 | + </el-select> | ||
| 61 | + <el-checkbox | ||
| 62 | + v-else-if="item.element == 'checkbox'" | ||
| 63 | + v-model="scope.row[item.prop]" | ||
| 64 | + @change="handleChangeValue(scope.row, scope.column)" | ||
| 65 | + /> | ||
| 66 | + <span v-else>{{ formatTextCell(scope.row[item.prop], item.element) }}</span> | ||
| 67 | + </template> | ||
| 68 | + </EditTable2> | ||
| 69 | + </div> | ||
| 70 | +</template> | ||
| 71 | + | ||
| 72 | +<script lang="ts" setup> | ||
| 73 | + import EditTable2 from './EditTable2.vue'; | ||
| 74 | + import Toolbar from './Toolbar.vue'; | ||
| 75 | + import { getDataTypeList } from '@/api/metaData'; | ||
| 76 | + import { useEditTabHooks } from './useEditTabHooks'; | ||
| 77 | + import type { CommonParams, TableColumn } from '../types'; | ||
| 78 | + const props = withDefaults( | ||
| 79 | + defineProps<{ | ||
| 80 | + data: any[]; | ||
| 81 | + commonParams: CommonParams; | ||
| 82 | + }>(), | ||
| 83 | + { | ||
| 84 | + data: () => [], | ||
| 85 | + }, | ||
| 86 | + ); | ||
| 87 | + | ||
| 88 | + const emit = defineEmits<{ | ||
| 89 | + (e: 'update:data', value: any[]): void; | ||
| 90 | + }>(); | ||
| 91 | + | ||
| 92 | + const idKey = ref('_id'); | ||
| 93 | + const rowStatusKey = ref('_rowStatus'); | ||
| 94 | + const editingSuffix = ref('_isEditing'); | ||
| 95 | + const editedSuffix = ref('_edited'); | ||
| 96 | + const globalEditing = ref(false); | ||
| 97 | + const barStatus = reactive({ | ||
| 98 | + addLine: true, | ||
| 99 | + removeLine: true, | ||
| 100 | + }); | ||
| 101 | + | ||
| 102 | + const dataTypeList = ref([]); | ||
| 103 | + const data = computed({ | ||
| 104 | + get: () => props.data, | ||
| 105 | + set: (val) => emit('update:data', val), | ||
| 106 | + }); | ||
| 107 | + const tableColumns = ref<TableColumn[]>([ | ||
| 108 | + { | ||
| 109 | + label: 'table.column.columnName', | ||
| 110 | + prop: 'columnName', | ||
| 111 | + slot: true, | ||
| 112 | + isI18n: true, | ||
| 113 | + element: 'input', | ||
| 114 | + }, | ||
| 115 | + { | ||
| 116 | + label: 'table.column.dataType', | ||
| 117 | + prop: 'dataType', | ||
| 118 | + slot: true, | ||
| 119 | + isI18n: true, | ||
| 120 | + element: 'select', | ||
| 121 | + options: [], | ||
| 122 | + }, | ||
| 123 | + { | ||
| 124 | + label: 'table.column.canBeNull', | ||
| 125 | + prop: 'canBeNull', | ||
| 126 | + slot: true, | ||
| 127 | + isI18n: true, | ||
| 128 | + element: 'checkbox', | ||
| 129 | + }, | ||
| 130 | + { | ||
| 131 | + label: 'table.column.defaultValue', | ||
| 132 | + prop: 'defaultValue', | ||
| 133 | + slot: true, | ||
| 134 | + isI18n: true, | ||
| 135 | + element: 'input', | ||
| 136 | + }, | ||
| 137 | + { | ||
| 138 | + label: 'table.column.isUnique', | ||
| 139 | + prop: 'isUnique', | ||
| 140 | + slot: true, | ||
| 141 | + isI18n: true, | ||
| 142 | + element: 'checkbox', | ||
| 143 | + }, | ||
| 144 | + { | ||
| 145 | + label: 'table.column.precisionSize', | ||
| 146 | + prop: 'precisionSize', | ||
| 147 | + slot: true, | ||
| 148 | + isI18n: true, | ||
| 149 | + element: 'inputNumber', | ||
| 150 | + attribute: { | ||
| 151 | + min: 0, | ||
| 152 | + step: 0, | ||
| 153 | + precision: 0, | ||
| 154 | + }, | ||
| 155 | + }, | ||
| 156 | + { | ||
| 157 | + label: 'table.column.range', | ||
| 158 | + prop: 'range', | ||
| 159 | + slot: true, | ||
| 160 | + isI18n: true, | ||
| 161 | + element: 'inputNumber', | ||
| 162 | + attribute: { | ||
| 163 | + min: 0, | ||
| 164 | + step: 0, | ||
| 165 | + precision: 0, | ||
| 166 | + }, | ||
| 167 | + }, | ||
| 168 | + { | ||
| 169 | + label: 'table.description', | ||
| 170 | + prop: 'description', | ||
| 171 | + slot: true, | ||
| 172 | + isI18n: true, | ||
| 173 | + element: 'input', | ||
| 174 | + attribute: { | ||
| 175 | + maxlength: 5000, | ||
| 176 | + }, | ||
| 177 | + }, | ||
| 178 | + ]); | ||
| 179 | + const formatTextCell = (value: string[] | string, type) => { | ||
| 180 | + if (['select'].includes(type) && Array.isArray(value)) return value.join(','); | ||
| 181 | + return value; | ||
| 182 | + }; | ||
| 183 | + const toAddLine = () => { | ||
| 184 | + handleAddLine(data.value, { | ||
| 185 | + columnName: '', | ||
| 186 | + dataType: dataTypeList.value[0]?.value, | ||
| 187 | + canBeNull: false, | ||
| 188 | + defaultValue: null, | ||
| 189 | + isUnique: false, | ||
| 190 | + precisionSize: null, | ||
| 191 | + range: null, | ||
| 192 | + description: null, | ||
| 193 | + }); | ||
| 194 | + }; | ||
| 195 | + const fetchDataTypeList = async () => { | ||
| 196 | + const res = (await getDataTypeList(props.commonParams.uuid)) as unknown as string[]; | ||
| 197 | + dataTypeList.value = res.map((item) => ({ value: item, label: item })); | ||
| 198 | + }; | ||
| 199 | + const { handleChangeValue, handleCurrentChange, handleAddLine, handleRemoveLine } = | ||
| 200 | + useEditTabHooks({ | ||
| 201 | + idKey: idKey.value, | ||
| 202 | + rowStatusKey: rowStatusKey.value, | ||
| 203 | + editingSuffix: editingSuffix.value, | ||
| 204 | + editedSuffix: editedSuffix.value, | ||
| 205 | + }); | ||
| 206 | + onMounted(() => { | ||
| 207 | + nextTick(fetchDataTypeList); | ||
| 208 | + }); | ||
| 209 | +</script> | ||
| 210 | + | ||
| 211 | +<style lang="scss" scoped> | ||
| 212 | + .table-container { | ||
| 213 | + flex: 1; | ||
| 214 | + display: flex; | ||
| 215 | + flex-direction: column; | ||
| 216 | + } | ||
| 217 | +</style> | ||
| @@ -0,0 +1,284 @@ | |||
| 1 | +<template> | ||
| 2 | + <div class="table-container"> | ||
| 3 | + <Toolbar | ||
| 4 | + :status="barStatus" | ||
| 5 | + @addLine="handleAddLine(data)" | ||
| 6 | + @removeLine="handleRemoveLine(data)" | ||
| 7 | + /> | ||
| 8 | + <EditTable2 | ||
| 9 | + :data="props.data" | ||
| 10 | + :columns="tableColumns" | ||
| 11 | + :idKey="idKey" | ||
| 12 | + :rowStatusKey="rowStatusKey" | ||
| 13 | + :editingSuffix="editingSuffix" | ||
| 14 | + :editedSuffix="editedSuffix" | ||
| 15 | + v-model:globalEditing="globalEditing" | ||
| 16 | + @currentChange="handleCurrentChange" | ||
| 17 | + > | ||
| 18 | + <template v-for="item in tableColumns" :key="item.prop" v-slot:[item.prop]="scope"> | ||
| 19 | + <el-input | ||
| 20 | + v-if="globalEditing && scope.row[item.prop + editingSuffix] && item.element == 'input'" | ||
| 21 | + v-model="scope.row[item.prop]" | ||
| 22 | + v-bind="item.attribute" | ||
| 23 | + @change="handleChangeValue(scope.row, scope.column)" | ||
| 24 | + /> | ||
| 25 | + <el-input-number | ||
| 26 | + v-else-if=" | ||
| 27 | + globalEditing && scope.row[item.prop + editingSuffix] && item.element == 'inputNumber' | ||
| 28 | + " | ||
| 29 | + v-model="scope.row[item.prop]" | ||
| 30 | + v-bind="item.attribute" | ||
| 31 | + :controls="false" | ||
| 32 | + @change="handleChangeValue(scope.row, scope.column)" | ||
| 33 | + style="width: 100%" | ||
| 34 | + /> | ||
| 35 | + <el-select | ||
| 36 | + v-else-if=" | ||
| 37 | + globalEditing && scope.row[item.prop + editingSuffix] && item.prop == 'dataType' | ||
| 38 | + " | ||
| 39 | + v-model="scope.row[item.prop]" | ||
| 40 | + v-bind="item.attribute" | ||
| 41 | + @change="handleChangeValue(scope.row, scope.column)" | ||
| 42 | + > | ||
| 43 | + <el-option | ||
| 44 | + v-for="op in dataTypeList" | ||
| 45 | + :key="op.value" | ||
| 46 | + :label="op.label" | ||
| 47 | + :value="op.value" | ||
| 48 | + /> | ||
| 49 | + </el-select> | ||
| 50 | + <el-select | ||
| 51 | + v-else-if=" | ||
| 52 | + globalEditing && scope.row[item.prop + editingSuffix] && item.prop == 'columnName' | ||
| 53 | + " | ||
| 54 | + v-model="scope.row[item.prop]" | ||
| 55 | + v-bind="item.attribute" | ||
| 56 | + @change="handleChangeValue(scope.row, scope.column)" | ||
| 57 | + > | ||
| 58 | + <el-option | ||
| 59 | + v-for="op in props.columns" | ||
| 60 | + :key="op.value" | ||
| 61 | + :label="op.label" | ||
| 62 | + :value="op.value" | ||
| 63 | + /> | ||
| 64 | + </el-select> | ||
| 65 | + <el-cascader | ||
| 66 | + v-else-if=" | ||
| 67 | + globalEditing && scope.row[item.prop + editingSuffix] && item.element == 'cascader' | ||
| 68 | + " | ||
| 69 | + v-model="scope.row[item.prop]" | ||
| 70 | + :props="cascaderProps" | ||
| 71 | + :options="item.options" | ||
| 72 | + @change="handleChangeValue(scope.row, scope.column)" | ||
| 73 | + /> | ||
| 74 | + <el-checkbox | ||
| 75 | + v-else-if="item.element == 'checkbox'" | ||
| 76 | + v-model="scope.row[item.prop]" | ||
| 77 | + @change="handleChangeValue(scope.row, scope.column)" | ||
| 78 | + /> | ||
| 79 | + <span v-else>{{ formatTextCell(scope.row[item.prop], item.element) }}</span> | ||
| 80 | + </template> | ||
| 81 | + </EditTable2> | ||
| 82 | + </div> | ||
| 83 | +</template> | ||
| 84 | + | ||
| 85 | +<script lang="ts" setup> | ||
| 86 | + import type { CascaderProps } from 'element-plus'; | ||
| 87 | + import EditTable2 from './EditTable2.vue'; | ||
| 88 | + import Toolbar from './Toolbar.vue'; | ||
| 89 | + import { getSchemaList, getSchemaObjectList } from '@/api/metaData'; | ||
| 90 | + import { getTableColumn } from '@/api/table'; | ||
| 91 | + import { useEditTabHooks } from './useEditTabHooks'; | ||
| 92 | + import type { CommonParams, TableColumn, AvailColumnList } from '../types'; | ||
| 93 | + interface FetchNode { | ||
| 94 | + name: string; | ||
| 95 | + oid: string; | ||
| 96 | + } | ||
| 97 | + const props = withDefaults( | ||
| 98 | + defineProps<{ | ||
| 99 | + data: any[]; | ||
| 100 | + commonParams: CommonParams; | ||
| 101 | + columns: AvailColumnList[]; | ||
| 102 | + }>(), | ||
| 103 | + { | ||
| 104 | + data: () => [], | ||
| 105 | + columns: () => [], | ||
| 106 | + }, | ||
| 107 | + ); | ||
| 108 | + | ||
| 109 | + const emit = defineEmits<{ | ||
| 110 | + (e: 'update:data', value: any[]): void; | ||
| 111 | + }>(); | ||
| 112 | + | ||
| 113 | + const idKey = ref('_id'); | ||
| 114 | + const rowStatusKey = ref('_rowStatus'); | ||
| 115 | + const editingSuffix = ref('_isEditing'); | ||
| 116 | + const editedSuffix = ref('_edited'); | ||
| 117 | + const globalEditing = ref(false); | ||
| 118 | + const barStatus = reactive({ | ||
| 119 | + addLine: true, | ||
| 120 | + removeLine: true, | ||
| 121 | + }); | ||
| 122 | + | ||
| 123 | + const dataTypeList = ref([]); | ||
| 124 | + const data = computed({ | ||
| 125 | + get: () => props.data, | ||
| 126 | + set: (val) => emit('update:data', val), | ||
| 127 | + }); | ||
| 128 | + const tableColumns = ref<TableColumn[]>([ | ||
| 129 | + { | ||
| 130 | + label: 'table.constraint.constrainName', | ||
| 131 | + prop: 'constrainName', | ||
| 132 | + slot: true, | ||
| 133 | + isI18n: true, | ||
| 134 | + element: 'input', | ||
| 135 | + }, | ||
| 136 | + { | ||
| 137 | + label: 'table.constraint.columnName', | ||
| 138 | + prop: 'columnName', | ||
| 139 | + slot: true, | ||
| 140 | + isI18n: true, | ||
| 141 | + element: 'select', | ||
| 142 | + attribute: { | ||
| 143 | + multiple: true, | ||
| 144 | + collapseTags: true, | ||
| 145 | + }, | ||
| 146 | + options: [], | ||
| 147 | + }, | ||
| 148 | + { | ||
| 149 | + label: 'table.constraint.constrainType', | ||
| 150 | + prop: 'constrainType', | ||
| 151 | + slot: true, | ||
| 152 | + isI18n: true, | ||
| 153 | + element: 'cascader', | ||
| 154 | + options: [ | ||
| 155 | + { | ||
| 156 | + value: 'c', | ||
| 157 | + label: 'CHECK', | ||
| 158 | + disabled: false, | ||
| 159 | + leaf: true, | ||
| 160 | + }, | ||
| 161 | + { | ||
| 162 | + value: 'u', | ||
| 163 | + label: 'UNIQUE', | ||
| 164 | + disabled: false, | ||
| 165 | + leaf: true, | ||
| 166 | + }, | ||
| 167 | + { | ||
| 168 | + value: 'p', | ||
| 169 | + label: 'PRIMARY KEY', | ||
| 170 | + disabled: false, | ||
| 171 | + leaf: true, | ||
| 172 | + }, | ||
| 173 | + { | ||
| 174 | + value: 's', | ||
| 175 | + label: 'PARTIAL CLUSTER KEY', | ||
| 176 | + disabled: false, | ||
| 177 | + leaf: true, | ||
| 178 | + }, | ||
| 179 | + { | ||
| 180 | + value: 'f', | ||
| 181 | + label: 'FOREIGN KEY', | ||
| 182 | + disabled: false, | ||
| 183 | + leaf: false, | ||
| 184 | + }, | ||
| 185 | + ], | ||
| 186 | + }, | ||
| 187 | + { | ||
| 188 | + label: 'table.constraint.expression', | ||
| 189 | + prop: 'expression', | ||
| 190 | + slot: true, | ||
| 191 | + isI18n: true, | ||
| 192 | + element: 'input', | ||
| 193 | + }, | ||
| 194 | + { | ||
| 195 | + label: 'table.constraint.isDeffered', | ||
| 196 | + prop: 'isDeffered', | ||
| 197 | + slot: true, | ||
| 198 | + isI18n: true, | ||
| 199 | + element: 'checkbox', | ||
| 200 | + }, | ||
| 201 | + { | ||
| 202 | + label: 'table.description', | ||
| 203 | + prop: 'description', | ||
| 204 | + slot: true, | ||
| 205 | + isI18n: true, | ||
| 206 | + element: 'input', | ||
| 207 | + attribute: { | ||
| 208 | + maxlength: 5000, | ||
| 209 | + }, | ||
| 210 | + }, | ||
| 211 | + ]); | ||
| 212 | + const cascaderProps: CascaderProps = { | ||
| 213 | + lazy: true, | ||
| 214 | + lazyLoad: async (node, resolve) => { | ||
| 215 | + if (node.level == 1) { | ||
| 216 | + resolve(await fetchSchemaList()); | ||
| 217 | + } else if (node.level == 2) { | ||
| 218 | + resolve(await fetchSchemaContentList(node.value)); | ||
| 219 | + } else if (node.level == 3) { | ||
| 220 | + resolve(await fetchColumnList(node)); | ||
| 221 | + } else { | ||
| 222 | + resolve([]); | ||
| 223 | + } | ||
| 224 | + }, | ||
| 225 | + }; | ||
| 226 | + const formatTextCell = (value: string[] | string, type) => { | ||
| 227 | + if (type == 'cascader' && Array.isArray(value)) { | ||
| 228 | + enum ConstrainType { | ||
| 229 | + c = 'CHECK', | ||
| 230 | + u = 'UNIQUE', | ||
| 231 | + p = 'PRIMARY KEY', | ||
| 232 | + s = 'PRIMARY KEY', | ||
| 233 | + f = 'FOREIGN KEY', | ||
| 234 | + } | ||
| 235 | + return value.length > 1 | ||
| 236 | + ? `${ConstrainType[value[0]]}/${value[1]}.${value[2]}.${value[3]}` | ||
| 237 | + : ConstrainType[value[0]]; | ||
| 238 | + } | ||
| 239 | + if (['select'].includes(type) && Array.isArray(value)) return value.join(','); | ||
| 240 | + return value; | ||
| 241 | + }; | ||
| 242 | + const fetchSchemaList = async () => { | ||
| 243 | + const data = (await getSchemaList({ | ||
| 244 | + uuid: props.commonParams.uuid, | ||
| 245 | + })) as unknown as FetchNode[]; | ||
| 246 | + return data.map((item) => ({ oid: item.oid, value: item.name, label: item.name, leaf: false })); | ||
| 247 | + }; | ||
| 248 | + const fetchSchemaContentList = async (schema) => { | ||
| 249 | + const data = (await getSchemaObjectList({ | ||
| 250 | + schema, | ||
| 251 | + uuid: props.commonParams.uuid, | ||
| 252 | + })) as unknown as any[]; | ||
| 253 | + return data[0]?.table.map((item: FetchNode) => ({ | ||
| 254 | + oid: item.oid, | ||
| 255 | + value: item.name, | ||
| 256 | + label: item.name, | ||
| 257 | + leaf: false, | ||
| 258 | + })); | ||
| 259 | + }; | ||
| 260 | + const fetchColumnList = async (node) => { | ||
| 261 | + const res = (await getTableColumn({ | ||
| 262 | + ...props.commonParams, | ||
| 263 | + schema: node.pathValues[1], | ||
| 264 | + oid: node.data.oid, | ||
| 265 | + tableName: node.data.value, | ||
| 266 | + })) as unknown as any; | ||
| 267 | + return res.result.map((item) => ({ value: item[0], label: item[0], leaf: true })); | ||
| 268 | + }; | ||
| 269 | + const { handleChangeValue, handleCurrentChange, handleAddLine, handleRemoveLine } = | ||
| 270 | + useEditTabHooks({ | ||
| 271 | + idKey: idKey.value, | ||
| 272 | + rowStatusKey: rowStatusKey.value, | ||
| 273 | + editingSuffix: editingSuffix.value, | ||
| 274 | + editedSuffix: editedSuffix.value, | ||
| 275 | + }); | ||
| 276 | +</script> | ||
| 277 | + | ||
| 278 | +<style lang="scss" scoped> | ||
| 279 | + .table-container { | ||
| 280 | + flex: 1; | ||
| 281 | + display: flex; | ||
| 282 | + flex-direction: column; | ||
| 283 | + } | ||
| 284 | +</style> | ||
| @@ -0,0 +1,40 @@ | |||
| 1 | +<template> | ||
| 2 | + <div class="monaco-wrapper" v-loading="props.loading"> | ||
| 3 | + <AceEditor ref="editorRef" readOnly style="margin: 4px 0; border: 1px solid #ddd" /> | ||
| 4 | + </div> | ||
| 5 | +</template> | ||
| 6 | + | ||
| 7 | +<script lang="ts" setup> | ||
| 8 | + import AceEditor from '@/components/AceEditor.vue'; | ||
| 9 | + | ||
| 10 | + const props = withDefaults( | ||
| 11 | + defineProps<{ | ||
| 12 | + data: any; | ||
| 13 | + loading?: boolean; | ||
| 14 | + }>(), | ||
| 15 | + { | ||
| 16 | + data: ``, | ||
| 17 | + loading: false, | ||
| 18 | + }, | ||
| 19 | + ); | ||
| 20 | + | ||
| 21 | + const editorRef = ref(); | ||
| 22 | + watch( | ||
| 23 | + () => props.data, | ||
| 24 | + (value) => { | ||
| 25 | + editorRef.value.setValue(value); | ||
| 26 | + }, | ||
| 27 | + ); | ||
| 28 | + | ||
| 29 | + onMounted(() => { | ||
| 30 | + editorRef.value.setValue(props.data); | ||
| 31 | + }); | ||
| 32 | +</script> | ||
| 33 | + | ||
| 34 | +<style> | ||
| 35 | + .monaco-wrapper { | ||
| 36 | + flex: 1; | ||
| 37 | + padding: 10px; | ||
| 38 | + height: 100%; | ||
| 39 | + } | ||
| 40 | +</style> | ||
| @@ -0,0 +1,116 @@ | |||
| 1 | +<template> | ||
| 2 | + <el-table | ||
| 3 | + :data="props.data" | ||
| 4 | + v-loading="props.loading" | ||
| 5 | + border | ||
| 6 | + highlight-current-row | ||
| 7 | + :cell-class-name="cellClassFn" | ||
| 8 | + @click="handleTableClick" | ||
| 9 | + @cell-dblclick="handleCellDbClick" | ||
| 10 | + @current-change="handleCurrentChange" | ||
| 11 | + style="width: 100%; height: 100%" | ||
| 12 | + v-click-outside.el-select__popper.el-cascader__dropdown="clickOutsideTable" | ||
| 13 | + flexible | ||
| 14 | + :row-key="idKey" | ||
| 15 | + > | ||
| 16 | + <el-table-column type="index" width="50" align="center" /> | ||
| 17 | + <template v-for="(item, index) in props.columns" :key="index"> | ||
| 18 | + <el-table-column | ||
| 19 | + align="center" | ||
| 20 | + header-align="center" | ||
| 21 | + v-bind="item" | ||
| 22 | + :label="item.isI18n ? t(item.label) : item.label" | ||
| 23 | + > | ||
| 24 | + <template v-if="item.slot" v-slot="scope"> | ||
| 25 | + <slot :name="item.prop" v-bind="scope"></slot> | ||
| 26 | + </template> | ||
| 27 | + </el-table-column> | ||
| 28 | + </template> | ||
| 29 | + </el-table> | ||
| 30 | +</template> | ||
| 31 | + | ||
| 32 | +<script lang="ts" setup> | ||
| 33 | + import vClickOutside from '@/directives/clickOutside'; | ||
| 34 | + import { findParentElement } from '@/utils'; | ||
| 35 | + import { useI18n } from 'vue-i18n'; | ||
| 36 | + const { t } = useI18n(); | ||
| 37 | + const props = withDefaults( | ||
| 38 | + defineProps<{ | ||
| 39 | + data: any[]; | ||
| 40 | + columns: any[]; | ||
| 41 | + loading?: boolean; | ||
| 42 | + idKey?: string; | ||
| 43 | + rowStatusKey?: string; // such as "id_rowStatus", value in [ '', 'add', 'delete', 'edit'] | ||
| 44 | + editingSuffix: string; // such as "id_isEditing" | ||
| 45 | + editedSuffix: string; // such as "id_edited" | ||
| 46 | + globalEditing: boolean; | ||
| 47 | + showEditColor?: boolean; | ||
| 48 | + }>(), | ||
| 49 | + { | ||
| 50 | + data: () => [], | ||
| 51 | + columns: () => [], | ||
| 52 | + loading: false, | ||
| 53 | + globalEditing: false, | ||
| 54 | + showEditColor: false, | ||
| 55 | + }, | ||
| 56 | + ); | ||
| 57 | + const emit = defineEmits<{ | ||
| 58 | + (e: 'currentChange', data: any): void; | ||
| 59 | + (e: 'cellDataChange', data?: any): void; | ||
| 60 | + (e: 'cellDblclick', row, column, cell, event): void; | ||
| 61 | + (e: 'update:edited', value: boolean): void; | ||
| 62 | + (e: 'update:globalEditing', value: boolean): void; | ||
| 63 | + }>(); | ||
| 64 | + const editingElement = ref(null); | ||
| 65 | + const editingData = reactive({ | ||
| 66 | + row: {}, | ||
| 67 | + column: {} as any, | ||
| 68 | + }); | ||
| 69 | + const cellClassFn = ({ row, column }) => { | ||
| 70 | + if (!props.showEditColor) return ''; | ||
| 71 | + if (props.rowStatusKey && row[props.rowStatusKey] == 'add') return 'add'; | ||
| 72 | + if (props.rowStatusKey && row[props.rowStatusKey] == 'delete') return 'delete'; | ||
| 73 | + if (row[column.property + props.editedSuffix]) return 'edited'; | ||
| 74 | + }; | ||
| 75 | + const clickOutsideTable = () => { | ||
| 76 | + if (props.globalEditing) { | ||
| 77 | + emit('update:globalEditing', false); | ||
| 78 | + editingElement.value = null; | ||
| 79 | + editingData.row[editingData.column.property + props.editingSuffix] = false; | ||
| 80 | + } | ||
| 81 | + }; | ||
| 82 | + const handleTableClick = (event) => { | ||
| 83 | + if ( | ||
| 84 | + props.globalEditing && | ||
| 85 | + editingElement.value && | ||
| 86 | + !editingElement.value.contains(event.target) | ||
| 87 | + ) { | ||
| 88 | + clickOutsideTable(); | ||
| 89 | + } | ||
| 90 | + }; | ||
| 91 | + const handleCellDbClick = (row, column, cell, event) => { | ||
| 92 | + emit('cellDblclick', row, column, cell, event); | ||
| 93 | + editingElement.value = findParentElement(event.target, 'el-table__cell'); | ||
| 94 | + emit('update:globalEditing', true); | ||
| 95 | + Object.assign(editingData, { | ||
| 96 | + row, | ||
| 97 | + column, | ||
| 98 | + }); | ||
| 99 | + row[column.property + props.editingSuffix] = true; | ||
| 100 | + nextTick(() => { | ||
| 101 | + cell.querySelector('.el-input__inner')?.focus(); | ||
| 102 | + }); | ||
| 103 | + }; | ||
| 104 | + const handleCurrentChange = (currentRow) => { | ||
| 105 | + emit('currentChange', currentRow); | ||
| 106 | + }; | ||
| 107 | +</script> | ||
| 108 | +<style lang="scss" scoped> | ||
| 109 | + .el-table { | ||
| 110 | + :deep(.el-table__body) { | ||
| 111 | + .el-table__cell .cell { | ||
| 112 | + min-height: 2em; | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + } | ||
| 116 | +</style> | ||
Rplugins/data-studio/web-ui/src/views/table/components/Constraint.vue→plugins/data-studio/web-ui/src/views/table/components/ConstraintTab.vue+0-0
Dplugins/data-studio/web-ui/src/views/table/components/Data.vue+0-52
Rplugins/data-studio/web-ui/src/views/table/components/Column.vue→plugins/data-studio/web-ui/src/views/table/components/GeneralTab.vue+7-7