|
|
@ -1,5 +1,5 @@ |
|
|
|
import { DATA_BASE_TYPES, DATA_BASE_TYPES_OTHER, DESIGN_DRIVER_TYPE } from '@constants/constant'; |
|
|
|
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 { DatabaseType } from './app.typings'; |
|
|
|
import { Connection } from './crud/crud.typings'; |
|
|
|
import { Connection } from './crud/crud.typings'; |
|
|
|
export function getAllDatabaseTypes():DatabaseType[] { |
|
|
|
export function getAllDatabaseTypes():DatabaseType[] { |
|
|
@ -14,21 +14,25 @@ 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) { |
|
|
|
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) { |
|
|
|
export function getPluginWidgetEdit(plugin: string) { |
|
|
|
return BI.Constants.getConstant(CONSTANT_PLUGIN_EDIT.replace('${databaseType}', plugin)); |
|
|
|
return BI.get(getPlugin(plugin), 'edit'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 由于database可能为空,所以为了兼容平台和设计器,需要根据driver来判断数据库类型
|
|
|
|
// 由于database可能为空,所以为了兼容平台和设计器,需要根据driver来判断数据库类型
|
|
|
|
export function getJdbcDatabaseType(database: string, driver: string): DatabaseType { |
|
|
|
export function getJdbcDatabaseType(database: string, driver: string): DatabaseType { |
|
|
|
|
|
|
|
if (!database && !driver) { |
|
|
|
|
|
|
|
return DATA_BASE_TYPES_OTHER; |
|
|
|
|
|
|
|
} |
|
|
|
let databaseType = null; |
|
|
|
let databaseType = null; |
|
|
|
// KERNEL-1655 兼容旧版 由于旧版设计器创建的数据连接database都为other,所以要根据driber来判断数据类型
|
|
|
|
// KERNEL-1655 兼容旧版 由于旧版设计器创建的数据连接database都为other,所以要根据driber来判断数据类型
|
|
|
|
// DEC-10872 不能过滤other,因为新版数据连接创建的其他jdbc也是other类型,会混淆,需要和后端讨论一个最佳的解决方案。
|
|
|
|
if (database && database !== 'other' && DATA_BASE_TYPES.some(item => item.databaseType === database)) { |
|
|
|
if (database && DATA_BASE_TYPES.some(item => item.databaseType === database)) { |
|
|
|
|
|
|
|
databaseType = DATA_BASE_TYPES.find(item => item.databaseType === database); |
|
|
|
databaseType = DATA_BASE_TYPES.find(item => item.databaseType === database); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const designDatabase = DESIGN_DRIVER_TYPE.find(item => item.driver === driver); |
|
|
|
const designDatabase = DESIGN_DRIVER_TYPE.find(item => item.driver === driver); |
|
|
@ -45,7 +49,16 @@ export function getJdbcDatabaseType(database: string, driver: string): DatabaseT |
|
|
|
|
|
|
|
|
|
|
|
export function resolveUrlInfo (url: string) { |
|
|
|
export function resolveUrlInfo (url: string) { |
|
|
|
if (BI.isNull(url)) return {}; |
|
|
|
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 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) { |
|
|
|
if (result) { |
|
|
|
return { |
|
|
|
return { |
|
|
|
host: result[5], |
|
|
|
host: result[5], |
|
|
@ -85,7 +98,8 @@ export function splitUrl(host: string, port: string, database: string, baseUrl: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') |
|
|
|
return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') |
|
|
|
.replace('database', database); |
|
|
|
.replace('database', database) |
|
|
|
|
|
|
|
.replace('dbname', database); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function connectionCanEdit(connection: Connection) { |
|
|
|
export function connectionCanEdit(connection: Connection) { |
|
|
|