Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
5e88a999
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,发现更多精彩内容 >>
提交
5e88a999
编写于
4月 21, 2019
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PG tables model refactoring. Redshift model adaptation
上级
f9e1029a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
75 addition
and
67 deletion
+75
-67
plugins/org.jkiss.dbeaver.ext.greenplum/src/org/jkiss/dbeaver/ext/greenplum/model/GreenplumExternalTable.java
...s/dbeaver/ext/greenplum/model/GreenplumExternalTable.java
+1
-3
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreSchema.java
...org/jkiss/dbeaver/ext/postgresql/model/PostgreSchema.java
+5
-5
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreTableBase.java
.../jkiss/dbeaver/ext/postgresql/model/PostgreTableBase.java
+2
-2
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/impls/redshift/RedshiftExternalSchema.java
...stgresql/model/impls/redshift/RedshiftExternalSchema.java
+6
-4
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/impls/redshift/RedshiftExternalTable.java
...ostgresql/model/impls/redshift/RedshiftExternalTable.java
+45
-19
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/impls/redshift/RedshiftExternalTableColumn.java
...sql/model/impls/redshift/RedshiftExternalTableColumn.java
+16
-34
未找到文件。
plugins/org.jkiss.dbeaver.ext.greenplum/src/org/jkiss/dbeaver/ext/greenplum/model/GreenplumExternalTable.java
浏览文件 @
5e88a999
...
...
@@ -24,7 +24,6 @@ import org.jkiss.dbeaver.DBException;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreTable
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreTableColumn
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreTableRegular
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
...
...
@@ -35,7 +34,6 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import
org.jkiss.utils.CommonUtils
;
import
java.sql.ResultSet
;
import
java.text.Format
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -276,7 +274,7 @@ public class GreenplumExternalTable extends PostgreTable {
private
List
<
PostgreTableColumn
>
filterOutNonMetadataColumns
(
DBRProgressMonitor
monitor
)
throws
DBException
{
List
<
PostgreTableColumn
>
tableColumns
;
Stream
<
PostgreTableColumn
>
tableColumnsStream
=
Optional
.
ofNullable
(
this
.
getAttributes
(
monitor
))
Stream
<
?
extends
PostgreTableColumn
>
tableColumnsStream
=
Optional
.
ofNullable
(
this
.
getAttributes
(
monitor
))
.
orElse
(
Collections
.
emptyList
())
.
stream
();
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreSchema.java
浏览文件 @
5e88a999
...
...
@@ -215,7 +215,7 @@ public class PostgreSchema implements DBSSchema, DBPNamedObject2, DBPSaveableObj
}
@Association
public
Collection
<?
extends
PostgreTable
>
getTables
(
DBRProgressMonitor
monitor
)
public
Collection
<?
extends
PostgreTable
Base
>
getTables
(
DBRProgressMonitor
monitor
)
throws
DBException
{
return
tableCache
.
getTypedObjects
(
monitor
,
this
,
PostgreTable
.
class
)
.
stream
()
...
...
@@ -595,8 +595,8 @@ public class PostgreSchema implements DBSSchema, DBPNamedObject2, DBPSaveableObj
return
null
;
}
Object
keyRefNumbers
=
JDBCUtils
.
safeGetArray
(
resultSet
,
"confkey"
);
Collection
<
PostgreTableColumn
>
attributes
=
table
.
getAttributes
(
monitor
);
Collection
<
PostgreTableColumn
>
refAttributes
=
refTable
.
getAttributes
(
monitor
);
Collection
<
?
extends
PostgreTableColumn
>
attributes
=
table
.
getAttributes
(
monitor
);
Collection
<
?
extends
PostgreTableColumn
>
refAttributes
=
refTable
.
getAttributes
(
monitor
);
assert
attributes
!=
null
&&
refAttributes
!=
null
;
int
colCount
=
Array
.
getLength
(
keyNumbers
);
int
refColCount
=
Array
.
getLength
(
keyRefNumbers
);
...
...
@@ -624,7 +624,7 @@ public class PostgreSchema implements DBSSchema, DBPNamedObject2, DBPSaveableObj
return
fkCols
;
}
else
{
Collection
<
PostgreTableColumn
>
attributes
=
table
.
getAttributes
(
monitor
);
Collection
<
?
extends
PostgreTableColumn
>
attributes
=
table
.
getAttributes
(
monitor
);
assert
attributes
!=
null
;
int
colCount
=
Array
.
getLength
(
keyNumbers
);
PostgreTableConstraintColumn
[]
cols
=
new
PostgreTableConstraintColumn
[
colCount
];
...
...
@@ -724,7 +724,7 @@ public class PostgreSchema implements DBSSchema, DBPNamedObject2, DBPSaveableObj
long
[]
indColClasses
=
PostgreUtils
.
getIdVector
(
JDBCUtils
.
safeGetObject
(
dbResult
,
"indclass"
));
int
[]
keyOptions
=
PostgreUtils
.
getIntVector
(
JDBCUtils
.
safeGetObject
(
dbResult
,
"indoption"
));
String
expr
=
JDBCUtils
.
safeGetString
(
dbResult
,
"expr"
);
Collection
<
PostgreTableColumn
>
attributes
=
parent
.
getAttributes
(
dbResult
.
getSession
().
getProgressMonitor
());
Collection
<
?
extends
PostgreTableColumn
>
attributes
=
parent
.
getAttributes
(
dbResult
.
getSession
().
getProgressMonitor
());
assert
attributes
!=
null
;
PostgreIndexColumn
[]
result
=
new
PostgreIndexColumn
[
keyNumbers
.
length
];
for
(
int
i
=
0
;
i
<
keyNumbers
.
length
;
i
++)
{
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreTableBase.java
浏览文件 @
5e88a999
...
...
@@ -157,7 +157,7 @@ public abstract class PostgreTableBase extends JDBCTable<PostgreDataSource, Post
* @param monitor progress monitor
*/
@Override
public
Collection
<
PostgreTableColumn
>
getAttributes
(
@NotNull
DBRProgressMonitor
monitor
)
public
Collection
<
?
extends
PostgreTableColumn
>
getAttributes
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
{
return
getContainer
().
getTableCache
().
getChildren
(
monitor
,
getContainer
(),
this
);
...
...
@@ -172,7 +172,7 @@ public abstract class PostgreTableBase extends JDBCTable<PostgreDataSource, Post
return
null
;
}
public
List
<
PostgreTableColumn
>
getCachedAttributes
()
public
List
<
?
extends
PostgreTableColumn
>
getCachedAttributes
()
{
final
DBSObjectCache
<
PostgreTableBase
,
PostgreTableColumn
>
childrenCache
=
getContainer
().
getTableCache
().
getChildrenCache
(
this
);
if
(
childrenCache
!=
null
)
{
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/impls/redshift/RedshiftExternalSchema.java
浏览文件 @
5e88a999
...
...
@@ -20,10 +20,7 @@ import org.jkiss.code.NotNull;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreRole
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase
;
import
org.jkiss.dbeaver.ext.postgresql.model.*
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
...
...
@@ -92,6 +89,11 @@ public class RedshiftExternalSchema extends PostgreSchema {
return
externalTableCache
.
getAllObjects
(
monitor
,
this
);
}
@Override
public
Collection
<?
extends
PostgreTableBase
>
getTables
(
DBRProgressMonitor
monitor
)
throws
DBException
{
return
getExternalTables
(
monitor
);
}
@Override
public
Collection
<
RedshiftExternalTable
>
getChildren
(
DBRProgressMonitor
monitor
)
throws
DBException
{
return
getExternalTables
(
monitor
);
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/impls/redshift/RedshiftExternalTable.java
浏览文件 @
5e88a999
...
...
@@ -20,39 +20,33 @@ import org.jkiss.code.NotNull;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.ext.postgresql.PostgreUtils
;
import
org.jkiss.dbeaver.ext.postgresql.model.*
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreRole
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreTableConstraint
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreTableConstraintBase
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBPNamedObject2
;
import
org.jkiss.dbeaver.model.DBPRefreshableObject
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.impl.DBObjectNameCaseTransformer
;
import
org.jkiss.dbeaver.model.impl.DBSObjectCache
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
import
org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCStructCache
;
import
org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTable
;
import
org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTableColumn
;
import
org.jkiss.dbeaver.model.meta.Association
;
import
org.jkiss.dbeaver.model.meta.IPropertyValueListProvider
;
import
org.jkiss.dbeaver.model.meta.Property
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSEntity
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAssociation
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSTableIndex
;
import
org.jkiss.utils.CommonUtils
;
import
java.sql.ResultSet
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
/**
* PostgreTable base
*/
public
class
RedshiftExternalTable
extends
JDBCTable
<
PostgreDataSource
,
RedshiftExternalSchema
>
implements
DBPRefreshableObject
public
class
RedshiftExternalTable
extends
PostgreTableBase
implements
DBPRefreshableObject
{
private
static
final
Log
log
=
Log
.
getLog
(
RedshiftExternalTable
.
class
);
private
String
location
;
...
...
@@ -65,14 +59,16 @@ public class RedshiftExternalTable extends JDBCTable<PostgreDataSource, Redshift
protected
RedshiftExternalTable
(
RedshiftExternalSchema
catalog
)
{
super
(
catalog
,
false
);
super
(
catalog
);
}
protected
RedshiftExternalTable
(
RedshiftExternalSchema
catalog
,
ResultSet
dbResult
)
{
super
(
catalog
,
JDBCUtils
.
safeGetString
(
dbResult
,
"tablename"
),
true
);
super
(
catalog
);
setName
(
JDBCUtils
.
safeGetString
(
dbResult
,
"tablename"
));
setPersisted
(
true
);
this
.
location
=
JDBCUtils
.
safeGetString
(
dbResult
,
"location"
);
this
.
inputFormat
=
JDBCUtils
.
safeGetString
(
dbResult
,
"input_format"
);
...
...
@@ -99,11 +95,32 @@ public class RedshiftExternalTable extends JDBCTable<PostgreDataSource, Redshift
}
@Override
public
JDBCStructCache
<
RedshiftExternalSchema
,
?
extends
RedshiftExternalTable
,
?
extends
RedshiftExternalTableColumn
>
getCache
()
{
return
getContainer
().
externalTableCache
;
public
RedshiftExternalSchema
getContainer
()
{
return
(
RedshiftExternalSchema
)
super
.
getContainer
();
}
////////////////////////////////////////////
// Remove standard PG table properties
@Override
public
long
getObjectId
()
{
return
0
;
}
@Override
@Nullable
public
String
[]
getRelOptions
()
{
return
null
;
}
@Override
public
PostgreRole
getOwner
(
DBRProgressMonitor
monitor
)
throws
DBException
{
return
null
;
}
////////////////////////////////////////////
// Redshift table properties
@Property
(
viewable
=
true
,
order
=
10
)
public
String
getLocation
()
{
return
location
;
...
...
@@ -157,7 +174,7 @@ public class RedshiftExternalTable extends JDBCTable<PostgreDataSource, Redshift
@NotNull
public
RedshiftExternalSchema
getSchema
()
{
return
super
.
getContainer
();
return
(
RedshiftExternalSchema
)
super
.
getContainer
();
}
/**
...
...
@@ -165,7 +182,7 @@ public class RedshiftExternalTable extends JDBCTable<PostgreDataSource, Redshift
* @param monitor progress monitor
*/
@Override
public
List
<
RedshiftExternalTableColumn
>
getAttributes
(
@NotNull
DBRProgressMonitor
monitor
)
public
Collection
<
RedshiftExternalTableColumn
>
getAttributes
(
@NotNull
DBRProgressMonitor
monitor
)
throws
DBException
{
return
getContainer
().
externalTableCache
.
getChildren
(
monitor
,
getContainer
(),
this
);
...
...
@@ -230,4 +247,13 @@ public class RedshiftExternalTable extends JDBCTable<PostgreDataSource, Redshift
return
getContainer
().
externalTableCache
.
refreshObject
(
monitor
,
getContainer
(),
this
);
}
@Override
public
void
setObjectDefinitionText
(
String
sourceText
)
throws
DBException
{
}
@Override
public
String
getObjectDefinitionText
(
DBRProgressMonitor
monitor
,
Map
<
String
,
Object
>
options
)
throws
DBException
{
return
null
;
}
}
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/impls/redshift/RedshiftExternalTableColumn.java
浏览文件 @
5e88a999
...
...
@@ -16,51 +16,33 @@
*/
package
org.jkiss.dbeaver.ext.postgresql.model.impls.redshift
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreTableConstraint
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreTableConstraintBase
;
import
org.jkiss.dbeaver.model.DBPDataSource
;
import
org.jkiss.dbeaver.model.DBPEvaluationContext
;
import
org.jkiss.dbeaver.model.DBPRefreshableObject
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet
;
import
org.jkiss.dbeaver.model.impl.DBSObjectCache
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
import
org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCStructCache
;
import
org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTable
;
import
org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTableColumn
;
import
org.jkiss.dbeaver.model.meta.Association
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSEntity
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAssociation
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAttribute
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
java.sql.ResultSet
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
import
org.jkiss.dbeaver.ext.postgresql.model.PostgreTableColumn
;
/**
* PostgreTable base
*/
public
class
RedshiftExternalTableColumn
extends
JDBCTableColumn
<
RedshiftExternalTable
>
public
class
RedshiftExternalTableColumn
extends
PostgreTableColumn
{
public
RedshiftExternalTableColumn
(
RedshiftExternalTable
table
,
boolean
persisted
)
{
super
(
table
,
persisted
);
super
(
table
);
setPersisted
(
persisted
);
}
public
RedshiftExternalTableColumn
(
RedshiftExternalTable
table
,
boolean
persisted
,
String
name
,
String
typeName
,
int
valueType
,
int
ordinalPosition
,
long
maxLength
,
Integer
scale
,
Integer
precision
,
boolean
required
,
boolean
autoGenerated
,
String
defaultValue
)
{
super
(
table
,
persisted
,
name
,
typeName
,
valueType
,
ordinalPosition
,
maxLength
,
scale
,
precision
,
required
,
autoGenerated
,
defaultValue
);
}
public
RedshiftExternalTableColumn
(
RedshiftExternalTable
table
,
DBSEntityAttribute
source
,
boolean
persisted
)
{
super
(
table
,
source
,
persisted
);
super
(
table
);
setPersisted
(
persisted
);
setName
(
name
);
setTypeName
(
typeName
);
setValueType
(
valueType
);
setOrdinalPosition
(
ordinalPosition
);
setMaxLength
(
maxLength
);
setScale
(
scale
);
setPrecision
(
precision
);
setRequired
(
required
);
setAutoGenerated
(
autoGenerated
);
setDefaultValue
(
defaultValue
);
}
@Override
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录