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 CsoportTipus_FoglalkozasTipus 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("CsoportTipus_FoglalkozasTipus")] // alapértelmezett EntityHistoryMode public class CsoportTipus_FoglalkozasTipus : Entity, ICsoportTipus_FoglalkozasTipus { internal protected CsoportTipus_FoglalkozasTipus() : base() { } public class AttributeInfo { public const string Csoportbontott = "Csoportbontott"; } public class AttributeLengthInfo { } #region General private CsoportTipus_FoglalkozasTipusDA m_DA = new CsoportTipus_FoglalkozasTipusDA(); protected static CsoportTipus_FoglalkozasTipus FakeCsoportTipus_FoglalkozasTipus { get; set; } public static CsoportTipus_FoglalkozasTipus GiveAnInstance() { CsoportTipus_FoglalkozasTipus result = FakeCsoportTipus_FoglalkozasTipus == null ? new CsoportTipus_FoglalkozasTipus() : (CsoportTipus_FoglalkozasTipus)FakeCsoportTipus_FoglalkozasTipus.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 CsoportTipus_FoglalkozasTipusDA().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 CsoportTipus_FoglalkozasTipusDA().LoadWithFilter(result, filter, columnFilterMode, columns, commandParameters); return result; } protected override void StoreOriginalValues() { base.StoreOriginalValues(); OriginalValues.Add("Csoportbontott", (Csoportbontott == null ? (object)DBNull.Value : (object)m_Csoportbontott)); OriginalValues.Add("IntezmenyId", (m_IntezmenyId < 0 ? (object)DBNull.Value : (object)m_IntezmenyId)); OriginalValues.Add("TanevId", (m_TanevId < 0 ? (object)DBNull.Value : (object)m_TanevId)); OriginalValues.Add("CsoportTipusId", m_CsoportTipusId); OriginalValues.Add("FoglalkozasTipusId", m_FoglalkozasTipusId); } #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... } // kötelező asszociációk ellenőrzése... if (m_IntezmenyId == -1) { throw new InvalidEntityAttributeException("CsoportTipus_FoglalkozasTipus", "IntezmenyId", EntityAttributeError.Empty); } if (m_TanevId == -1) { throw new InvalidEntityAttributeException("CsoportTipus_FoglalkozasTipus", "TanevId", EntityAttributeError.Empty); } if (this.FoglalkozasTipusId == -1) { throw new InvalidEntityAttributeException("CsoportTipus_FoglalkozasTipus", "FoglalkozasTipusId", EntityAttributeError.Empty); } if (this.CsoportTipusId == -1) { throw new InvalidEntityAttributeException("CsoportTipus_FoglalkozasTipus", "CsoportTipusId", EntityAttributeError.Empty); } } #endregion #region Alaphelyzetbe állítás protected override void Reset() { base.Reset(); // alaphelyzetbe állítjuk az egyszerű mezőket this.m_Csoportbontott = null; // alaphelyzetbe állítjuk az asszociációkból származó mezőket this.m_CsoportTipusId = -1; // ID this.m_FoglalkozasTipusId = -1; // ID 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... // 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 Csoportbontott protected internal bool? m_Csoportbontott; /// /// Nincs definiálva megjegyzés. /// [EntityProperty("Csoportbontott", EntityPropertyBaseType.ValueType, typeof(bool), EntityCopyMethod.ShallowCopy)] public virtual bool? Csoportbontott { get { return m_Csoportbontott; } set { CheckModifyable(); if (m_Csoportbontott == value) return; m_Csoportbontott = value; FieldModified("Csoportbontott", value); } } #endregion #endregion #region Asszociációkkal kapcsolatos dolgok #region CsoportTipus (*) -> FoglalkozasTipus (*) CsoportTipus_FoglalkozasTipus public void DeleteByCsoportTipusAndFoglalkozasTipus(int startId, int endId) { DeAssociateBeforeDelete(); m_DA.DeleteByCsoportTipusAndFoglalkozasTipus(startId, endId); } public void DeleteByFoglalkozasTipusAndCsoportTipus(int startId, int endId) { DeAssociateBeforeDelete(); m_DA.DeleteByCsoportTipusAndFoglalkozasTipus(endId, startId); } protected internal int m_CsoportTipusId; protected internal CsoportTipus m_CsoportTipus = null; /// /// Csak akkor használhatod, ha pontosan tudod, hogy mit csinál és hogyan, és /// milyen mellékhatásai lehetnek! /// public int CsoportTipusId { get { return m_CsoportTipusId; } set { m_CsoportTipusId = value; FieldModified("CsoportTipusId", value); } } public bool LoadByCsoportTipus(CsoportTipus entity, FoglalkozasTipus partner) { if (m_DA.LoadByCsoportTipus(entity, partner, this) == true) { SetLoaded(); return true; } else { return false; } } ICsoportTipus ICsoportTipus_FoglalkozasTipus.CsoportTipus { get { return CsoportTipus; } set { CsoportTipus = value as CsoportTipus; } } /// /// Nincs definiálva megjegyzés. /// /// /// Az entitás szerepel a(z) 'CsoportTipus (*) -> FoglalkozasTipus (*)' asszociációban, mint asszociációs osztály. /// [EntityProperty("CsoportTipus", EntityPropertyBaseType.Entity, typeof(CsoportTipus), EntityCopyMethod.ShallowCopy)] public CsoportTipus CsoportTipus { get { if (m_CsoportTipusId == -1) { return null; } if (m_CsoportTipus == null || m_CsoportTipus.ID != m_CsoportTipusId) { m_CsoportTipus = SDA.Kreta.Entities.CsoportTipus.GiveAnInstance(); m_CsoportTipus.LoadByID(m_CsoportTipusId); } return m_CsoportTipus; } set { m_CsoportTipus = value; CsoportTipusId = value.ID; if (this.State != EntityState.New) { UpdateAssociations(true); } FieldModified("CsoportTipusId", value.ID); } } protected internal int m_FoglalkozasTipusId; protected internal FoglalkozasTipus m_FoglalkozasTipus = null; /// /// Csak akkor használhatod, ha pontosan tudod, hogy mit csinál és hogyan, és /// milyen mellékhatásai lehetnek! /// public int FoglalkozasTipusId { get { return this.m_FoglalkozasTipusId; } set { this.m_FoglalkozasTipusId = value; FieldModified("FoglalkozasTipusId", value); } } public bool LoadByFoglalkozasTipus(FoglalkozasTipus entity, CsoportTipus partner) { if (this.m_DA.LoadByFoglalkozasTipus(entity, partner, this) == true) { this.SetState(EntityState.Initialized); return true; } else { return false; } } IFoglalkozasTipus ICsoportTipus_FoglalkozasTipus.FoglalkozasTipus { get { return FoglalkozasTipus; } set { FoglalkozasTipus = value as FoglalkozasTipus; } } /// /// Nincs definiálva megjegyzés. /// /// /// Az entitás szerepel a(z) 'CsoportTipus (*) -> FoglalkozasTipus (*)' asszociációban, mint asszociációs osztály. /// [EntityProperty("FoglalkozasTipus", EntityPropertyBaseType.Entity, typeof(FoglalkozasTipus), EntityCopyMethod.ShallowCopy)] public FoglalkozasTipus FoglalkozasTipus { get { if (m_FoglalkozasTipusId == -1) { return null; } if (m_FoglalkozasTipus == null || m_FoglalkozasTipus.ID != m_FoglalkozasTipusId) { m_FoglalkozasTipus = SDA.Kreta.Entities.FoglalkozasTipus.GiveAnInstance(); m_FoglalkozasTipus.LoadByID(m_FoglalkozasTipusId); } return m_FoglalkozasTipus; } set { m_FoglalkozasTipus = value; this.FoglalkozasTipusId = value.ID; if (this.State != EntityState.New) { UpdateAssociations(true); } FieldModified("FoglalkozasTipusId", value.ID); } } #endregion #region CsoportTipus_FoglalkozasTipus (*) -> 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 ICsoportTipus_FoglalkozasTipus.Intezmeny { get { return Intezmeny; } set { Intezmeny = value as Intezmeny; } } /// /// Nincs definiálva megjegyzés. /// /// /// Az UML modellben szereplő CsoportTipus_FoglalkozasTipus é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_CsoportTipus_FoglalkozasTipus_DA da = new Intezmeny_CsoportTipus_FoglalkozasTipus_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 CsoportTipus_FoglalkozasTipus (*) -> 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 ICsoportTipus_FoglalkozasTipus.Tanev { get { return Tanev; } set { Tanev = value as Tanev; } } /// /// Nincs definiálva megjegyzés. /// /// /// Az UML modellben szereplő CsoportTipus_FoglalkozasTipus é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_CsoportTipus_FoglalkozasTipus_DA da = new Tanev_CsoportTipus_FoglalkozasTipus_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 } }