Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
085e67b8
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,发现更多精彩内容 >>
提交
085e67b8
编写于
4月 11, 2018
作者:
E
Evgeny Fradkin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Mock Data. Inserts #3215
上级
6214dbc4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
2 deletion
+29
-2
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/MockDataExecuteWizard.java
...org/jkiss/dbeaver/ext/mockdata/MockDataExecuteWizard.java
+29
-2
未找到文件。
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/MockDataExecuteWizard.java
浏览文件 @
085e67b8
...
...
@@ -29,10 +29,12 @@ import org.jkiss.dbeaver.ext.mockdata.model.MockValueGenerator;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.connection.DBPClientHome
;
import
org.jkiss.dbeaver.model.data.DBDAttributeValue
;
import
org.jkiss.dbeaver.model.edit.DBEPersistAction
;
import
org.jkiss.dbeaver.model.exec.*
;
import
org.jkiss.dbeaver.model.impl.AbstractExecutionSource
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.sql.SQLUtils
;
import
org.jkiss.dbeaver.model.struct.DBSAttributeBase
;
import
org.jkiss.dbeaver.model.struct.DBSDataManipulator
;
import
org.jkiss.dbeaver.model.struct.DBSEntity
;
...
...
@@ -49,6 +51,7 @@ public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulato
private
static
final
Log
log
=
Log
.
getLog
(
MockDataExecuteWizard
.
class
);
private
static
final
int
BATCH_SIZE
=
1000
;
public
static
final
boolean
JUST_GENERATE_SCRIPT
=
false
;
private
static
final
String
RS_EXPORT_WIZARD_DIALOG_SETTINGS
=
"MockData"
;
//$NON-NLS-1$
...
...
@@ -167,6 +170,7 @@ public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulato
boolean
success
=
true
;
monitor
.
beginTask
(
"Generate Mock Data"
,
3
);
ArrayList
<
DBEPersistAction
>
persistActions
=
new
ArrayList
<>();
if
(
mockDataSettings
.
isRemoveOldData
())
{
logPage
.
appendLog
(
"Removing old data from the '"
+
dataManipulator
.
getName
()
+
"'.\n"
);
monitor
.
subTask
(
"Cleanup old data"
);
...
...
@@ -175,7 +179,11 @@ public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulato
// TODO: truncate is much faster than delete
try
(
DBSDataManipulator
.
ExecuteBatch
batch
=
dataManipulator
.
deleteData
(
session
,
new
DBSAttributeBase
[]{},
executionSource
))
{
batch
.
add
(
new
Object
[]{});
deleteStats
.
accumulate
(
batch
.
execute
(
session
));
if
(
JUST_GENERATE_SCRIPT
)
{
batch
.
generatePersistActions
(
session
,
persistActions
);
}
else
{
deleteStats
.
accumulate
(
batch
.
execute
(
session
));
}
}
if
(
txnManager
!=
null
&&
!
autoCommit
)
{
txnManager
.
commit
(
session
);
...
...
@@ -186,6 +194,13 @@ public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulato
log
.
error
(
message
,
e
);
logPage
.
appendLog
(
message
+
"\n\n"
,
true
);
}
if
(
JUST_GENERATE_SCRIPT
)
{
String
scriptText
=
SQLUtils
.
generateScript
(
dataManipulator
.
getDataSource
(),
persistActions
.
toArray
(
new
DBEPersistAction
[
persistActions
.
size
()]),
false
);
logPage
.
appendLog
(
" The insert data script:\n "
+
scriptText
+
"\n\n"
);
}
logPage
.
appendLog
(
" Rows updated: "
+
deleteStats
.
getRowsUpdated
()
+
"\n"
);
logPage
.
appendLog
(
" Duration: "
+
deleteStats
.
getExecuteTime
()
+
"ms\n\n"
);
}
else
{
...
...
@@ -201,6 +216,7 @@ public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulato
logPage
.
appendLog
(
"Inserting mock data into the '"
+
dataManipulator
.
getName
()
+
"'.\n"
);
DBCStatistics
insertStats
=
new
DBCStatistics
();
persistActions
=
new
ArrayList
<>();
// build and init the generators
generators
.
clear
();
...
...
@@ -280,7 +296,11 @@ public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulato
}
}
if
(
batch
!=
null
)
{
insertStats
.
accumulate
(
batch
.
execute
(
session
));
if
(
JUST_GENERATE_SCRIPT
)
{
batch
.
generatePersistActions
(
session
,
persistActions
);
}
else
{
insertStats
.
accumulate
(
batch
.
execute
(
session
));
}
}
}
catch
(
Exception
e
)
{
...
...
@@ -301,6 +321,13 @@ public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulato
txnManager
.
commit
(
session
);
}
if
(
JUST_GENERATE_SCRIPT
)
{
String
scriptText
=
SQLUtils
.
generateScript
(
dataManipulator
.
getDataSource
(),
persistActions
.
toArray
(
new
DBEPersistAction
[
persistActions
.
size
()]),
false
);
logPage
.
appendLog
(
" The insert data script:\n "
+
scriptText
+
"\n\n"
);
}
logPage
.
appendLog
(
" Rows updated: "
+
insertStats
.
getRowsUpdated
()
+
"\n"
);
logPage
.
appendLog
(
" Duration: "
+
insertStats
.
getExecuteTime
()
+
"ms\n\n"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录