482 lines
16 KiB
C#
482 lines
16 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// Az UML modell IntezmenyConfig entitásának megvalósítása.
|
|
/// </summary>
|
|
/// <remarks>A kód teljes egészében generált, kézi módosítása nem megengedett!</remarks>
|
|
[Entity("IntezmenyConfig")]
|
|
// alapértelmezett EntityHistoryMode
|
|
public class IntezmenyConfig : Entity, IIntezmenyConfig
|
|
{
|
|
internal protected IntezmenyConfig()
|
|
: base()
|
|
{
|
|
}
|
|
|
|
public class AttributeInfo
|
|
{
|
|
public const string Ertek = "Ertek";
|
|
}
|
|
|
|
public class AttributeLengthInfo
|
|
{
|
|
public const int ErtekLength = 255;
|
|
}
|
|
|
|
#region General
|
|
private IntezmenyConfigDA m_DA = new IntezmenyConfigDA();
|
|
|
|
protected static IntezmenyConfig FakeIntezmenyConfig { get; set; }
|
|
|
|
public static IntezmenyConfig GiveAnInstance()
|
|
{
|
|
IntezmenyConfig result = FakeIntezmenyConfig == null
|
|
? new IntezmenyConfig()
|
|
: (IntezmenyConfig)FakeIntezmenyConfig.MemberwiseClone();
|
|
result.Reset();
|
|
result.SetDefaultData();
|
|
|
|
return result;
|
|
}
|
|
|
|
protected void SetDefaultData()
|
|
{
|
|
if (UserContext.Instance != null)
|
|
{
|
|
if (UserContext.Instance.IntezmenyId > 0)
|
|
{
|
|
IntezmenyId = UserContext.Instance.IntezmenyId;
|
|
}
|
|
|
|
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<IntezmenyConfig> 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<IntezmenyConfig> LoadAll(ColumnFilterMode columnFilterMode, IEnumerable<string> 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<IntezmenyConfig> LoadWithFilter(string filter, Dictionary<string, object> commandParameters = null)
|
|
{
|
|
var result = new EntityCollection<IntezmenyConfig>();
|
|
new IntezmenyConfigDA().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<IntezmenyConfig> LoadWithFilter(string filter, ColumnFilterMode columnFilterMode, IEnumerable<string> columns, Dictionary<string, object> commandParameters = null)
|
|
{
|
|
var result = new EntityCollection<IntezmenyConfig>();
|
|
new IntezmenyConfigDA().LoadWithFilter(result, filter, columnFilterMode, columns, commandParameters);
|
|
return result;
|
|
}
|
|
|
|
protected override void StoreOriginalValues()
|
|
{
|
|
base.StoreOriginalValues();
|
|
OriginalValues.Add("Ertek", (Ertek == null ? (object)DBNull.Value : (object)m_Ertek));
|
|
OriginalValues.Add("ConfigTipusId", (m_ConfigTipusId < 0 ? (object)DBNull.Value : (object)m_ConfigTipusId));
|
|
OriginalValues.Add("IntezmenyId", (m_IntezmenyId < 0 ? (object)DBNull.Value : (object)m_IntezmenyId));
|
|
}
|
|
|
|
#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_Ertek != null && m_Ertek.Length > 255)
|
|
{
|
|
throw new InvalidEntityAttributeException("IntezmenyConfig", "Ertek", EntityAttributeError.TooLong);
|
|
}
|
|
|
|
}
|
|
|
|
// kötelező asszociációk ellenőrzése...
|
|
if (m_ConfigTipusId == -1) { throw new InvalidEntityAttributeException("IntezmenyConfig", "ConfigTipusId", EntityAttributeError.Empty); }
|
|
if (m_IntezmenyId == -1) { throw new InvalidEntityAttributeException("IntezmenyConfig", "IntezmenyId", EntityAttributeError.Empty); }
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Alaphelyzetbe állítás
|
|
protected override void Reset()
|
|
{
|
|
base.Reset();
|
|
|
|
// alaphelyzetbe állítjuk az egyszerű mezőket
|
|
this.m_Ertek = null;
|
|
|
|
// alaphelyzetbe állítjuk az asszociációkból származó mezőket
|
|
this.m_ConfigTipusId = -1;
|
|
this.m_ConfigTipus = null; // Entity
|
|
this.m_IntezmenyId = -1;
|
|
this.m_Intezmeny = 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...
|
|
|
|
// ConfigTipus esetében mi mutatunk a másikra: startrole: *, endrole: 1
|
|
// Intezmeny 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 Ertek
|
|
|
|
protected internal string m_Ertek;
|
|
|
|
/// <summary>
|
|
/// Nincs definiálva megjegyzés.
|
|
/// </summary>
|
|
[EntityProperty("Ertek", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)]
|
|
public virtual string Ertek
|
|
{
|
|
get
|
|
{
|
|
return m_Ertek;
|
|
}
|
|
set
|
|
{
|
|
CheckModifyable();
|
|
|
|
if (m_Ertek == value) return;
|
|
m_Ertek = value;
|
|
FieldModified("Ertek", value);
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region Asszociációkkal kapcsolatos dolgok
|
|
|
|
#region IntezmenyConfig (*) -> ConfigTipus (1)
|
|
|
|
protected internal int m_ConfigTipusId = -1;
|
|
|
|
/// <summary>
|
|
/// A(z) ConfigTipus asszociáció végpontjának ID-ja.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// - 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
|
|
/// </remarks>
|
|
public virtual int ConfigTipusId
|
|
{
|
|
get
|
|
{
|
|
return InternalConfigTipusId;
|
|
}
|
|
set
|
|
{
|
|
InternalConfigTipusId = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ez egy külön bejárat a DA számára
|
|
/// <summary>
|
|
internal int InternalConfigTipusId
|
|
{
|
|
get
|
|
{
|
|
if (m_ConfigTipus != null)
|
|
{
|
|
return m_ConfigTipus.ID;
|
|
}
|
|
else
|
|
{
|
|
return m_ConfigTipusId;// XXX az meg nem teljesen OK
|
|
}
|
|
}
|
|
set
|
|
{
|
|
CheckModifyable();
|
|
if (m_ConfigTipusId != value)
|
|
{
|
|
m_ConfigTipusId = value;
|
|
m_ConfigTipus = null;
|
|
FieldModified("ConfigTipusId", value);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ez egy külön bejárat a DA számára
|
|
/// <summary>
|
|
internal void ModifyConfigTipus(ConfigTipus value)
|
|
{
|
|
m_ConfigTipusId = value != null ? value.ID : -1;
|
|
m_ConfigTipus = value;
|
|
FieldModified("ConfigTipusId", value != null ? (object)value.ID : DBNull.Value);
|
|
}
|
|
|
|
protected internal void SetConfigTipus(ConfigTipus value)
|
|
{
|
|
m_ConfigTipus = value;
|
|
if (value != null)
|
|
{
|
|
m_ConfigTipusId = value.ID;
|
|
}
|
|
else
|
|
{
|
|
m_ConfigTipusId = -1;
|
|
}
|
|
}
|
|
|
|
protected ConfigTipus m_ConfigTipus = null;
|
|
|
|
IConfigTipus IIntezmenyConfig.ConfigTipus
|
|
{
|
|
get { return ConfigTipus; }
|
|
set { ConfigTipus = value as ConfigTipus; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Nincs definiálva megjegyzés.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Az UML modellben szereplő IntezmenyConfig és ConfigTipus entitások közötti asszociáció megvalósítása.
|
|
/// </remarks>
|
|
[EntityProperty("ConfigTipus", EntityPropertyBaseType.Entity, typeof(ConfigTipus), EntityCopyMethod.ShallowCopy)]
|
|
public virtual ConfigTipus ConfigTipus
|
|
{
|
|
get
|
|
{
|
|
if ((m_ConfigTipus == null) && (m_ConfigTipusId != -1))
|
|
{
|
|
SDA.Kreta.Entities.ConfigTipus partner = SDA.Kreta.Entities.ConfigTipus.GiveAnInstance();
|
|
partner.LoadByID(m_ConfigTipusId);
|
|
|
|
this.SetConfigTipus(partner);
|
|
}
|
|
// természetesen null-t adunk vissza, ha nem tudtunk felhozni semmit
|
|
return m_ConfigTipus;
|
|
}
|
|
set
|
|
{
|
|
CheckModifyable();
|
|
if (value != null)
|
|
{
|
|
if ((m_ConfigTipus == null) || (value.ID != m_ConfigTipus.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.ConfigTipus_IntezmenyConfig_DA da = new ConfigTipus_IntezmenyConfig_DA(value);
|
|
da.AddItem(this);
|
|
this.SetConfigTipus(value);
|
|
}
|
|
else
|
|
{
|
|
this.SetConfigTipus(value);
|
|
}
|
|
FieldModified("ConfigTipusId", value.ID);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// ki kell törölni a kapcsolatot az adatbázisban
|
|
this.SetConfigTipus(null);
|
|
UpdateAssociations();
|
|
FieldModified("ConfigTipusId", DBNull.Value);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region IntezmenyConfig (*) -> Intezmeny (1)
|
|
|
|
protected internal int m_IntezmenyId = -1;
|
|
|
|
/// <summary>
|
|
/// A(z) Intezmeny asszociáció végpontjának ID-ja.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// - 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
|
|
/// </remarks>
|
|
public virtual int IntezmenyId
|
|
{
|
|
get
|
|
{
|
|
return InternalIntezmenyId;
|
|
}
|
|
set
|
|
{
|
|
InternalIntezmenyId = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ez egy külön bejárat a DA számára
|
|
/// <summary>
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ez egy külön bejárat a DA számára
|
|
/// <summary>
|
|
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 IIntezmenyConfig.Intezmeny
|
|
{
|
|
get { return Intezmeny; }
|
|
set { Intezmeny = value as Intezmeny; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Nincs definiálva megjegyzés.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Az UML modellben szereplő IntezmenyConfig és Intezmeny entitások közötti asszociáció megvalósítása.
|
|
/// </remarks>
|
|
[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_IntezmenyConfig_DA da = new Intezmeny_IntezmenyConfig_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
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|