You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by le...@apache.org on 2022/07/01 04:34:11 UTC
[incubator-linkis] branch dev-1.2.0 updated: fix-bug #2273 Data source edit form supports Chinese and English (#2388)
This is an automated email from the ASF dual-hosted git repository.
leojie pushed a commit to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.2.0 by this push:
new 84a48a001 fix-bug #2273 Data source edit form supports Chinese and English (#2388)
84a48a001 is described below
commit 84a48a0010850cd84172e2854f2f369db3a257d2
Author: yyuser5201314 <63...@users.noreply.github.com>
AuthorDate: Fri Jul 1 12:34:06 2022 +0800
fix-bug #2273 Data source edit form supports Chinese and English (#2388)
* fix-bug #2273 Data source edit form supports Chinese and English
* fix-bug #2273 Data source edit form supports Chinese and English Code format fix
* fix-bug #2273 Data source edit form supports Chinese and English Reduce Code Redundancy
---
linkis-dist/package/db/linkis_ddl.sql | 10 ++++++----
linkis-dist/package/db/linkis_dml.sql | 22 +++++++++++-----------
.../package/db/module/linkis_datasource.sql | 8 +++++---
.../core/dao/DataSourceParamKeyDao.java | 8 ++++++++
.../core/dao/mapper/DataSourceParamKeyMapper.xml | 12 +++++++++++-
.../core/restful/DataSourceCoreRestfulApi.java | 6 ++++--
.../core/service/DataSourceRelateService.java | 10 ++++++++++
.../service/impl/DataSourceRelateServiceImpl.java | 10 ++++++++++
8 files changed, 65 insertions(+), 21 deletions(-)
diff --git a/linkis-dist/package/db/linkis_ddl.sql b/linkis-dist/package/db/linkis_ddl.sql
index d73b9df1d..b0f83303c 100644
--- a/linkis-dist/package/db/linkis_ddl.sql
+++ b/linkis-dist/package/db/linkis_ddl.sql
@@ -5,16 +5,16 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS `linkis_ps_configuration_config_key`;
@@ -902,11 +902,13 @@ CREATE TABLE `linkis_ps_dm_datasource_type_key`
`data_source_type_id` int(11) NOT NULL,
`key` varchar(32) COLLATE utf8_bin NOT NULL,
`name` varchar(32) COLLATE utf8_bin NOT NULL,
+ `name_en` varchar(32) COLLATE utf8_bin NOT NULL,
`default_value` varchar(50) COLLATE utf8_bin NULL DEFAULT NULL,
`value_type` varchar(50) COLLATE utf8_bin NOT NULL,
`scope` varchar(50) COLLATE utf8_bin NULL DEFAULT NULL,
`require` tinyint(1) NULL DEFAULT 0,
`description` varchar(200) COLLATE utf8_bin NULL DEFAULT NULL,
+ `description_en` varchar(200) COLLATE utf8_bin NULL DEFAULT NULL,
`value_regex` varchar(200) COLLATE utf8_bin NULL DEFAULT NULL,
`ref_id` bigint(20) NULL DEFAULT NULL,
`ref_value` varchar(50) COLLATE utf8_bin NULL DEFAULT NULL,
@@ -946,4 +948,4 @@ CREATE TABLE `linkis_mg_gateway_auth_token` (
`update_by` varchar(32),
PRIMARY KEY (`id`),
UNIQUE KEY `token_name` (`token_name`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\ No newline at end of file
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/linkis-dist/package/db/linkis_dml.sql b/linkis-dist/package/db/linkis_dml.sql
index 338b13088..a538ee6bc 100644
--- a/linkis-dist/package/db/linkis_dml.sql
+++ b/linkis-dist/package/db/linkis_dml.sql
@@ -5,16 +5,16 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
-- 变量:
@@ -456,14 +456,14 @@ INSERT INTO `linkis_ps_dm_datasource_type` (`name`, `description`, `option`, `cl
INSERT INTO `linkis_ps_dm_datasource_type` (`name`, `description`, `option`, `classifier`, `icon`, `layers`) VALUES ('mongodb', 'default', 'default', 'DEFAULT', NULL, 3);
-INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `default_value`, `value_type`, `scope`, `require`, `description`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'host', '主机名(Host)', NULL, 'TEXT', NULL, 1, '主机名(Host)', NULL, NULL, NULL, NULL, now(), now());
-INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `default_value`, `value_type`, `scope`, `require`, `description`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'port', '端口号(Port)', NULL, 'TEXT', NULL, 1, '端口号(Port)', NULL, NULL, NULL, NULL, now(), now());
-INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `default_value`, `value_type`, `scope`, `require`, `description`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'driverClassName', '驱动类名(Driver class name)', 'com.mysql.jdbc.Driver', 'TEXT', NULL, 1, '驱动类名(Driver class name)', NULL, NULL, NULL, NULL, now(), now());
-INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `default_value`, `value_type`, `scope`, `require`, `description`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'params', '连接参数(Connection params)', NULL, 'TEXT', NULL, 0, '输入JSON格式(Input JSON format): {"param":"value"}', NULL, NULL, NULL, NULL, now(), now());
-INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `default_value`, `value_type`, `scope`, `require`, `description`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'username', '用户名(Username)', NULL, 'TEXT', NULL, 1, '用户名(Username)', '^[0-9A-Za-z_-]+$', NULL, NULL, NULL, now(), now());
-INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `default_value`, `value_type`, `scope`, `require`, `description`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'password', '密码(Password)', NULL, 'PASSWORD', NULL, 1, '密码(Password)', '', NULL, NULL, NULL, now(), now());
-INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `default_value`, `value_type`, `scope`, `require`, `description`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'databaseName', '数据库名(Database name)', NULL, 'TEXT', NULL, 0, '数据库名(Database name)', NULL, NULL, NULL, NULL, now(), now());
-INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `default_value`, `value_type`, `scope`, `require`, `description`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (4, 'envId', '集群环境(Cluster env)', NULL, 'SELECT', NULL, 1, '集群环境(Cluster env)', NULL, NULL, NULL, '/data-source-manager/env-list/all/type/4', now(), now());
+INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `name_en`, `default_value`, `value_type`, `scope`, `require`, `description`, `description_en`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'host', '主机名(Host)', 'Host', NULL, 'TEXT', NULL, 1, '主机名(Host)', 'Host', NULL, NULL, NULL, NULL, now(), now());
+INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `name_en`, `default_value`, `value_type`, `scope`, `require`, `description`, `description_en`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'port', '端口号(Port)','Port', NULL, 'TEXT', NULL, 1, '端口号(Port)','Port', NULL, NULL, NULL, NULL, now(), now());
+INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `name_en`, `default_value`, `value_type`, `scope`, `require`, `description`, `description_en`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'driverClassName', '驱动类名(Driver class name)', 'Driver class name', 'com.mysql.jdbc.Driver', 'TEXT', NULL, 1, '驱动类名(Driver class name)', 'Driver class name', NULL, NULL, NULL, NULL, now(), now());
+INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `name_en`, `default_value`, `value_type`, `scope`, `require`, `description`, `description_en`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'params', '连接参数(Connection params)', 'Connection params', NULL, 'TEXT', NULL, 0, '输入JSON格式(Input JSON format): {"param":"value"}', 'Input JSON format: {"param":"value"}', NULL, NULL, NULL, NULL, now(), now());
+INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `name_en`, `default_value`, `value_type`, `scope`, `require`, `description`, `description_en`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'username', '用户名(Username)', 'Username', NULL, 'TEXT', NULL, 1, '用户名(Username)', 'Username', '^[0-9A-Za-z_-]+$', NULL, NULL, NULL, now(), now());
+INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `name_en`, `default_value`, `value_type`, `scope`, `require`, `description`, `description_en`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'password', '密码(Password)', 'Password', NULL, 'PASSWORD', NULL, 1, '密码(Password)', 'Password', '', NULL, NULL, NULL, now(), now());
+INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `name_en`, `default_value`, `value_type`, `scope`, `require`, `description`, `description_en`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (1, 'databaseName', '数据库名(Database name)', 'Database name', NULL, 'TEXT', NULL, 0, '数据库名(Database name)', 'Database name', NULL, NULL, NULL, NULL, now(), now());
+INSERT INTO `linkis_ps_dm_datasource_type_key` (`data_source_type_id`, `key`, `name`, `name_en`, `default_value`, `value_type`, `scope`, `require`, `description`, `description_en`, `value_regex`, `ref_id`, `ref_value`, `data_source`, `update_time`, `create_time`) VALUES (4, 'envId', '集群环境(Cluster env)', 'Cluster env', NULL, 'SELECT', NULL, 1, '集群环境(Cluster env)', 'Cluster env', NULL, NULL, NULL, '/data-source-manager/env-list/all/type/4', now(), now());
INSERT INTO `linkis_ps_dm_datasource_env` (`env_name`, `env_desc`, `datasource_type_id`, `parameter`, `create_time`, `create_user`, `modify_time`, `modify_user`) VALUES ('测试环境SIT', '测试环境SIT', 4, '{"uris":"thrift://localhost:9083", "hadoopConf":{"hive.metastore.execute.setugi":"true"}}', now(), NULL, now(), NULL);
diff --git a/linkis-dist/package/db/module/linkis_datasource.sql b/linkis-dist/package/db/module/linkis_datasource.sql
index 2a012cf16..453923be9 100644
--- a/linkis-dist/package/db/module/linkis_datasource.sql
+++ b/linkis-dist/package/db/module/linkis_datasource.sql
@@ -5,16 +5,16 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
@@ -92,11 +92,13 @@ CREATE TABLE `linkis_ps_dm_datasource_type_key`
`data_source_type_id` int(11) NOT NULL,
`key` varchar(32) COLLATE utf8_bin NOT NULL,
`name` varchar(32) COLLATE utf8_bin NOT NULL,
+ `name_en` varchar(32) COLLATE utf8_bin NOT NULL,
`default_value` varchar(50) COLLATE utf8_bin NULL DEFAULT NULL,
`value_type` varchar(50) COLLATE utf8_bin NOT NULL,
`scope` varchar(50) COLLATE utf8_bin NULL DEFAULT NULL,
`require` tinyint(1) NULL DEFAULT 0,
`description` varchar(200) COLLATE utf8_bin NULL DEFAULT NULL,
+ `description_en` varchar(200) COLLATE utf8_bin NULL DEFAULT NULL,
`value_regex` varchar(200) COLLATE utf8_bin NULL DEFAULT NULL,
`ref_id` bigint(20) NULL DEFAULT NULL,
`ref_value` varchar(50) COLLATE utf8_bin NULL DEFAULT NULL,
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/dao/DataSourceParamKeyDao.java b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/dao/DataSourceParamKeyDao.java
index 664835145..53b787c53 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/dao/DataSourceParamKeyDao.java
+++ b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/dao/DataSourceParamKeyDao.java
@@ -33,6 +33,14 @@ public interface DataSourceParamKeyDao {
*/
List<DataSourceParamKeyDefinition> listByDataSourceType(Long dataSourceTypeId);
+ /**
+ * List by data source type id
+ *
+ * @param dataSourceTypeId type id
+ * @return
+ */
+ List<DataSourceParamKeyDefinition> listByDataSourceTypeEn(Long dataSourceTypeId);
+
/**
* List by data source type id and scope
*
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/dao/mapper/DataSourceParamKeyMapper.xml b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/dao/mapper/DataSourceParamKeyMapper.xml
index 86cf7ddac..6f6c89314 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/dao/mapper/DataSourceParamKeyMapper.xml
+++ b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/dao/mapper/DataSourceParamKeyMapper.xml
@@ -32,19 +32,29 @@
<result property="refValue" column="ref_value"/>
<result property="dataSource" column="data_source" />
</resultMap>
+
<sql id="param_key_query">
`id`, `key`, `description`, `name`, `require`, `scope`,
`default_value`, `value_type`, `value_regex`, `ref_id`, `ref_value`, `data_source`
</sql>
+ <sql id="param_key_query_en">
+ `id`, `key`, `description_en` as `description`, `name_en` as `name`, `require`, `scope`,
+ `default_value`, `value_type`, `value_regex`, `ref_id`, `ref_value`, `data_source`
+ </sql>
<select id="listByDataSourceType" resultMap="paramKeyMap" parameterType="Long">
SELECT
<include refid="param_key_query"/>
FROM `linkis_ps_dm_datasource_type_key` WHERE `data_source_type_id` = #{dataSourceTypeId};
</select>
+ <select id="listByDataSourceTypeEn" resultMap="paramKeyMap" parameterType="Long">
+ SELECT
+ <include refid="param_key_query_en"/>
+ FROM `linkis_ps_dm_datasource_type_key` WHERE `data_source_type_id` = #{dataSourceTypeId};
+ </select>
<select id="listByDataSourceTypeAndScope" resultMap="paramKeyMap">
<![CDATA[SELECT ]]>
<include refid="param_key_query"/>
<![CDATA[ FROM `linkis_ps_dm_datasource_type_key`
WHERE `data_source_type_id` = #{dataSourceTypeId} AND `scope` = #{scope};]]>
</select>
-</mapper>
\ No newline at end of file
+</mapper>
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/restful/DataSourceCoreRestfulApi.java b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/restful/DataSourceCoreRestfulApi.java
index a4888597b..74f7ae5bb 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/restful/DataSourceCoreRestfulApi.java
+++ b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/restful/DataSourceCoreRestfulApi.java
@@ -92,11 +92,13 @@ public class DataSourceCoreRestfulApi {
}
@RequestMapping(value = "/key-define/type/{typeId}", method = RequestMethod.GET)
- public Message getKeyDefinitionsByType(@PathVariable("typeId") Long dataSourceTypeId) {
+ public Message getKeyDefinitionsByType(
+ @PathVariable("typeId") Long dataSourceTypeId, HttpServletRequest req) {
return RestfulApiHelper.doAndResponse(
() -> {
List<DataSourceParamKeyDefinition> keyDefinitions =
- dataSourceRelateService.getKeyDefinitionsByType(dataSourceTypeId);
+ dataSourceRelateService.getKeyDefinitionsByType(
+ dataSourceTypeId, req.getHeader("Content-Language"));
return Message.ok().data("keyDefine", keyDefinitions);
},
"Fail to get key definitions of data source type[查询数据源参数键值对失败]");
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/service/DataSourceRelateService.java b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/service/DataSourceRelateService.java
index f5b1fc02a..800e35ae0 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/service/DataSourceRelateService.java
+++ b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/service/DataSourceRelateService.java
@@ -41,6 +41,16 @@ public interface DataSourceRelateService {
*/
List<DataSourceParamKeyDefinition> getKeyDefinitionsByType(Long dataSourceTypeId);
+ /**
+ * Get key definitions by data source type and languageType
+ *
+ * @param dataSourceTypeId data source type id
+ * @param languageType language type zh or en
+ * @return
+ */
+ List<DataSourceParamKeyDefinition> getKeyDefinitionsByType(
+ Long dataSourceTypeId, String languageType);
+
/**
* Get all data source types
*
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/service/impl/DataSourceRelateServiceImpl.java b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/service/impl/DataSourceRelateServiceImpl.java
index c3373ad22..dcba7e9d3 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/service/impl/DataSourceRelateServiceImpl.java
+++ b/linkis-public-enhancements/linkis-datasource/linkis-datasource-manager/server/src/main/java/org/apache/linkis/datasourcemanager/core/service/impl/DataSourceRelateServiceImpl.java
@@ -46,6 +46,16 @@ public class DataSourceRelateServiceImpl implements DataSourceRelateService {
return paramKeyDao.listByDataSourceType(dataSourceTypeId);
}
+ @Override
+ public List<DataSourceParamKeyDefinition> getKeyDefinitionsByType(
+ Long dataSourceTypeId, String languageType) {
+ if (languageType.equals("zh-CN")) {
+ return paramKeyDao.listByDataSourceType(dataSourceTypeId);
+ } else {
+ return paramKeyDao.listByDataSourceTypeEn(dataSourceTypeId);
+ }
+ }
+
@Override
public List<DataSourceType> getAllDataSourceTypes() {
return dataSourceTypeDao.getAllTypes();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org