Imrpovements over the Entity Generator

This commit is contained in:
Daniele Teti 2023-10-03 11:11:01 +02:00
parent ec9140f2a7
commit 9356cca93d
4 changed files with 286 additions and 359 deletions

View File

@ -511,6 +511,64 @@ type
property f_blob: TStream read ff_blob write ff_blob;
end;
[MVCNameCase(ncLowerCase)]
[MVCTable('default_values_test')]
TDefaultValuesTest = class(TCustomEntity)
private
[MVCTableField('f_int2', [foPrimaryKey])]
ff_int2: NullableInt16;
[MVCTableField('f_int4')]
ff_int4: NullableInt32;
[MVCTableField('f_int8')]
ff_int8: NullableInt64;
[MVCTableField('f_date')]
ff_date: NullableTDate;
[MVCTableField('f_time')]
ff_time: NullableTTime;
[MVCTableField('f_bool')]
ff_bool: NullableBoolean;
[MVCTableField('f_datetime')]
ff_datetime: NullableTDateTime;
[MVCTableField('f_float4')]
ff_float4: NullableSingle;
[MVCTableField('f_float8')]
ff_float8: NullableDouble;
[MVCTableField('f_string')]
ff_string: NullableString;
[MVCTableField('f_currency')]
ff_currency: NullableCurrency;
[MVCTableField('f_blob')]
ff_blob: TStream;
public
constructor Create; override;
destructor Destroy; override;
// f_int2 int2 NULL,
property f_int2: NullableInt16 read ff_int2 write ff_int2;
// f_int4 int4 NULL,
property f_int4: NullableInt32 read ff_int4 write ff_int4;
// f_int8 int8 NULL,
property f_int8: NullableInt64 read ff_int8 write ff_int8;
// f_string varchar NULL,
property f_string: NullableString read ff_string write ff_string;
// f_bool bool NULL,
property f_bool: NullableBoolean read ff_bool write ff_bool;
// f_date date NULL,
property f_date: NullableTDate read ff_date write ff_date;
// f_time time NULL,
property f_time: NullableTTime read ff_time write ff_time;
// f_datetime timestamp NULL,
property f_datetime: NullableTDateTime read ff_datetime write ff_datetime;
// f_float4 float4 NULL,
property f_float4: NullableSingle read ff_float4 write ff_float4;
// f_float8 float8 NULL,
property f_float8: NullableDouble read ff_float8 write ff_float8;
// f_currency numeric(18,4) NULL
property f_currency: NullableCurrency read ff_currency write ff_currency;
// f_blob bytea NULL
property f_blob: TStream read ff_blob write ff_blob;
end;
[MVCNameCase(ncLowerCase)]
[MVCTable('complex_types')]
TComplexTypes = class(TCustomEntity)
@ -821,4 +879,18 @@ begin
FID := Value;
end;
{ TDefaultValuesTest }
constructor TDefaultValuesTest.Create;
begin
inherited Create;
ff_blob := TMemoryStream.Create;
end;
destructor TDefaultValuesTest.Destroy;
begin
ff_blob.Free;
inherited;
end;
end.

View File

@ -1301,7 +1301,6 @@ begin
lValue := StrToInt(GetPartitionInfo.FieldValues[I])
else
lValue := GetPartitionInfo.FieldValues[I];
// lPar.DataTypeName := fPartitionInfo.FieldValues[I];
MapTValueToParam(lValue, lPar);
end
end;

View File

@ -2,99 +2,73 @@ object MainForm: TMainForm
Left = 0
Top = 0
Caption = '[DMVCFramework] MVCActiveRecord Entity Generator'
ClientHeight = 1720
ClientWidth = 2989
ClientHeight = 687
ClientWidth = 1192
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -40
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
Menu = MainMenu1
OnClose = FormClose
OnCreate = FormCreate
PixelsPerInch = 240
TextHeight = 54
TextHeight = 21
object Splitter1: TSplitter
Left = 0
Top = 1358
Width = 2989
Height = 7
Top = 542
Width = 1192
Height = 3
Cursor = crVSplit
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Align = alBottom
ExplicitWidth = 2983
ExplicitTop = 543
ExplicitWidth = 1196
end
object pcMain: TPageControl
Left = 0
Top = 0
Width = 2989
Height = 1358
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Width = 1192
Height = 542
ActivePage = tsTablesMapping
Align = alClient
TabOrder = 0
ExplicitWidth = 2969
ExplicitHeight = 1356
object tsConnectionDefinition: TTabSheet
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Caption = 'Connection Definition'
ImageIndex = 1
object Panel2: TPanel
Left = 0
Top = 223
Width = 2969
Height = 1048
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Top = 89
Width = 1184
Height = 417
Align = alClient
Caption = 'Panel1'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -28
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
TabOrder = 0
object Label2: TLabel
AlignWithMargins = True
Left = 9
Top = 9
Width = 2951
Height = 34
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 4
Top = 4
Width = 1176
Height = 13
Align = alTop
Caption = 'FireDAC connection parameters'
ExplicitWidth = 392
ExplicitWidth = 152
end
object mmConnectionParams: TMemo
AlignWithMargins = True
Left = 9
Top = 59
Width = 1956
Height = 980
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 4
Top = 23
Width = 778
Height = 390
Align = alClient
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -33
Font.Height = -13
Font.Name = 'Consolas'
Font.Style = []
ParentFont = False
@ -104,14 +78,10 @@ object MainForm: TMainForm
OnChange = mmConnectionParamsChange
end
object Panel6: TPanel
Left = 1973
Top = 51
Width = 995
Height = 996
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 785
Top = 20
Width = 398
Height = 396
Align = alRight
BevelOuter = bvNone
Caption = 'Panel6'
@ -119,33 +89,25 @@ object MainForm: TMainForm
TabOrder = 1
object GroupBox1: TGroupBox
AlignWithMargins = True
Left = 8
Top = 8
Width = 979
Height = 980
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 3
Top = 3
Width = 392
Height = 390
Align = alClient
Caption = 'Filter by Schema'
Padding.Left = 13
Padding.Top = 13
Padding.Right = 13
Padding.Bottom = 13
Padding.Left = 5
Padding.Top = 5
Padding.Right = 5
Padding.Bottom = 5
TabOrder = 0
object lstSchema: TListBox
AlignWithMargins = True
Left = 23
Top = 57
Width = 933
Height = 900
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 10
Top = 23
Width = 372
Height = 357
Align = alClient
ItemHeight = 34
ItemHeight = 13
TabOrder = 0
end
end
@ -154,37 +116,33 @@ object MainForm: TMainForm
object Panel1: TPanel
Left = 0
Top = 0
Width = 2969
Height = 223
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Width = 1184
Height = 89
Align = alTop
TabOrder = 1
object Label1: TLabel
AlignWithMargins = True
Left = 48
Top = 30
Width = 706
Height = 54
Margins.Left = 25
Margins.Top = 25
Margins.Right = 25
Margins.Bottom = 25
Left = 19
Top = 12
Width = 276
Height = 21
Margins.Left = 10
Margins.Top = 10
Margins.Right = 10
Margins.Bottom = 10
Caption = 'Select a FireDAC Connection Definitions'
Layout = tlCenter
end
object Label3: TLabel
AlignWithMargins = True
Left = 1512
Top = 26
Width = 1431
Height = 171
Margins.Left = 25
Margins.Top = 25
Margins.Right = 25
Margins.Bottom = 25
Left = 620
Top = 11
Width = 553
Height = 67
Margins.Left = 10
Margins.Top = 10
Margins.Right = 10
Margins.Bottom = 10
Align = alRight
Caption =
'Please, select the FireDAC connection definition from the combo ' +
@ -193,18 +151,16 @@ object MainForm: TMainForm
'generated from that set of tables.'
Layout = tlCenter
WordWrap = True
ExplicitHeight = 162
ExplicitLeft = 605
ExplicitTop = 10
ExplicitHeight = 63
end
object cboConnectionDefs: TComboBox
AlignWithMargins = True
Left = 48
Top = 115
Width = 690
Height = 62
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 19
Top = 46
Width = 276
Height = 29
Style = csDropDownList
TabOrder = 0
OnChange = cboConnectionDefsChange
@ -212,70 +168,47 @@ object MainForm: TMainForm
end
end
object tsTablesMapping: TTabSheet
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Caption = 'Tables Mapping'
ImageIndex = 2
object Panel3: TPanel
Left = 0
Top = 0
Width = 2969
Height = 1271
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Width = 1184
Height = 506
Align = alClient
Caption = 'Panel3'
ShowCaption = False
TabOrder = 0
ExplicitWidth = 2949
ExplicitHeight = 1269
object Panel4: TPanel
Left = 1
Top = 1
Width = 2967
Height = 377
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Width = 1182
Height = 151
Align = alTop
BevelOuter = bvNone
Caption = 'Panel4'
ShowCaption = False
TabOrder = 0
ExplicitWidth = 2947
DesignSize = (
2967
377)
1182
151)
object btnGenEntities: TButton
AlignWithMargins = True
Left = 3059
Top = -1
Width = 403
Height = 88
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 1214
Top = 0
Width = 161
Height = 35
Anchors = [akRight, akBottom]
Caption = 'Generate Entities'
TabOrder = 0
ExplicitLeft = 3039
end
object chkGenerateMapping: TCheckBox
AlignWithMargins = True
Left = 25
Top = 289
Width = 2934
Height = 80
Margins.Left = 25
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 10
Top = 116
Width = 1169
Height = 32
Margins.Left = 10
Align = alBottom
Caption =
'Register entities in ActiveRecordMappingRegistry (needed by TMVC' +
@ -284,17 +217,12 @@ object MainForm: TMainForm
State = cbChecked
TabOrder = 1
WordWrap = True
ExplicitWidth = 2914
end
object rgNameCase: TRadioGroup
Left = 18
Top = 23
Width = 982
Height = 260
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 7
Top = 9
Width = 393
Height = 104
Caption = 'Class MVCNameCase'
Columns = 3
ItemIndex = 0
@ -308,14 +236,10 @@ object MainForm: TMainForm
TabOrder = 2
end
object rgFieldNameFormatting: TRadioGroup
Left = 1015
Top = 23
Width = 973
Height = 260
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 406
Top = 9
Width = 389
Height = 104
Caption = 'Field Names Formatting'
ItemIndex = 1
Items.Strings = (
@ -324,25 +248,17 @@ object MainForm: TMainForm
TabOrder = 3
end
object gbOptions: TGroupBox
Left = 2004
Top = 23
Width = 837
Height = 263
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 802
Top = 9
Width = 334
Height = 105
Caption = 'Other Options'
TabOrder = 4
object chkClassAsAbstract: TCheckBox
Left = 40
Top = 80
Width = 581
Height = 43
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 16
Top = 32
Width = 232
Height = 17
Caption = 'Declare classes as abstract'
TabOrder = 0
end
@ -350,41 +266,27 @@ object MainForm: TMainForm
end
object PageControl1: TPageControl
AlignWithMargins = True
Left = 9
Top = 514
Width = 2951
Height = 748
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 4
Top = 206
Width = 1176
Height = 296
ActivePage = TabSheet1
Align = alClient
TabOrder = 1
ExplicitWidth = 2931
ExplicitHeight = 746
object TabSheet1: TTabSheet
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Caption = 'Tables'
object DBGrid1: TDBGrid
Left = 0
Top = 0
Width = 2931
Height = 558
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Width = 1168
Height = 219
Align = alClient
DataSource = dsrcTablesMapping
DefaultDrawing = False
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -40
TitleFont.Height = -16
TitleFont.Name = 'Segoe UI'
TitleFont.Style = []
OnCellClick = DBGrid1CellClick
@ -398,57 +300,42 @@ object MainForm: TMainForm
'yes'
'no')
ReadOnly = True
Width = 215
Width = 86
Visible = True
end
item
Expanded = False
FieldName = 'TABLE_NAME'
ReadOnly = True
Width = 1195
Width = 478
Visible = True
end
item
Expanded = False
FieldName = 'CLASS_NAME'
Width = 1360
Visible = True
end>
end
object Panel7: TPanel
Left = 0
Top = 558
Width = 2931
Height = 103
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Top = 219
Width = 1168
Height = 41
Align = alBottom
BevelOuter = bvNone
TabOrder = 1
ExplicitTop = 556
ExplicitWidth = 2911
object Label4: TLabel
Left = 8
Top = 23
Width = 359
Height = 54
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 3
Top = 9
Width = 140
Height = 21
Caption = 'Filter for table name'
end
object EditTableNameFilter: TEdit
Left = 373
Top = 15
Width = 690
Height = 62
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 149
Top = 6
Width = 276
Height = 29
TabOrder = 0
OnChange = EditTableNameFilterChange
end
@ -457,69 +344,64 @@ object MainForm: TMainForm
end
object Panel10: TPanel
Left = 1
Top = 378
Width = 2967
Height = 128
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Top = 152
Width = 1182
Height = 51
Align = alTop
Caption = 'Panel10'
ShowCaption = False
TabOrder = 2
ExplicitWidth = 2947
object SpeedButton1: TSpeedButton
AlignWithMargins = True
Left = 450
Top = 20
Width = 405
Height = 90
Margins.Left = 13
Margins.Top = 13
Margins.Right = 13
Margins.Bottom = 13
Left = 180
Top = 8
Width = 162
Height = 36
Margins.Left = 5
Margins.Top = 5
Margins.Right = 5
Margins.Bottom = 5
Caption = 'Select All'
OnClick = SpeedButton1Click
end
object SpeedButton2: TSpeedButton
AlignWithMargins = True
Left = 880
Top = 20
Width = 408
Height = 90
Margins.Left = 13
Margins.Top = 13
Margins.Right = 13
Margins.Bottom = 13
Left = 352
Top = 8
Width = 163
Height = 36
Margins.Left = 5
Margins.Top = 5
Margins.Right = 5
Margins.Bottom = 5
Caption = 'Select None'
OnClick = SpeedButton2Click
end
object SpeedButton3: TSpeedButton
AlignWithMargins = True
Left = 1313
Top = 20
Width = 405
Height = 90
Margins.Left = 13
Margins.Top = 13
Margins.Right = 13
Margins.Bottom = 13
Left = 525
Top = 8
Width = 162
Height = 36
Margins.Left = 5
Margins.Top = 5
Margins.Right = 5
Margins.Bottom = 5
Caption = 'Invert Selection'
OnClick = SpeedButton3Click
end
object btnGetTables: TButton
AlignWithMargins = True
Left = 18
Top = 20
Width = 407
Height = 90
Margins.Left = 13
Margins.Top = 13
Margins.Right = 13
Margins.Bottom = 13
Left = 7
Top = 8
Width = 163
Height = 36
Margins.Left = 5
Margins.Top = 5
Margins.Right = 5
Margins.Bottom = 5
Action = actRefreshTableList
Constraints.MinWidth = 400
Constraints.MinWidth = 160
TabOrder = 0
end
end
@ -528,58 +410,39 @@ object MainForm: TMainForm
end
object Panel8: TPanel
Left = 0
Top = 1583
Width = 2989
Height = 137
Margins.Left = 8
Margins.Top = 8
Margins.Right = 15
Margins.Bottom = 8
Top = 632
Width = 1192
Height = 55
Margins.Right = 6
Align = alBottom
BevelOuter = bvNone
TabOrder = 1
ExplicitTop = 1581
ExplicitWidth = 2969
object btnPrev: TButton
AlignWithMargins = True
Left = 2445
Top = 8
Width = 260
Height = 121
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 975
Top = 3
Width = 104
Height = 49
Action = TabPreviousTab1
Align = alRight
TabOrder = 0
ExplicitLeft = 2425
end
object btnNext: TButton
AlignWithMargins = True
Left = 2721
Top = 8
Width = 260
Height = 121
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 1085
Top = 3
Width = 104
Height = 49
Action = TabNextTab1
Align = alRight
TabOrder = 1
ExplicitLeft = 2701
end
object Panel5: TPanel
AlignWithMargins = True
Left = 8
Top = 8
Width = 2235
Height = 121
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 3
Top = 3
Width = 894
Height = 49
Align = alLeft
BevelKind = bkTile
BevelOuter = bvNone
@ -587,48 +450,32 @@ object MainForm: TMainForm
ShowCaption = False
TabOrder = 2
object Label6: TLabel
Left = 18
Top = 28
Width = 325
Height = 54
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 7
Top = 11
Width = 126
Height = 21
Caption = 'Output File Name:'
end
object btnSaveAs: TSpeedButton
Left = 1635
Top = 10
Width = 138
Height = 93
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 654
Top = 4
Width = 55
Height = 37
Action = actSaveGeneratedCode
end
object EditOutputFileName: TEdit
Left = 348
Top = 20
Width = 1272
Height = 62
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 139
Top = 8
Width = 509
Height = 29
TabOrder = 0
end
object Button6: TButton
AlignWithMargins = True
Left = 1788
Top = 10
Width = 397
Height = 93
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Left = 715
Top = 4
Width = 159
Height = 37
Action = actGenerateCode
Images = ImageListButtons
TabOrder = 1
@ -637,41 +484,30 @@ object MainForm: TMainForm
end
object Panel12: TPanel
Left = 0
Top = 1365
Width = 2989
Height = 218
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Top = 545
Width = 1192
Height = 87
Align = alBottom
BevelOuter = bvNone
Caption = 'Panel12'
TabOrder = 2
ExplicitTop = 1363
ExplicitWidth = 2969
object lbLog: TListBox
Left = 0
Top = 0
Width = 2989
Height = 218
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
Width = 1192
Height = 87
Align = alClient
BevelInner = bvNone
BevelOuter = bvNone
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -40
Font.Height = -16
Font.Name = 'Consolas'
Font.Style = []
ItemHeight = 47
ItemHeight = 19
ParentFont = False
ScrollWidth = 5000
TabOrder = 0
ExplicitWidth = 2969
end
end
object FDConnection: TFDConnection
@ -1174,4 +1010,16 @@ object MainForm: TMainForm
Left = 96
Top = 176
end
object FDMoniFlatFileClientLink1: TFDMoniFlatFileClientLink
Left = 1088
Top = 56
end
object FDMoniCustomClientLink1: TFDMoniCustomClientLink
Left = 1096
Top = 64
end
object FDMoniRemoteClientLink1: TFDMoniRemoteClientLink
Left = 1104
Top = 72
end
end

View File

@ -54,7 +54,8 @@ uses
Vcl.ExtActns, System.ImageList, Vcl.ImgList,
LoggerPro.FileAppender,
LoggerPro.VCLListBoxAppender,
LoggerPro;
LoggerPro, FireDAC.Moni.RemoteClient, FireDAC.Moni.Custom, FireDAC.Moni.Base,
FireDAC.Moni.FlatFile;
type
TSelectionType = (stAll, stNone, stInverse);
@ -149,6 +150,9 @@ type
Button6: TButton;
gbOptions: TGroupBox;
chkClassAsAbstract: TCheckBox;
FDMoniFlatFileClientLink1: TFDMoniFlatFileClientLink;
FDMoniCustomClientLink1: TFDMoniCustomClientLink;
FDMoniRemoteClientLink1: TFDMoniRemoteClientLink;
procedure cboConnectionDefsChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
@ -1177,6 +1181,10 @@ begin
if pcMain.ActivePage = tsTablesMapping then
begin
actRefreshTableList.Execute;
if EditOutputFileName.Text = '' then
begin
EditOutputFileName.Text := TPath.Combine(TPath.GetDocumentsPath, 'EntitiesU.pas');
end;
end;
end;