Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
3914163b
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,发现更多精彩内容 >>
提交
3914163b
编写于
5月 10, 2018
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/devel' into devel
上级
dff60f7c
1917b44d
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
173 addition
and
62 deletion
+173
-62
nls/bundles/org.jkiss.dbeaver.core.nls/src/org/jkiss/dbeaver/core/CoreResources_zh.properties
...ls/src/org/jkiss/dbeaver/core/CoreResources_zh.properties
+8
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/CoreMessages.java
...dbeaver.core/src/org/jkiss/dbeaver/core/CoreMessages.java
+8
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/CoreResources.properties
....core/src/org/jkiss/dbeaver/core/CoreResources.properties
+8
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/handlers/RedoChangesHandler.java
...beaver/ui/editors/entity/handlers/RedoChangesHandler.java
+2
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/handlers/UndoChangesHandler.java
...beaver/ui/editors/entity/handlers/UndoChangesHandler.java
+2
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/object/struct/CreateProcedurePage.java
...dbeaver/ui/editors/object/struct/CreateProcedurePage.java
+1
-1
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/object/struct/CreateSequencePage.java
.../dbeaver/ui/editors/object/struct/CreateSequencePage.java
+2
-2
plugins/org.jkiss.dbeaver.ext.mockdata/plugin.xml
plugins/org.jkiss.dbeaver.ext.mockdata/plugin.xml
+43
-43
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/MockDataExecuteWizard.java
...org/jkiss/dbeaver/ext/mockdata/MockDataExecuteWizard.java
+41
-4
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/MockDataSettings.java
.../src/org/jkiss/dbeaver/ext/mockdata/MockDataSettings.java
+1
-3
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/MockDataWizardPageSettings.java
...kiss/dbeaver/ext/mockdata/MockDataWizardPageSettings.java
+1
-1
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/generator/AbstractMockValueGenerator.java
...er/ext/mockdata/generator/AbstractMockValueGenerator.java
+1
-1
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/generator/FKGenerator.java
...org/jkiss/dbeaver/ext/mockdata/generator/FKGenerator.java
+1
-1
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/model/MockGeneratorDescriptor.java
...s/dbeaver/ext/mockdata/model/MockGeneratorDescriptor.java
+7
-0
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/model/MockGeneratorRegistry.java
...iss/dbeaver/ext/mockdata/model/MockGeneratorRegistry.java
+5
-0
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreSequence.java
...g/jkiss/dbeaver/ext/postgresql/model/PostgreSequence.java
+6
-0
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
...ss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
+22
-3
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDAttributeValue.java
...l/src/org/jkiss/dbeaver/model/data/DBDAttributeValue.java
+14
-0
未找到文件。
nls/bundles/org.jkiss.dbeaver.core.nls/src/org/jkiss/dbeaver/core/CoreResources_zh.properties
浏览文件 @
3914163b
...
...
@@ -613,6 +613,10 @@ dialog_struct_create_entity_title = \u521B\u5EFA\u65B0\u7684
dialog_struct_create_procedure_combo_type
=
\u
7C7B
\u
578B
dialog_struct_create_procedure_label_name
=
\u
540D
\u
79F0
dialog_struct_create_procedure_title
=
\u
521B
\u
5EFA
\u
65B0
\u7684\u
8FC7
\u
7A0B/
\u
51FD
\u6570
dialog_struct_create_procedure_container
=
\u
6A21
\u
5F0F
dialog_struct_create_sequence_title
=
\u
521B
\u
5EFA
\u
65B0
\u
5E8F
\u5217
dialog_struct_create_sequence_name
=
\u
5E8F
\u5217\u
540D
\u
79F0
dialog_struct_create_sequence_container
=
\u
6A21
\u
5F0F
dialog_struct_edit_constrain_label_type
=
\u
7C7B
\u
578B
dialog_struct_edit_fk_column_col_type
=
\u
5B57
\u
6BB5
\u
7C7B
\u
578B
dialog_struct_edit_fk_column_column
=
\u
5B57
\u
6BB5
...
...
@@ -1241,5 +1245,9 @@ obj_editor_properties_control_action_configure_columns = \u914D\u7F6E\u5B57\u6BB
obj_editor_properties_control_action_configure_columns_description
=
\u
914D
\u
7F6E
\u
5B57
\u
6BB5
\u
53EF
\u
89C1
\u6027
## object properties editor ##
##toolbar editor menu item##
toolbar_cmd_undo_name
=
\u
64A4
\u9500
toolbar_cmd_redo_name
=
\u
91CD
\u
505A
##toolbar editor menu item##
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/CoreMessages.java
浏览文件 @
3914163b
...
...
@@ -627,6 +627,10 @@ public class CoreMessages extends NLS {
public
static
String
dialog_struct_create_procedure_combo_type
;
public
static
String
dialog_struct_create_procedure_label_name
;
public
static
String
dialog_struct_create_procedure_title
;
public
static
String
dialog_struct_create_procedure_container
;
public
static
String
dialog_struct_create_sequence_title
;
public
static
String
dialog_struct_create_sequence_name
;
public
static
String
dialog_struct_create_sequence_container
;
public
static
String
dialog_struct_edit_constrain_label_type
;
public
static
String
dialog_struct_edit_fk_column_col_type
;
public
static
String
dialog_struct_edit_fk_column_column
;
...
...
@@ -1342,7 +1346,10 @@ public class CoreMessages extends NLS {
public
static
String
obj_editor_properties_control_action_configure_columns_description
;
//object properties editor
//toolbar editor menu item
public
static
String
toolbar_cmd_undo_name
;
public
static
String
toolbar_cmd_redo_name
;
//toolbar editor menu item
static
{
// initialize resource bundle
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/core/CoreResources.properties
浏览文件 @
3914163b
...
...
@@ -623,6 +623,10 @@ dialog_struct_create_entity_title = Create new
dialog_struct_create_procedure_combo_type
=
Type
dialog_struct_create_procedure_label_name
=
Name
dialog_struct_create_procedure_title
=
Create new procedure/function
dialog_struct_create_procedure_container
=
Container
dialog_struct_create_sequence_title
=
Create new Sequence
dialog_struct_create_sequence_name
=
Sequence Name
dialog_struct_create_sequence_container
=
Container
dialog_struct_edit_constrain_label_type
=
Type
dialog_struct_edit_fk_column_col_type
=
Column Type
dialog_struct_edit_fk_column_column
=
Column
...
...
@@ -1301,6 +1305,10 @@ obj_editor_properties_control_action_configure_columns = Configure columns
obj_editor_properties_control_action_configure_columns_description
=
Configure columns visibility
## object properties editor ##
##toolbar editor menu item##
toolbar_cmd_undo_name
=
Undo
toolbar_cmd_redo_name
=
Redo
##toolbar editor menu item##
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/handlers/RedoChangesHandler.java
浏览文件 @
3914163b
...
...
@@ -24,6 +24,7 @@ import org.eclipse.ui.IWorkbenchWindow;
import
org.eclipse.ui.commands.IElementUpdater
;
import
org.eclipse.ui.handlers.HandlerUtil
;
import
org.eclipse.ui.menus.UIElement
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.edit.DBECommandContext
;
import
org.jkiss.dbeaver.ui.editors.entity.EntityEditor
;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
...
...
@@ -54,7 +55,7 @@ public class RedoChangesHandler extends AbstractHandler implements IElementUpdat
final
IEditorPart
activeEditor
=
workbenchWindow
.
getActivePage
().
getActiveEditor
();
if
(
activeEditor
instanceof
EntityEditor
)
{
final
DBECommandContext
commandContext
=
((
EntityEditor
)
activeEditor
).
getCommandContext
();
String
text
=
"Redo"
;
String
text
=
CoreMessages
.
toolbar_cmd_redo_name
;
if
(
commandContext
!=
null
&&
commandContext
.
getRedoCommand
()
!=
null
)
{
text
+=
" "
+
commandContext
.
getRedoCommand
().
getTitle
();
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/entity/handlers/UndoChangesHandler.java
浏览文件 @
3914163b
...
...
@@ -24,6 +24,7 @@ import org.eclipse.ui.IWorkbenchWindow;
import
org.eclipse.ui.commands.IElementUpdater
;
import
org.eclipse.ui.handlers.HandlerUtil
;
import
org.eclipse.ui.menus.UIElement
;
import
org.jkiss.dbeaver.core.CoreMessages
;
import
org.jkiss.dbeaver.model.edit.DBECommandContext
;
import
org.jkiss.dbeaver.ui.editors.entity.EntityEditor
;
import
org.jkiss.dbeaver.utils.RuntimeUtils
;
...
...
@@ -54,7 +55,7 @@ public class UndoChangesHandler extends AbstractHandler implements IElementUpdat
final
IEditorPart
activeEditor
=
workbenchWindow
.
getActivePage
().
getActiveEditor
();
if
(
activeEditor
instanceof
EntityEditor
)
{
final
DBECommandContext
commandContext
=
((
EntityEditor
)
activeEditor
).
getCommandContext
();
String
text
=
"Undo"
;
String
text
=
CoreMessages
.
toolbar_cmd_undo_name
;
if
(
commandContext
!=
null
&&
commandContext
.
getUndoCommand
()
!=
null
)
{
text
+=
" "
+
commandContext
.
getUndoCommand
().
getTitle
();
}
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/object/struct/CreateProcedurePage.java
浏览文件 @
3914163b
...
...
@@ -54,7 +54,7 @@ public class CreateProcedurePage extends BaseObjectEditPage {
GridData
gd
=
new
GridData
(
GridData
.
FILL_HORIZONTAL
);
propsGroup
.
setLayoutData
(
gd
);
final
Text
containerText
=
UIUtils
.
createLabelText
(
propsGroup
,
"Container"
,
DBUtils
.
getObjectFullName
(
this
.
container
,
DBPEvaluationContext
.
UI
));
final
Text
containerText
=
UIUtils
.
createLabelText
(
propsGroup
,
CoreMessages
.
dialog_struct_create_procedure_container
,
DBUtils
.
getObjectFullName
(
this
.
container
,
DBPEvaluationContext
.
UI
));
containerText
.
setEditable
(
false
);
final
Text
nameText
=
UIUtils
.
createLabelText
(
propsGroup
,
CoreMessages
.
dialog_struct_create_procedure_label_name
,
null
);
nameText
.
addModifyListener
(
e
->
{
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/editors/object/struct/CreateSequencePage.java
浏览文件 @
3914163b
...
...
@@ -51,8 +51,8 @@ public class CreateSequencePage extends BaseObjectEditPage {
GridData
gd
=
new
GridData
(
GridData
.
FILL_HORIZONTAL
);
propsGroup
.
setLayoutData
(
gd
);
UIUtils
.
createLabelText
(
propsGroup
,
"Container"
,
DBUtils
.
getObjectFullName
(
container
,
DBPEvaluationContext
.
UI
)).
setEditable
(
false
);
final
Text
nameText
=
UIUtils
.
createLabelText
(
propsGroup
,
"Sequence Name"
,
null
);
UIUtils
.
createLabelText
(
propsGroup
,
CoreMessages
.
dialog_struct_create_sequence_container
,
DBUtils
.
getObjectFullName
(
container
,
DBPEvaluationContext
.
UI
)).
setEditable
(
false
);
final
Text
nameText
=
UIUtils
.
createLabelText
(
propsGroup
,
CoreMessages
.
dialog_struct_create_sequence_name
,
null
);
nameText
.
addModifyListener
(
new
ModifyListener
()
{
@Override
public
void
modifyText
(
ModifyEvent
e
)
...
...
plugins/org.jkiss.dbeaver.ext.mockdata/plugin.xml
浏览文件 @
3914163b
...
...
@@ -64,9 +64,44 @@
<extension
point=
"org.jkiss.dbeaver.mockGenerator"
>
<generator
id=
"numericConstantGenerator"
label=
"Numeric Constant"
description=
"Constant numeric value"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.ConstantGenerator"
>
<type
kind=
"NUMERIC"
/>
<propertyGroup
label=
"General"
>
<property
id=
"value"
label=
"Value"
type=
"numeric"
defaultValue=
"0"
/>
</propertyGroup>
</generator>
<generator
id=
"numericRandomGenerator"
label=
"Numeric Random"
description=
"Random numeric values"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.NumericRandomGenerator"
>
<type
kind=
"NUMERIC"
/>
</generator>
<generator
id=
"numericSequenceGenerator"
label=
"Numeric Sequence"
description=
"Sequence of numbers with adjustable start, step and order"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.NumericSequenceGenerator"
tags=
"id,number,order"
>
<type
kind=
"NUMERIC"
/>
<propertyGroup
label=
"General"
>
<property
id=
"start"
label=
"Start value"
type=
"long"
defaultValue=
"0"
description=
"Initial sequence value"
/>
<property
id=
"step"
label=
"Increment step"
type=
"long"
defaultValue=
"1"
description=
"Sequence increment step"
/>
<property
id=
"reverse"
label=
"Reverse order"
type=
"boolean"
defaultValue=
"FALSE"
description=
"Reverse the sequence order"
/>
</propertyGroup>
</generator>
<generator
id=
"booleanConstantGenerator"
label=
"Constant"
label=
"
Boolean
Constant"
description=
"Constant boolean value"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.ConstantGenerator"
>
<type
kind=
"BOOLEAN"
/>
...
...
@@ -78,7 +113,7 @@
<generator
id=
"booleanRandomGenerator"
label=
"Random"
label=
"
Boolean
Random"
description=
"Random boolean values"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.BooleanRandomGenerator"
>
<type
kind=
"BOOLEAN"
/>
...
...
@@ -86,7 +121,7 @@
<generator
id=
"booleanSequenceGenerator"
label=
"Sequence"
label=
"
Boolean
Sequence"
description=
"Adjustable sequence of boolean values"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.BooleanSequenceGenerator"
>
<type
kind=
"BOOLEAN"
/>
...
...
@@ -99,7 +134,7 @@
<generator
id=
"dateConstantGenerator"
label=
"Constant"
label=
"
Date
Constant"
description=
"Constant date value"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.ConstantGenerator"
>
<type
kind=
"DATETIME"
/>
...
...
@@ -111,7 +146,7 @@
<generator
id=
"dateRandomGenerator"
label=
"Random"
label=
"
Date
Random"
description=
"Random date values"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.DateRandomGenerator"
>
<type
kind=
"DATETIME"
/>
...
...
@@ -124,7 +159,7 @@
<generator
id=
"dateSequenceGenerator"
label=
"Sequence"
label=
"
Date
Sequence"
description=
"Adjustable sequence of dates"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.DateSequenceGenerator"
>
<type
kind=
"DATETIME"
/>
...
...
@@ -148,44 +183,9 @@
-->
</generator>
<generator
id=
"numericConstantGenerator"
label=
"Constant"
description=
"Constant numeric value"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.ConstantGenerator"
>
<type
kind=
"NUMERIC"
/>
<propertyGroup
label=
"General"
>
<property
id=
"value"
label=
"Value"
type=
"numeric"
defaultValue=
"0"
/>
</propertyGroup>
</generator>
<generator
id=
"numericRandomGenerator"
label=
"Random"
description=
"Random numeric values"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.NumericRandomGenerator"
>
<type
kind=
"NUMERIC"
/>
</generator>
<generator
id=
"numericSequenceGenerator"
label=
"Sequence"
description=
"Sequence of numbers with adjustable start, step and order"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.NumericSequenceGenerator"
tags=
"id,number,order"
>
<type
kind=
"NUMERIC"
/>
<propertyGroup
label=
"General"
>
<property
id=
"start"
label=
"Start value"
type=
"long"
defaultValue=
"0"
description=
"Initial sequence value"
/>
<property
id=
"step"
label=
"Increment step"
type=
"long"
defaultValue=
"1"
description=
"Sequence increment step"
/>
<property
id=
"reverse"
label=
"Reverse order"
type=
"boolean"
defaultValue=
"FALSE"
description=
"Reverse the sequence order"
/>
</propertyGroup>
</generator>
<generator
id=
"stringConstantGenerator"
label=
"Constant"
label=
"
String
Constant"
description=
"Constant string"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.ConstantGenerator"
>
<type
kind=
"STRING"
/>
...
...
@@ -216,7 +216,7 @@
label=
"UUID"
description=
"UUID random values"
class=
"org.jkiss.dbeaver.ext.mockdata.generator.StringUuidGenerator"
tags=
"uuid"
>
tags=
"
id,
uuid"
>
<type
kind=
"STRING"
/>
</generator>
...
...
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/MockDataExecuteWizard.java
浏览文件 @
3914163b
...
...
@@ -34,10 +34,7 @@ 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.sql.SQLUtils
;
import
org.jkiss.dbeaver.model.struct.DBSAttributeBase
;
import
org.jkiss.dbeaver.model.struct.DBSDataManipulator
;
import
org.jkiss.dbeaver.model.struct.DBSEntity
;
import
org.jkiss.dbeaver.model.struct.DBSEntityAttribute
;
import
org.jkiss.dbeaver.model.struct.*
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.dialogs.tools.AbstractToolWizard
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -239,6 +236,21 @@ public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulato
monitor
.
beginTask
(
"Insert data"
,
(
int
)
rowsNumber
);
boolean
hasMiltiUniqs
=
false
;
Set
<
String
>
miltiUniqColumns
=
new
HashSet
<>();
for
(
DBSAttributeBase
attribute
:
attributes
)
{
if
(
DBUtils
.
checkUnique
(
monitor
,
dbsEntity
,
attribute
)
==
DBUtils
.
UNIQ_TYPE
.
MULTI
)
{
hasMiltiUniqs
=
true
;
// collect the columns from multi-uniqs
DBSEntityReferrer
constraint
=
(
DBSEntityReferrer
)
DBUtils
.
getConstraint
(
monitor
,
dbsEntity
,
attribute
);
for
(
DBSEntityAttributeRef
attributeRef
:
constraint
.
getAttributeReferences
(
monitor
))
{
miltiUniqColumns
.
add
(
attributeRef
.
getAttribute
().
getName
());
}
}
}
List
<
List
<
DBDAttributeValue
>>
valuesCacheForUniqs
=
new
ArrayList
<>();
// generate and insert the data
session
.
enableLogging
(
false
);
DBSDataManipulator
.
ExecuteBatch
batch
=
null
;
...
...
@@ -275,6 +287,31 @@ public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulato
return
true
;
}
// skip duplicate records for uniqs
if
(
hasMiltiUniqs
)
{
boolean
collision
=
false
;
for
(
List
<
DBDAttributeValue
>
valueList
:
valuesCacheForUniqs
)
{
boolean
theSame
=
true
;
for
(
int
j
=
0
;
j
<
valueList
.
size
();
j
++)
{
if
(
miltiUniqColumns
.
contains
(
valueList
.
get
(
j
).
getAttribute
().
getName
()))
{
if
(!
CommonUtils
.
equalObjects
(
valueList
.
get
(
j
),
attributeValues
.
get
(
j
)))
{
theSame
=
false
;
break
;
}
}
}
if
(
theSame
)
{
collision
=
true
;
break
;
}
}
if
(
collision
)
{
continue
;
}
else
{
valuesCacheForUniqs
.
add
(
attributeValues
);
}
}
if
(
batch
==
null
)
{
batch
=
dataManipulator
.
insertData
(
session
,
...
...
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/MockDataSettings.java
浏览文件 @
3914163b
...
...
@@ -33,8 +33,6 @@ import java.util.*;
public
class
MockDataSettings
{
public
static
final
String
FK_GENERATOR_ID
=
"fkGenerator"
;
//$NON-NLS-1$
public
static
final
String
PROP_REMOVE_OLD_DATA
=
"removeOldData"
;
//$NON-NLS-1$
public
static
final
String
PROP_ROWS_NUMBER
=
"rowsNumber"
;
//$NON-NLS-1$
...
...
@@ -73,7 +71,7 @@ public class MockDataSettings {
//((JDBCColumnKeyType) attribute).isInUniqueKey()
List
<
DBSEntityReferrer
>
attributeReferrers
=
DBUtils
.
getAttributeReferrers
(
monitor
,
(
DBSEntityAttribute
)
attribute
);
if
(!
CommonUtils
.
isEmpty
(
attributeReferrers
))
{
MockGeneratorDescriptor
generator
=
generatorRegistry
.
getGenerator
(
FK_GENERATOR_ID
);
MockGeneratorDescriptor
generator
=
generatorRegistry
.
getGenerator
(
MockGeneratorRegistry
.
FK_GENERATOR_ID
);
putGenerator
(
generatorProperties
,
generator
);
}
else
{
List
<
MockGeneratorDescriptor
>
generators
=
generatorRegistry
.
findAllGenerators
(
dataManipulator
.
getDataSource
(),
attribute
);
...
...
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/MockDataWizardPageSettings.java
浏览文件 @
3914163b
...
...
@@ -186,7 +186,7 @@ public class MockDataWizardPageSettings extends ActiveWizardPage<MockDataExecute
cell
.
setImage
(
DBeaverIcons
.
getImage
(
DBValueFormatting
.
getTypeImage
(
attribute
)));
cell
.
setText
(
attribute
.
getName
());
try
{
if
(
DBUtils
.
checkUnique
(
mockDataSettings
.
getMonitor
(),
mockDataSettings
.
getEntity
(),
attribute
))
{
if
(
DBUtils
.
checkUnique
(
mockDataSettings
.
getMonitor
(),
mockDataSettings
.
getEntity
(),
attribute
)
!=
null
)
{
cell
.
setFont
(
boldFont
);
}
}
catch
(
DBException
e
)
{
...
...
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/generator/AbstractMockValueGenerator.java
浏览文件 @
3914163b
...
...
@@ -81,7 +81,7 @@ public abstract class AbstractMockValueGenerator implements MockValueGenerator {
public
Object
generateValue
(
DBRProgressMonitor
monitor
)
throws
DBException
,
IOException
{
if
(
isFirstRun
)
{
isFirstRun
=
false
;
isUnique
=
DBUtils
.
checkUnique
(
monitor
,
dbsEntity
,
attribute
);
isUnique
=
(
DBUtils
.
checkUnique
(
monitor
,
dbsEntity
,
attribute
)
==
DBUtils
.
UNIQ_TYPE
.
SINGLE
);
if
(
isUnique
&&
(
attribute
instanceof
DBSAttributeEnumerable
))
{
uniqueValues
=
new
HashSet
<>();
Collection
<
DBDLabelValuePair
>
valuePairs
=
readColumnValues
(
monitor
,
dbsEntity
.
getDataSource
(),
(
DBSAttributeEnumerable
)
attribute
,
UNIQUE_VALUES_SET_SIZE
);
...
...
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/generator/FKGenerator.java
浏览文件 @
3914163b
...
...
@@ -72,7 +72,7 @@ public class FKGenerator extends AbstractMockValueGenerator
throw
new
DBException
(
"Can't find reference column for '"
+
attribute
.
getName
()
+
"'"
);
}
int
numberRefRecords
=
DBUtils
.
checkUnique
(
monitor
,
dbsEntity
,
attribute
)
?
UNIQ_REF_RECORDS_LIMIT
:
REF_RECORDS_LIMIT
;
int
numberRefRecords
=
(
DBUtils
.
checkUnique
(
monitor
,
dbsEntity
,
attribute
)
==
DBUtils
.
UNIQ_TYPE
.
SINGLE
)
?
UNIQ_REF_RECORDS_LIMIT
:
REF_RECORDS_LIMIT
;
Collection
<
DBDLabelValuePair
>
values
=
readColumnValues
(
monitor
,
fk
.
getDataSource
(),
(
DBSAttributeEnumerable
)
column
.
getReferencedColumn
(),
numberRefRecords
);
for
(
DBDLabelValuePair
value
:
values
)
{
refValues
.
add
(
value
.
getValue
());
...
...
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/model/MockGeneratorDescriptor.java
浏览文件 @
3914163b
...
...
@@ -23,6 +23,7 @@ import org.jkiss.dbeaver.model.DBPDataKind;
import
org.jkiss.dbeaver.model.DBPImage
;
import
org.jkiss.dbeaver.model.impl.PropertyDescriptor
;
import
org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.registry.RegistryConstants
;
import
org.jkiss.dbeaver.registry.datatype.DataTypeAbstractDescriptor
;
import
org.jkiss.utils.CommonUtils
;
...
...
@@ -177,6 +178,12 @@ public class MockGeneratorDescriptor extends DataTypeAbstractDescriptor<MockValu
return
null
;
}
@Override
public
boolean
supportsType
(
DBSTypedObject
typedObject
)
{
return
(
typedObject
.
getDataKind
()
==
DBPDataKind
.
STRING
)
||
super
.
supportsType
(
typedObject
);
}
@NotNull
public
MockValueGenerator
createGenerator
()
{
return
createInstance
();
...
...
plugins/org.jkiss.dbeaver.ext.mockdata/src/org/jkiss/dbeaver/ext/mockdata/model/MockGeneratorRegistry.java
浏览文件 @
3914163b
...
...
@@ -32,6 +32,8 @@ public class MockGeneratorRegistry
{
static
final
String
TAG_GENERATOR
=
"generator"
;
//$NON-NLS-1$
public
static
final
String
FK_GENERATOR_ID
=
"fkGenerator"
;
//$NON-NLS-1$
private
static
final
Log
log
=
Log
.
getLog
(
MockGeneratorRegistry
.
class
);
private
static
MockGeneratorRegistry
instance
=
null
;
...
...
@@ -94,6 +96,9 @@ public class MockGeneratorRegistry
List
<
MockGeneratorDescriptor
>
result
=
new
ArrayList
<>();
for
(
MockGeneratorDescriptor
descriptor
:
generators
)
{
if
(
FK_GENERATOR_ID
.
equalsIgnoreCase
(
descriptor
.
getId
()))
{
continue
;
}
if
(((!
descriptor
.
isGlobal
()
&&
descriptor
.
supportsDataSource
(
dataSource
)
&&
descriptor
.
supportsType
(
typedObject
))
||
(
descriptor
.
isGlobal
()
&&
descriptor
.
supportsType
(
typedObject
))))
...
...
plugins/org.jkiss.dbeaver.ext.postgresql/src/org/jkiss/dbeaver/ext/postgresql/model/PostgreSequence.java
浏览文件 @
3914163b
...
...
@@ -38,6 +38,7 @@ import org.jkiss.dbeaver.model.sql.SQLUtils;
import
org.jkiss.dbeaver.model.struct.DBSEntityType
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSSequence
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSTableIndex
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.ArrayList
;
import
java.util.Collection
;
...
...
@@ -214,6 +215,11 @@ public class PostgreSequence extends PostgreTableBase implements DBSSequence, DB
sql
.
append
(
"\n\tSTART "
).
append
(
info
.
getLastValue
());
}
if
(!
CommonUtils
.
isEmpty
(
getDescription
()))
{
sql
.
append
(
"\nCOMMENT ON SEQUENCE "
).
append
(
DBUtils
.
getQuotedIdentifier
(
this
)).
append
(
" IS "
)
.
append
(
SQLUtils
.
quoteString
(
this
,
getDescription
())).
append
(
";"
);
}
List
<
DBEPersistAction
>
actions
=
new
ArrayList
<>();
PostgreUtils
.
getObjectGrantPermissionActions
(
monitor
,
this
,
actions
,
options
);
if
(!
actions
.
isEmpty
())
{
...
...
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/DBUtils.java
浏览文件 @
3914163b
...
...
@@ -1554,16 +1554,35 @@ public final class DBUtils {
return
true
;
}
public
static
boolean
checkUnique
(
DBRProgressMonitor
monitor
,
DBSEntity
dbsEntity
,
DBSAttributeBase
attribute
)
throws
DBException
{
public
enum
UNIQ_TYPE
{
SINGLE
,
MULTI
}
public
static
UNIQ_TYPE
checkUnique
(
DBRProgressMonitor
monitor
,
DBSEntity
dbsEntity
,
DBSAttributeBase
attribute
)
throws
DBException
{
for
(
DBSEntityConstraint
constraint
:
dbsEntity
.
getConstraints
(
monitor
))
{
DBSEntityConstraintType
constraintType
=
constraint
.
getConstraintType
();
if
(
constraintType
.
isUnique
())
{
DBSEntityAttributeRef
constraintAttribute
=
getConstraintAttribute
(
monitor
,
((
DBSEntityReferrer
)
constraint
),
attribute
.
getName
());
if
(
constraintAttribute
!=
null
&&
constraintAttribute
.
getAttribute
()
==
attribute
)
{
return
true
;
List
<?
extends
DBSEntityAttributeRef
>
refColumns
=
((
DBSEntityReferrer
)
constraint
).
getAttributeReferences
(
monitor
);
if
(
refColumns
.
size
()
>
1
)
{
return
UNIQ_TYPE
.
MULTI
;
}
else
{
return
UNIQ_TYPE
.
SINGLE
;
}
}
}
}
return
false
;
return
null
;
}
public
static
DBSEntityConstraint
getConstraint
(
DBRProgressMonitor
monitor
,
DBSEntity
dbsEntity
,
DBSAttributeBase
attribute
)
throws
DBException
{
for
(
DBSEntityConstraint
constraint
:
dbsEntity
.
getConstraints
(
monitor
))
{
DBSEntityAttributeRef
constraintAttribute
=
getConstraintAttribute
(
monitor
,
((
DBSEntityReferrer
)
constraint
),
attribute
.
getName
());
if
(
constraintAttribute
!=
null
&&
constraintAttribute
.
getAttribute
()
==
attribute
)
{
return
constraint
;
}
}
return
null
;
}
}
plugins/org.jkiss.dbeaver.model/src/org/jkiss/dbeaver/model/data/DBDAttributeValue.java
浏览文件 @
3914163b
...
...
@@ -19,6 +19,7 @@ package org.jkiss.dbeaver.model.data;
import
org.jkiss.code.NotNull
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.model.struct.DBSAttributeBase
;
import
org.jkiss.utils.CommonUtils
;
import
java.util.List
;
...
...
@@ -71,4 +72,17 @@ public class DBDAttributeValue {
return
values
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
==
null
||
!(
obj
instanceof
DBDAttributeValue
))
{
return
false
;
}
if
(!
CommonUtils
.
equalObjects
(
value
,
((
DBDAttributeValue
)
obj
).
value
))
{
return
false
;
}
if
(!
CommonUtils
.
equalObjects
(
attribute
.
getName
(),
((
DBDAttributeValue
)
obj
).
attribute
.
getName
()))
{
return
false
;
}
return
true
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录