From 170ce3228707198ef15d10397a90a021f3c7e06c Mon Sep 17 00:00:00 2001 From: VVTsyk Date: Fri, 6 Dec 2024 10:47:42 +0100 Subject: [PATCH 1/4] fluent mapping --- .../BusinessRole.cs | 2 + .../Permission.cs | 1 + .../PermissionRestriction.cs | 2 + .../Principal.cs | 2 + .../SecurityContextType.cs | 2 + ...horization.Generated.DAL.NHibernate.csproj | 4 - .../Mapping/Base/AuthBaseMap.cs | 23 ++ .../Mapping/BusinessRoleMap.cs | 14 + ...ted.Framework.Authorization.Domain.hbm.xml | 80 ------ .../Mapping/PermissionMap.cs | 25 ++ .../Mapping/PermissionRestrictionMap.cs | 17 ++ .../Mapping/PrincipalMap.cs | 14 + .../Mapping/SecurityContextTypeMap.cs | 9 + .../ServerGenerators.DB.cs | 25 ++ .../CodeFirstSubscription.cs | 1 + .../ControlSettings/ControlSettings.cs | 1 + .../ControlSettings/ControlSettingsParam.cs | 1 + .../ControlSettingsParamValue.cs | 1 + .../DomainObjectQueue/DomainObjectEvent.cs | 1 + .../DomainObjectModification.cs | 1 + .../DomainObjectNotification.cs | 1 + .../ExceptionMessage.cs | 1 + .../Lock/GenericNamedLock.cs | 1 + .../SentMessage.cs | 1 + .../Sequence.cs | 1 + .../SystemConstant.cs | 1 + .../TargetSystem/TargetSystem.cs | 1 + .../TargetSystem/Type/DomainType.cs | 1 + .../Type/DomainTypeEventOperation.cs | 1 + ...figuration.Generated.DAL.NHibernate.csproj | 3 - .../Mapping/Base/ConfigurationBaseMap.cs | 24 ++ .../Mapping/CodeFirstSubscriptionMap.cs | 10 + .../Mapping/ControlSettingsMap.cs | 17 ++ .../Mapping/ControlSettingsParamMap.cs | 14 + .../Mapping/ControlSettingsParamValueMap.cs | 15 ++ .../Mapping/DomainObjectEventMap.cs | 21 ++ .../Mapping/DomainObjectModificationMap.cs | 24 ++ .../Mapping/DomainObjectNotificationMap.cs | 16 ++ .../Mapping/DomainTypeEventOperationMap.cs | 17 ++ .../Mapping/DomainTypeMap.cs | 19 ++ .../Mapping/ExceptionMessageMap.cs | 17 ++ ...ted.Framework.Configuration.Domain.hbm.xml | 241 ------------------ .../Mapping/GenericNamedLockMap.cs | 9 + .../Mapping/SentMessageMap.cs | 21 ++ .../Mapping/SequenceMap.cs | 13 + .../Mapping/SystemConstantMap.cs | 16 ++ .../Mapping/TargetSystemMap.cs | 17 ++ .../DbGeneratorTest.cs | 169 ++++++------ 48 files changed, 514 insertions(+), 404 deletions(-) create mode 100644 src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Base/AuthBaseMap.cs create mode 100644 src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/BusinessRoleMap.cs delete mode 100644 src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Generated.Framework.Authorization.Domain.hbm.xml create mode 100644 src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/PermissionMap.cs create mode 100644 src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/PermissionRestrictionMap.cs create mode 100644 src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/PrincipalMap.cs create mode 100644 src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/SecurityContextTypeMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Base/ConfigurationBaseMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/CodeFirstSubscriptionMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ControlSettingsMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ControlSettingsParamMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ControlSettingsParamValueMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainObjectEventMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainObjectModificationMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainObjectNotificationMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainTypeEventOperationMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainTypeMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ExceptionMessageMap.cs delete mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Generated.Framework.Configuration.Domain.hbm.xml create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/GenericNamedLockMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/SentMessageMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/SequenceMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/SystemConstantMap.cs create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/TargetSystemMap.cs diff --git a/src/_Authorization/Framework.Authorization.Domain/BusinessRole.cs b/src/_Authorization/Framework.Authorization.Domain/BusinessRole.cs index fabff520f..46528cf5c 100644 --- a/src/_Authorization/Framework.Authorization.Domain/BusinessRole.cs +++ b/src/_Authorization/Framework.Authorization.Domain/BusinessRole.cs @@ -1,6 +1,7 @@ using Framework.Core; using Framework.DomainDriven.Serialization; using Framework.Persistent; +using Framework.Persistent.Mapping; using Framework.Restriction; namespace Framework.Authorization.Domain; @@ -9,6 +10,7 @@ namespace Framework.Authorization.Domain; /// Набор секьюрных операций, который выдается принципалу вместе с контекcтом их применения /// [UniqueGroup] +[IgnoreHbmMapping] public class BusinessRole : BaseDirectory { private readonly ICollection permissions = new List(); diff --git a/src/_Authorization/Framework.Authorization.Domain/Permission.cs b/src/_Authorization/Framework.Authorization.Domain/Permission.cs index 72545c7f3..87fe6bca0 100644 --- a/src/_Authorization/Framework.Authorization.Domain/Permission.cs +++ b/src/_Authorization/Framework.Authorization.Domain/Permission.cs @@ -14,6 +14,7 @@ namespace Framework.Authorization.Domain; /// Пермиссии могут выдаваться в рамках контекстов /// /// +[IgnoreHbmMapping] [System.Diagnostics.DebuggerDisplay("Principal={Principal.Name}, Role={Role.Name}")] public class Permission : AuditPersistentDomainObjectBase, diff --git a/src/_Authorization/Framework.Authorization.Domain/PermissionRestriction.cs b/src/_Authorization/Framework.Authorization.Domain/PermissionRestriction.cs index 0188b2a21..d17cf90e4 100644 --- a/src/_Authorization/Framework.Authorization.Domain/PermissionRestriction.cs +++ b/src/_Authorization/Framework.Authorization.Domain/PermissionRestriction.cs @@ -1,6 +1,7 @@ using Framework.DomainDriven.Serialization; using Framework.DomainDriven.Tracking.LegacyValidators; using Framework.Persistent; +using Framework.Persistent.Mapping; using Framework.Restriction; namespace Framework.Authorization.Domain; @@ -8,6 +9,7 @@ namespace Framework.Authorization.Domain; /// /// Связь между пермиссией и контекстом /// +[IgnoreHbmMapping] public class PermissionRestriction : AuditPersistentDomainObjectBase, IDetail { private readonly Permission permission; diff --git a/src/_Authorization/Framework.Authorization.Domain/Principal.cs b/src/_Authorization/Framework.Authorization.Domain/Principal.cs index 560634998..6c0dd26e5 100644 --- a/src/_Authorization/Framework.Authorization.Domain/Principal.cs +++ b/src/_Authorization/Framework.Authorization.Domain/Principal.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using Framework.Persistent; +using Framework.Persistent.Mapping; using Framework.Restriction; namespace Framework.Authorization.Domain; @@ -10,6 +11,7 @@ namespace Framework.Authorization.Domain; /// [DebuggerDisplay("{Name}, RunAs={RunAs}")] [UniqueGroup] +[IgnoreHbmMapping] public class Principal : BaseDirectory, IMaster { private readonly ICollection permissions = new List(); diff --git a/src/_Authorization/Framework.Authorization.Domain/SecurityContextType.cs b/src/_Authorization/Framework.Authorization.Domain/SecurityContextType.cs index 8ee3a6ed8..a5bd9873e 100644 --- a/src/_Authorization/Framework.Authorization.Domain/SecurityContextType.cs +++ b/src/_Authorization/Framework.Authorization.Domain/SecurityContextType.cs @@ -1,4 +1,5 @@ using Framework.DomainDriven.Serialization; +using Framework.Persistent.Mapping; namespace Framework.Authorization.Domain; @@ -11,6 +12,7 @@ namespace Framework.Authorization.Domain; /// /// Типы, в контексте которых выдаются права пользователю, записываются вручную на уровне SQL в базу конкретной системы /// +[IgnoreHbmMapping] public class SecurityContextType : BaseDirectory { /// diff --git a/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Framework.Authorization.Generated.DAL.NHibernate.csproj b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Framework.Authorization.Generated.DAL.NHibernate.csproj index e032b740f..5a4c785ae 100644 --- a/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Framework.Authorization.Generated.DAL.NHibernate.csproj +++ b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Framework.Authorization.Generated.DAL.NHibernate.csproj @@ -9,10 +9,6 @@ - - - - diff --git a/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Base/AuthBaseMap.cs b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Base/AuthBaseMap.cs new file mode 100644 index 000000000..81a306467 --- /dev/null +++ b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Base/AuthBaseMap.cs @@ -0,0 +1,23 @@ +using FluentNHibernate.Mapping; + +using Framework.Authorization.Domain; + +namespace Framework.Authorization.Generated.DAL.NHibernate.Mapping.Base; + +public abstract class AuthBaseMap : ClassMap + where TEntity : AuditPersistentDomainObjectBase +{ + protected AuthBaseMap() + { + this.Schema("auth"); + + this.DynamicUpdate(); + + this.Id(x => x.Id).GeneratedBy.GuidComb(); + + this.Map(x => x.CreatedBy); + this.Map(x => x.CreateDate); + this.Map(x => x.ModifiedBy); + this.Map(x => x.ModifyDate); + } +} diff --git a/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/BusinessRoleMap.cs b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/BusinessRoleMap.cs new file mode 100644 index 000000000..d04f7bf32 --- /dev/null +++ b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/BusinessRoleMap.cs @@ -0,0 +1,14 @@ +using Framework.Authorization.Domain; +using Framework.Authorization.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Authorization.Generated.DAL.NHibernate.Mapping; + +public class BusinessRoleMap : AuthBaseMap +{ + public BusinessRoleMap() + { + this.Map(x => x.Name).Unique().Not.Nullable(); + this.Map(x => x.Description); + this.HasMany(x => x.Permissions).AsSet().Inverse().Cascade.None(); + } +} diff --git a/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Generated.Framework.Authorization.Domain.hbm.xml b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Generated.Framework.Authorization.Domain.hbm.xml deleted file mode 100644 index 07d34cef2..000000000 --- a/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Generated.Framework.Authorization.Domain.hbm.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/PermissionMap.cs b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/PermissionMap.cs new file mode 100644 index 000000000..44a9d25f4 --- /dev/null +++ b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/PermissionMap.cs @@ -0,0 +1,25 @@ +using Framework.Authorization.Domain; +using Framework.Authorization.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Authorization.Generated.DAL.NHibernate.Mapping; + +public class PermissionMap : AuthBaseMap +{ + public PermissionMap() + { + this.Map(x => x.Comment).Length(int.MaxValue); + this.References(x => x.DelegatedFrom).Column($"{nameof(Permission.DelegatedFrom)}Id"); + this.References(x => x.Principal).Column($"{nameof(Permission.Principal)}Id").Not.Nullable(); + this.References(x => x.Role).Column($"{nameof(Permission.Role)}Id").Not.Nullable(); + this.Component( + x => x.Period, + part => + { + part.Map(x => x.EndDate).Column("periodendDate"); + part.Map(x => x.StartDate).Column("periodstartDate"); + }); + + this.HasMany(x => x.DelegatedTo).AsSet().Inverse().Cascade.AllDeleteOrphan(); + this.HasMany(x => x.Restrictions).AsSet().Inverse().Cascade.AllDeleteOrphan(); + } +} diff --git a/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/PermissionRestrictionMap.cs b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/PermissionRestrictionMap.cs new file mode 100644 index 000000000..5bc2adf39 --- /dev/null +++ b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/PermissionRestrictionMap.cs @@ -0,0 +1,17 @@ +using Framework.Authorization.Domain; +using Framework.Authorization.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Authorization.Generated.DAL.NHibernate.Mapping; + +public class PermissionRestrictionMap : AuthBaseMap +{ + public PermissionRestrictionMap() + { + this.Map(x => x.SecurityContextId).Not.Nullable() + .UniqueKey("UIX_permission_securityContextId_securityContextTypePermissionRestriction"); + this.References(x => x.Permission).Column($"{nameof(PermissionRestriction.Permission)}Id").Not.Nullable() + .UniqueKey("UIX_permission_securityContextId_securityContextTypePermissionRestriction"); + this.References(x => x.SecurityContextType).Column($"{nameof(PermissionRestriction.SecurityContextType)}Id").Not.Nullable() + .UniqueKey("UIX_permission_securityContextId_securityContextTypePermissionRestriction"); + } +} diff --git a/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/PrincipalMap.cs b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/PrincipalMap.cs new file mode 100644 index 000000000..1edec5a66 --- /dev/null +++ b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/PrincipalMap.cs @@ -0,0 +1,14 @@ +using Framework.Authorization.Domain; +using Framework.Authorization.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Authorization.Generated.DAL.NHibernate.Mapping; + +public class PrincipalMap : AuthBaseMap +{ + public PrincipalMap() + { + this.Map(x => x.Name).Not.Nullable().UniqueKey("UIX_namePrincipal"); + this.References(x => x.RunAs).Column($"{nameof(Principal.RunAs)}Id"); + this.HasMany(x => x.Permissions).AsSet().Inverse().Cascade.AllDeleteOrphan(); + } +} diff --git a/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/SecurityContextTypeMap.cs b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/SecurityContextTypeMap.cs new file mode 100644 index 000000000..5d704e414 --- /dev/null +++ b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/SecurityContextTypeMap.cs @@ -0,0 +1,9 @@ +using Framework.Authorization.Domain; +using Framework.Authorization.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Authorization.Generated.DAL.NHibernate.Mapping; + +public class SecurityContextTypeMap : AuthBaseMap +{ + public SecurityContextTypeMap() => this.Map(x => x.Name).Not.Nullable(); +} diff --git a/src/_Authorization/Framework.Authorization.TestGenerate/ServerGenerators.DB.cs b/src/_Authorization/Framework.Authorization.TestGenerate/ServerGenerators.DB.cs index effb6ec6c..d47352f4d 100644 --- a/src/_Authorization/Framework.Authorization.TestGenerate/ServerGenerators.DB.cs +++ b/src/_Authorization/Framework.Authorization.TestGenerate/ServerGenerators.DB.cs @@ -1,5 +1,6 @@ using Framework.DomainDriven; using Framework.DomainDriven.DBGenerator; +using Framework.DomainDriven.NHibernate; namespace Framework.Authorization.TestGenerate; @@ -50,4 +51,28 @@ public string GenerateDB( var lines = result.ToNewLinesCombined(); return lines; } + + public string GenerateDB( + MappingSettings mappingSettings, + string serverName, + DatabaseScriptGeneratorMode generatorMode = DatabaseScriptGeneratorMode.AutoGenerateUpdateChangeTypeScript, + DBGenerateScriptMode mode = DBGenerateScriptMode.AppliedOnTargetDatabase, + IEnumerable migrationScriptFolderPaths = null, + IEnumerable auditMigrationScriptFolderPaths = null, + bool preserveSchemaDatabase = false, + DbUserCredential credentials = null) + { + var generator = new DBGenerator(mappingSettings); + var result = generator.Generate( + serverName, + mode: mode, + generatorMode: generatorMode, + migrationScriptFolderPaths: migrationScriptFolderPaths, + auditMigrationScriptFolderPaths: auditMigrationScriptFolderPaths, + preserveSchemaDatabase: preserveSchemaDatabase, + credentials: credentials); + + var lines = result.ToNewLinesCombined(); + return lines; + } } diff --git a/src/_Configuration/Framework.Configuration.Domain/CodeFirstSubscription.cs b/src/_Configuration/Framework.Configuration.Domain/CodeFirstSubscription.cs index 6200ea86a..118bccce1 100644 --- a/src/_Configuration/Framework.Configuration.Domain/CodeFirstSubscription.cs +++ b/src/_Configuration/Framework.Configuration.Domain/CodeFirstSubscription.cs @@ -13,6 +13,7 @@ namespace Framework.Configuration.Domain; /// [UniqueGroup] [NotAuditedClass] +[IgnoreHbmMapping] public class CodeFirstSubscription : AuditPersistentDomainObjectBase, ICodeObject { private readonly string code; diff --git a/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettings.cs b/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettings.cs index 050785e72..2b1133ea2 100644 --- a/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettings.cs +++ b/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettings.cs @@ -8,6 +8,7 @@ namespace Framework.Configuration.Domain; [NotAuditedClass] +[IgnoreHbmMapping] public class ControlSettings : BaseDirectory, IMaster, IMaster, diff --git a/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParam.cs b/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParam.cs index c24994956..c31817ec1 100644 --- a/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParam.cs +++ b/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParam.cs @@ -4,6 +4,7 @@ namespace Framework.Configuration.Domain; [NotAuditedClass] +[IgnoreHbmMapping] public class ControlSettingsParam : AuditPersistentDomainObjectBase, IMaster, IDetail, ITypeObject { private readonly ICollection controlSettingsParamValues = new List(); diff --git a/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParamValue.cs b/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParamValue.cs index 668ef4d73..788ee6ff1 100644 --- a/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParamValue.cs +++ b/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParamValue.cs @@ -6,6 +6,7 @@ namespace Framework.Configuration.Domain; [NotAuditedClass] +[IgnoreHbmMapping] public class ControlSettingsParamValue : AuditPersistentDomainObjectBase, IDetail { private readonly ControlSettingsParam controlSettingsParam; diff --git a/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectEvent.cs b/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectEvent.cs index df5049462..09c109b6d 100644 --- a/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectEvent.cs +++ b/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectEvent.cs @@ -7,6 +7,7 @@ namespace Framework.Configuration.Domain; /// Событие над объектом (Save, Remove etc), сохраняемое в базу. /// [NotAuditedClass] +[IgnoreHbmMapping] public class DomainObjectEvent : AuditPersistentDomainObjectBase { private readonly QueueProgressStatus status; diff --git a/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectModification.cs b/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectModification.cs index afc3dc83d..c6e3f3715 100644 --- a/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectModification.cs +++ b/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectModification.cs @@ -10,6 +10,7 @@ namespace Framework.Configuration.Domain; /// [UniqueGroup] [NotAuditedClass] +[IgnoreHbmMapping] public class DomainObjectModification : AuditPersistentDomainObjectBase, ITypeObject, IVersionObject { private Guid domainObjectId; diff --git a/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectNotification.cs b/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectNotification.cs index 1e0a1ed8f..8b6bb7b9f 100644 --- a/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectNotification.cs +++ b/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectNotification.cs @@ -7,6 +7,7 @@ namespace Framework.Configuration.Domain; /// Нотификация хранимая в бд /// [NotAuditedClass] +[IgnoreHbmMapping] public class DomainObjectNotification : AuditPersistentDomainObjectBase { private readonly QueueProgressStatus status; diff --git a/src/_Configuration/Framework.Configuration.Domain/ExceptionMessage.cs b/src/_Configuration/Framework.Configuration.Domain/ExceptionMessage.cs index 82519cf4a..5846258c6 100644 --- a/src/_Configuration/Framework.Configuration.Domain/ExceptionMessage.cs +++ b/src/_Configuration/Framework.Configuration.Domain/ExceptionMessage.cs @@ -13,6 +13,7 @@ namespace Framework.Configuration.Domain; /// Механизм Framework-а сохраняет все ошибки по всем системам, записывает их в базу и высылает на почту /// [NotAuditedClass] +[IgnoreHbmMapping] public class ExceptionMessage : AuditPersistentDomainObjectBase { private ExceptionMessage innerException; diff --git a/src/_Configuration/Framework.Configuration.Domain/Lock/GenericNamedLock.cs b/src/_Configuration/Framework.Configuration.Domain/Lock/GenericNamedLock.cs index 3484a4f5c..af852d47c 100644 --- a/src/_Configuration/Framework.Configuration.Domain/Lock/GenericNamedLock.cs +++ b/src/_Configuration/Framework.Configuration.Domain/Lock/GenericNamedLock.cs @@ -8,4 +8,5 @@ namespace Framework.Configuration.Domain; /// [UniqueGroup] [NotAuditedClass] +[IgnoreHbmMapping] public class GenericNamedLock : BaseDirectory; diff --git a/src/_Configuration/Framework.Configuration.Domain/SentMessage.cs b/src/_Configuration/Framework.Configuration.Domain/SentMessage.cs index 17cbb4594..28365734a 100644 --- a/src/_Configuration/Framework.Configuration.Domain/SentMessage.cs +++ b/src/_Configuration/Framework.Configuration.Domain/SentMessage.cs @@ -7,6 +7,7 @@ namespace Framework.Configuration.Domain; /// Сообщение, отправленное пользователю /// [NotAuditedClass] +[IgnoreHbmMapping] public class SentMessage : AuditPersistentDomainObjectBase { private readonly string from; diff --git a/src/_Configuration/Framework.Configuration.Domain/Sequence.cs b/src/_Configuration/Framework.Configuration.Domain/Sequence.cs index c767fb354..93577a08e 100644 --- a/src/_Configuration/Framework.Configuration.Domain/Sequence.cs +++ b/src/_Configuration/Framework.Configuration.Domain/Sequence.cs @@ -10,6 +10,7 @@ namespace Framework.Configuration.Domain; /// [UniqueGroup] [NotAuditedClass] +[IgnoreHbmMapping] public class Sequence : BaseDirectory, INumberObject { private long number; diff --git a/src/_Configuration/Framework.Configuration.Domain/SystemConstant.cs b/src/_Configuration/Framework.Configuration.Domain/SystemConstant.cs index 2db55f7e6..7534998f9 100644 --- a/src/_Configuration/Framework.Configuration.Domain/SystemConstant.cs +++ b/src/_Configuration/Framework.Configuration.Domain/SystemConstant.cs @@ -11,6 +11,7 @@ namespace Framework.Configuration.Domain; /// [UniqueGroup] [NotAuditedClass] +[IgnoreHbmMapping] public class SystemConstant : AuditPersistentDomainObjectBase, ICodeObject, diff --git a/src/_Configuration/Framework.Configuration.Domain/TargetSystem/TargetSystem.cs b/src/_Configuration/Framework.Configuration.Domain/TargetSystem/TargetSystem.cs index b705f0971..eb1f2690f 100644 --- a/src/_Configuration/Framework.Configuration.Domain/TargetSystem/TargetSystem.cs +++ b/src/_Configuration/Framework.Configuration.Domain/TargetSystem/TargetSystem.cs @@ -13,6 +13,7 @@ namespace Framework.Configuration.Domain; /// [UniqueGroup] [NotAuditedClass] +[IgnoreHbmMapping] public class TargetSystem : BaseDirectory, IMaster { private readonly ICollection domainTypes = new List(); diff --git a/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainType.cs b/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainType.cs index 4f5b5ccd1..9eeb2c2e3 100644 --- a/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainType.cs +++ b/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainType.cs @@ -10,6 +10,7 @@ namespace Framework.Configuration.Domain; /// Описание доменного типа целевой системы /// [NotAuditedClass] +[IgnoreHbmMapping] public class DomainType : BaseDirectory, ITargetSystemElement, IDetail, IMaster, IDomainType { private readonly ICollection eventOperations = new List(); diff --git a/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainTypeEventOperation.cs b/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainTypeEventOperation.cs index d8c5f5a1d..3b641e466 100644 --- a/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainTypeEventOperation.cs +++ b/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainTypeEventOperation.cs @@ -8,6 +8,7 @@ namespace Framework.Configuration.Domain; /// Операция доменного типа /// [NotAuditedClass] +[IgnoreHbmMapping] public class DomainTypeEventOperation : BaseDirectory, IDetail { private readonly DomainType domainType; diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Framework.Configuration.Generated.DAL.NHibernate.csproj b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Framework.Configuration.Generated.DAL.NHibernate.csproj index fc4470b39..5a61eda9c 100644 --- a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Framework.Configuration.Generated.DAL.NHibernate.csproj +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Framework.Configuration.Generated.DAL.NHibernate.csproj @@ -9,7 +9,4 @@ - - - diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Base/ConfigurationBaseMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Base/ConfigurationBaseMap.cs new file mode 100644 index 000000000..77b5c2246 --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Base/ConfigurationBaseMap.cs @@ -0,0 +1,24 @@ +using FluentNHibernate.Mapping; + +using Framework.Configuration.Domain; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +public abstract class ConfigurationBaseMap : ClassMap + where TEntity : AuditPersistentDomainObjectBase +{ + protected ConfigurationBaseMap() + { + this.Schema("configuration"); + + this.DynamicUpdate(); + + this.Id(x => x.Id).GeneratedBy.GuidComb(); + + this.Map(x => x.Active); + this.Map(x => x.CreatedBy); + this.Map(x => x.CreateDate); + this.Map(x => x.ModifiedBy); + this.Map(x => x.ModifyDate); + } +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/CodeFirstSubscriptionMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/CodeFirstSubscriptionMap.cs new file mode 100644 index 000000000..79c25e2c3 --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/CodeFirstSubscriptionMap.cs @@ -0,0 +1,10 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class CodeFirstSubscriptionMap : ConfigurationBaseMap +{ + public CodeFirstSubscriptionMap() => + this.Map(x => x.Code).Length(512).UniqueKey("UIX_codeCodeFirstSubscription").Not.Nullable(); +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ControlSettingsMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ControlSettingsMap.cs new file mode 100644 index 000000000..deb3a8580 --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ControlSettingsMap.cs @@ -0,0 +1,17 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class ControlSettingsMap : ConfigurationBaseMap +{ + public ControlSettingsMap() + { + this.Map(x => x.Name).Length(int.MaxValue).Not.Nullable(); + this.Map(x => x.AccountName); + this.Map(x => x.Type); + this.References(x => x.Parent).Column($"{nameof(ControlSettings.Parent)}Id"); + this.HasMany(x => x.Children).AsSet().Inverse().Cascade.None(); + this.HasMany(x => x.ControlSettingsParams).AsSet().Inverse().Cascade.AllDeleteOrphan(); + } +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ControlSettingsParamMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ControlSettingsParamMap.cs new file mode 100644 index 000000000..f03af82e8 --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ControlSettingsParamMap.cs @@ -0,0 +1,14 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class ControlSettingsParamMap : ConfigurationBaseMap +{ + public ControlSettingsParamMap() + { + this.Map(x => x.Type); + this.References(x => x.ControlSettings).Column($"{nameof(ControlSettingsParam.ControlSettings)}Id").Not.Nullable(); + this.HasMany(x => x.ControlSettingsParamValues).AsSet().Inverse().Cascade.AllDeleteOrphan(); + } +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ControlSettingsParamValueMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ControlSettingsParamValueMap.cs new file mode 100644 index 000000000..df2bdec35 --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ControlSettingsParamValueMap.cs @@ -0,0 +1,15 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class ControlSettingsParamValueMap : ConfigurationBaseMap +{ + public ControlSettingsParamValueMap() + { + this.Map(x => x.Culture); + this.Map(x => x.Value).Length(int.MaxValue); + this.Map(x => x.ValueTypeName); + this.References(x => x.ControlSettingsParam).Column($"{nameof(ControlSettingsParamValue.ControlSettingsParam)}Id").Not.Nullable(); + } +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainObjectEventMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainObjectEventMap.cs new file mode 100644 index 000000000..4a9bec546 --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainObjectEventMap.cs @@ -0,0 +1,21 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class DomainObjectEventMap : ConfigurationBaseMap +{ + public DomainObjectEventMap() + { + this.Map(x => x.DomainObjectId); + this.Map(x => x.HostName); + this.Map(x => x.ProcessDate); + this.Map(x => x.QueueTag).Not.Nullable(); + this.Map(x => x.Revision); + this.Map(x => x.SerializeData).Length(int.MaxValue); + this.Map(x => x.SerializeType).Length(int.MaxValue); + this.Map(x => x.Size); + this.Map(x => x.Status); + this.References(x => x.Operation).Column($"{nameof(DomainObjectEvent.Operation)}Id"); + } +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainObjectModificationMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainObjectModificationMap.cs new file mode 100644 index 000000000..347c2ced7 --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainObjectModificationMap.cs @@ -0,0 +1,24 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class DomainObjectModificationMap : ConfigurationBaseMap +{ + public DomainObjectModificationMap() + { + this.Map(x => x.Type); + this.Map(x => x.Processed); + this.Map(x => x.DomainObjectId) + .Not.Nullable() + .UniqueKey("UIX_domainObjectId_domainType_revisionDomainObjectModification"); + this.Map(x => x.Revision) + .Not.Nullable() + .UniqueKey("UIX_domainObjectId_domainType_revisionDomainObjectModification"); + this.References(x => x.DomainType).Column($"{nameof(DomainObjectModification.DomainType)}Id") + .Not.Nullable() + .UniqueKey("UIX_domainObjectId_domainType_revisionDomainObjectModification"); + + this.Version(x => x.Version).Generated.Never().Not.Nullable(); + } +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainObjectNotificationMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainObjectNotificationMap.cs new file mode 100644 index 000000000..d3ddcdf18 --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainObjectNotificationMap.cs @@ -0,0 +1,16 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class DomainObjectNotificationMap : ConfigurationBaseMap +{ + public DomainObjectNotificationMap() + { + this.Map(x => x.HostName); + this.Map(x => x.ProcessDate); + this.Map(x => x.SerializeData).Length(int.MaxValue).Not.Nullable(); + this.Map(x => x.Size); + this.Map(x => x.Status); + } +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainTypeEventOperationMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainTypeEventOperationMap.cs new file mode 100644 index 000000000..6fddb72dc --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainTypeEventOperationMap.cs @@ -0,0 +1,17 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class DomainTypeEventOperationMap : ConfigurationBaseMap +{ + public DomainTypeEventOperationMap() + { + this.Map(x => x.Name) + .UniqueKey("UIX_domainType_nameDomainTypeEventOperation") + .Not.Nullable(); + this.References(x => x.DomainType).Column($"{nameof(DomainTypeEventOperation.DomainType)}Id") + .UniqueKey("UIX_domainType_nameDomainTypeEventOperation") + .Not.Nullable(); + } +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainTypeMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainTypeMap.cs new file mode 100644 index 000000000..7e004d1b0 --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/DomainTypeMap.cs @@ -0,0 +1,19 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class DomainTypeMap : ConfigurationBaseMap +{ + public DomainTypeMap() + { + this.Map(x => x.Name) + .UniqueKey("UIX_name_nameSpace_targetSystemDomainType") + .Not.Nullable(); + this.Map(x => x.NameSpace) + .UniqueKey("UIX_name_nameSpace_targetSystemDomainType"); + this.References(x => x.TargetSystem).Column($"{nameof(DomainType.TargetSystem)}Id") + .UniqueKey("UIX_name_nameSpace_targetSystemDomainType").Not.Nullable(); + this.HasMany(x => x.EventOperations).AsSet().Inverse().Cascade.AllDeleteOrphan(); + } +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ExceptionMessageMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ExceptionMessageMap.cs new file mode 100644 index 000000000..d4605887c --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/ExceptionMessageMap.cs @@ -0,0 +1,17 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class ExceptionMessageMap : ConfigurationBaseMap +{ + public ExceptionMessageMap() + { + this.Map(x => x.IsClient); + this.Map(x => x.IsRoot); + this.Map(x => x.Message).Length(int.MaxValue); + this.Map(x => x.MessageType); + this.Map(x => x.StackTrace).Length(int.MaxValue); + this.References(x => x.InnerException).Column($"{nameof(ExceptionMessage.InnerException)}Id"); + } +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Generated.Framework.Configuration.Domain.hbm.xml b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Generated.Framework.Configuration.Domain.hbm.xml deleted file mode 100644 index fb91e7d8b..000000000 --- a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Generated.Framework.Configuration.Domain.hbm.xml +++ /dev/null @@ -1,241 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/GenericNamedLockMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/GenericNamedLockMap.cs new file mode 100644 index 000000000..aeded4dff --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/GenericNamedLockMap.cs @@ -0,0 +1,9 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class GenericNamedLockMap : ConfigurationBaseMap +{ + public GenericNamedLockMap() => this.Map(x => x.Name).UniqueKey("UIX_nameGenericNamedLock").Not.Nullable(); +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/SentMessageMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/SentMessageMap.cs new file mode 100644 index 000000000..9b48e5275 --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/SentMessageMap.cs @@ -0,0 +1,21 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class SentMessageMap : ConfigurationBaseMap +{ + public SentMessageMap() + { + this.Map(x => x.Comment); + this.Map(x => x.ContextObjectId); + this.Map(x => x.ContextObjectType); + this.Map(x => x.Copy).Length(int.MaxValue); + this.Map(x => x.From); + this.Map(x => x.Message).Length(int.MaxValue); + this.Map(x => x.ReplyTo).Length(int.MaxValue); + this.Map(x => x.Subject).Length(1000); + this.Map(x => x.TemplateName); + this.Map(x => x.To).Length(int.MaxValue); + } +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/SequenceMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/SequenceMap.cs new file mode 100644 index 000000000..c12b5b97c --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/SequenceMap.cs @@ -0,0 +1,13 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class SequenceMap : ConfigurationBaseMap +{ + public SequenceMap() + { + this.Map(x => x.Name).UniqueKey("UIX_nameSequence").Not.Nullable(); + this.Map(x => x.Number); + } +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/SystemConstantMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/SystemConstantMap.cs new file mode 100644 index 000000000..7ada40ceb --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/SystemConstantMap.cs @@ -0,0 +1,16 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class SystemConstantMap : ConfigurationBaseMap +{ + public SystemConstantMap() + { + this.Map(x => x.Code).UniqueKey("UIX_codeSystemConstant").Not.Nullable(); + this.Map(x => x.Description).Length(int.MaxValue); + this.Map(x => x.Value).Length(int.MaxValue); + this.Map(x => x.IsManual); + this.References(x => x.Type).Column($"{nameof(SystemConstant.Type)}Id").Not.Nullable(); + } +} diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/TargetSystemMap.cs b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/TargetSystemMap.cs new file mode 100644 index 000000000..eb606ffef --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/TargetSystemMap.cs @@ -0,0 +1,17 @@ +using Framework.Configuration.Domain; +using Framework.Configuration.Generated.DAL.NHibernate.Mapping.Base; + +namespace Framework.Configuration.Generated.DAL.NHibernate.Mapping; + +public class TargetSystemMap : ConfigurationBaseMap +{ + public TargetSystemMap() + { + this.Map(x => x.IsBase); + this.Map(x => x.IsMain); + this.Map(x => x.IsRevision); + this.Map(x => x.Name).UniqueKey("UIX_nameTargetSystem").Not.Nullable(); + this.Map(x => x.SubscriptionEnabled); + this.HasMany(x => x.DomainTypes).AsSet().Inverse().Cascade.AllDeleteOrphan(); + } +} diff --git a/src/_SampleSystem/_Tests/SampleSystem.DbGenerate/DbGeneratorTest.cs b/src/_SampleSystem/_Tests/SampleSystem.DbGenerate/DbGeneratorTest.cs index 8ac44efdb..2f13f0736 100644 --- a/src/_SampleSystem/_Tests/SampleSystem.DbGenerate/DbGeneratorTest.cs +++ b/src/_SampleSystem/_Tests/SampleSystem.DbGenerate/DbGeneratorTest.cs @@ -1,4 +1,5 @@ -using Framework.DomainDriven; +using Framework.Authorization.Generated.DAL.NHibernate; +using Framework.DomainDriven; using Framework.DomainDriven.DBGenerator; using Framework.DomainDriven.NHibernate; @@ -35,122 +36,133 @@ public void GenerateDatabase(DbGenerationOptions options) } public string GenerateAllDB( - string serverName, - string mainDatabaseName = nameof(SampleSystem), - DatabaseScriptGeneratorMode generatorMode = DatabaseScriptGeneratorMode.AutoGenerateUpdateChangeTypeScript, - DBGenerateScriptMode mode = DBGenerateScriptMode.AppliedOnTargetDatabase, - ICollection ignoredIndexes = null, - bool skipFrameworkDatabases = false, - DbUserCredential credential = null, - params string[] migrationScriptFolderPaths) + string serverName, + string mainDatabaseName = nameof(SampleSystem), + DatabaseScriptGeneratorMode generatorMode = DatabaseScriptGeneratorMode.AutoGenerateUpdateChangeTypeScript, + DBGenerateScriptMode mode = DBGenerateScriptMode.AppliedOnTargetDatabase, + ICollection ignoredIndexes = null, + bool skipFrameworkDatabases = false, + DbUserCredential credential = null, + params string[] migrationScriptFolderPaths) { if (!skipFrameworkDatabases) { this.GenerateAuthorizationDatabase( - serverName, - new DatabaseName(mainDatabaseName, "auth"), - new DatabaseName(mainDatabaseName, "auth").ToDefaultAudit(), - mode, - true, - credential); + serverName, + new DatabaseName(mainDatabaseName, "auth"), + new DatabaseName(mainDatabaseName, "auth").ToDefaultAudit(), + mode, + true, + credential); this.GenerateConfigurationDatabase( - serverName, - new DatabaseName(mainDatabaseName, "configuration"), - mode, - true, - credential); + serverName, + new DatabaseName(mainDatabaseName, "configuration"), + mode, + true, + credential); } var result = this.GenerateSampleSystemDB( - serverName, - new DatabaseName(mainDatabaseName, "app"), - new DatabaseName(mainDatabaseName, "app").ToDefaultAudit(), - mode: mode, - generatorMode: generatorMode, - migrationScriptFolderPaths: migrationScriptFolderPaths, - preserveSchemaDatabase: true, - ignoredIndexes: ignoredIndexes, - credential: credential); + serverName, + new DatabaseName(mainDatabaseName, "app"), + new DatabaseName(mainDatabaseName, "app").ToDefaultAudit(), + mode: mode, + generatorMode: generatorMode, + migrationScriptFolderPaths: migrationScriptFolderPaths, + preserveSchemaDatabase: true, + ignoredIndexes: ignoredIndexes, + credential: credential); return result; } private string GenerateSampleSystemDB( - string serverName, - DatabaseName databaseName, - AuditDatabaseName auditDatabaseName, - DatabaseScriptGeneratorMode generatorMode = DatabaseScriptGeneratorMode.AutoGenerateUpdateChangeTypeScript, - DBGenerateScriptMode mode = DBGenerateScriptMode.AppliedOnTargetDatabase, - IEnumerable migrationScriptFolderPaths = null, - IEnumerable auditMigrationScriptFolderPaths = null, - bool preserveSchemaDatabase = false, - ICollection ignoredIndexes = null, - DbUserCredential credential = null) + string serverName, + DatabaseName databaseName, + AuditDatabaseName auditDatabaseName, + DatabaseScriptGeneratorMode generatorMode = DatabaseScriptGeneratorMode.AutoGenerateUpdateChangeTypeScript, + DBGenerateScriptMode mode = DBGenerateScriptMode.AppliedOnTargetDatabase, + IEnumerable migrationScriptFolderPaths = null, + IEnumerable auditMigrationScriptFolderPaths = null, + bool preserveSchemaDatabase = false, + ICollection ignoredIndexes = null, + DbUserCredential credential = null) { var generator = new SampleSystemDBGenerator(this.GetMappingSettings(serverName, databaseName, auditDatabaseName)); var result = generator.Generate( - serverName, - mode: mode, - generatorMode: generatorMode, - migrationScriptFolderPaths: migrationScriptFolderPaths, - auditMigrationScriptFolderPaths: auditMigrationScriptFolderPaths, - preserveSchemaDatabase: preserveSchemaDatabase, - ignoredIndexes: ignoredIndexes, - credentials: credential); + serverName, + mode: mode, + generatorMode: generatorMode, + migrationScriptFolderPaths: migrationScriptFolderPaths, + auditMigrationScriptFolderPaths: auditMigrationScriptFolderPaths, + preserveSchemaDatabase: preserveSchemaDatabase, + ignoredIndexes: ignoredIndexes, + credentials: credential); var lines = result.ToNewLinesCombined(); return lines; } private void GenerateConfigurationDatabase( - string serverName, - DatabaseName mainDatabaseName, - DBGenerateScriptMode mode = DBGenerateScriptMode.AppliedOnCopySchemeDatabase, - bool preserveSchemaDatabase = false, - DbUserCredential credential = null) + string serverName, + DatabaseName mainDatabaseName, + DBGenerateScriptMode mode = DBGenerateScriptMode.AppliedOnCopySchemeDatabase, + bool preserveSchemaDatabase = false, + DbUserCredential credential = null) { string[] migrationScriptFolderPaths = null; Console.WriteLine("------ start Utilities"); var resultScript = new Framework.Configuration.TestGenerate.ServerGenerators( - new Framework.Configuration.TestGenerate.ServerGenerationEnvironment(new DatabaseName("Configuration"))) - .GenerateDB( - serverName, - mainDatabaseName, - migrationScriptFolderPaths: migrationScriptFolderPaths, - mode: mode, - preserveSchemaDatabase: preserveSchemaDatabase, - credentials: credential); + new Framework.Configuration.TestGenerate.ServerGenerationEnvironment(new DatabaseName("Configuration"))) + .GenerateDB( + serverName, + mainDatabaseName, + migrationScriptFolderPaths: migrationScriptFolderPaths, + mode: mode, + preserveSchemaDatabase: preserveSchemaDatabase, + credentials: credential); var lines = resultScript; Console.WriteLine("------ end Utilities"); Console.WriteLine(lines); } - private void GenerateAuthorizationDatabase( - string serverName, - DatabaseName mainDatabaseName, - AuditDatabaseName auditDatabaseName, - DBGenerateScriptMode mode = DBGenerateScriptMode.AppliedOnCopySchemeDatabase, - bool preserveSchemaDatabase = false, - DbUserCredential credential = null) + string serverName, + DatabaseName mainDatabaseName, + AuditDatabaseName auditDatabaseName, + DBGenerateScriptMode mode = DBGenerateScriptMode.AppliedOnCopySchemeDatabase, + bool preserveSchemaDatabase = false, + DbUserCredential credential = null) { string[] migrationScriptFolderPaths = null; var result = new Framework.Authorization.TestGenerate.ServerGenerators().GenerateDB( - serverName, - mainDatabaseName, - auditDatabaseName, - migrationScriptFolderPaths: migrationScriptFolderPaths, - mode: mode, - preserveSchemaDatabase: preserveSchemaDatabase, - credentials: credential); + GetAuthMappingSettings(serverName, mainDatabaseName, auditDatabaseName), + serverName, + migrationScriptFolderPaths: migrationScriptFolderPaths, + mode: mode, + preserveSchemaDatabase: preserveSchemaDatabase, + credentials: credential); Console.WriteLine(result); } + private static MappingSettings GetAuthMappingSettings(string serverName, DatabaseName dbName, AuditDatabaseName dbAuditName) => + Framework.Authorization.TestGenerate.ServerGenerationEnvironment.Default.GetMappingSettings(dbName, dbAuditName).AddInitializer( + new DefaultConfigurationInitializer( + new ManualDefaultConnectionStringSource( + $"Data Source={serverName};Initial Catalog={dbName.Name};Application Name=SampleSystem"), + new DefaultConfigurationInitializerSettings + { + FluentAssemblyList = + [ + typeof(AuthorizationMappingSettings).Assembly + ] + })); + private MappingSettings GetMappingSettings(string serverName, DatabaseName dbName, AuditDatabaseName dbAuditName) { var initMappingAction = this.environment.DAL.GetMappingGenerators() @@ -162,10 +174,15 @@ private MappingSettings GetMappingSettings(string serverName, DatabaseName dbNam initMappingAction, dbName, dbAuditName) - .AddInitializer( new DefaultConfigurationInitializer( new ManualDefaultConnectionStringSource(connectionString), - new DefaultConfigurationInitializerSettings { FluentAssemblyList = [typeof(SampleSystemMappingSettings).Assembly] })); + new DefaultConfigurationInitializerSettings + { + FluentAssemblyList = + [ + typeof(SampleSystemMappingSettings).Assembly + ] + })); } } From d24c27e9b8ebc90da6b4b3e1969801b189c6411a Mon Sep 17 00:00:00 2001 From: VVTsyk Date: Wed, 18 Dec 2024 11:44:08 +0100 Subject: [PATCH 2/4] autogen --- .../Mapping/Generated.Framework.Authorization.Domain.hbm.xml | 2 ++ .../Mapping/Generated.Framework.Configuration.Domain.hbm.xml | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Generated.Framework.Authorization.Domain.hbm.xml create mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Generated.Framework.Configuration.Domain.hbm.xml diff --git a/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Generated.Framework.Authorization.Domain.hbm.xml b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Generated.Framework.Authorization.Domain.hbm.xml new file mode 100644 index 000000000..481de6884 --- /dev/null +++ b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Generated.Framework.Authorization.Domain.hbm.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Generated.Framework.Configuration.Domain.hbm.xml b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Generated.Framework.Configuration.Domain.hbm.xml new file mode 100644 index 000000000..2f98c9a2d --- /dev/null +++ b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Generated.Framework.Configuration.Domain.hbm.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file From 75ffa7ac7acf120c87685ba5591761c1f129d354 Mon Sep 17 00:00:00 2001 From: VVTsyk Date: Thu, 16 Jan 2025 18:19:22 +0100 Subject: [PATCH 3/4] update, remove IgnoreHbmMapping --- .../BusinessRole.cs | 2 - .../Permission.cs | 1 - .../PermissionRestriction.cs | 2 - .../Principal.cs | 2 - .../SecurityContextType.cs | 2 - ...ted.Framework.Authorization.Domain.hbm.xml | 2 - .../ServerGenerationEnvironment.cs | 4 +- ...ramework.Authorization.TestGenerate.csproj | 2 + .../ServerGenerators.DB.cs | 42 +++++++------------ .../ServerGenerators.cs | 16 +------ .../CodeFirstSubscription.cs | 1 - .../ControlSettings/ControlSettings.cs | 1 - .../ControlSettings/ControlSettingsParam.cs | 1 - .../ControlSettingsParamValue.cs | 1 - .../DomainObjectQueue/DomainObjectEvent.cs | 1 - .../DomainObjectModification.cs | 1 - .../DomainObjectNotification.cs | 1 - .../ExceptionMessage.cs | 1 - .../Lock/GenericNamedLock.cs | 1 - .../SentMessage.cs | 1 - .../Sequence.cs | 1 - .../SystemConstant.cs | 1 - .../TargetSystem/TargetSystem.cs | 1 - .../TargetSystem/Type/DomainType.cs | 1 - .../Type/DomainTypeEventOperation.cs | 1 - ...ted.Framework.Configuration.Domain.hbm.xml | 2 - .../ServerGenerationEnvironment.cs | 2 +- .../ServerGenerators.cs | 22 +--------- .../DbGeneratorTest.cs | 16 +------ 29 files changed, 25 insertions(+), 107 deletions(-) delete mode 100644 src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Generated.Framework.Authorization.Domain.hbm.xml delete mode 100644 src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Generated.Framework.Configuration.Domain.hbm.xml diff --git a/src/_Authorization/Framework.Authorization.Domain/BusinessRole.cs b/src/_Authorization/Framework.Authorization.Domain/BusinessRole.cs index 46528cf5c..fabff520f 100644 --- a/src/_Authorization/Framework.Authorization.Domain/BusinessRole.cs +++ b/src/_Authorization/Framework.Authorization.Domain/BusinessRole.cs @@ -1,7 +1,6 @@ using Framework.Core; using Framework.DomainDriven.Serialization; using Framework.Persistent; -using Framework.Persistent.Mapping; using Framework.Restriction; namespace Framework.Authorization.Domain; @@ -10,7 +9,6 @@ namespace Framework.Authorization.Domain; /// Набор секьюрных операций, который выдается принципалу вместе с контекcтом их применения /// [UniqueGroup] -[IgnoreHbmMapping] public class BusinessRole : BaseDirectory { private readonly ICollection permissions = new List(); diff --git a/src/_Authorization/Framework.Authorization.Domain/Permission.cs b/src/_Authorization/Framework.Authorization.Domain/Permission.cs index 87fe6bca0..72545c7f3 100644 --- a/src/_Authorization/Framework.Authorization.Domain/Permission.cs +++ b/src/_Authorization/Framework.Authorization.Domain/Permission.cs @@ -14,7 +14,6 @@ namespace Framework.Authorization.Domain; /// Пермиссии могут выдаваться в рамках контекстов /// /// -[IgnoreHbmMapping] [System.Diagnostics.DebuggerDisplay("Principal={Principal.Name}, Role={Role.Name}")] public class Permission : AuditPersistentDomainObjectBase, diff --git a/src/_Authorization/Framework.Authorization.Domain/PermissionRestriction.cs b/src/_Authorization/Framework.Authorization.Domain/PermissionRestriction.cs index d17cf90e4..0188b2a21 100644 --- a/src/_Authorization/Framework.Authorization.Domain/PermissionRestriction.cs +++ b/src/_Authorization/Framework.Authorization.Domain/PermissionRestriction.cs @@ -1,7 +1,6 @@ using Framework.DomainDriven.Serialization; using Framework.DomainDriven.Tracking.LegacyValidators; using Framework.Persistent; -using Framework.Persistent.Mapping; using Framework.Restriction; namespace Framework.Authorization.Domain; @@ -9,7 +8,6 @@ namespace Framework.Authorization.Domain; /// /// Связь между пермиссией и контекстом /// -[IgnoreHbmMapping] public class PermissionRestriction : AuditPersistentDomainObjectBase, IDetail { private readonly Permission permission; diff --git a/src/_Authorization/Framework.Authorization.Domain/Principal.cs b/src/_Authorization/Framework.Authorization.Domain/Principal.cs index 6c0dd26e5..560634998 100644 --- a/src/_Authorization/Framework.Authorization.Domain/Principal.cs +++ b/src/_Authorization/Framework.Authorization.Domain/Principal.cs @@ -1,7 +1,6 @@ using System.Diagnostics; using Framework.Persistent; -using Framework.Persistent.Mapping; using Framework.Restriction; namespace Framework.Authorization.Domain; @@ -11,7 +10,6 @@ namespace Framework.Authorization.Domain; /// [DebuggerDisplay("{Name}, RunAs={RunAs}")] [UniqueGroup] -[IgnoreHbmMapping] public class Principal : BaseDirectory, IMaster { private readonly ICollection permissions = new List(); diff --git a/src/_Authorization/Framework.Authorization.Domain/SecurityContextType.cs b/src/_Authorization/Framework.Authorization.Domain/SecurityContextType.cs index a5bd9873e..8ee3a6ed8 100644 --- a/src/_Authorization/Framework.Authorization.Domain/SecurityContextType.cs +++ b/src/_Authorization/Framework.Authorization.Domain/SecurityContextType.cs @@ -1,5 +1,4 @@ using Framework.DomainDriven.Serialization; -using Framework.Persistent.Mapping; namespace Framework.Authorization.Domain; @@ -12,7 +11,6 @@ namespace Framework.Authorization.Domain; /// /// Типы, в контексте которых выдаются права пользователю, записываются вручную на уровне SQL в базу конкретной системы /// -[IgnoreHbmMapping] public class SecurityContextType : BaseDirectory { /// diff --git a/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Generated.Framework.Authorization.Domain.hbm.xml b/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Generated.Framework.Authorization.Domain.hbm.xml deleted file mode 100644 index 481de6884..000000000 --- a/src/_Authorization/Framework.Authorization.Generated.DAL.NHibernate/Mapping/Generated.Framework.Authorization.Domain.hbm.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/src/_Authorization/Framework.Authorization.TestGenerate/Configurations/ServerGenerationEnvironment.cs b/src/_Authorization/Framework.Authorization.TestGenerate/Configurations/ServerGenerationEnvironment.cs index c56c50de4..f31c0c5c9 100644 --- a/src/_Authorization/Framework.Authorization.TestGenerate/Configurations/ServerGenerationEnvironment.cs +++ b/src/_Authorization/Framework.Authorization.TestGenerate/Configurations/ServerGenerationEnvironment.cs @@ -48,7 +48,7 @@ public ServerGenerationEnvironment(DatabaseName databaseName) /// DatabaseName - Берётся из namespace'а сборки, которая сдержит тип PersistentDomainObjectBase (метод GetTargetSystemName); /// Types - Список доменных объектов. Это все типы наследованные от PersistentDomainObjectBase той сборки, в которой содеержится PersistentDomainObjectBase. /// - public MappingSettings MappingSettings => new MappingSettings(this.DAL.GetMappingGenerators().Select(mg => mg.Generate()), this.DatabaseName, this.DatabaseName.ToDefaultAudit()); + public MappingSettings MappingSettings => new MappingSettings(this.DatabaseName, this.DatabaseName.ToDefaultAudit()); public DatabaseName DatabaseName { get; } @@ -56,7 +56,7 @@ public ServerGenerationEnvironment(DatabaseName databaseName) public MappingSettings GetMappingSettings(DatabaseName dbName, AuditDatabaseName dbAuditName) { - return new MappingSettings(this.DAL.GetMappingGenerators().Select(mg => mg.Generate()), dbName, dbAuditName); + return new MappingSettings(dbName, dbAuditName); } public MappingSettings GetMappingSettingsWithoutAudit(DatabaseName dbName) diff --git a/src/_Authorization/Framework.Authorization.TestGenerate/Framework.Authorization.TestGenerate.csproj b/src/_Authorization/Framework.Authorization.TestGenerate/Framework.Authorization.TestGenerate.csproj index ee057f5b8..5b36f7407 100644 --- a/src/_Authorization/Framework.Authorization.TestGenerate/Framework.Authorization.TestGenerate.csproj +++ b/src/_Authorization/Framework.Authorization.TestGenerate/Framework.Authorization.TestGenerate.csproj @@ -17,6 +17,8 @@ + + diff --git a/src/_Authorization/Framework.Authorization.TestGenerate/ServerGenerators.DB.cs b/src/_Authorization/Framework.Authorization.TestGenerate/ServerGenerators.DB.cs index d47352f4d..52b8703dd 100644 --- a/src/_Authorization/Framework.Authorization.TestGenerate/ServerGenerators.DB.cs +++ b/src/_Authorization/Framework.Authorization.TestGenerate/ServerGenerators.DB.cs @@ -1,4 +1,5 @@ -using Framework.DomainDriven; +using Framework.Authorization.Generated.DAL.NHibernate; +using Framework.DomainDriven; using Framework.DomainDriven.DBGenerator; using Framework.DomainDriven.NHibernate; @@ -38,31 +39,7 @@ public string GenerateDB( bool preserveSchemaDatabase = false, DbUserCredential credentials = null) { - var generator = new DBGenerator(this.Environment.GetMappingSettings(databaseName, auditDatabaseName)); - var result = generator.Generate( - serverName, - mode: mode, - generatorMode: generatorMode, - migrationScriptFolderPaths: migrationScriptFolderPaths, - auditMigrationScriptFolderPaths: auditMigrationScriptFolderPaths, - preserveSchemaDatabase: preserveSchemaDatabase, - credentials: credentials); - - var lines = result.ToNewLinesCombined(); - return lines; - } - - public string GenerateDB( - MappingSettings mappingSettings, - string serverName, - DatabaseScriptGeneratorMode generatorMode = DatabaseScriptGeneratorMode.AutoGenerateUpdateChangeTypeScript, - DBGenerateScriptMode mode = DBGenerateScriptMode.AppliedOnTargetDatabase, - IEnumerable migrationScriptFolderPaths = null, - IEnumerable auditMigrationScriptFolderPaths = null, - bool preserveSchemaDatabase = false, - DbUserCredential credentials = null) - { - var generator = new DBGenerator(mappingSettings); + var generator = new DBGenerator(this.GetAuthMappingSettings(serverName, databaseName, auditDatabaseName)); var result = generator.Generate( serverName, mode: mode, @@ -75,4 +52,17 @@ public string GenerateDB( var lines = result.ToNewLinesCombined(); return lines; } + + private MappingSettings GetAuthMappingSettings(string serverName, DatabaseName dbName, AuditDatabaseName dbAuditName) => + this.Environment.GetMappingSettings(dbName, dbAuditName).AddInitializer( + new DefaultConfigurationInitializer( + new ManualDefaultConnectionStringSource( + $"Data Source={serverName};Initial Catalog={dbName}"), + new DefaultConfigurationInitializerSettings + { + FluentAssemblyList = + [ + typeof(AuthorizationMappingSettings).Assembly + ] + })); } diff --git a/src/_Authorization/Framework.Authorization.TestGenerate/ServerGenerators.cs b/src/_Authorization/Framework.Authorization.TestGenerate/ServerGenerators.cs index ba655a8f7..d7410ab9d 100644 --- a/src/_Authorization/Framework.Authorization.TestGenerate/ServerGenerators.cs +++ b/src/_Authorization/Framework.Authorization.TestGenerate/ServerGenerators.cs @@ -23,8 +23,7 @@ public IEnumerable GenerateMain() { return this.GenerateBLLCore() .Concat(this.GenerateBLL()) - .Concat(this.GenerateServerDTO()) - .Concat(this.GenerateDAL()); + .Concat(this.GenerateServerDTO()); } [TestMethod] @@ -77,17 +76,4 @@ private IEnumerable GenerateServerDTO() "Authorization.Generated", this.CheckOutService); } - - [TestMethod] - public void GenerateDALTest() - { - this.GenerateDAL().ToList(); - } - - private IEnumerable GenerateDAL() - { - var generator = new DALFileGenerator(this.Environment.DAL); - - return generator.Generate(this.GeneratePath + @"/Framework.Authorization.Generated.DAL.NHibernate/Mapping", this.CheckOutService); - } } diff --git a/src/_Configuration/Framework.Configuration.Domain/CodeFirstSubscription.cs b/src/_Configuration/Framework.Configuration.Domain/CodeFirstSubscription.cs index 118bccce1..6200ea86a 100644 --- a/src/_Configuration/Framework.Configuration.Domain/CodeFirstSubscription.cs +++ b/src/_Configuration/Framework.Configuration.Domain/CodeFirstSubscription.cs @@ -13,7 +13,6 @@ namespace Framework.Configuration.Domain; /// [UniqueGroup] [NotAuditedClass] -[IgnoreHbmMapping] public class CodeFirstSubscription : AuditPersistentDomainObjectBase, ICodeObject { private readonly string code; diff --git a/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettings.cs b/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettings.cs index 2b1133ea2..050785e72 100644 --- a/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettings.cs +++ b/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettings.cs @@ -8,7 +8,6 @@ namespace Framework.Configuration.Domain; [NotAuditedClass] -[IgnoreHbmMapping] public class ControlSettings : BaseDirectory, IMaster, IMaster, diff --git a/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParam.cs b/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParam.cs index c31817ec1..c24994956 100644 --- a/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParam.cs +++ b/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParam.cs @@ -4,7 +4,6 @@ namespace Framework.Configuration.Domain; [NotAuditedClass] -[IgnoreHbmMapping] public class ControlSettingsParam : AuditPersistentDomainObjectBase, IMaster, IDetail, ITypeObject { private readonly ICollection controlSettingsParamValues = new List(); diff --git a/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParamValue.cs b/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParamValue.cs index 788ee6ff1..668ef4d73 100644 --- a/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParamValue.cs +++ b/src/_Configuration/Framework.Configuration.Domain/ControlSettings/ControlSettingsParamValue.cs @@ -6,7 +6,6 @@ namespace Framework.Configuration.Domain; [NotAuditedClass] -[IgnoreHbmMapping] public class ControlSettingsParamValue : AuditPersistentDomainObjectBase, IDetail { private readonly ControlSettingsParam controlSettingsParam; diff --git a/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectEvent.cs b/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectEvent.cs index 09c109b6d..df5049462 100644 --- a/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectEvent.cs +++ b/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectEvent.cs @@ -7,7 +7,6 @@ namespace Framework.Configuration.Domain; /// Событие над объектом (Save, Remove etc), сохраняемое в базу. /// [NotAuditedClass] -[IgnoreHbmMapping] public class DomainObjectEvent : AuditPersistentDomainObjectBase { private readonly QueueProgressStatus status; diff --git a/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectModification.cs b/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectModification.cs index c6e3f3715..afc3dc83d 100644 --- a/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectModification.cs +++ b/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectModification.cs @@ -10,7 +10,6 @@ namespace Framework.Configuration.Domain; /// [UniqueGroup] [NotAuditedClass] -[IgnoreHbmMapping] public class DomainObjectModification : AuditPersistentDomainObjectBase, ITypeObject, IVersionObject { private Guid domainObjectId; diff --git a/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectNotification.cs b/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectNotification.cs index 8b6bb7b9f..1e0a1ed8f 100644 --- a/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectNotification.cs +++ b/src/_Configuration/Framework.Configuration.Domain/DomainObjectQueue/DomainObjectNotification.cs @@ -7,7 +7,6 @@ namespace Framework.Configuration.Domain; /// Нотификация хранимая в бд /// [NotAuditedClass] -[IgnoreHbmMapping] public class DomainObjectNotification : AuditPersistentDomainObjectBase { private readonly QueueProgressStatus status; diff --git a/src/_Configuration/Framework.Configuration.Domain/ExceptionMessage.cs b/src/_Configuration/Framework.Configuration.Domain/ExceptionMessage.cs index 5846258c6..82519cf4a 100644 --- a/src/_Configuration/Framework.Configuration.Domain/ExceptionMessage.cs +++ b/src/_Configuration/Framework.Configuration.Domain/ExceptionMessage.cs @@ -13,7 +13,6 @@ namespace Framework.Configuration.Domain; /// Механизм Framework-а сохраняет все ошибки по всем системам, записывает их в базу и высылает на почту /// [NotAuditedClass] -[IgnoreHbmMapping] public class ExceptionMessage : AuditPersistentDomainObjectBase { private ExceptionMessage innerException; diff --git a/src/_Configuration/Framework.Configuration.Domain/Lock/GenericNamedLock.cs b/src/_Configuration/Framework.Configuration.Domain/Lock/GenericNamedLock.cs index af852d47c..3484a4f5c 100644 --- a/src/_Configuration/Framework.Configuration.Domain/Lock/GenericNamedLock.cs +++ b/src/_Configuration/Framework.Configuration.Domain/Lock/GenericNamedLock.cs @@ -8,5 +8,4 @@ namespace Framework.Configuration.Domain; /// [UniqueGroup] [NotAuditedClass] -[IgnoreHbmMapping] public class GenericNamedLock : BaseDirectory; diff --git a/src/_Configuration/Framework.Configuration.Domain/SentMessage.cs b/src/_Configuration/Framework.Configuration.Domain/SentMessage.cs index 28365734a..17cbb4594 100644 --- a/src/_Configuration/Framework.Configuration.Domain/SentMessage.cs +++ b/src/_Configuration/Framework.Configuration.Domain/SentMessage.cs @@ -7,7 +7,6 @@ namespace Framework.Configuration.Domain; /// Сообщение, отправленное пользователю /// [NotAuditedClass] -[IgnoreHbmMapping] public class SentMessage : AuditPersistentDomainObjectBase { private readonly string from; diff --git a/src/_Configuration/Framework.Configuration.Domain/Sequence.cs b/src/_Configuration/Framework.Configuration.Domain/Sequence.cs index 93577a08e..c767fb354 100644 --- a/src/_Configuration/Framework.Configuration.Domain/Sequence.cs +++ b/src/_Configuration/Framework.Configuration.Domain/Sequence.cs @@ -10,7 +10,6 @@ namespace Framework.Configuration.Domain; /// [UniqueGroup] [NotAuditedClass] -[IgnoreHbmMapping] public class Sequence : BaseDirectory, INumberObject { private long number; diff --git a/src/_Configuration/Framework.Configuration.Domain/SystemConstant.cs b/src/_Configuration/Framework.Configuration.Domain/SystemConstant.cs index 7534998f9..2db55f7e6 100644 --- a/src/_Configuration/Framework.Configuration.Domain/SystemConstant.cs +++ b/src/_Configuration/Framework.Configuration.Domain/SystemConstant.cs @@ -11,7 +11,6 @@ namespace Framework.Configuration.Domain; /// [UniqueGroup] [NotAuditedClass] -[IgnoreHbmMapping] public class SystemConstant : AuditPersistentDomainObjectBase, ICodeObject, diff --git a/src/_Configuration/Framework.Configuration.Domain/TargetSystem/TargetSystem.cs b/src/_Configuration/Framework.Configuration.Domain/TargetSystem/TargetSystem.cs index eb1f2690f..b705f0971 100644 --- a/src/_Configuration/Framework.Configuration.Domain/TargetSystem/TargetSystem.cs +++ b/src/_Configuration/Framework.Configuration.Domain/TargetSystem/TargetSystem.cs @@ -13,7 +13,6 @@ namespace Framework.Configuration.Domain; /// [UniqueGroup] [NotAuditedClass] -[IgnoreHbmMapping] public class TargetSystem : BaseDirectory, IMaster { private readonly ICollection domainTypes = new List(); diff --git a/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainType.cs b/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainType.cs index 9eeb2c2e3..4f5b5ccd1 100644 --- a/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainType.cs +++ b/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainType.cs @@ -10,7 +10,6 @@ namespace Framework.Configuration.Domain; /// Описание доменного типа целевой системы /// [NotAuditedClass] -[IgnoreHbmMapping] public class DomainType : BaseDirectory, ITargetSystemElement, IDetail, IMaster, IDomainType { private readonly ICollection eventOperations = new List(); diff --git a/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainTypeEventOperation.cs b/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainTypeEventOperation.cs index 3b641e466..d8c5f5a1d 100644 --- a/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainTypeEventOperation.cs +++ b/src/_Configuration/Framework.Configuration.Domain/TargetSystem/Type/DomainTypeEventOperation.cs @@ -8,7 +8,6 @@ namespace Framework.Configuration.Domain; /// Операция доменного типа /// [NotAuditedClass] -[IgnoreHbmMapping] public class DomainTypeEventOperation : BaseDirectory, IDetail { private readonly DomainType domainType; diff --git a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Generated.Framework.Configuration.Domain.hbm.xml b/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Generated.Framework.Configuration.Domain.hbm.xml deleted file mode 100644 index 2f98c9a2d..000000000 --- a/src/_Configuration/Framework.Configuration.Generated.DAL.NHibernate/Mapping/Generated.Framework.Configuration.Domain.hbm.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/src/_Configuration/Framework.Configuration.TestGenerate/Configurations/ServerGenerationEnvironment.cs b/src/_Configuration/Framework.Configuration.TestGenerate/Configurations/ServerGenerationEnvironment.cs index 16c8a600c..2c57a0620 100644 --- a/src/_Configuration/Framework.Configuration.TestGenerate/Configurations/ServerGenerationEnvironment.cs +++ b/src/_Configuration/Framework.Configuration.TestGenerate/Configurations/ServerGenerationEnvironment.cs @@ -57,7 +57,7 @@ public ServerGenerationEnvironment(DatabaseName databaseName) public MappingSettings GetMappingSettings(DatabaseName dbName) { - return new MappingSettings(this.DAL.GetMappingGenerators().Select(mg => mg.Generate()), dbName); + return new MappingSettings(dbName); } public override IDomainTypeRootExtendedMetadata ExtendedMetadata { get; } = diff --git a/src/_Configuration/Framework.Configuration.TestGenerate/ServerGenerators.cs b/src/_Configuration/Framework.Configuration.TestGenerate/ServerGenerators.cs index 2af5dd3f2..abb726159 100644 --- a/src/_Configuration/Framework.Configuration.TestGenerate/ServerGenerators.cs +++ b/src/_Configuration/Framework.Configuration.TestGenerate/ServerGenerators.cs @@ -23,8 +23,7 @@ public IEnumerable GenerateMain() { return this.GenerateBLLCore() .Concat(this.GenerateBLL()) - .Concat(this.GenerateServerDTO()) - .Concat(this.GenerateDAL()); + .Concat(this.GenerateServerDTO()); } [TestMethod] @@ -46,12 +45,6 @@ private IEnumerable GenerateBLLCore() this.CheckOutService); } - [TestMethod] - public void GenerateBLLTest() - { - this.GenerateBLL().ToList(); - } - private IEnumerable GenerateBLL() { var generator = new BLLFileGenerator(this.Environment.BLL); @@ -77,17 +70,4 @@ private IEnumerable GenerateServerDTO() "Configuration.Generated", this.CheckOutService); } - - [TestMethod] - public void GenerateDALTest() - { - this.GenerateDAL().ToList(); - } - - private IEnumerable GenerateDAL() - { - var generator = new DALFileGenerator(this.Environment.DAL); - - return generator.Generate(this.GeneratePath + @"/Framework.Configuration.Generated.DAL.NHibernate/Mapping", this.CheckOutService); - } } diff --git a/src/_SampleSystem/_Tests/SampleSystem.DbGenerate/DbGeneratorTest.cs b/src/_SampleSystem/_Tests/SampleSystem.DbGenerate/DbGeneratorTest.cs index 2f13f0736..81710e6ba 100644 --- a/src/_SampleSystem/_Tests/SampleSystem.DbGenerate/DbGeneratorTest.cs +++ b/src/_SampleSystem/_Tests/SampleSystem.DbGenerate/DbGeneratorTest.cs @@ -140,8 +140,9 @@ private void GenerateAuthorizationDatabase( { string[] migrationScriptFolderPaths = null; var result = new Framework.Authorization.TestGenerate.ServerGenerators().GenerateDB( - GetAuthMappingSettings(serverName, mainDatabaseName, auditDatabaseName), serverName, + mainDatabaseName, + auditDatabaseName, migrationScriptFolderPaths: migrationScriptFolderPaths, mode: mode, preserveSchemaDatabase: preserveSchemaDatabase, @@ -150,19 +151,6 @@ private void GenerateAuthorizationDatabase( Console.WriteLine(result); } - private static MappingSettings GetAuthMappingSettings(string serverName, DatabaseName dbName, AuditDatabaseName dbAuditName) => - Framework.Authorization.TestGenerate.ServerGenerationEnvironment.Default.GetMappingSettings(dbName, dbAuditName).AddInitializer( - new DefaultConfigurationInitializer( - new ManualDefaultConnectionStringSource( - $"Data Source={serverName};Initial Catalog={dbName.Name};Application Name=SampleSystem"), - new DefaultConfigurationInitializerSettings - { - FluentAssemblyList = - [ - typeof(AuthorizationMappingSettings).Assembly - ] - })); - private MappingSettings GetMappingSettings(string serverName, DatabaseName dbName, AuditDatabaseName dbAuditName) { var initMappingAction = this.environment.DAL.GetMappingGenerators() From 1bc3b337529fccfda9364accc0bf32c343df8542 Mon Sep 17 00:00:00 2001 From: VVTsyk Date: Thu, 16 Jan 2025 18:23:52 +0100 Subject: [PATCH 4/4] clear usings --- .../_Tests/SampleSystem.DbGenerate/DbGeneratorTest.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/_SampleSystem/_Tests/SampleSystem.DbGenerate/DbGeneratorTest.cs b/src/_SampleSystem/_Tests/SampleSystem.DbGenerate/DbGeneratorTest.cs index 81710e6ba..0950689f8 100644 --- a/src/_SampleSystem/_Tests/SampleSystem.DbGenerate/DbGeneratorTest.cs +++ b/src/_SampleSystem/_Tests/SampleSystem.DbGenerate/DbGeneratorTest.cs @@ -1,5 +1,4 @@ -using Framework.Authorization.Generated.DAL.NHibernate; -using Framework.DomainDriven; +using Framework.DomainDriven; using Framework.DomainDriven.DBGenerator; using Framework.DomainDriven.NHibernate;