Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
66b44775
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,发现更多精彩内容 >>
提交
66b44775
编写于
5月 12, 2019
作者:
R
RiedNyko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SQL Developer parse json #5654
上级
ef287ced
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
113 addition
and
5 deletion
+113
-5
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tools/sqldeveloper/ConfigImportWizardPageSqlDeveloper.java
...ools/sqldeveloper/ConfigImportWizardPageSqlDeveloper.java
+113
-5
未找到文件。
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/tools/sqldeveloper/ConfigImportWizardPageSqlDeveloper.java
浏览文件 @
66b44775
...
...
@@ -17,6 +17,9 @@
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.ext.import_config.wizards.ConfigImportWizardPage
;
import
org.jkiss.dbeaver.ext.import_config.wizards.ImportConnectionInfo
;
...
...
@@ -26,6 +29,7 @@ import org.jkiss.dbeaver.ext.oracle.Activator;
import
org.jkiss.dbeaver.ext.oracle.OracleMessages
;
import
org.jkiss.dbeaver.ext.oracle.model.OracleConstants
;
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.utils.CommonUtils
;
import
org.jkiss.utils.xml.XMLException
;
...
...
@@ -33,9 +37,10 @@ import org.jkiss.utils.xml.XMLUtils;
import
org.w3c.dom.Document
;
import
org.w3c.dom.Element
;
import
java.io.
File
;
import
java.
io.FilenameFilter
;
import
java.io.
*
;
import
java.
util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -43,6 +48,7 @@ public class ConfigImportWizardPageSqlDeveloper extends ConfigImportWizardPage {
public
static
final
String
SQLD_HOME_FOLDER
=
"SQL Developer"
;
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_CONNECTIONS_FOLDER
=
"o.jdeveloper.db.connection"
;
...
...
@@ -95,11 +101,113 @@ public class ConfigImportWizardPageSqlDeveloper extends ConfigImportWizardPage {
continue
;
}
final
File
connectionFolder
=
connectionFolders
[
0
];
final
File
connectionsJsonFile
=
new
File
(
connectionFolder
,
SQLD_CONFIG_JSON_FILE
);
final
File
connectionsFile
=
new
File
(
connectionFolder
,
SQLD_CONFIG_FILE
);
if
(!
connectionsFile
.
exists
())
{
continue
;
}
if
(
connectionsFile
.
exists
())
{
parseConnections
(
connectionsFile
,
importData
);
}
else
if
(
connectionsJsonFile
.
exists
())
{
parseJsonConnections
(
connectionsJsonFile
,
importData
);
}
}
}
public
class
Connection
{
@SerializedName
(
"name"
)
@Expose
private
String
name
;
@SerializedName
(
"type"
)
@Expose
private
String
type
;
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
class
JsonConnection
{
@SerializedName
(
"connections"
)
@Expose
private
List
<
Connection
>
connections
=
new
ArrayList
<
Connection
>();
public
List
<
Connection
>
getConnections
()
{
return
connections
;
}
public
void
setConnections
(
List
<
Connection
>
connections
)
{
this
.
connections
=
connections
;
}
}
private
void
parseJsonConnections
(
File
connectionsFile
,
ImportData
importData
)
throws
DBException
{
Gson
gson
=
new
Gson
();
BufferedReader
br
=
null
;
try
{
br
=
new
BufferedReader
(
new
FileReader
(
connectionsFile
));
JsonConnection
result
=
gson
.
fromJson
(
br
,
JsonConnection
.
class
);
if
(
result
!=
null
)
{
for
(
Connection
conn
:
result
.
getConnections
())
{
conn
.
getName
();
conn
.
getType
();
}
}
/**
JsonObject rootObject = element.getAsJsonObject();
JsonArray ja = rootObject.getAsJsonArray("connection");
rootObject = ja.getAsJsonObject();
JsonObject name = rootObject.getAsJsonObject("name");
JsonElement typeElem = rootObject.get("type");
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)) {
//continue;
}
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());
} else if (!CommonUtils.isEmpty(serviceName)) {
connectionInfo.setProviderProperty(OracleConstants.PROP_SID_SERVICE, OracleConnectionType.SERVICE.name());
}
if (CommonUtils.toBoolean(osAuth)) {
connectionInfo.setUser(OracleConstants.OS_AUTH_PROP);
}
if (!CommonUtils.isEmpty(role)) {
connectionInfo.setProviderProperty(OracleConstants.PROP_INTERNAL_LOGON, role);
}
if (!CommonUtils.isEmpty(type)) {
connectionInfo.setProviderProperty(OracleConstants.PROP_CONNECTION_TYPE, type);
}
importData.addConnection(connectionInfo);
*/
}
catch
(
FileNotFoundException
ex
){
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录