Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
a16b8c16
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,发现更多精彩内容 >>
提交
a16b8c16
编写于
7月 18, 2019
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#5384 Virtual model additions. Find object by ID.
上级
447d70d2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
59 addition
and
5 deletion
+59
-5
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
...ss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
+50
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
....model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
+3
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVModelSerializerModern.java
...jkiss/dbeaver/model/virtual/DBVModelSerializerModern.java
+4
-3
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/EditVirtualEntityDialog.java
...beaver/ui/controls/resultset/EditVirtualEntityDialog.java
+2
-1
未找到文件。
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
浏览文件 @
a16b8c16
...
...
@@ -540,12 +540,61 @@ public final class DBUtils {
if
(
obj
instanceof
DBPDataSourceContainer
)
{
pathStr
.
append
(((
DBPDataSourceContainer
)
obj
).
getId
());
}
else
{
pathStr
.
append
(
getQuotedIdentifier
(
obj
));
pathStr
.
append
(
obj
.
getName
(
));
}
}
return
pathStr
.
toString
();
}
/**
* Find object by unique ID.
* Note: this function searches only inside DBSObjectContainer objects.
* Usually it works only for entities and entity containers (schemas, catalogs).
*/
public
static
DBSObject
findObjectById
(
@NotNull
DBRProgressMonitor
monitor
,
@NotNull
DBPProject
project
,
@NotNull
String
objectId
)
throws
DBException
{
String
[]
names
=
objectId
.
split
(
"/"
);
DBPDataSourceContainer
dataSourceContainer
=
project
.
getDataSourceRegistry
().
getDataSource
(
names
[
0
]);
if
(
dataSourceContainer
==
null
)
{
log
.
debug
(
"Can't find datasource '"
+
names
[
0
]
+
"' for object ID "
+
objectId
);
return
null
;
}
if
(!
dataSourceContainer
.
isConnected
())
{
dataSourceContainer
.
connect
(
monitor
,
true
,
true
);
}
DBPDataSource
dataSource
=
dataSourceContainer
.
getDataSource
();
if
(
dataSource
==
null
)
{
log
.
debug
(
"Null datasource in container "
+
dataSourceContainer
.
getId
());
return
null
;
}
DBSObjectContainer
sc
=
DBUtils
.
getAdapter
(
DBSObjectContainer
.
class
,
dataSource
);
if
(
sc
!=
null
)
{
for
(
int
i
=
1
;
i
<
names
.
length
-
1
;
i
++)
{
String
name
=
names
[
i
];
DBSObject
child
=
sc
.
getChild
(
monitor
,
name
);
if
(
child
==
null
)
{
log
.
debug
(
"Can't find child container "
+
name
+
" in container "
+
DBUtils
.
getObjectFullName
(
sc
,
DBPEvaluationContext
.
UI
));
return
null
;
}
if
(
child
instanceof
DBSObjectContainer
)
{
sc
=
(
DBSObjectContainer
)
child
;
}
else
{
log
.
debug
(
"Child object '"
+
name
+
"' is not a container"
);
return
null
;
}
}
}
if
(
sc
!=
null
)
{
String
objectName
=
names
[
names
.
length
-
1
];
DBSObject
object
=
sc
.
getChild
(
monitor
,
objectName
);
if
(
object
==
null
)
{
log
.
debug
(
"Child object '"
+
objectName
+
"' not found in container "
+
DBUtils
.
getObjectFullName
(
sc
,
DBPEvaluationContext
.
UI
));
return
null
;
}
return
object
;
}
return
null
;
}
public
static
boolean
isNullValue
(
@Nullable
Object
value
)
{
return
(
value
==
null
||
(
value
instanceof
DBDValue
&&
((
DBDValue
)
value
).
isNull
()));
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
浏览文件 @
a16b8c16
...
...
@@ -129,6 +129,9 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
for
(
Map
<
String
,
Object
>
fkObject
:
JSONUtils
.
getObjectList
(
map
,
"foreign-keys"
))
{
String
entityId
=
JSONUtils
.
getString
(
fkObject
,
"entity"
);
String
refConsId
=
JSONUtils
.
getString
(
fkObject
,
"constraint"
);
Map
<
String
,
Object
>
attributes
=
JSONUtils
.
getObject
(
fkObject
,
"attributes"
);
//DBUtils.findObjectById()
if
(
entityForeignKeys
==
null
)
entityForeignKeys
=
new
ArrayList
<>();
log
.
warn
(
"Virtual foreign keys load is not implemented yet"
);
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVModelSerializerModern.java
浏览文件 @
a16b8c16
...
...
@@ -135,11 +135,12 @@ class DBVModelSerializerModern implements DBVModelSerializer
List
<
DBVEntityForeignKeyColumn
>
refAttrs
=
fk
.
getAttributeReferences
(
null
);
if
(!
CommonUtils
.
isEmpty
(
refAttrs
))
{
json
.
name
(
"attributes"
);
json
.
begin
Array
();
json
.
begin
Object
();
for
(
DBVEntityForeignKeyColumn
cc
:
refAttrs
)
{
json
.
value
(
cc
.
getAttributeName
());
json
.
name
(
cc
.
getAttributeName
());
json
.
value
(
cc
.
getRefAttributeName
());
}
json
.
end
Array
();
json
.
end
Object
();
}
json
.
endObject
();
}
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/EditVirtualEntityDialog.java
浏览文件 @
a16b8c16
...
...
@@ -29,6 +29,7 @@ import org.jkiss.code.Nullable;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBIcon
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.DBValueFormatting
;
import
org.jkiss.dbeaver.model.data.DBDAttributeBinding
;
...
...
@@ -238,7 +239,7 @@ class EditVirtualEntityDialog extends BaseDialog {
TableItem
item
=
new
TableItem
(
fkTable
,
SWT
.
NONE
);
item
.
setImage
(
0
,
DBeaverIcons
.
getImage
(
DBIcon
.
TREE_FOREIGN_KEY
));
if
(
fk
.
getReferencedConstraint
()
!=
null
)
{
item
.
setText
(
0
,
fk
.
getReferencedConstraint
().
getParentObject
().
getName
(
));
item
.
setText
(
0
,
DBUtils
.
getObjectFullName
(
fk
.
getReferencedConstraint
().
getParentObject
(),
DBPEvaluationContext
.
UI
));
}
String
ownAttrNames
=
fk
.
getAttributes
().
stream
().
map
(
DBVEntityForeignKeyColumn:
:
getAttributeName
)
.
collect
(
Collectors
.
joining
(
","
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录