Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
6513ab15
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
6513ab15
编写于
5月 15, 2019
作者:
S
Serge Rider
提交者:
GitHub
5月 15, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5907 from riednyko/#5654_sqldeveloper_json
SQL Developer connection import #5654
上级
071b2d36
f2af88af
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
185 addition
and
9 deletion
+185
-9
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tools/sqldeveloper/ConfigImportWizardPageSqlDeveloper.java
...ools/sqldeveloper/ConfigImportWizardPageSqlDeveloper.java
+185
-9
未找到文件。
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tools/sqldeveloper/ConfigImportWizardPageSqlDeveloper.java
浏览文件 @
6513ab15
...
@@ -17,7 +17,11 @@
...
@@ -17,7 +17,11 @@
package
org.jkiss.dbeaver.ext.oracle.tools.sqldeveloper
;
package
org.jkiss.dbeaver.ext.oracle.tools.sqldeveloper
;
import
com.google.gson.*
;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.SerializedName
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.ext.import_config.wizards.ConfigImportWizardPage
;
import
org.jkiss.dbeaver.ext.import_config.wizards.ConfigImportWizardPage
;
import
org.jkiss.dbeaver.ext.import_config.wizards.ImportConnectionInfo
;
import
org.jkiss.dbeaver.ext.import_config.wizards.ImportConnectionInfo
;
import
org.jkiss.dbeaver.ext.import_config.wizards.ImportData
;
import
org.jkiss.dbeaver.ext.import_config.wizards.ImportData
;
...
@@ -26,6 +30,7 @@ import org.jkiss.dbeaver.ext.oracle.Activator;
...
@@ -26,6 +30,7 @@ import org.jkiss.dbeaver.ext.oracle.Activator;
import
org.jkiss.dbeaver.ext.oracle.OracleMessages
;
import
org.jkiss.dbeaver.ext.oracle.OracleMessages
;
import
org.jkiss.dbeaver.ext.oracle.model.OracleConstants
;
import
org.jkiss.dbeaver.ext.oracle.model.OracleConstants
;
import
org.jkiss.dbeaver.ext.oracle.model.dict.OracleConnectionType
;
import
org.jkiss.dbeaver.ext.oracle.model.dict.OracleConnectionType
;
import
org.jkiss.dbeaver.model.data.json.JSONUtils
;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.CommonUtils
;
import
org.jkiss.utils.xml.XMLException
;
import
org.jkiss.utils.xml.XMLException
;
...
@@ -33,24 +38,24 @@ import org.jkiss.utils.xml.XMLUtils;
...
@@ -33,24 +38,24 @@ import org.jkiss.utils.xml.XMLUtils;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Element
;
import
org.w3c.dom.Element
;
import
java.io.File
;
import
java.io.*
;
import
java.io.FilenameFilter
;
import
java.util.*
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
public
class
ConfigImportWizardPageSqlDeveloper
extends
ConfigImportWizardPage
{
public
class
ConfigImportWizardPageSqlDeveloper
extends
ConfigImportWizardPage
{
public
static
final
String
SQLD_HOME_FOLDER
=
"SQL Developer"
;
public
static
final
String
SQLD_HOME_FOLDER
=
"SQL Developer"
;
public
static
final
String
SQLD_CONFIG_FILE
=
"connections.xml"
;
public
static
final
String
SQLD_CONFIG_FILE
=
"connections.xml"
;
public
static
final
String
SQLD_CONFIG_JSON_FILE
=
"connections.json"
;
public
static
final
String
SQLD_SYSCONFIG_FOLDER
=
"system"
;
public
static
final
String
SQLD_SYSCONFIG_FOLDER
=
"system"
;
public
static
final
String
SQLD_CONNECTIONS_FOLDER
=
"o.jdeveloper.db.connection"
;
public
static
final
String
SQLD_CONNECTIONS_FOLDER
=
"o.jdeveloper.db.connection"
;
private
static
final
Log
log
=
Log
.
getLog
(
ConfigImportWizardPageSqlDeveloper
.
class
);
private
final
ImportDriverInfo
oraDriver
;
private
final
ImportDriverInfo
oraDriver
;
protected
ConfigImportWizardPageSqlDeveloper
()
protected
ConfigImportWizardPageSqlDeveloper
()
{
{
super
(
"SQLDeveloper"
);
super
(
"SQLDeveloper"
);
setTitle
(
"SQL Developer"
);
setTitle
(
"SQL Developer"
);
setDescription
(
"Import Oracle SQL Developer connections"
);
setDescription
(
"Import Oracle SQL Developer connections"
);
...
@@ -95,11 +100,182 @@ public class ConfigImportWizardPageSqlDeveloper extends ConfigImportWizardPage {
...
@@ -95,11 +100,182 @@ public class ConfigImportWizardPageSqlDeveloper extends ConfigImportWizardPage {
continue
;
continue
;
}
}
final
File
connectionFolder
=
connectionFolders
[
0
];
final
File
connectionFolder
=
connectionFolders
[
0
];
final
File
connectionsJsonFile
=
new
File
(
connectionFolder
,
SQLD_CONFIG_JSON_FILE
);
final
File
connectionsFile
=
new
File
(
connectionFolder
,
SQLD_CONFIG_FILE
);
final
File
connectionsFile
=
new
File
(
connectionFolder
,
SQLD_CONFIG_FILE
);
if
(!
connectionsFile
.
exists
())
{
if
(
connectionsFile
.
exists
())
{
continue
;
parseConnections
(
connectionsFile
,
importData
);
}
else
if
(
connectionsJsonFile
.
exists
())
{
parseJsonConnections
(
connectionsJsonFile
,
importData
);
}
}
}
public
static
class
ConnectionDescription
{
@SerializedName
(
"name"
)
private
String
name
;
@SerializedName
(
"type"
)
private
String
type
;
@SerializedName
(
"info"
)
private
ConnectionInfo
info
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
ConnectionInfo
getInfo
()
{
return
info
;
}
public
void
setInfo
(
ConnectionInfo
info
)
{
this
.
info
=
info
;
}
}
public
static
class
ConnectionList
{
@SerializedName
(
"connections"
)
private
List
<
ConnectionDescription
>
connections
=
new
ArrayList
();
public
List
<
ConnectionDescription
>
getConnections
()
{
return
connections
;
}
}
public
class
ConnectionInfo
{
@SerializedName
(
"role"
)
private
String
role
;
@SerializedName
(
"hostname"
)
private
String
hostname
;
@SerializedName
(
"port"
)
private
String
port
;
@SerializedName
(
"sid"
)
private
String
sid
;
@SerializedName
(
"serviceName"
)
private
String
serviceName
;
@SerializedName
(
"user"
)
private
String
user
;
@SerializedName
(
"customUrl"
)
private
String
customUrl
;
@SerializedName
(
"OS_AUTHENTICATION"
)
private
String
OsAuth
;
public
String
getRole
()
{
return
role
;
}
public
void
setRole
(
String
role
)
{
this
.
role
=
role
;
}
public
String
getHost
()
{
return
hostname
;
}
public
void
setHost
(
String
hostname
)
{
this
.
hostname
=
hostname
;
}
public
String
getPort
()
{
return
port
;
}
public
void
setPort
(
String
port
)
{
this
.
port
=
port
;
}
public
String
getSID
()
{
return
sid
;
}
public
void
setSID
(
String
sid
)
{
this
.
sid
=
sid
;
}
public
String
getServiceName
()
{
return
serviceName
;
}
public
void
setServiceName
(
String
serviceName
)
{
this
.
serviceName
=
serviceName
;
}
public
String
getUser
()
{
return
user
;
}
public
void
setUser
(
String
user
)
{
this
.
user
=
user
;
}
public
String
getUrl
()
{
return
customUrl
;
}
public
void
setUrl
(
String
customUrl
)
{
this
.
customUrl
=
customUrl
;
}
public
String
getOsAuth
()
{
return
OsAuth
;
}
public
void
setOsAuth
(
String
OS_AUTHENTICATION
)
{
this
.
OsAuth
=
OS_AUTHENTICATION
;
}
}
private
void
parseJsonConnections
(
File
connectionsFile
,
ImportData
importData
)
throws
JsonSyntaxException
{
try
{
Gson
gson
=
new
GsonBuilder
().
create
();
try
(
Reader
br
=
new
BufferedReader
(
new
FileReader
(
connectionsFile
)))
{
ConnectionList
connResult
=
gson
.
fromJson
(
br
,
ConnectionList
.
class
);
for
(
ConnectionDescription
conn
:
connResult
.
getConnections
())
{
if
(
CommonUtils
.
isEmpty
(
conn
.
getName
()))
{
continue
;
}
ConnectionInfo
info
=
conn
.
getInfo
();
if
(
CommonUtils
.
isEmpty
(
info
.
getHost
())
&&
CommonUtils
.
isEmpty
(
info
.
getUrl
()))
{
continue
;
}
String
dbName
=
CommonUtils
.
isEmpty
(
info
.
getSID
())
?
info
.
getServiceName
()
:
info
.
getSID
();
ImportConnectionInfo
connectionInfo
=
new
ImportConnectionInfo
(
oraDriver
,
null
,
conn
.
getName
(),
info
.
getUrl
(),
info
.
getHost
(),
info
.
getPort
(),
dbName
,
info
.
getHost
(),
null
);
if
(!
CommonUtils
.
isEmpty
(
info
.
getSID
()))
{
connectionInfo
.
setProviderProperty
(
OracleConstants
.
PROP_SID_SERVICE
,
OracleConnectionType
.
SID
.
name
());
}
else
if
(!
CommonUtils
.
isEmpty
(
info
.
getServiceName
()))
{
connectionInfo
.
setProviderProperty
(
OracleConstants
.
PROP_SID_SERVICE
,
OracleConnectionType
.
SERVICE
.
name
());
}
if
(
CommonUtils
.
toBoolean
(
info
.
getOsAuth
()))
{
connectionInfo
.
setUser
(
OracleConstants
.
OS_AUTH_PROP
);
}
if
(!
CommonUtils
.
isEmpty
(
info
.
getRole
()))
{
connectionInfo
.
setProviderProperty
(
OracleConstants
.
PROP_INTERNAL_LOGON
,
info
.
getRole
());
}
if
(!
CommonUtils
.
isEmpty
(
conn
.
getType
()))
{
connectionInfo
.
setProviderProperty
(
OracleConstants
.
PROP_CONNECTION_TYPE
,
conn
.
getType
());
}
importData
.
addConnection
(
connectionInfo
);
}
}
}
parseConnections
(
connectionsFile
,
importData
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Configuration parse error"
,
e
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录