From dac2515602fd9533896a3fc336b0ab0a0014b2ef Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 8 Nov 2019 14:18:34 +0800 Subject: [PATCH 01/11] =?UTF-8?q?fix:=20DEC-10883=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=85=B6=E4=BB=96JDBC=E7=9A=84=E7=B1=BB=E5=9E=8B=E4=B8=BAother?= =?UTF-8?q?JDBC=E4=BB=A5=E5=8C=BA=E5=88=AB=E6=97=A7=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/app.service.ts | 2 +- src/modules/constants/constant.ts | 15 +++++++++------ src/modules/pages/database/database.ts | 8 ++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index 55b8621..d37c088 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -28,7 +28,7 @@ export function getJdbcDatabaseType(database: string, driver: string): DatabaseT let databaseType = null; // KERNEL-1655 兼容旧版 由于旧版设计器创建的数据连接database都为other,所以要根据driber来判断数据类型 // DEC-10872 不能过滤other,因为新版数据连接创建的其他jdbc也是other类型,会混淆,需要和后端讨论一个最佳的解决方案。 - if (database && DATA_BASE_TYPES.some(item => item.databaseType === database)) { + if (database && database !== 'other' && DATA_BASE_TYPES.some(item => item.databaseType === database)) { databaseType = DATA_BASE_TYPES.find(item => item.databaseType === database); } else { const designDatabase = DESIGN_DRIVER_TYPE.find(item => item.driver === driver); diff --git a/src/modules/constants/constant.ts b/src/modules/constants/constant.ts index 20f0200..019cf43 100644 --- a/src/modules/constants/constant.ts +++ b/src/modules/constants/constant.ts @@ -7,19 +7,22 @@ export const PAGE_INDEX = { POOL: 'pool', }; +export const OTHER_JDBC = 'otherJDBC'; + export const DATEBASE_FILTER_TYPE = { COMMONLY: 'commonly', ALL: 'all', - OTHER: 'other', + OTHER: OTHER_JDBC, }; BI.constant(CONSTANT_PLUGIN_TYPES, [ ]); + export const DATA_BASE_TYPES_OTHER = { - text: 'other', - databaseType: 'other', + text: OTHER_JDBC, + databaseType: OTHER_JDBC, driver: '', url: '', commonly: false, @@ -162,7 +165,7 @@ export const DATA_BASE_DRIVER_LINK = DecCst && DecCst.Hyperlink ? [ link: DecCst.Hyperlink.Database.INCEPTOR, }, { - databaseType: 'other', + databaseType: OTHER_JDBC, link: DecCst.Hyperlink.Database.OTHER, }, ] : []; @@ -570,13 +573,13 @@ export const DATA_BASE_TYPES = [ }, { text: BI.i18nText('Dec-Dcm_Connection_JDBC_Other'), - databaseType: 'other', + databaseType: OTHER_JDBC, driver: 'org.h2.Driver', drivers: ['org.h2.Driver', 'com.fr.third.org.hsqldb.jdbcDriver', 'org.sqlite.JDBC'], url: 'jdbc:h2://${ENV_HOME}/../database', commonly: false, internal: true, - type: 'other', + type: OTHER_JDBC, hasSchema: true, kerberos: false, urls: { diff --git a/src/modules/pages/database/database.ts b/src/modules/pages/database/database.ts index 9eb3bd8..a13921e 100644 --- a/src/modules/pages/database/database.ts +++ b/src/modules/pages/database/database.ts @@ -2,7 +2,7 @@ import { SearchEditor, Vtape, Right, Htape, Vertical, ButtonGroup, Left, Vertica import { shortcut, store } from '@core/core'; import { FilterXtype } from './filter/filter'; import { DatebaseModel, DatebaseModelXtype } from './database.model'; -import { DATEBASE_FILTER_TYPE } from '@constants/constant'; +import { DATEBASE_FILTER_TYPE, OTHER_JDBC } from '@constants/constant'; import { connectionType } from '@constants/env'; import { DatebaseTypeXtype } from './database_type/database_type'; import { getAllDatabaseTypes } from '../../app.service'; @@ -56,7 +56,7 @@ export class Datebase extends BI.Widget { if (this.model.isPlugin) { datebaseTypes = [...datebaseTypes, ...this.allDatabaseTypes.filter(item => !item.internal)]; } - this.store.setDatebaseTypes(datebaseTypes.filter(item => item.type !== connectionType.JNDI && item.type !== 'other')); + this.store.setDatebaseTypes(datebaseTypes.filter(item => item.type !== connectionType.JNDI && item.type !== OTHER_JDBC)); } }, } @@ -241,10 +241,10 @@ export class Datebase extends BI.Widget { this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => item.commonly)); break; case DATEBASE_FILTER_TYPE.OTHER: - this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => item.type === connectionType.JNDI || item.type === 'other')); + this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => item.type === connectionType.JNDI || item.type === OTHER_JDBC)); break; default: - this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => item.type !== connectionType.JNDI && item.type !== 'other')); + this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => item.type !== connectionType.JNDI && item.type !== OTHER_JDBC)); break; } } From 55ed0a0ec3fa87398a2dce3b6c959c80e0154121 Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 8 Nov 2019 15:09:13 +0800 Subject: [PATCH 02/11] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BD=BF=E7=94=A8providew?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/app.constant.ts | 2 ++ src/modules/app.provider.ts | 9 +++++++++ src/modules/app.service.ts | 10 ++++++---- src/modules/app.ts | 1 + src/modules/constants/constant.ts | 6 +----- src/modules/constants/plugin.ts | 3 --- .../connection/connection_plugin/connection_plugin.ts | 2 +- .../pages/maintain/forms/components/form.plugin.ts | 4 ++-- 8 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 src/modules/app.constant.ts create mode 100644 src/modules/app.provider.ts delete mode 100644 src/modules/constants/plugin.ts diff --git a/src/modules/app.constant.ts b/src/modules/app.constant.ts new file mode 100644 index 0000000..ebb5253 --- /dev/null +++ b/src/modules/app.constant.ts @@ -0,0 +1,2 @@ +export const CONSTANT_PLUGIN_TYPES = 'dec.constant.database.conf.connect.types'; +BI.constant(CONSTANT_PLUGIN_TYPES, []); diff --git a/src/modules/app.provider.ts b/src/modules/app.provider.ts new file mode 100644 index 0000000..af4542a --- /dev/null +++ b/src/modules/app.provider.ts @@ -0,0 +1,9 @@ +import { CONSTANT_PLUGIN_TYPES } from './app.constant'; + +BI.provider('dec.connection.provider.datebase', function() { + this.registerDatabaseType = (config: any) => { + BI.config(CONSTANT_PLUGIN_TYPES, connections => BI.concat(connections, config)); + }; + this.$get = () => BI.inherit(BI.OB, { + }); +}); diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index d37c088..a7fe9be 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -1,5 +1,5 @@ import { DATA_BASE_TYPES, DATA_BASE_TYPES_OTHER, DESIGN_DRIVER_TYPE } from '@constants/constant'; -import { CONSTANT_PLUGIN_TYPES, CONSTANT_PLUGIN_SHOW, CONSTANT_PLUGIN_EDIT } from '@constants/plugin'; +import { CONSTANT_PLUGIN_TYPES } from './app.constant'; import { DatabaseType } from './app.typings'; import { Connection } from './crud/crud.typings'; export function getAllDatabaseTypes():DatabaseType[] { @@ -14,13 +14,15 @@ export function getAllDatabaseTypes():DatabaseType[] { }), ]; } - +function getPlugin(type: string) { + return BI.Constants.getConstant(CONSTANT_PLUGIN_TYPES).find(item => item.databaseType === type); +} export function getPluginWidgetShow(plugin: string) { - return BI.Constants.getConstant(CONSTANT_PLUGIN_SHOW.replace('${databaseType}', plugin)); + return BI.get(getPlugin(plugin), 'show'); } export function getPluginWidgetEdit(plugin: string) { - return BI.Constants.getConstant(CONSTANT_PLUGIN_EDIT.replace('${databaseType}', plugin)); + return BI.get(getPlugin(plugin), 'edit'); } // 由于database可能为空,所以为了兼容平台和设计器,需要根据driver来判断数据库类型 diff --git a/src/modules/app.ts b/src/modules/app.ts index e2b4927..3dd69aa 100644 --- a/src/modules/app.ts +++ b/src/modules/app.ts @@ -4,6 +4,7 @@ import { TitleXtype } from './title/title'; import { PAGE_INDEX } from './constants/constant'; import { ConnectionXtype, DatebaseXtype, MaintainXtype, ConnectionPoolXtype } from './pages'; import { AppModel, AppModelXtype } from './app.model'; +import './app.provider'; import '../less/index.less'; export const AppXtype = 'dec.dcm.main'; diff --git a/src/modules/constants/constant.ts b/src/modules/constants/constant.ts index 019cf43..863c4f7 100644 --- a/src/modules/constants/constant.ts +++ b/src/modules/constants/constant.ts @@ -1,4 +1,4 @@ -import { CONSTANT_PLUGIN_TYPES } from './plugin'; +import { CONSTANT_PLUGIN_TYPES } from '../app.constant'; export const PAGE_INDEX = { CONNECTION: 'connection', @@ -15,10 +15,6 @@ export const DATEBASE_FILTER_TYPE = { OTHER: OTHER_JDBC, }; -BI.constant(CONSTANT_PLUGIN_TYPES, [ -]); - - export const DATA_BASE_TYPES_OTHER = { text: OTHER_JDBC, diff --git a/src/modules/constants/plugin.ts b/src/modules/constants/plugin.ts deleted file mode 100644 index 6037508..0000000 --- a/src/modules/constants/plugin.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const CONSTANT_PLUGIN_TYPES = 'dec.constant.database.conf.connect.types'; -export const CONSTANT_PLUGIN_SHOW = 'dec.constant.database.conf.connect.form.${databaseType}.show'; -export const CONSTANT_PLUGIN_EDIT = 'dec.constant.database.conf.connect.form.${databaseType}.edit'; diff --git a/src/modules/pages/connection/connection_plugin/connection_plugin.ts b/src/modules/pages/connection/connection_plugin/connection_plugin.ts index af6968a..14e6990 100644 --- a/src/modules/pages/connection/connection_plugin/connection_plugin.ts +++ b/src/modules/pages/connection/connection_plugin/connection_plugin.ts @@ -12,7 +12,7 @@ export class ConnectionPlugin extends BI.Widget { return { type: getPluginWidgetShow(databaseType), - formData: this.model.connectionSelectedOne.connectionData, + value: this.model.connectionSelectedOne.connectionData, }; } } diff --git a/src/modules/pages/maintain/forms/components/form.plugin.ts b/src/modules/pages/maintain/forms/components/form.plugin.ts index a25b9d3..6774bca 100644 --- a/src/modules/pages/maintain/forms/components/form.plugin.ts +++ b/src/modules/pages/maintain/forms/components/form.plugin.ts @@ -18,7 +18,7 @@ export class FormPlugin extends BI.Widget { ref: (_ref: any) => { this.plugin = _ref; }, - formData: this.options.formData.connectionData, + value: this.options.formData.connectionData, }; } @@ -29,7 +29,7 @@ export class FormPlugin extends BI.Widget { connectionId, connectionType, connectionName, - connectionData: this.plugin.getSubmitValue(), + connectionData: this.plugin.getValue(), }; } } From 2a47d960ae447ce905eaa6e3d91e881ff80319cb Mon Sep 17 00:00:00 2001 From: alan Date: Tue, 12 Nov 2019 09:56:11 +0800 Subject: [PATCH 03/11] =?UTF-8?q?fix:=20DEC-10944=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A5=E7=A8=8Bservlet=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webpack/webpack.prod.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webpack/webpack.prod.js b/webpack/webpack.prod.js index d71dcd3..bac5eba 100644 --- a/webpack/webpack.prod.js +++ b/webpack/webpack.prod.js @@ -51,9 +51,9 @@ module.exports = merge.smart(common, { options: { plugins: [vars({ variables: { - fontUrl: '/webroot/decision/resources?path=/com/fr/web/ui/font', - imageUrl: '/webroot/decision/resources?path=/com/fr/web/resources/dist/images/1x', - image2xUrl: '/webroot/decision/resources?path=/com/fr/web/resources/dist/images/2x', + fontUrl: '${fineServletURL}/resources?path=/com/fr/web/ui/font', + imageUrl: '${fineServletURL}/resources?path=/com/fr/web/resources/dist/images/1x', + image2xUrl: '${fineServletURL}/resources?path=/com/fr/web/resources/dist/images/2x', } })] }, From 454e3c026ed18cf319900ce8ce75d7e76aaf3963 Mon Sep 17 00:00:00 2001 From: alan Date: Mon, 18 Nov 2019 10:08:10 +0800 Subject: [PATCH 04/11] =?UTF-8?q?fix:=20DEC-10992=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=90=8D=E5=8C=85=E5=90=AB=E7=89=B9?= =?UTF-8?q?=E6=AE=8A=E7=AC=A6=E5=8F=B7=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/__test__/app.test.ts | 16 +++++++++++++++- src/modules/app.service.ts | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/modules/__test__/app.test.ts b/src/modules/__test__/app.test.ts index 5b8cf72..07ded52 100644 --- a/src/modules/__test__/app.test.ts +++ b/src/modules/__test__/app.test.ts @@ -1,11 +1,25 @@ -import { connectionCanEdit } from '../app.service'; +import { connectionCanEdit, resolveUrlInfo } from '../app.service'; const connection = { connectionId: '', connectionType: '', connectionName: '', connectionData: '', }; +/** + * test_author_alan + */ +test('DEC-10992 数据连接名称带-', () => { + expect(resolveUrlInfo('jdbc:sqlserver://192.168.17.111:1433;databaseName=L-Pick-DAS-MengYan')).toEqual({ + host: '192.168.17.111', + port: '1433', + databaseName: 'L-Pick-DAS-MengYan', + urlInfo: '', + }); +}); +/** + * test_author_alan + */ test('BI-51537 判断数据连接是否有权限', () => { expect(connectionCanEdit({ ...connection, diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index a7fe9be..c51f1d9 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -47,7 +47,7 @@ export function getJdbcDatabaseType(database: string, driver: string): DatabaseT export function resolveUrlInfo (url: string) { if (BI.isNull(url)) return {}; - const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([0-9a-zA-Z_\\.]+)(.*)/i); + const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([^]+)(.*)/i); if (result) { return { host: result[5], From 9b3e74d13a4895307f8a8e15a4ebbff432d750f8 Mon Sep 17 00:00:00 2001 From: alan Date: Tue, 19 Nov 2019 14:31:04 +0800 Subject: [PATCH 05/11] =?UTF-8?q?fix:=20DEC-11030=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E9=A9=B1=E5=8A=A8=E6=97=B6=E8=A7=A3=E6=9E=90?= =?UTF-8?q?url=E7=9A=84=E9=97=AE=E9=A2=98=E5=B9=B6=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/__test__/app.test.ts | 31 ++++++++++++++++++- src/modules/app.service.ts | 14 +++++++-- src/modules/constants/constant.ts | 4 +-- .../maintain/forms/components/form.jdbc.ts | 19 ++++++------ 4 files changed, 54 insertions(+), 14 deletions(-) diff --git a/src/modules/__test__/app.test.ts b/src/modules/__test__/app.test.ts index 07ded52..27d080c 100644 --- a/src/modules/__test__/app.test.ts +++ b/src/modules/__test__/app.test.ts @@ -1,10 +1,18 @@ -import { connectionCanEdit, resolveUrlInfo } from '../app.service'; +import { connectionCanEdit, resolveUrlInfo, splitUrl } from '../app.service'; const connection = { connectionId: '', connectionType: '', connectionName: '', connectionData: '', }; + +/** + * test_author_alan + */ +test('DEC-11030', () => { + expect(splitUrl('localhost', '22', 'dbname', 'jdbc:pivotal:greenplum://hostname:port;dbname')).toEqual('jdbc:pivotal:greenplum://localhost:22;dbname'); +}); + /** * test_author_alan */ @@ -17,6 +25,27 @@ test('DEC-10992 数据连接名称带-', () => { }); }); +test('解析url', () => { + expect(resolveUrlInfo('jdbc:postgresql://endpoint:port/database')).toEqual({ + host: 'endpoint', + port: '', + databaseName: 'database', + urlInfo: '', + }); + expect(resolveUrlInfo('jdbc:pivotal:greenplum://hostname:port;dbname')).toEqual({ + host: 'hostname', + port: '', + databaseName: 'dbname', + urlInfo: '', + }); + expect(resolveUrlInfo('jdbc:mysql://hostname:22/database')).toEqual({ + host: 'hostname', + port: '22', + databaseName: 'database', + urlInfo: '', + }); +}); + /** * test_author_alan */ diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index c51f1d9..bcc6268 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -47,7 +47,16 @@ export function getJdbcDatabaseType(database: string, driver: string): DatabaseT export function resolveUrlInfo (url: string) { if (BI.isNull(url)) return {}; - const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([^]+)(.*)/i); + const greenplumUrl = url.match(/^jdbc:(pivotal:greenplum):(thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;)([^]+)(.*)/i); + if (greenplumUrl) { + return { + host: greenplumUrl[4], + port: greenplumUrl[6] === 'port' ? '' : greenplumUrl[6], + databaseName: greenplumUrl[8], + urlInfo: greenplumUrl[9], + }; + } + const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto|redshift|postgresql):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([^]+)(.*)/i); if (result) { return { host: result[5], @@ -87,7 +96,8 @@ export function splitUrl(host: string, port: string, database: string, baseUrl: } return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') - .replace('database', database); + .replace('database', database) + .replace('dbname', database); } export function connectionCanEdit(connection: Connection) { diff --git a/src/modules/constants/constant.ts b/src/modules/constants/constant.ts index 863c4f7..f63fb59 100644 --- a/src/modules/constants/constant.ts +++ b/src/modules/constants/constant.ts @@ -446,8 +446,8 @@ export const DATA_BASE_TYPES = [ hasSchema: false, kerberos: false, urls: { - 'com.mysql.jdbc.Driver': 'jdbc:mysql://localhost/dbname', - 'org.gjt.mm.mysql.Driver': 'jdbc:mysql://localhost/dbname', + 'com.mysql.jdbc.Driver': 'jdbc:mysql://hostname:port/database', + 'org.gjt.mm.mysql.Driver': 'jdbc:mysql://hostname:port/database', }, }, { diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index 637e1bd..a39b3c1 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -98,13 +98,12 @@ export class FormJdbc extends BI.Widget { const value = this.form.driver.getValue(); const connectionData = this.options.formData.connectionData as ConnectionJDBC; const connectionType = getJdbcDatabaseType(connectionData.database, connectionData.driver); - if (connectionType.urls) { - this.form.url.setValue(connectionType.urls[value]); - const urlInfo = resolveUrlInfo(connectionType.urls[value]); - this.form.host.setValue(urlInfo.host); - this.form.database.setValue(urlInfo.databaseName); - this.form.port.setValue(urlInfo.port); - } + const url = connectionType.urls ? connectionType.urls[value] : connectionType.url; + this.form.url.setValue(url); + const urlInfo = resolveUrlInfo(url); + this.form.host.setValue(urlInfo.host); + this.form.database.setValue(urlInfo.databaseName); + this.form.port.setValue(urlInfo.port); }, }], }], @@ -692,11 +691,13 @@ export class FormJdbc extends BI.Widget { } private onHostPortChange(databaseType) { - const { url = '' } = databaseType; + const { urls, url } = databaseType; + const driver = this.form.driver.getValue(); + const selectUrl = BI.get(urls, driver) || url; const host = this.form.host.getValue(); const port = this.form.port.getValue(); const database = this.form.database.getValue(); - this.form.url.setValue(splitUrl(host, port, database, url)); + this.form.url.setValue(splitUrl(host, port, database, selectUrl)); } public setSchemas(schemas: string[]) { From fe1e00b2f8af9731ab6646a17b4ed008abf61e9b Mon Sep 17 00:00:00 2001 From: alan Date: Tue, 19 Nov 2019 15:00:41 +0800 Subject: [PATCH 06/11] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/__test__/app.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/__test__/app.test.ts b/src/modules/__test__/app.test.ts index 27d080c..5cea84c 100644 --- a/src/modules/__test__/app.test.ts +++ b/src/modules/__test__/app.test.ts @@ -9,7 +9,7 @@ const connection = { /** * test_author_alan */ -test('DEC-11030', () => { +test('DEC-11030 拼接url', () => { expect(splitUrl('localhost', '22', 'dbname', 'jdbc:pivotal:greenplum://hostname:port;dbname')).toEqual('jdbc:pivotal:greenplum://localhost:22;dbname'); }); From abcd508dae26934ed5ddf0ec4224b66d315eb111 Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 29 Nov 2019 09:45:17 +0800 Subject: [PATCH 07/11] =?UTF-8?q?fix:=20DEC-11216=20jdbc=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=9C=80=E5=B0=8F=E7=A9=BA=E9=97=B2=E5=80=BC=E4=B8=BA0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/constants/constant.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/constants/constant.ts b/src/modules/constants/constant.ts index f63fb59..d2d22a6 100644 --- a/src/modules/constants/constant.ts +++ b/src/modules/constants/constant.ts @@ -667,6 +667,7 @@ export const DEFAULT_JDBC_POOL = { initialSize: 0, maxActive: 50, maxIdle: 10, + minIdle: 0, maxWait: 10000, testOnBorrow: true, testOnReturn: false, From d6f3834748c8b0d79524ccd9fae665a4b600d13b Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 29 Nov 2019 15:26:22 +0800 Subject: [PATCH 08/11] =?UTF-8?q?fix:=20DEC-11219=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/pages/maintain/forms/components/form.jdbc.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index a39b3c1..7badcea 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -374,6 +374,7 @@ export class FormJdbc extends BI.Widget { }, { type: CollapseXtype, + bgap: -15, width: 70, name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Advanced_Setting'), listeners: [ @@ -396,6 +397,7 @@ export class FormJdbc extends BI.Widget { items: [ { type: FormItemXtype, + tgap: 15, name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Initial_Size'), forms: [{ type: TextCheckerXtype, From 3bfa7d6464a2f8fd90c5e26925d2bb821f1b5e9d Mon Sep 17 00:00:00 2001 From: alan Date: Mon, 2 Dec 2019 10:26:24 +0800 Subject: [PATCH 09/11] =?UTF-8?q?fix:=20BI-56355=20=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E7=B1=BB=E5=9E=8B=E5=92=8C=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8=E9=83=BD=E4=B8=BA=E7=A9=BA=EF=BC=8C=E5=88=99=E8=AE=A4?= =?UTF-8?q?=E4=B8=BA=E6=98=AF=E5=85=B6=E4=BB=96jdbc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/__test__/app.test.ts | 10 +++++++++- src/modules/app.service.ts | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/modules/__test__/app.test.ts b/src/modules/__test__/app.test.ts index 5cea84c..a1c15e8 100644 --- a/src/modules/__test__/app.test.ts +++ b/src/modules/__test__/app.test.ts @@ -1,4 +1,4 @@ -import { connectionCanEdit, resolveUrlInfo, splitUrl } from '../app.service'; +import { connectionCanEdit, resolveUrlInfo, splitUrl, getJdbcDatabaseType } from '../app.service'; const connection = { connectionId: '', connectionType: '', @@ -12,6 +12,14 @@ const connection = { test('DEC-11030 拼接url', () => { expect(splitUrl('localhost', '22', 'dbname', 'jdbc:pivotal:greenplum://hostname:port;dbname')).toEqual('jdbc:pivotal:greenplum://localhost:22;dbname'); }); +/** + * test_author_alan + */ +test('BI-56355 如果驱动和URL均为空,则为其他jdbc', () => { + expect(getJdbcDatabaseType('', '').databaseType).toEqual('otherJDBC'); + expect(getJdbcDatabaseType('mysql', '').databaseType).toEqual('mysql'); + expect(getJdbcDatabaseType('', 'com.mysql.jdbc.Driver').databaseType).toEqual('mysql'); +}); /** * test_author_alan diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index bcc6268..31e6ff8 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -27,6 +27,9 @@ export function getPluginWidgetEdit(plugin: string) { // 由于database可能为空,所以为了兼容平台和设计器,需要根据driver来判断数据库类型 export function getJdbcDatabaseType(database: string, driver: string): DatabaseType { + if (!database && !driver) { + return DATA_BASE_TYPES_OTHER; + } let databaseType = null; // KERNEL-1655 兼容旧版 由于旧版设计器创建的数据连接database都为other,所以要根据driber来判断数据类型 // DEC-10872 不能过滤other,因为新版数据连接创建的其他jdbc也是other类型,会混淆,需要和后端讨论一个最佳的解决方案。 @@ -56,7 +59,7 @@ export function resolveUrlInfo (url: string) { urlInfo: greenplumUrl[9], }; } - const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto|redshift|postgresql):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([^]+)(.*)/i); + const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto|redshift|postgresql):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([^\\?]+)(.*)/i); if (result) { return { host: result[5], From e4289b5c6aeb83f2930122e7ab0f5c45ee0631f2 Mon Sep 17 00:00:00 2001 From: alan Date: Mon, 2 Dec 2019 10:28:16 +0800 Subject: [PATCH 10/11] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/__test__/app.test.ts | 2 +- src/modules/app.service.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/__test__/app.test.ts b/src/modules/__test__/app.test.ts index a1c15e8..9ea92be 100644 --- a/src/modules/__test__/app.test.ts +++ b/src/modules/__test__/app.test.ts @@ -15,7 +15,7 @@ test('DEC-11030 拼接url', () => { /** * test_author_alan */ -test('BI-56355 如果驱动和URL均为空,则为其他jdbc', () => { +test('BI-56355 如果数据库类型和驱动都为空,则为其他jdbc', () => { expect(getJdbcDatabaseType('', '').databaseType).toEqual('otherJDBC'); expect(getJdbcDatabaseType('mysql', '').databaseType).toEqual('mysql'); expect(getJdbcDatabaseType('', 'com.mysql.jdbc.Driver').databaseType).toEqual('mysql'); diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index 31e6ff8..706a0ab 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -59,7 +59,7 @@ export function resolveUrlInfo (url: string) { urlInfo: greenplumUrl[9], }; } - const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto|redshift|postgresql):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([^\\?]+)(.*)/i); + const result = url.match(/^jdbc:(oracle|mysql|sqlserver|db2|impala|kylin|phoenix|derby|gbase|gbasedbt-sqli|informix-sqli|h2|postgresql|hive2|vertica|kingbase|presto|redshift|postgresql):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/|;DatabaseName=)([^]+)(.*)/i); if (result) { return { host: result[5], From eb68523149d233f30fe9b747a43bcb964f0910d2 Mon Sep 17 00:00:00 2001 From: alan Date: Mon, 2 Dec 2019 10:29:25 +0800 Subject: [PATCH 11/11] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/app.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index 706a0ab..fc18f77 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -32,7 +32,6 @@ export function getJdbcDatabaseType(database: string, driver: string): DatabaseT } let databaseType = null; // KERNEL-1655 兼容旧版 由于旧版设计器创建的数据连接database都为other,所以要根据driber来判断数据类型 - // DEC-10872 不能过滤other,因为新版数据连接创建的其他jdbc也是other类型,会混淆,需要和后端讨论一个最佳的解决方案。 if (database && database !== 'other' && DATA_BASE_TYPES.some(item => item.databaseType === database)) { databaseType = DATA_BASE_TYPES.find(item => item.databaseType === database); } else {