Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
a746c3d8
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,发现更多精彩内容 >>
提交
a746c3d8
编写于
9月 09, 2016
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MySQL table copy. Copy constructors in RDB model.
Former-commit-id:
0d981add
上级
d16e09c3
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
133 addition
and
37 deletion
+133
-37
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/edit/MySQLTableManager.java
...c/org/jkiss/dbeaver/ext/mysql/edit/MySQLTableManager.java
+12
-29
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/model/MySQLPartition.java
...src/org/jkiss/dbeaver/ext/mysql/model/MySQLPartition.java
+13
-0
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/model/MySQLTable.java
...sql/src/org/jkiss/dbeaver/ext/mysql/model/MySQLTable.java
+21
-1
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/model/MySQLTableBase.java
...src/org/jkiss/dbeaver/ext/mysql/model/MySQLTableBase.java
+14
-0
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/model/MySQLTableColumn.java
...c/org/jkiss/dbeaver/ext/mysql/model/MySQLTableColumn.java
+20
-2
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/model/MySQLTableForeignKey.java
...g/jkiss/dbeaver/ext/mysql/model/MySQLTableForeignKey.java
+13
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/edit/DBEObjectMaker.java
...odel/src/org/jkiss/dbeaver/model/edit/DBEObjectMaker.java
+2
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/struct/JDBCAttribute.java
...g/jkiss/dbeaver/model/impl/jdbc/struct/JDBCAttribute.java
+6
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/struct/JDBCTableColumn.java
...jkiss/dbeaver/model/impl/jdbc/struct/JDBCTableColumn.java
+11
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/sql/edit/SQLObjectEditor.java
...rg/jkiss/dbeaver/model/impl/sql/edit/SQLObjectEditor.java
+2
-3
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/sql/edit/struct/SQLTableManager.java
...s/dbeaver/model/impl/sql/edit/struct/SQLTableManager.java
+5
-1
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/struct/AbstractAttribute.java
...rg/jkiss/dbeaver/model/impl/struct/AbstractAttribute.java
+14
-0
未找到文件。
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/edit/MySQLTableManager.java
浏览文件 @
a746c3d8
...
...
@@ -30,6 +30,7 @@ import org.jkiss.dbeaver.model.exec.DBCException;
import
org.jkiss.dbeaver.model.impl.DBSObjectCache
;
import
org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction
;
import
org.jkiss.dbeaver.model.impl.sql.edit.struct.SQLTableManager
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.sql.SQLUtils
;
...
...
@@ -55,18 +56,22 @@ public class MySQLTableManager extends SQLTableManager<MySQLTableBase, MySQLCata
}
@Override
protected
MySQLTable
createDatabaseObject
(
DBECommandContext
context
,
MySQLCatalog
parent
,
Object
copyFrom
)
protected
MySQLTable
createDatabaseObject
(
DBECommandContext
context
,
MySQLCatalog
parent
,
Object
copyFrom
)
throws
DBException
{
final
MySQLTable
table
=
new
MySQLTable
(
parent
);
try
{
DBRProgressMonitor
monitor
=
VoidProgressMonitor
.
INSTANCE
;
final
MySQLTable
table
;
if
(
copyFrom
instanceof
MySQLTable
)
{
table
=
new
MySQLTable
(
monitor
,
(
MySQLTable
)
copyFrom
);
table
.
setName
(
getTableName
(
parent
,
((
MySQLTable
)
copyFrom
).
getName
()));
}
else
{
table
=
new
MySQLTable
(
parent
);
setTableName
(
parent
,
table
);
final
MySQLTable
.
AdditionalInfo
additionalInfo
=
table
.
getAdditionalInfo
(
VoidProgressMonitor
.
INSTANCE
);
final
MySQLTable
.
AdditionalInfo
additionalInfo
=
table
.
getAdditionalInfo
(
monitor
);
additionalInfo
.
setEngine
(
parent
.
getDataSource
().
getDefaultEngine
());
additionalInfo
.
setCharset
(
parent
.
getDefaultCharset
());
additionalInfo
.
setCollation
(
parent
.
getDefaultCollation
());
}
catch
(
DBException
e
)
{
// Never be here
log
.
error
(
e
);
}
return
table
;
...
...
@@ -136,26 +141,4 @@ public class MySQLTableManager extends SQLTableManager<MySQLTableBase, MySQLCata
processObjectRename
(
commandContext
,
object
,
newName
);
}
/*
public ITabDescriptor[] getTabDescriptors(IWorkbenchWindow workbenchWindow, final IDatabaseEditor activeEditor, final MySQLTable object)
{
if (object.getContainer().isSystem()) {
return null;
}
return new ITabDescriptor[] {
new PropertyTabDescriptor(
PropertiesContributor.CATEGORY_INFO,
"table.ddl", //$NON-NLS-1$
"DDL", //$NON-NLS-1$
DBIcon.SOURCES.getImage(),
new SectionDescriptor("default", "DDL") { //$NON-NLS-1$ //$NON-NLS-2$
public ISection getSectionClass()
{
return new MySQLDDLViewEditor(activeEditor);
}
})
};
}
*/
}
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/model/MySQLPartition.java
浏览文件 @
a746c3d8
...
...
@@ -23,6 +23,7 @@ import org.jkiss.dbeaver.ext.mysql.MySQLConstants;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
import
org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTableObject
;
import
org.jkiss.dbeaver.model.meta.Property
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
java.sql.ResultSet
;
import
java.util.ArrayList
;
...
...
@@ -92,6 +93,18 @@ public class MySQLPartition extends JDBCTableObject<MySQLTable>
super
(
source
);
}
// Copy constructor
protected
MySQLPartition
(
DBRProgressMonitor
monitor
,
MySQLTable
table
,
MySQLPartition
source
)
{
super
(
table
,
source
.
getName
(),
false
);
this
.
position
=
source
.
position
;
this
.
method
=
source
.
method
;
this
.
expression
=
source
.
expression
;
this
.
description
=
source
.
description
;
this
.
comment
=
source
.
comment
;
this
.
nodegroup
=
source
.
nodegroup
;
}
private
void
addSubPartitions
(
MySQLPartition
partition
)
{
if
(
subPartitions
==
null
)
{
...
...
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/model/MySQLTable.java
浏览文件 @
a746c3d8
...
...
@@ -33,7 +33,6 @@ import org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCObjectCache;
import
org.jkiss.dbeaver.model.meta.*
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSEntityConstraintType
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSForeignKeyModifyRule
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -99,6 +98,27 @@ public class MySQLTable extends MySQLTableBase
super
(
catalog
);
}
// Copy constructor
public
MySQLTable
(
DBRProgressMonitor
monitor
,
MySQLTable
source
)
throws
DBException
{
super
(
monitor
,
source
);
additionalInfo
.
loaded
=
source
.
additionalInfo
.
loaded
;
additionalInfo
.
description
=
source
.
additionalInfo
.
description
;
additionalInfo
.
createTime
=
source
.
additionalInfo
.
createTime
;
additionalInfo
.
charset
=
source
.
additionalInfo
.
charset
;
additionalInfo
.
collation
=
source
.
additionalInfo
.
collation
;
additionalInfo
.
engine
=
source
.
additionalInfo
.
engine
;
// Copy partitions
for
(
MySQLPartition
partition
:
source
.
partitionCache
.
getCachedObjects
())
{
partitionCache
.
cacheObject
(
new
MySQLPartition
(
monitor
,
this
,
partition
));
}
// Copy indexes
// Copy constraints
// Copy FKs
for
(
MySQLTableForeignKey
fk
:
foreignKeys
.
getCachedObjects
())
{
foreignKeys
.
cacheObject
(
new
MySQLTableForeignKey
(
monitor
,
this
,
fk
));
}
}
public
MySQLTable
(
MySQLCatalog
catalog
,
ResultSet
dbResult
)
...
...
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/model/MySQLTableBase.java
浏览文件 @
a746c3d8
...
...
@@ -24,11 +24,13 @@ import org.jkiss.dbeaver.model.DBPNamedObject2;
import
org.jkiss.dbeaver.model.DBPRefreshableObject
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.exec.jdbc.JDBCSession
;
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.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
import
java.io.UnsupportedEncodingException
;
...
...
@@ -50,6 +52,18 @@ public abstract class MySQLTableBase extends JDBCTable<MySQLDataSource, MySQLCat
super
(
catalog
,
false
);
}
// Copy constructor
protected
MySQLTableBase
(
DBRProgressMonitor
monitor
,
MySQLTableBase
source
)
throws
DBException
{
super
(
source
.
getContainer
(),
false
);
DBSObjectCache
<
MySQLTableBase
,
MySQLTableColumn
>
colCache
=
getContainer
().
getTableCache
().
getChildrenCache
(
this
);
// Copy columns
for
(
MySQLTableColumn
srcColumn
:
source
.
getAttributes
(
monitor
))
{
MySQLTableColumn
column
=
new
MySQLTableColumn
(
this
,
srcColumn
);
colCache
.
cacheObject
(
column
);
}
}
protected
MySQLTableBase
(
MySQLCatalog
catalog
,
ResultSet
dbResult
)
...
...
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/model/MySQLTableColumn.java
浏览文件 @
a746c3d8
...
...
@@ -47,7 +47,6 @@ public class MySQLTableColumn extends JDBCTableColumn<MySQLTableBase> implements
private
static
final
Log
log
=
Log
.
getLog
(
MySQLTableColumn
.
class
);
private
static
Pattern
enumPattern
=
Pattern
.
compile
(
"'([^']*)'"
);
private
String
fullTypeName
;
public
enum
KeyType
implements
JDBCColumnKeyType
{
PRI
,
...
...
@@ -73,6 +72,7 @@ public class MySQLTableColumn extends JDBCTableColumn<MySQLTableBase> implements
private
KeyType
keyType
;
private
String
extraInfo
;
private
String
fullTypeName
;
private
List
<
String
>
enumValues
;
public
MySQLTableColumn
(
MySQLTableBase
table
)
...
...
@@ -89,6 +89,24 @@ public class MySQLTableColumn extends JDBCTableColumn<MySQLTableBase> implements
loadInfo
(
dbResult
);
}
// Copy constructor
public
MySQLTableColumn
(
MySQLTableBase
table
,
MySQLTableColumn
source
)
throws
DBException
{
super
(
table
,
source
,
false
);
this
.
comment
=
source
.
comment
;
this
.
charLength
=
source
.
charLength
;
this
.
collation
=
source
.
collation
;
this
.
keyType
=
source
.
keyType
;
this
.
extraInfo
=
source
.
extraInfo
;
this
.
fullTypeName
=
source
.
fullTypeName
;
if
(
source
.
enumValues
!=
null
)
{
this
.
enumValues
=
new
ArrayList
<>(
source
.
enumValues
);
}
}
private
void
loadInfo
(
ResultSet
dbResult
)
throws
DBException
{
...
...
@@ -139,7 +157,7 @@ public class MySQLTableColumn extends JDBCTableColumn<MySQLTableBase> implements
this
.
extraInfo
=
JDBCUtils
.
safeGetString
(
dbResult
,
MySQLConstants
.
COL_COLUMN_EXTRA
);
this
.
autoGenerated
=
extraInfo
!=
null
&&
extraInfo
.
contains
(
MySQLConstants
.
EXTRA_AUTO_INCREMENT
);
fullTypeName
=
JDBCUtils
.
safeGetString
(
dbResult
,
MySQLConstants
.
COL_COLUMN_TYPE
);
this
.
fullTypeName
=
JDBCUtils
.
safeGetString
(
dbResult
,
MySQLConstants
.
COL_COLUMN_TYPE
);
if
(!
CommonUtils
.
isEmpty
(
fullTypeName
)
&&
(
isTypeEnum
()
||
isTypeSet
()))
{
enumValues
=
new
ArrayList
<>();
Matcher
enumMatcher
=
enumPattern
.
matcher
(
fullTypeName
);
...
...
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/model/MySQLTableForeignKey.java
浏览文件 @
a746c3d8
...
...
@@ -18,6 +18,7 @@
package
org.jkiss.dbeaver.ext.mysql.model
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.impl.jdbc.struct.JDBCTableForeignKey
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
...
...
@@ -45,6 +46,18 @@ public class MySQLTableForeignKey extends JDBCTableForeignKey<MySQLTable, MySQLT
super
(
table
,
name
,
remarks
,
referencedKey
,
deleteRule
,
updateRule
,
persisted
);
}
// Copy constructor
public
MySQLTableForeignKey
(
DBRProgressMonitor
monitor
,
MySQLTable
table
,
MySQLTableForeignKey
source
)
throws
DBException
{
super
(
table
,
source
.
getName
(),
source
.
getDescription
(),
table
.
getConstraint
(
monitor
,
source
.
referencedKey
.
getName
()),
source
.
deleteRule
,
source
.
updateRule
,
false
);
}
@Override
public
List
<
MySQLTableForeignKeyColumn
>
getAttributeReferences
(
DBRProgressMonitor
monitor
)
{
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/edit/DBEObjectMaker.java
浏览文件 @
a746c3d8
...
...
@@ -19,6 +19,7 @@
package
org.jkiss.dbeaver.model.edit
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.model.impl.DBSObjectCache
;
import
org.jkiss.dbeaver.model.struct.DBSObject
;
...
...
@@ -60,7 +61,7 @@ public interface DBEObjectMaker<OBJECT_TYPE extends DBSObject, CONTAINER_TYPE> e
OBJECT_TYPE
createNewObject
(
DBECommandContext
commandContext
,
CONTAINER_TYPE
parent
,
Object
copyFrom
);
Object
copyFrom
)
throws
DBException
;
/**
* Deletes specified object.
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/struct/JDBCAttribute.java
浏览文件 @
a746c3d8
...
...
@@ -38,6 +38,12 @@ public abstract class JDBCAttribute extends AbstractAttribute implements DBSObje
super
(
name
,
typeName
,
valueType
,
ordinalPosition
,
maxLength
,
scale
,
precision
,
required
,
sequence
);
}
// Copy constructor
protected
JDBCAttribute
(
JDBCAttribute
source
)
{
super
(
source
);
}
@Nullable
@Override
public
DBPImage
getObjectImage
()
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/jdbc/struct/JDBCTableColumn.java
浏览文件 @
a746c3d8
...
...
@@ -77,6 +77,17 @@ public abstract class JDBCTableColumn<TABLE_TYPE extends DBSEntity> extends JDBC
this
.
persisted
=
persisted
;
}
protected
JDBCTableColumn
(
TABLE_TYPE
table
,
JDBCTableColumn
source
,
boolean
persisted
)
{
super
(
source
);
this
.
table
=
table
;
this
.
persisted
=
persisted
;
this
.
defaultValue
=
source
.
defaultValue
;
}
public
TABLE_TYPE
getTable
()
{
return
table
;
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/sql/edit/SQLObjectEditor.java
浏览文件 @
a746c3d8
...
...
@@ -78,8 +78,7 @@ public abstract class SQLObjectEditor<OBJECT_TYPE extends DBSObject, CONTAINER_T
// Commands
@Override
public
final
OBJECT_TYPE
createNewObject
(
DBECommandContext
commandContext
,
CONTAINER_TYPE
parent
,
Object
copyFrom
)
{
public
final
OBJECT_TYPE
createNewObject
(
DBECommandContext
commandContext
,
CONTAINER_TYPE
parent
,
Object
copyFrom
)
throws
DBException
{
OBJECT_TYPE
newObject
;
try
{
newObject
=
createDatabaseObject
(
commandContext
,
parent
,
copyFrom
);
...
...
@@ -114,7 +113,7 @@ public abstract class SQLObjectEditor<OBJECT_TYPE extends DBSObject, CONTAINER_T
protected
abstract
OBJECT_TYPE
createDatabaseObject
(
DBECommandContext
context
,
CONTAINER_TYPE
parent
,
Object
copyFrom
);
Object
copyFrom
)
throws
DBException
;
//////////////////////////////////////////////////
// Actions
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/sql/edit/struct/SQLTableManager.java
浏览文件 @
a746c3d8
...
...
@@ -126,8 +126,12 @@ public abstract class SQLTableManager<OBJECT_TYPE extends JDBCTable, CONTAINER_T
}
protected
String
getTableName
(
CONTAINER_TYPE
container
)
throws
DBException
{
return
getTableName
(
container
,
BASE_TABLE_NAME
);
}
protected
String
getTableName
(
CONTAINER_TYPE
container
,
String
baseName
)
throws
DBException
{
for
(
int
i
=
0
;
;
i
++)
{
String
tableName
=
DBObjectNameCaseTransformer
.
transformName
(
container
.
getDataSource
(),
i
==
0
?
BASE_TABLE_NAME
:
(
BASE_TABLE_NAME
+
"_"
+
i
));
String
tableName
=
DBObjectNameCaseTransformer
.
transformName
(
container
.
getDataSource
(),
i
==
0
?
baseName
:
(
baseName
+
"_"
+
i
));
DBSObject
child
=
container
.
getChild
(
VoidProgressMonitor
.
INSTANCE
,
tableName
);
if
(
child
==
null
)
{
return
tableName
;
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/impl/struct/AbstractAttribute.java
浏览文件 @
a746c3d8
...
...
@@ -42,6 +42,20 @@ public abstract class AbstractAttribute implements DBSAttributeBase
{
}
// Copy constructor
protected
AbstractAttribute
(
AbstractAttribute
source
)
{
this
.
name
=
source
.
name
;
this
.
valueType
=
source
.
valueType
;
this
.
maxLength
=
source
.
maxLength
;
this
.
scale
=
source
.
scale
;
this
.
precision
=
source
.
precision
;
this
.
required
=
source
.
required
;
this
.
autoGenerated
=
source
.
autoGenerated
;
this
.
typeName
=
source
.
typeName
;
this
.
ordinalPosition
=
source
.
ordinalPosition
;
}
protected
AbstractAttribute
(
String
name
,
String
typeName
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录