Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
5beb4b6c
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,发现更多精彩内容 >>
提交
5beb4b6c
编写于
5月 01, 2019
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#5800 Orphan virtual entities model
Former-commit-id:
dde9cec6
上级
04553d20
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
64 addition
and
40 deletion
+64
-40
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
....model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
+7
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVUtils.java
...r.model/src/org/jkiss/dbeaver/model/virtual/DBVUtils.java
+25
-17
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetModel.java
...g/jkiss/dbeaver/ui/controls/resultset/ResultSetModel.java
+29
-13
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
.../jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
+3
-9
未找到文件。
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVEntity.java
浏览文件 @
5beb4b6c
...
...
@@ -124,7 +124,7 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
@Override
public
DBPDataSource
getDataSource
()
{
return
container
.
getDataSource
();
return
container
==
null
?
null
:
container
.
getDataSource
();
}
public
void
setDescription
(
String
description
)
...
...
@@ -464,4 +464,10 @@ public class DBVEntity extends DBVObject implements DBSEntity, DBPQualifiedObjec
return
name
;
}
public
void
persistConfiguration
()
{
DBPDataSource
dataSource
=
getDataSource
();
if
(
dataSource
!=
null
)
{
dataSource
.
getContainer
().
persistConfiguration
();
}
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/virtual/DBVUtils.java
浏览文件 @
5beb4b6c
...
...
@@ -28,6 +28,7 @@ import org.jkiss.dbeaver.model.exec.DBCException;
import
org.jkiss.dbeaver.model.exec.DBCResultSet
;
import
org.jkiss.dbeaver.model.exec.DBCSession
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSDataContainer
;
import
org.jkiss.dbeaver.model.struct.DBSEntity
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAttribute
;
...
...
@@ -38,35 +39,42 @@ import java.util.*;
*/
public
abstract
class
DBVUtils
{
//
Transform setting
s for unmapped attributes (custom queries, pseudo attributes, etc)
private
static
final
Map
<
String
,
DBV
TransformSettings
>
orphanTransformSetting
s
=
new
HashMap
<>();
//
Entitie
s for unmapped attributes (custom queries, pseudo attributes, etc)
private
static
final
Map
<
String
,
DBV
Entity
>
orphanVirtualEntitie
s
=
new
HashMap
<>();
@Nullable
public
static
DBVTransformSettings
getTransformSettings
(
@NotNull
DBDAttributeBinding
binding
,
boolean
create
)
{
DBVEntity
vEntity
=
getVirtualEntity
(
binding
,
create
);
if
(
vEntity
!=
null
)
{
DBVEntityAttribute
vAttr
=
vEntity
.
getVirtualAttribute
(
binding
,
create
);
if
(
vAttr
!=
null
)
{
return
getTransformSettings
(
vAttr
,
create
);
}
}
return
null
;
}
public
static
DBVEntity
getVirtualEntity
(
@NotNull
DBDAttributeBinding
binding
,
boolean
create
)
{
DBSEntityAttribute
entityAttribute
=
binding
.
getEntityAttribute
();
DBVEntity
vEntity
;
if
(
entityAttribute
!=
null
)
{
DBVEntity
vEntity
=
findVirtualEntity
(
entityAttribute
.
getParentObject
(),
create
);
if
(
vEntity
!=
null
)
{
DBVEntityAttribute
vAttr
=
vEntity
.
getVirtualAttribute
(
binding
,
create
);
if
(
vAttr
!=
null
)
{
return
getTransformSettings
(
vAttr
,
create
);
}
}
vEntity
=
findVirtualEntity
(
entityAttribute
.
getParentObject
(),
create
);
}
else
{
// Not an entity. Most likely a custom query. Use local cache for such attributes.
// There shouldn't be too many such settings as they are defined by user manually
// so we shouldn't eay too much memory for that
String
attrKey
=
DBUtils
.
getObjectFullId
(
binding
.
getDataContainer
())
+
":"
+
binding
.
getName
();
synchronized
(
orphanTransformSettings
)
{
DBVTransformSettings
settings
=
orphanTransformSettings
.
get
(
attrKey
);
if
(
settings
==
null
&&
create
)
{
settings
=
new
DBVTransformSettings
();
orphanTransformSettings
.
put
(
attrKey
,
settings
);
String
attrKey
=
DBUtils
.
getObjectFullId
(
binding
.
getDataContainer
());
synchronized
(
orphanVirtualEntities
)
{
vEntity
=
orphanVirtualEntities
.
get
(
attrKey
);
if
(
vEntity
==
null
&&
create
)
{
vEntity
=
new
DBVEntity
(
binding
.
getDataContainer
().
getDataSource
().
getContainer
().
getVirtualModel
(),
binding
.
getDataContainer
().
getName
(),
""
);
orphanVirtualEntities
.
put
(
attrKey
,
vEntity
);
}
return
settings
;
}
}
return
null
;
return
vEntity
;
}
@Nullable
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetModel.java
浏览文件 @
5beb4b6c
...
...
@@ -580,20 +580,36 @@ public class ResultSetModel {
void
updateColorMapping
()
{
colorMapping
.
clear
();
DBSEntity
entity
=
getSingleSource
();
if
(
entity
==
null
)
{
return
;
}
DBVEntity
virtualEntity
=
DBVUtils
.
findVirtualEntity
(
entity
,
false
);
if
(
virtualEntity
!=
null
)
{
List
<
DBVColorOverride
>
coList
=
virtualEntity
.
getColorOverrides
();
if
(!
CommonUtils
.
isEmpty
(
coList
))
{
for
(
DBVColorOverride
co
:
coList
)
{
DBDAttributeBinding
binding
=
getAttributeBinding
(
entity
,
co
.
getAttributeName
());
if
(
binding
!=
null
)
{
List
<
AttributeColorSettings
>
cmList
=
colorMapping
.
computeIfAbsent
(
binding
,
k
->
new
ArrayList
<>());
cmList
.
add
(
new
AttributeColorSettings
(
co
));
if
(
entity
!=
null
)
{
DBVEntity
virtualEntity
=
DBVUtils
.
findVirtualEntity
(
entity
,
false
);
if
(
virtualEntity
!=
null
)
{
List
<
DBVColorOverride
>
coList
=
virtualEntity
.
getColorOverrides
();
if
(!
CommonUtils
.
isEmpty
(
coList
))
{
for
(
DBVColorOverride
co
:
coList
)
{
DBDAttributeBinding
binding
=
getAttributeBinding
(
entity
,
co
.
getAttributeName
());
if
(
binding
!=
null
)
{
List
<
AttributeColorSettings
>
cmList
=
colorMapping
.
computeIfAbsent
(
binding
,
k
->
new
ArrayList
<>());
cmList
.
add
(
new
AttributeColorSettings
(
co
));
}
}
}
}
}
else
{
for
(
DBDAttributeBinding
attr
:
attributes
)
{
DBVEntity
virtualEntity
=
DBVUtils
.
getVirtualEntity
(
attr
,
false
);
if
(
virtualEntity
!=
null
)
{
List
<
DBVColorOverride
>
coList
=
virtualEntity
.
getColorOverrides
();
if
(!
CommonUtils
.
isEmpty
(
coList
))
{
for
(
DBVColorOverride
co
:
coList
)
{
if
(
CommonUtils
.
equalObjects
(
attr
.
getName
(),
co
.
getAttributeName
()))
{
List
<
AttributeColorSettings
>
cmList
=
colorMapping
.
computeIfAbsent
(
attr
,
k
->
new
ArrayList
<>());
cmList
.
add
(
new
AttributeColorSettings
(
co
));
}
}
}
}
}
...
...
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java
浏览文件 @
5beb4b6c
...
...
@@ -2208,7 +2208,7 @@ public class ResultSetViewer extends Viewer
}
viewMenu
.
add
(
new
TransformComplexTypesToggleAction
());
viewMenu
.
add
(
new
ColorizeDataTypesToggleAction
());
if
(
getModel
().
isSingleSource
())
{
{
if
(
valueController
!=
null
)
{
viewMenu
.
add
(
new
SetRowColorAction
(
attr
,
valueController
.
getValue
()));
if
(
getModel
().
hasColorMapping
(
attr
))
{
...
...
@@ -4132,19 +4132,13 @@ public class ResultSetViewer extends Viewer
DBVEntity
getVirtualEntity
(
DBDAttributeBinding
binding
)
throws
IllegalStateException
{
final
DBSEntity
entity
=
getModel
().
getSingleSource
();
if
(
entity
==
null
)
{
throw
new
IllegalStateException
(
"No virtual entity for multi-source query"
);
}
final
DBVEntity
vEntity
=
DBVUtils
.
findVirtualEntity
(
entity
,
true
);
assert
vEntity
!=
null
;
return
vEntity
;
return
DBVUtils
.
getVirtualEntity
(
binding
,
true
);
}
void
updateColors
(
DBVEntity
entity
)
{
model
.
updateColorMapping
();
redrawData
(
false
,
false
);
entity
.
getDataSource
().
getContainer
().
persistConfiguration
();
entity
.
persistConfiguration
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录