using System; using System.Collections.Generic; using System.Linq; using Kreta.DataAccess.Interfaces; using Kreta.Framework; using Kreta.Framework.Actions; using Kreta.Framework.Collections; using Kreta.Framework.Collections.Generic; using Kreta.Framework.Entities; using Kreta.Framework.Entities.Generic; using Kreta.Framework.Exceptions; namespace SDA.Kreta.Entities { /// /// Az UML modell DictionaryItemBaseNyelv entitásának megvalósítása. /// /// A kód teljes egészében generált, kézi módosítása nem megengedett! [Entity("DictionaryItemBaseNyelv")] // alapértelmezett EntityHistoryMode public class DictionaryItemBaseNyelv : Entity, IDictionaryItemBaseNyelv { internal protected DictionaryItemBaseNyelv() : base() { } public class AttributeInfo { public const string Name = "Name"; public const string Name_1 = "Name_1"; public const string Name_2 = "Name_2"; public const string Name_3 = "Name_3"; public const string Name_4 = "Name_4"; public const string NyelvId = "NyelvId"; public const string ShortName = "ShortName"; } public class AttributeLengthInfo { public const int NameLength = 255; public const int Name_1Length = 255; public const int Name_2Length = 255; public const int Name_3Length = 255; public const int Name_4Length = 255; public const int ShortNameLength = 30; } #region General private DictionaryItemBaseNyelvDA m_DA = new DictionaryItemBaseNyelvDA(); protected static DictionaryItemBaseNyelv FakeDictionaryItemBaseNyelv { get; set; } public static DictionaryItemBaseNyelv GiveAnInstance() { DictionaryItemBaseNyelv result = FakeDictionaryItemBaseNyelv == null ? new DictionaryItemBaseNyelv() : (DictionaryItemBaseNyelv)FakeDictionaryItemBaseNyelv.MemberwiseClone(); result.Reset(); result.SetDefaultData(); return result; } protected void SetDefaultData() { if (UserContext.Instance != null) { if (UserContext.Instance.IntezmenyId > 0) { IntezmenyId = UserContext.Instance.IntezmenyId; } if (UserContext.Instance.AktivTanevId > 0) { TanevId = UserContext.Instance.AktivTanevId; } m_State = EntityState.Uninitialized; } } protected override IEntityDataAccessor GetDataAccessor() { return m_DA; } protected internal virtual IEntityDataAccessor InheritedDA { get { return null; } } [Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")] public static IEntityCollection LoadAll() { return LoadWithFilter(""); } [Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")] public static IEntityCollection LoadAll(ColumnFilterMode columnFilterMode, IEnumerable columns) { return LoadWithFilter("", columnFilterMode, columns); } [Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")] public static IEntityCollection LoadWithFilter(string filter, Dictionary commandParameters = null) { var result = new EntityCollection(); new DictionaryItemBaseNyelvDA().LoadWithFilter(result, filter, commandParameters); return result; } [Obsolete("Ezt ne használjátok, mert mindenhova bele kellene fogalmazni a tanév szűrést is! Meg fog majd szűnni!")] public static IEntityCollection LoadWithFilter(string filter, ColumnFilterMode columnFilterMode, IEnumerable columns, Dictionary commandParameters = null) { var result = new EntityCollection(); new DictionaryItemBaseNyelvDA().LoadWithFilter(result, filter, columnFilterMode, columns, commandParameters); return result; } protected override void StoreOriginalValues() { base.StoreOriginalValues(); OriginalValues.Add("Name", (object)m_Name); OriginalValues.Add("Name_1", (Name_1 == null ? (object)DBNull.Value : (object)m_Name_1)); OriginalValues.Add("Name_2", (Name_2 == null ? (object)DBNull.Value : (object)m_Name_2)); OriginalValues.Add("Name_3", (Name_3 == null ? (object)DBNull.Value : (object)m_Name_3)); OriginalValues.Add("Name_4", (Name_4 == null ? (object)DBNull.Value : (object)m_Name_4)); OriginalValues.Add("NyelvId", (object)m_NyelvId); OriginalValues.Add("ShortName", (ShortName == null ? (object)DBNull.Value : (object)m_ShortName)); OriginalValues.Add("DictionaryItemBaseId", (m_DictionaryItemBaseId < 0 ? (object)DBNull.Value : (object)m_DictionaryItemBaseId)); OriginalValues.Add("IntezmenyId", (m_IntezmenyId < 0 ? (object)DBNull.Value : (object)m_IntezmenyId)); OriginalValues.Add("TanevId", (m_TanevId < 0 ? (object)DBNull.Value : (object)m_TanevId)); } #endregion #region Ellenőrzés protected override void Validate(bool skipValidateAttributes = false) { base.Validate(); if (!skipValidateAttributes) { // korlátos hosszúságú mezők ellenőrzése... if (m_Name != null && m_Name.Length > 255) { throw new InvalidEntityAttributeException("DictionaryItemBaseNyelv", "Name", EntityAttributeError.TooLong); } if (m_Name_1 != null && m_Name_1.Length > 255) { throw new InvalidEntityAttributeException("DictionaryItemBaseNyelv", "Name_1", EntityAttributeError.TooLong); } if (m_Name_2 != null && m_Name_2.Length > 255) { throw new InvalidEntityAttributeException("DictionaryItemBaseNyelv", "Name_2", EntityAttributeError.TooLong); } if (m_Name_3 != null && m_Name_3.Length > 255) { throw new InvalidEntityAttributeException("DictionaryItemBaseNyelv", "Name_3", EntityAttributeError.TooLong); } if (m_Name_4 != null && m_Name_4.Length > 255) { throw new InvalidEntityAttributeException("DictionaryItemBaseNyelv", "Name_4", EntityAttributeError.TooLong); } if (m_ShortName != null && m_ShortName.Length > 30) { throw new InvalidEntityAttributeException("DictionaryItemBaseNyelv", "ShortName", EntityAttributeError.TooLong); } } // kötelező asszociációk ellenőrzése... if (m_DictionaryItemBaseId == -1) { throw new InvalidEntityAttributeException("DictionaryItemBaseNyelv", "DictionaryItemBaseId", EntityAttributeError.Empty); } if (m_IntezmenyId == -1) { throw new InvalidEntityAttributeException("DictionaryItemBaseNyelv", "IntezmenyId", EntityAttributeError.Empty); } if (m_TanevId == -1) { throw new InvalidEntityAttributeException("DictionaryItemBaseNyelv", "TanevId", EntityAttributeError.Empty); } } #endregion #region Alaphelyzetbe állítás protected override void Reset() { base.Reset(); // alaphelyzetbe állítjuk az egyszerű mezőket this.m_Name = ""; this.m_Name_1 = null; this.m_Name_2 = null; this.m_Name_3 = null; this.m_Name_4 = null; this.m_NyelvId = -1; this.m_ShortName = null; // alaphelyzetbe állítjuk az asszociációkból származó mezőket this.m_DictionaryItemBaseId = -1; this.m_DictionaryItemBase = null; // Entity this.m_IntezmenyId = -1; this.m_Intezmeny = null; // Entity this.m_TanevId = -1; this.m_Tanev = null; // Entity } #endregion protected override void DeAssociateBeforeDelete(bool runHandler = false) { // Nem kaszkád törölhető asszociációk ellenőrzése, hogy üresek-e... // DictionaryItemBase esetében mi mutatunk a másikra: startrole: 0..*, endrole: 1 // Intezmeny esetében mi mutatunk a másikra: startrole: *, endrole: 1 // Tanev esetében mi mutatunk a másikra: startrole: *, endrole: 1 // kaszkád törlések... } #region Mezők és tulajdonságok #region Egyszerű mezők #region Name protected internal string m_Name; /// /// Nincs definiálva megjegyzés. /// [EntityProperty("Name", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Name { get { return m_Name; } set { CheckModifyable(); if (m_Name == value) return; m_Name = value; FieldModified("Name", value); } } #endregion #region Name_1 protected internal string m_Name_1; /// /// Nincs definiálva megjegyzés. /// [EntityProperty("Name_1", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Name_1 { get { return m_Name_1; } set { CheckModifyable(); if (m_Name_1 == value) return; m_Name_1 = value; FieldModified("Name_1", value); } } #endregion #region Name_2 protected internal string m_Name_2; /// /// Nincs definiálva megjegyzés. /// [EntityProperty("Name_2", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Name_2 { get { return m_Name_2; } set { CheckModifyable(); if (m_Name_2 == value) return; m_Name_2 = value; FieldModified("Name_2", value); } } #endregion #region Name_3 protected internal string m_Name_3; /// /// Nincs definiálva megjegyzés. /// [EntityProperty("Name_3", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Name_3 { get { return m_Name_3; } set { CheckModifyable(); if (m_Name_3 == value) return; m_Name_3 = value; FieldModified("Name_3", value); } } #endregion #region Name_4 protected internal string m_Name_4; /// /// Nincs definiálva megjegyzés. /// [EntityProperty("Name_4", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string Name_4 { get { return m_Name_4; } set { CheckModifyable(); if (m_Name_4 == value) return; m_Name_4 = value; FieldModified("Name_4", value); } } #endregion #region NyelvId protected internal int /* DictionaryItem */ m_NyelvId; /// /// Nincs definiálva megjegyzés. /// [EntityProperty("NyelvId", EntityPropertyBaseType.ValueType, typeof(int /* DictionaryItem */), EntityCopyMethod.ShallowCopy)] [EntityDictionaryItemProperty("NyelvId", "Anyanyelv", typeof(SDA.Kreta.Entities.Anyanyelv))] public virtual int /* DictionaryItem */ NyelvId { get { return m_NyelvId; } set { CheckModifyable(); if (m_NyelvId == value) return; m_NyelvId = value; FieldModified("NyelvId", value); } } #endregion #region ShortName protected internal string m_ShortName; /// /// Nincs definiálva megjegyzés. /// [EntityProperty("ShortName", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)] public virtual string ShortName { get { return m_ShortName; } set { CheckModifyable(); if (m_ShortName == value) return; m_ShortName = value; FieldModified("ShortName", value); } } #endregion #endregion #region Asszociációkkal kapcsolatos dolgok #region DictionaryItemBaseNyelv (0..*) -> DictionaryItemBase (1) protected internal int m_DictionaryItemBaseId = -1; /// /// A(z) DictionaryItemBase asszociáció végpontjának ID-ja. /// /// /// - Insert() előtt célszerű kitölteni /// - Update() nincs rá hatással: ezt a mezőt nem frissíti /// - LoadByID() felhozza ezt a mezőt /// public virtual int DictionaryItemBaseId { get { return InternalDictionaryItemBaseId; } set { InternalDictionaryItemBaseId = value; } } /// /// Ez egy külön bejárat a DA számára /// internal int InternalDictionaryItemBaseId { get { if (m_DictionaryItemBase != null) { return m_DictionaryItemBase.ID; } else { return m_DictionaryItemBaseId;// XXX az meg nem teljesen OK } } set { CheckModifyable(); if (m_DictionaryItemBaseId != value) { m_DictionaryItemBaseId = value; m_DictionaryItemBase = null; FieldModified("DictionaryItemBaseId", value); } } } /// /// Ez egy külön bejárat a DA számára /// internal void ModifyDictionaryItemBase(DictionaryItemBase value) { m_DictionaryItemBaseId = value != null ? value.ID : -1; m_DictionaryItemBase = value; FieldModified("DictionaryItemBaseId", value != null ? (object)value.ID : DBNull.Value); } protected internal void SetDictionaryItemBase(DictionaryItemBase value) { m_DictionaryItemBase = value; if (value != null) { m_DictionaryItemBaseId = value.ID; } else { m_DictionaryItemBaseId = -1; } } protected DictionaryItemBase m_DictionaryItemBase = null; IDictionaryItemBase IDictionaryItemBaseNyelv.DictionaryItemBase { get { return DictionaryItemBase; } set { DictionaryItemBase = value as DictionaryItemBase; } } /// /// Nincs definiálva megjegyzés. /// /// /// Az UML modellben szereplő DictionaryItemBaseNyelv és DictionaryItemBase entitások közötti asszociáció megvalósítása. /// [EntityProperty("DictionaryItemBase", EntityPropertyBaseType.Entity, typeof(DictionaryItemBase), EntityCopyMethod.ShallowCopy)] public virtual DictionaryItemBase DictionaryItemBase { get { if ((m_DictionaryItemBase == null) && (m_DictionaryItemBaseId != -1)) { SDA.Kreta.Entities.DictionaryItemBase partner = SDA.Kreta.Entities.DictionaryItemBase.GiveAnInstance(); partner.LoadByID(m_DictionaryItemBaseId); this.SetDictionaryItemBase(partner); } // természetesen null-t adunk vissza, ha nem tudtunk felhozni semmit return m_DictionaryItemBase; } set { CheckModifyable(); if (value != null) { if ((m_DictionaryItemBase == null) || (value.ID != m_DictionaryItemBase.ID)) { if (value.State != EntityState.Initialized) { throw new EntityStateException(value.State); } if ((this.State != EntityState.New)) { // Lista van a másik oldalon, úgyhogy a lista DA-ját használjuk SDA.Kreta.Entities.DictionaryItemBase_DictionaryItemBaseNyelv_DA da = new DictionaryItemBase_DictionaryItemBaseNyelv_DA(value); da.AddItem(this); this.SetDictionaryItemBase(value); } else { this.SetDictionaryItemBase(value); } FieldModified("DictionaryItemBaseId", value.ID); } } else { // ki kell törölni a kapcsolatot az adatbázisban this.SetDictionaryItemBase(null); UpdateAssociations(); FieldModified("DictionaryItemBaseId", DBNull.Value); } } } #endregion #region DictionaryItemBaseNyelv (*) -> Intezmeny (1) protected internal int m_IntezmenyId = -1; /// /// A(z) Intezmeny asszociáció végpontjának ID-ja. /// /// /// - Insert() előtt célszerű kitölteni /// - Update() nincs rá hatással: ezt a mezőt nem frissíti /// - LoadByID() felhozza ezt a mezőt /// public virtual int IntezmenyId { get { return InternalIntezmenyId; } set { InternalIntezmenyId = value; } } /// /// Ez egy külön bejárat a DA számára /// internal int InternalIntezmenyId { get { if (m_Intezmeny != null) { return m_Intezmeny.ID; } else { return m_IntezmenyId;// XXX az meg nem teljesen OK } } set { CheckModifyable(); if (m_IntezmenyId != value) { m_IntezmenyId = value; m_Intezmeny = null; FieldModified("IntezmenyId", value); } } } /// /// Ez egy külön bejárat a DA számára /// internal void ModifyIntezmeny(Intezmeny value) { m_IntezmenyId = value != null ? value.ID : -1; m_Intezmeny = value; FieldModified("IntezmenyId", value != null ? (object)value.ID : DBNull.Value); } protected internal void SetIntezmeny(Intezmeny value) { m_Intezmeny = value; if (value != null) { m_IntezmenyId = value.ID; } else { m_IntezmenyId = -1; } } protected Intezmeny m_Intezmeny = null; IIntezmeny IDictionaryItemBaseNyelv.Intezmeny { get { return Intezmeny; } set { Intezmeny = value as Intezmeny; } } /// /// Nincs definiálva megjegyzés. /// /// /// Az UML modellben szereplő DictionaryItemBaseNyelv és Intezmeny entitások közötti asszociáció megvalósítása. /// [EntityProperty("Intezmeny", EntityPropertyBaseType.Entity, typeof(Intezmeny), EntityCopyMethod.ShallowCopy)] public virtual Intezmeny Intezmeny { get { if ((m_Intezmeny == null) && (m_IntezmenyId != -1)) { SDA.Kreta.Entities.Intezmeny partner = SDA.Kreta.Entities.Intezmeny.GiveAnInstance(); partner.LoadByID(m_IntezmenyId); this.SetIntezmeny(partner); } // természetesen null-t adunk vissza, ha nem tudtunk felhozni semmit return m_Intezmeny; } set { CheckModifyable(); if (value != null) { if ((m_Intezmeny == null) || (value.ID != m_Intezmeny.ID)) { if (value.State != EntityState.Initialized) { throw new EntityStateException(value.State); } if ((this.State != EntityState.New)) { // Lista van a másik oldalon, úgyhogy a lista DA-ját használjuk SDA.Kreta.Entities.Intezmeny_DictionaryItemBaseNyelv_DA da = new Intezmeny_DictionaryItemBaseNyelv_DA(value); da.AddItem(this); this.SetIntezmeny(value); } else { this.SetIntezmeny(value); } FieldModified("IntezmenyId", value.ID); } } else { // ki kell törölni a kapcsolatot az adatbázisban this.SetIntezmeny(null); UpdateAssociations(); FieldModified("IntezmenyId", DBNull.Value); } } } #endregion #region DictionaryItemBaseNyelv (*) -> Tanev (1) protected internal int m_TanevId = -1; /// /// A(z) Tanev asszociáció végpontjának ID-ja. /// /// /// - Insert() előtt célszerű kitölteni /// - Update() nincs rá hatással: ezt a mezőt nem frissíti /// - LoadByID() felhozza ezt a mezőt /// public virtual int TanevId { get { return InternalTanevId; } set { InternalTanevId = value; } } /// /// Ez egy külön bejárat a DA számára /// internal int InternalTanevId { get { if (m_Tanev != null) { return m_Tanev.ID; } else { return m_TanevId;// XXX az meg nem teljesen OK } } set { CheckModifyable(); if (m_TanevId != value) { m_TanevId = value; m_Tanev = null; FieldModified("TanevId", value); } } } /// /// Ez egy külön bejárat a DA számára /// internal void ModifyTanev(Tanev value) { m_TanevId = value != null ? value.ID : -1; m_Tanev = value; FieldModified("TanevId", value != null ? (object)value.ID : DBNull.Value); } protected internal void SetTanev(Tanev value) { m_Tanev = value; if (value != null) { m_TanevId = value.ID; } else { m_TanevId = -1; } } protected Tanev m_Tanev = null; ITanev IDictionaryItemBaseNyelv.Tanev { get { return Tanev; } set { Tanev = value as Tanev; } } /// /// Nincs definiálva megjegyzés. /// /// /// Az UML modellben szereplő DictionaryItemBaseNyelv és Tanev entitások közötti asszociáció megvalósítása. /// [EntityProperty("Tanev", EntityPropertyBaseType.Entity, typeof(Tanev), EntityCopyMethod.ShallowCopy)] public virtual Tanev Tanev { get { if ((m_Tanev == null) && (m_TanevId != -1)) { SDA.Kreta.Entities.Tanev partner = SDA.Kreta.Entities.Tanev.GiveAnInstance(); partner.LoadByID(m_TanevId); this.SetTanev(partner); } // természetesen null-t adunk vissza, ha nem tudtunk felhozni semmit return m_Tanev; } set { CheckModifyable(); if (value != null) { if ((m_Tanev == null) || (value.ID != m_Tanev.ID)) { if (value.State != EntityState.Initialized) { throw new EntityStateException(value.State); } if ((this.State != EntityState.New)) { // Lista van a másik oldalon, úgyhogy a lista DA-ját használjuk SDA.Kreta.Entities.Tanev_DictionaryItemBaseNyelv_DA da = new Tanev_DictionaryItemBaseNyelv_DA(value); da.AddItem(this); this.SetTanev(value); } else { this.SetTanev(value); } FieldModified("TanevId", value.ID); } } else { // ki kell törölni a kapcsolatot az adatbázisban this.SetTanev(null); UpdateAssociations(); FieldModified("TanevId", DBNull.Value); } } } #endregion #endregion #endregion } }