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 Merohely 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("Merohely")]
// alapértelmezett EntityHistoryMode
public class Merohely : Entity, IMerohely
{
internal protected Merohely()
: base()
{
}
public class AttributeInfo
{
public const string MeroallasFrissiteseSzukseges = "MeroallasFrissiteseSzukseges";
public const string MerohelyTipusId = "MerohelyTipusId";
public const string Nev = "Nev";
public const string MerooraAzonosito = "MerooraAzonosito";
public const string EgyediAzonosito = "EgyediAzonosito";
}
public class AttributeLengthInfo
{
public const int NevLength = 2147483647;
public const int MerooraAzonositoLength = 100;
}
#region General
private MerohelyDA m_DA = new MerohelyDA();
protected static Merohely FakeMerohely { get; set; }
public static Merohely GiveAnInstance()
{
Merohely result = FakeMerohely == null
? new Merohely()
: (Merohely)FakeMerohely.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 MerohelyDA().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 MerohelyDA().LoadWithFilter(result, filter, columnFilterMode, columns, commandParameters);
return result;
}
protected override void StoreOriginalValues()
{
base.StoreOriginalValues();
OriginalValues.Add("MeroallasFrissiteseSzukseges", (object)m_MeroallasFrissiteseSzukseges);
OriginalValues.Add("MerohelyTipusId", (object)m_MerohelyTipusId);
OriginalValues.Add("Nev", (Nev == null ? (object)DBNull.Value : (object)m_Nev));
OriginalValues.Add("MerooraAzonosito", (MerooraAzonosito == null ? (object)DBNull.Value : (object)m_MerooraAzonosito));
OriginalValues.Add("EgyediAzonosito", (object)m_EgyediAzonosito);
OriginalValues.Add("MukodesiHelyId", (m_MukodesiHelyId < 0 ? (object)DBNull.Value : (object)m_MukodesiHelyId));
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_Nev != null && m_Nev.Length > 2147483647)
{
throw new InvalidEntityAttributeException("Merohely", "Nev", EntityAttributeError.TooLong);
}
if (m_MerooraAzonosito != null && m_MerooraAzonosito.Length > 100)
{
throw new InvalidEntityAttributeException("Merohely", "MerooraAzonosito", EntityAttributeError.TooLong);
}
}
// kötelező asszociációk ellenőrzése...
if (m_MukodesiHelyId == -1) { throw new InvalidEntityAttributeException("Merohely", "MukodesiHelyId", EntityAttributeError.Empty); }
if (m_IntezmenyId == -1) { throw new InvalidEntityAttributeException("Merohely", "IntezmenyId", EntityAttributeError.Empty); }
if (m_TanevId == -1) { throw new InvalidEntityAttributeException("Merohely", "TanevId", EntityAttributeError.Empty); }
}
#endregion
#region Alaphelyzetbe állítás
protected override void Reset()
{
base.Reset();
// alaphelyzetbe állítjuk az egyszerű mezőket
this.m_MeroallasFrissiteseSzukseges = false;
this.m_MerohelyTipusId = -1;
this.m_Nev = null;
this.m_MerooraAzonosito = null;
this.m_EgyediAzonosito = Guid.NewGuid();
// alaphelyzetbe állítjuk az asszociációkból származó mezőket
this.m_KozmuSzamla = null; // EntityCollection
this.m_Meroallas = null; // EntityCollection
this.m_MukodesiHelyId = -1;
this.m_MukodesiHely = 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...
if (this.KozmuSzamla.Count > 0)
{
throw new EntityDeleteFailedException("Merohely", "KozmuSzamla", EntityUtil.GetAssociationDescription("T_KOZMUSZAMLA_OSSZES", "C_MEROHELYID")); // nincs kapcsolotabla
}
if (this.Meroallas.Count > 0)
{
throw new EntityDeleteFailedException("Merohely", "Meroallas", EntityUtil.GetAssociationDescription("T_MEROALLAS_OSSZES", "C_MEROHELYID")); // nincs kapcsolotabla
}
// MukodesiHely esetében mi mutatunk a másikra: startrole: *, 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 MeroallasFrissiteseSzukseges
protected internal bool m_MeroallasFrissiteseSzukseges;
///
/// Nincs definiálva megjegyzés.
///
[EntityProperty("MeroallasFrissiteseSzukseges", EntityPropertyBaseType.ValueType, typeof(bool), EntityCopyMethod.ShallowCopy)]
public virtual bool MeroallasFrissiteseSzukseges
{
get
{
return m_MeroallasFrissiteseSzukseges;
}
set
{
CheckModifyable();
if (m_MeroallasFrissiteseSzukseges == value) return;
m_MeroallasFrissiteseSzukseges = value;
FieldModified("MeroallasFrissiteseSzukseges", value);
}
}
#endregion
#region MerohelyTipusId
protected internal int /* DictionaryItem */ m_MerohelyTipusId;
///
/// Nincs definiálva megjegyzés.
///
[EntityProperty("MerohelyTipusId", EntityPropertyBaseType.ValueType, typeof(int /* DictionaryItem */), EntityCopyMethod.ShallowCopy)]
[EntityDictionaryItemProperty("MerohelyTipusId", "MerohelyTipus", typeof(SDA.Kreta.Entities.MerohelyTipus))]
public virtual int /* DictionaryItem */ MerohelyTipusId
{
get
{
return m_MerohelyTipusId;
}
set
{
CheckModifyable();
if (m_MerohelyTipusId == value) return;
m_MerohelyTipusId = value;
FieldModified("MerohelyTipusId", value);
}
}
#endregion
#region Nev
protected internal string m_Nev;
///
/// Nincs definiálva megjegyzés.
///
[EntityProperty("Nev", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)]
public virtual string Nev
{
get
{
return m_Nev;
}
set
{
CheckModifyable();
if (m_Nev == value) return;
m_Nev = value;
FieldModified("Nev", value);
}
}
#endregion
#region MerooraAzonosito
protected internal string m_MerooraAzonosito;
///
/// Nincs definiálva megjegyzés.
///
[EntityProperty("MerooraAzonosito", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)]
public virtual string MerooraAzonosito
{
get
{
return m_MerooraAzonosito;
}
set
{
CheckModifyable();
if (m_MerooraAzonosito == value) return;
m_MerooraAzonosito = value;
FieldModified("MerooraAzonosito", value);
}
}
#endregion
#region EgyediAzonosito
protected internal Guid m_EgyediAzonosito;
///
/// Nincs definiálva megjegyzés.
///
[EntityProperty("EgyediAzonosito", EntityPropertyBaseType.ValueType, typeof(Guid), EntityCopyMethod.ShallowCopy)]
public virtual Guid EgyediAzonosito
{
get
{
return m_EgyediAzonosito;
}
set
{
CheckModifyable();
if (m_EgyediAzonosito == value) return;
m_EgyediAzonosito = value;
FieldModified("EgyediAzonosito", value);
}
}
#endregion
#endregion
#region Asszociációkkal kapcsolatos dolgok
protected internal virtual bool LoadByKozmuSzamlaId(int id)
{
return m_DA.LoadByKozmuSzamlaId(id, this);
}
protected internal virtual bool LoadByMeroallasId(int id)
{
return m_DA.LoadByMeroallasId(id, this);
}
#region Merohely (*) -> MukodesiHely (1)
protected internal int m_MukodesiHelyId = -1;
///
/// A(z) MukodesiHely 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 MukodesiHelyId
{
get
{
return InternalMukodesiHelyId;
}
set
{
InternalMukodesiHelyId = value;
}
}
///
/// Ez egy külön bejárat a DA számára
///
internal int InternalMukodesiHelyId
{
get
{
if (m_MukodesiHely != null)
{
return m_MukodesiHely.ID;
}
else
{
return m_MukodesiHelyId;// XXX az meg nem teljesen OK
}
}
set
{
CheckModifyable();
if (m_MukodesiHelyId != value)
{
m_MukodesiHelyId = value;
m_MukodesiHely = null;
FieldModified("MukodesiHelyId", value);
}
}
}
///
/// Ez egy külön bejárat a DA számára
///
internal void ModifyMukodesiHely(MukodesiHely value)
{
m_MukodesiHelyId = value != null ? value.ID : -1;
m_MukodesiHely = value;
FieldModified("MukodesiHelyId", value != null ? (object)value.ID : DBNull.Value);
}
protected internal void SetMukodesiHely(MukodesiHely value)
{
m_MukodesiHely = value;
if (value != null)
{
m_MukodesiHelyId = value.ID;
}
else
{
m_MukodesiHelyId = -1;
}
}
protected MukodesiHely m_MukodesiHely = null;
IMukodesiHely IMerohely.MukodesiHely
{
get { return MukodesiHely; }
set { MukodesiHely = value as MukodesiHely; }
}
///
/// Nincs definiálva megjegyzés.
///
///
/// Az UML modellben szereplő Merohely és MukodesiHely entitások közötti asszociáció megvalósítása.
///
[EntityProperty("MukodesiHely", EntityPropertyBaseType.Entity, typeof(MukodesiHely), EntityCopyMethod.ShallowCopy)]
public virtual MukodesiHely MukodesiHely
{
get
{
if ((m_MukodesiHely == null) && (m_MukodesiHelyId != -1))
{
SDA.Kreta.Entities.MukodesiHely partner = SDA.Kreta.Entities.MukodesiHely.GiveAnInstance();
partner.LoadByID(m_MukodesiHelyId);
this.SetMukodesiHely(partner);
}
// természetesen null-t adunk vissza, ha nem tudtunk felhozni semmit
return m_MukodesiHely;
}
set
{
CheckModifyable();
if (value != null)
{
if ((m_MukodesiHely == null) || (value.ID != m_MukodesiHely.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.MukodesiHely_Merohely_DA da = new MukodesiHely_Merohely_DA(value);
da.AddItem(this);
this.SetMukodesiHely(value);
}
else
{
this.SetMukodesiHely(value);
}
FieldModified("MukodesiHelyId", value.ID);
}
}
else
{
// ki kell törölni a kapcsolatot az adatbázisban
this.SetMukodesiHely(null);
UpdateAssociations();
FieldModified("MukodesiHelyId", DBNull.Value);
}
}
}
#endregion
#region Merohely (*) -> 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 IMerohely.Intezmeny
{
get { return Intezmeny; }
set { Intezmeny = value as Intezmeny; }
}
///
/// Nincs definiálva megjegyzés.
///
///
/// Az UML modellben szereplő Merohely é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_Merohely_DA da = new Intezmeny_Merohely_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 Merohely (*) -> 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 IMerohely.Tanev
{
get { return Tanev; }
set { Tanev = value as Tanev; }
}
///
/// Nincs definiálva megjegyzés.
///
///
/// Az UML modellben szereplő Merohely é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_Merohely_DA da = new Tanev_Merohely_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
#region Merohely (1) -> KozmuSzamla (*)
protected IAssociatedEntityCollection m_KozmuSzamla = null;
IReadOnlyList IMerohely.KozmuSzamla => KozmuSzamla.Cast().ToList();
///
/// Nincs definiálva megjegyzés.
///
///
/// Az UML modellben szereplő Merohely és KozmuSzamla entitások közötti asszociáció megvalósítása.
///
[EntityProperty("KozmuSzamla", EntityPropertyBaseType.EntityCollection, typeof(IAssociatedEntityCollection), EntityCopyMethod.DeepCopy, "MerohelyId")]
public virtual IAssociatedEntityCollection KozmuSzamla
{
get
{
if (m_KozmuSzamla == null)
{
m_KozmuSzamla = new AssociatedEntityCollection(
new Merohely_KozmuSzamla_DA(this)
);
m_KozmuSzamla.Load();
}
return m_KozmuSzamla;
}
}
#endregion
#region Merohely (1) -> Meroallas (*)
protected IAssociatedEntityCollection m_Meroallas = null;
IReadOnlyList IMerohely.Meroallas => Meroallas.Cast().ToList();
///
/// Nincs definiálva megjegyzés.
///
///
/// Az UML modellben szereplő Merohely és Meroallas entitások közötti asszociáció megvalósítása.
///
[EntityProperty("Meroallas", EntityPropertyBaseType.EntityCollection, typeof(IAssociatedEntityCollection), EntityCopyMethod.DeepCopy, "MerohelyId")]
public virtual IAssociatedEntityCollection Meroallas
{
get
{
if (m_Meroallas == null)
{
m_Meroallas = new AssociatedEntityCollection(
new Merohely_Meroallas_DA(this)
);
m_Meroallas.Load();
}
return m_Meroallas;
}
}
#endregion
#endregion
#endregion
}
}