Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
551a3305
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
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,发现更多精彩内容 >>
提交
551a3305
编写于
5月 13, 2019
作者:
R
RiedNyko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SQL Developer parse json #5654
上级
66b44775
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
127 addition
and
53 deletion
+127
-53
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tools/sqldeveloper/ConfigImportWizardPageSqlDeveloper.java
...ools/sqldeveloper/ConfigImportWizardPageSqlDeveloper.java
+127
-53
未找到文件。
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tools/sqldeveloper/ConfigImportWizardPageSqlDeveloper.java
浏览文件 @
551a3305
...
@@ -38,10 +38,7 @@ import org.w3c.dom.Document;
...
@@ -38,10 +38,7 @@ import org.w3c.dom.Document;
import
org.w3c.dom.Element
;
import
org.w3c.dom.Element
;
import
java.io.*
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
ConfigImportWizardPageSqlDeveloper
extends
ConfigImportWizardPage
{
public
class
ConfigImportWizardPageSqlDeveloper
extends
ConfigImportWizardPage
{
...
@@ -112,42 +109,130 @@ public class ConfigImportWizardPageSqlDeveloper extends ConfigImportWizardPage {
...
@@ -112,42 +109,130 @@ public class ConfigImportWizardPageSqlDeveloper extends ConfigImportWizardPage {
}
}
}
}
public
class
Connection
{
public
class
Connection
Info
{
@SerializedName
(
"name"
)
@SerializedName
(
"name"
)
@Expose
@Expose
private
String
name
;
private
String
name
;
@SerializedName
(
"type"
)
@SerializedName
(
"type"
)
@Expose
@Expose
private
String
type
;
private
String
type
;
@SerializedName
(
"info"
)
@Expose
private
String
info
;
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getType
()
{
public
String
getType
()
{
return
type
;
return
type
;
}
}
public
String
getInfo
()
{
return
info
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
void
setType
(
String
type
)
{
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
this
.
type
=
type
;
}
}
public
void
setInfo
(
String
info
)
{
this
.
info
=
info
;
}
}
}
public
class
JsonConnection
{
public
class
ConnectionList
{
@SerializedName
(
"connections"
)
@SerializedName
(
"connections"
)
@Expose
@Expose
private
List
<
Connection
>
connections
=
new
ArrayList
<
Connection
>();
private
List
<
Connection
Info
>
connections
=
new
ArrayList
<
ConnectionInfo
>();
public
List
<
Connection
>
getConnections
()
{
public
List
<
Connection
Info
>
getConnections
()
{
return
connections
;
return
connections
;
}
}
}
public
class
InfoList
{
@SerializedName
(
"info"
)
@Expose
private
List
<
Info
>
info
=
new
LinkedList
<
Info
>();
public
void
setConnections
(
List
<
Connection
>
connections
)
{
public
List
<
Info
>
getInfo
()
{
this
.
connections
=
connections
;
return
info
;
}
}
public
class
Info
{
@SerializedName
(
"role"
)
@Expose
private
String
role
;
@SerializedName
(
"hostname"
)
@Expose
private
String
hostname
;
@SerializedName
(
"port"
)
@Expose
private
String
port
;
@SerializedName
(
"sid"
)
@Expose
private
String
sid
;
@SerializedName
(
"serviceName"
)
@Expose
private
String
serviceName
;
@SerializedName
(
"user"
)
@Expose
private
String
user
;
@SerializedName
(
"customUrl"
)
@Expose
private
String
customUrl
;
@SerializedName
(
"OS_AUTHENTICATION"
)
@Expose
private
String
OS_AUTHENTICATION
;
public
String
getRole
()
{
return
role
;
}
public
String
getHost
()
{
return
hostname
;
}
public
String
getPort
()
{
return
port
;
}
public
String
getSID
()
{
return
sid
;
}
public
String
getServiceName
()
{
return
serviceName
;
}
public
String
getUser
()
{
return
user
;
}
public
String
getUrl
()
{
return
customUrl
;
}
public
String
getOsAuth
()
{
return
OS_AUTHENTICATION
;
}
public
void
setRole
(
String
role
)
{
this
.
role
=
role
;
}
public
void
setHost
(
String
hostname
)
{
this
.
hostname
=
hostname
;
}
public
void
setPort
(
String
port
)
{
this
.
port
=
port
;
}
public
void
setSID
(
String
sid
)
{
this
.
sid
=
sid
;
}
public
void
setServiceName
(
String
serviceName
)
{
this
.
serviceName
=
serviceName
;
}
public
void
setUrl
(
String
customUrl
)
{
this
.
customUrl
=
customUrl
;
}
public
void
setOsAuth
(
String
OS_AUTHENTICATION
)
{
this
.
OS_AUTHENTICATION
=
OS_AUTHENTICATION
;
}
public
void
setUser
(
String
user
)
{
this
.
user
=
user
;
}
}
}
}
...
@@ -156,56 +241,45 @@ public class ConfigImportWizardPageSqlDeveloper extends ConfigImportWizardPage {
...
@@ -156,56 +241,45 @@ public class ConfigImportWizardPageSqlDeveloper extends ConfigImportWizardPage {
BufferedReader
br
=
null
;
BufferedReader
br
=
null
;
try
{
try
{
br
=
new
BufferedReader
(
new
FileReader
(
connectionsFile
));
br
=
new
BufferedReader
(
new
FileReader
(
connectionsFile
));
JsonConnection
result
=
gson
.
fromJson
(
br
,
JsonConnection
.
class
);
ConnectionList
connResult
=
gson
.
fromJson
(
br
,
ConnectionList
.
class
);
if
(
result
!=
null
)
{
if
(
connResult
!=
null
)
{
for
(
Connection
conn
:
result
.
getConnections
())
{
for
(
ConnectionInfo
conn
:
connResult
.
getConnections
())
{
conn
.
getName
();
if
(
CommonUtils
.
isEmpty
(
conn
.
getName
()))
{
conn
.
getType
();
continue
;
}
}
}
/**
JsonObject rootObject = element.getAsJsonObject();
JsonArray ja = rootObject.getAsJsonArray("connection");
rootObject = ja.getAsJsonObject();
JsonObject name = rootObject.getAsJsonObject("name");
InfoList
infoResult
=
gson
.
fromJson
(
br
,
InfoList
.
class
);
if
(
infoResult
!=
null
)
{
for
(
Info
info
:
infoResult
.
getInfo
())
{
if
(
CommonUtils
.
isEmpty
(
info
.
getHost
())
&&
CommonUtils
.
isEmpty
(
info
.
getUrl
()))
{
continue
;
}
JsonElement typeElem = rootObject.get("type");
String
dbName
=
CommonUtils
.
isEmpty
(
info
.
getSID
())
?
info
.
getServiceName
()
:
info
.
getSID
();
String type = typeElem == null ? null : typeElem.getAsString();
JsonObject childObject = rootObject.getAsJsonObject("info");
String role = childObject.get("role").getAsString();
String serviceName = childObject.get("serviceName").getAsString();
String sid = childObject.get("sid").getAsString();
String host = childObject.get("hostname").getAsString();
String user = childObject.get("user").getAsString();
String url = childObject.get("customUrl").getAsString();
String conName = childObject.get("ConnName").getAsString();
String port = childObject.get("port").getAsString();
String osAuth = childObject.get("OS_AUTHENTICATION").getAsString();
if (CommonUtils.isEmpty(host) && CommonUtils.isEmpty(url)) {
ImportConnectionInfo
connectionInfo
=
new
ImportConnectionInfo
(
oraDriver
,
null
,
conn
.
getName
(),
info
.
getUrl
(),
info
.
getHost
(),
info
.
getPort
(),
dbName
,
info
.
getHost
(),
null
);
//continue;
if
(!
CommonUtils
.
isEmpty
(
info
.
getSID
()))
{
}
String dbName = CommonUtils.isEmpty(sid) ? serviceName : sid;
ImportConnectionInfo connectionInfo = new ImportConnectionInfo(oraDriver, null, conName, url, host, port, dbName, user, null);
if (!CommonUtils.isEmpty(sid)) {
connectionInfo
.
setProviderProperty
(
OracleConstants
.
PROP_SID_SERVICE
,
OracleConnectionType
.
SID
.
name
());
connectionInfo
.
setProviderProperty
(
OracleConstants
.
PROP_SID_SERVICE
,
OracleConnectionType
.
SID
.
name
());
} else if (!CommonUtils.isEmpty(
serviceName
)) {
}
else
if
(!
CommonUtils
.
isEmpty
(
info
.
getServiceName
()
))
{
connectionInfo
.
setProviderProperty
(
OracleConstants
.
PROP_SID_SERVICE
,
OracleConnectionType
.
SERVICE
.
name
());
connectionInfo
.
setProviderProperty
(
OracleConstants
.
PROP_SID_SERVICE
,
OracleConnectionType
.
SERVICE
.
name
());
}
}
if (CommonUtils.toBoolean(
osAuth
)) {
if
(
CommonUtils
.
toBoolean
(
info
.
getOsAuth
()
))
{
connectionInfo
.
setUser
(
OracleConstants
.
OS_AUTH_PROP
);
connectionInfo
.
setUser
(
OracleConstants
.
OS_AUTH_PROP
);
}
}
if (!CommonUtils.isEmpty(
role
)) {
if
(!
CommonUtils
.
isEmpty
(
info
.
getRole
()
))
{
connectionInfo.setProviderProperty(OracleConstants.PROP_INTERNAL_LOGON,
role
);
connectionInfo
.
setProviderProperty
(
OracleConstants
.
PROP_INTERNAL_LOGON
,
info
.
getRole
()
);
}
}
if (!CommonUtils.isEmpty(
type
)) {
if
(!
CommonUtils
.
isEmpty
(
conn
.
getType
()
))
{
connectionInfo.setProviderProperty(OracleConstants.PROP_CONNECTION_TYPE,
type
);
connectionInfo
.
setProviderProperty
(
OracleConstants
.
PROP_CONNECTION_TYPE
,
conn
.
getType
()
);
}
}
importData
.
addConnection
(
connectionInfo
);
importData
.
addConnection
(
connectionInfo
);
*/
}
}
}
}
}
catch
(
FileNotFoundException
ex
){
}
catch
(
FileNotFoundException
ex
){
throw
new
DBException
(
"Configuration parse error: "
+
ex
.
getMessage
());
throw
new
DBException
(
"Configuration parse error: "
+
ex
.
getMessage
());
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录