@ -4,9 +4,39 @@ import { DATA_BASE_TYPES } from '@constants/constant';
BI . provider ( 'dec.connection.provider.datebase' , function ( ) {
this . resolves = { } ;
function starRocksResolve ( url : string ) {
// 处理starRocks数据连接常规模式
const result = url . match ( /^jdbc:mysql:\/\/([0-9a-zA-Z_\\.-]+):([0-9a-zA-Z_\\.-]+)\/([0-9a-zA-Z_\\.-]+)\.([^]+)(.*)/i ) ;
if ( result ) {
return {
host : result [ 1 ] ,
port : result [ 2 ] === 'port' ? '' : result [ 2 ] ,
databaseName : result [ 4 ] || '' ,
urlInfo : result [ 0 ] ,
} ;
}
// 处理starRocks数据连接负载均衡模式
const loadBalance = url . match ( /^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)\.([^/]+)/i ) ;
if ( loadBalance ) {
const database : string = loadBalance [ 2 ] ;
return {
host : '' ,
port : '' ,
databaseName : database ,
urlInfo : loadBalance [ 0 ] ,
}
}
return {
host : '' ,
port : '' ,
databaseName : '' ,
urlInfo : '' ,
} ;
}
// 原service中resolveUrlInfo方法
function jdbcResolve ( url : string ) {
if ( BI . isNull ( url ) ) return { } ;
const oracleUlr = url . match ( /^jdbc:(oracle):(thin:([0-9a-zA-Z/]*)?@|thin:([0-9a-zA-Z/]*)?@\/\/|\/\/|)([0-9a-zA-Z_\\.-]+)(:([0-9|port]+))?(:|\/)([^]+)(.*)/i ) ;
if ( oracleUlr ) {
return {
@ -60,7 +90,6 @@ BI.provider('dec.connection.provider.datebase', function () {
urlInfo : '' ,
} ;
}
return {
host : '' ,
port : '' ,
@ -92,7 +121,6 @@ BI.provider('dec.connection.provider.datebase', function () {
. . . config ,
type : 'jdbc' ,
} ;
BI . isFunction ( resolve ) && ( this . resolves [ config . databaseType ] = resolve ) ;
if ( coverBaseDatabase ( config ) ) return ;
@ -101,7 +129,14 @@ BI.provider('dec.connection.provider.datebase', function () {
} ;
this . $get = ( ) = > BI . inherit ( BI . OB , {
getJdbcResolveByType : ( type : string ) = > this . resolves [ type ] || jdbcResolve ,
getJdbcResolveByType : ( type : string ) = > {
// starRocks特殊处理
// todo: 后面有专门的迭代系统处理,这里先临时解决下bug
if ( type === "starrocks" ) {
return starRocksResolve
}
return this . resolves [ type ] || jdbcResolve
} ,
customDatabaseType : BI.Constants.getConstant ( CONSTANT_PLUGIN_TYPES ) ,
} ) ;
} ) ;