Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
7ac9c7c4
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,发现更多精彩内容 >>
提交
7ac9c7c4
编写于
9月 13, 2016
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PG view DDL + view edit
上级
d62b0fb1
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
38 addition
and
39 deletion
+38
-39
plugins/org.jkiss.dbeaver.ext.postgresql/plugin.properties
plugins/org.jkiss.dbeaver.ext.postgresql/plugin.properties
+2
-0
plugins/org.jkiss.dbeaver.ext.postgresql/plugin.xml
plugins/org.jkiss.dbeaver.ext.postgresql/plugin.xml
+3
-0
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreViewManager.java
...jkiss/dbeaver/ext/postgresql/edit/PostgreViewManager.java
+12
-11
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreMaterializedView.java
...dbeaver/ext/postgresql/model/PostgreMaterializedView.java
+4
-0
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreTableBase.java
.../jkiss/dbeaver/ext/postgresql/model/PostgreTableBase.java
+1
-0
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreView.java
...c/org/jkiss/dbeaver/ext/postgresql/model/PostgreView.java
+2
-23
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreViewBase.java
...g/jkiss/dbeaver/ext/postgresql/model/PostgreViewBase.java
+14
-5
未找到文件。
plugins/org.jkiss.dbeaver.ext.postgresql/plugin.properties
浏览文件 @
7ac9c7c4
...
...
@@ -286,6 +286,8 @@ meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTable.superTables.name=Super
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTable.superTables.description
=
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTable.tablespace.name=Tablespace
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTable.tablespace.description
=
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase.objectId.name=ID
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase.objectId.description
=
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase.description.name=Description
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase.description.description
=
meta.org.jkiss.dbeaver.ext.postgresql.model.PostgreTableConstraint.source.name=Expression
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/plugin.xml
浏览文件 @
7ac9c7c4
...
...
@@ -223,6 +223,9 @@
<manager
class=
"org.jkiss.dbeaver.ext.postgresql.edit.PostgreViewManager"
objectType=
"org.jkiss.dbeaver.ext.postgresql.model.PostgreView"
/>
<manager
class=
"org.jkiss.dbeaver.ext.postgresql.edit.PostgreViewManager"
objectType=
"org.jkiss.dbeaver.ext.postgresql.model.PostgreMaterializedView"
/>
<manager
class=
"org.jkiss.dbeaver.ext.postgresql.edit.PostgreTriggerManager"
objectType=
"org.jkiss.dbeaver.ext.postgresql.model.PostgreTrigger"
/>
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/edit/PostgreViewManager.java
浏览文件 @
7ac9c7c4
...
...
@@ -22,6 +22,7 @@ import org.jkiss.dbeaver.DBException;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreView
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreViewBase
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.edit.DBECommandContext
;
import
org.jkiss.dbeaver.model.edit.DBEPersistAction
;
...
...
@@ -29,7 +30,7 @@ import org.jkiss.dbeaver.model.impl.DBSObjectCache;
import
org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction
;
import
org.jkiss.dbeaver.model.impl.sql.edit.SQLObjectEditor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.
utils.GeneralUtils
;
import
org.jkiss.dbeaver.
model.runtime.VoidProgressMonitor
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.List
;
...
...
@@ -69,7 +70,7 @@ public class PostgreViewManager extends SQLObjectEditor<PostgreTableBase, Postgr
protected
PostgreView
createDatabaseObject
(
DBRProgressMonitor
monitor
,
DBECommandContext
context
,
PostgreSchema
parent
,
Object
copyFrom
)
{
PostgreView
newCatalog
=
new
PostgreView
(
parent
);
newCatalog
.
setName
(
"
NewV
iew"
);
//$NON-NLS-1$
newCatalog
.
setName
(
"
new_v
iew"
);
//$NON-NLS-1$
return
newCatalog
;
}
...
...
@@ -82,7 +83,7 @@ public class PostgreViewManager extends SQLObjectEditor<PostgreTableBase, Postgr
@Override
protected
void
addObjectModifyActions
(
List
<
DBEPersistAction
>
actionList
,
ObjectChangeCommand
command
)
{
createOrReplaceViewQuery
(
actionList
,
(
PostgreView
)
command
.
getObject
());
createOrReplaceViewQuery
(
actionList
,
(
PostgreView
Base
)
command
.
getObject
());
}
@Override
...
...
@@ -93,16 +94,16 @@ public class PostgreViewManager extends SQLObjectEditor<PostgreTableBase, Postgr
);
}
private
void
createOrReplaceViewQuery
(
List
<
DBEPersistAction
>
actions
,
PostgreView
view
)
private
void
createOrReplaceViewQuery
(
List
<
DBEPersistAction
>
actions
,
PostgreView
Base
view
)
{
StringBuilder
decl
=
new
StringBuilder
(
200
);
final
String
lineSeparator
=
GeneralUtils
.
getDefaultLineSeparator
();
decl
.
append
(
"CREATE OR REPLACE VIEW "
).
append
(
view
.
getFullyQualifiedName
(
DBPEvaluationContext
.
DDL
)).
append
(
lineSeparator
)
//$NON-NLS-1$
.
append
(
"AS "
).
append
(
view
.
getSource
());
//$NON-NLS-1$
String
ddl
;
try
{
ddl
=
view
.
getObjectDefinitionText
(
VoidProgressMonitor
.
INSTANCE
);
}
catch
(
DBException
e
)
{
ddl
=
e
.
getMessage
();
}
actions
.
add
(
new
SQLDatabasePersistAction
(
"Create view"
,
decl
.
toString
())
);
new
SQLDatabasePersistAction
(
"Create view"
,
ddl
));
}
}
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreMaterializedView.java
浏览文件 @
7ac9c7c4
...
...
@@ -48,4 +48,8 @@ public class PostgreMaterializedView extends PostgreViewBase
throw
new
DBException
(
"Not Implemented"
);
}
public
String
getViewType
()
{
return
"MATERIALIZED VIEW"
;
}
}
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreTableBase.java
浏览文件 @
7ac9c7c4
...
...
@@ -75,6 +75,7 @@ public abstract class PostgreTableBase extends JDBCTable<PostgreDataSource, Post
return
getContainer
().
getDatabase
();
}
@Property
(
viewable
=
true
,
editable
=
false
,
updatable
=
false
,
order
=
9
)
@Override
public
long
getObjectId
()
{
return
this
.
oid
;
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreView.java
浏览文件 @
7ac9c7c4
...
...
@@ -19,17 +19,12 @@ package org.jkiss.dbeaver.ext.postgresql.model;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
import
org.jkiss.dbeaver.model.impl.DBObjectNameCaseTransformer
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
import
org.jkiss.dbeaver.model.meta.Property
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSTableIndex
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.List
;
/**
...
...
@@ -37,8 +32,6 @@ import java.util.List;
*/
public
class
PostgreView
extends
PostgreViewBase
{
private
String
source
;
public
PostgreView
(
PostgreSchema
catalog
)
{
super
(
catalog
);
...
...
@@ -71,22 +64,8 @@ public class PostgreView extends PostgreViewBase
return
null
;
}
@Override
public
DBSObject
refreshObject
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
{
source
=
null
;
super
.
refreshObject
(
monitor
);
return
this
;
}
public
String
getSource
()
{
return
source
;
}
@Override
public
void
setObjectDefinitionText
(
String
sourceText
)
throws
DBException
{
throw
new
DBException
(
"Not Implemented"
);
public
String
getViewType
()
{
return
"VIEW"
;
}
}
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreViewBase.java
浏览文件 @
7ac9c7c4
...
...
@@ -19,6 +19,7 @@ package org.jkiss.dbeaver.ext.postgresql.model;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
import
org.jkiss.dbeaver.model.impl.DBObjectNameCaseTransformer
;
...
...
@@ -89,11 +90,17 @@ public abstract class PostgreViewBase extends PostgreTableReal
public
String
getObjectDefinitionText
(
DBRProgressMonitor
monitor
)
throws
DBException
{
if
(
source
==
null
)
{
try
(
JDBCSession
session
=
DBUtils
.
openMetaSession
(
monitor
,
getDataSource
(),
"Read view definition"
))
{
source
=
JDBCUtils
.
queryString
(
session
,
"SELECT pg_get_viewdef(?, true)"
,
getObjectId
());
}
catch
(
SQLException
e
)
{
throw
new
DBException
(
"Error reading view definition"
,
e
);
String
body
;
if
(
isPersisted
())
{
try
(
JDBCSession
session
=
DBUtils
.
openMetaSession
(
monitor
,
getDataSource
(),
"Read view definition"
))
{
body
=
JDBCUtils
.
queryString
(
session
,
"SELECT pg_get_viewdef(?, true)"
,
getObjectId
());
}
catch
(
SQLException
e
)
{
throw
new
DBException
(
"Error reading view definition"
,
e
);
}
}
else
{
body
=
""
;
}
source
=
"CREATE OR REPLACE "
+
getViewType
()
+
" "
+
getFullyQualifiedName
(
DBPEvaluationContext
.
DDL
)
+
" AS\n"
+
body
;
}
return
source
;
}
...
...
@@ -101,7 +108,9 @@ public abstract class PostgreViewBase extends PostgreTableReal
@Override
public
void
setObjectDefinitionText
(
String
sourceText
)
throws
DBException
{
th
row
new
DBException
(
"Not Implemented"
)
;
th
is
.
source
=
sourceText
;
}
public
abstract
String
getViewType
();
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录