347 lines
11 KiB
C#
347 lines
11 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 Fenntarto 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("Fenntarto")]
|
|
// alapértelmezett EntityHistoryMode
|
|
public class Fenntarto : Entity, IFenntarto
|
|
{
|
|
internal protected Fenntarto()
|
|
: base()
|
|
{
|
|
}
|
|
|
|
public class AttributeInfo
|
|
{
|
|
public const string Nev = "Nev";
|
|
public const string Azonosito = "Azonosito";
|
|
public const string Guid = "Guid";
|
|
public const string LegmagasabbSzintuFenntartoId = "LegmagasabbSzintuFenntartoId";
|
|
public const string IsTesztFenntarto = "IsTesztFenntarto";
|
|
}
|
|
|
|
public class AttributeLengthInfo
|
|
{
|
|
public const int NevLength = 1000;
|
|
public const int AzonositoLength = 16;
|
|
}
|
|
|
|
#region General
|
|
private FenntartoDA m_DA = new FenntartoDA();
|
|
|
|
protected static Fenntarto FakeFenntarto { get; set; }
|
|
|
|
public static Fenntarto GiveAnInstance()
|
|
{
|
|
Fenntarto result = FakeFenntarto == null
|
|
? new Fenntarto()
|
|
: (Fenntarto)FakeFenntarto.MemberwiseClone();
|
|
result.Reset();
|
|
result.SetDefaultData();
|
|
|
|
return result;
|
|
}
|
|
|
|
protected void SetDefaultData()
|
|
{
|
|
}
|
|
|
|
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<Fenntarto> 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<Fenntarto> 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<Fenntarto> LoadWithFilter(string filter, Dictionary<string, object> commandParameters = null)
|
|
{
|
|
var result = new EntityCollection<Fenntarto>();
|
|
new FenntartoDA().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<Fenntarto> LoadWithFilter(string filter, ColumnFilterMode columnFilterMode, IEnumerable<string> columns, Dictionary<string, object> commandParameters = null)
|
|
{
|
|
var result = new EntityCollection<Fenntarto>();
|
|
new FenntartoDA().LoadWithFilter(result, filter, columnFilterMode, columns, commandParameters);
|
|
return result;
|
|
}
|
|
|
|
protected override void StoreOriginalValues()
|
|
{
|
|
base.StoreOriginalValues();
|
|
OriginalValues.Add("Nev", (object)m_Nev);
|
|
OriginalValues.Add("Azonosito", (object)m_Azonosito);
|
|
OriginalValues.Add("Guid", (object)m_Guid);
|
|
OriginalValues.Add("LegmagasabbSzintuFenntartoId", (LegmagasabbSzintuFenntartoId == null ? (object)DBNull.Value : (object)m_LegmagasabbSzintuFenntartoId));
|
|
OriginalValues.Add("IsTesztFenntarto", (object)m_IsTesztFenntarto);
|
|
}
|
|
|
|
#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 > 1000)
|
|
{
|
|
throw new InvalidEntityAttributeException("Fenntarto", "Nev", EntityAttributeError.TooLong);
|
|
}
|
|
if (m_Azonosito != null && m_Azonosito.Length > 16)
|
|
{
|
|
throw new InvalidEntityAttributeException("Fenntarto", "Azonosito", EntityAttributeError.TooLong);
|
|
}
|
|
}
|
|
|
|
// kötelező asszociációk ellenőrzése...
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Alaphelyzetbe állítás
|
|
protected override void Reset()
|
|
{
|
|
base.Reset();
|
|
|
|
// alaphelyzetbe állítjuk az egyszerű mezőket
|
|
this.m_Nev = "";
|
|
this.m_Azonosito = "";
|
|
this.m_Guid = default(Guid);
|
|
this.m_LegmagasabbSzintuFenntartoId = null;
|
|
this.m_IsTesztFenntarto = false;
|
|
|
|
// alaphelyzetbe állítjuk az asszociációkból származó mezőket
|
|
this.m_Intezmeny = null; // EntityCollection
|
|
}
|
|
|
|
#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.Intezmeny.Count > 0)
|
|
{
|
|
throw new EntityDeleteFailedException("Fenntarto", "Intezmeny", EntityUtil.GetAssociationDescription("T_INTEZMENY_OSSZES", "C_FENNTARTOID")); // nincs kapcsolotabla
|
|
}
|
|
|
|
// kaszkád törlések...
|
|
|
|
}
|
|
|
|
#region Mezők és tulajdonságok
|
|
|
|
#region Egyszerű mezők
|
|
|
|
#region Nev
|
|
|
|
protected internal string m_Nev;
|
|
|
|
/// <summary>
|
|
/// Fenntartó neve
|
|
/// </summary>
|
|
[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 Azonosito
|
|
|
|
protected internal string m_Azonosito;
|
|
|
|
/// <summary>
|
|
/// A fenntartó rendszerbeli egyedi azonosítója
|
|
/// </summary>
|
|
[EntityProperty("Azonosito", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)]
|
|
public virtual string Azonosito
|
|
{
|
|
get
|
|
{
|
|
return m_Azonosito;
|
|
}
|
|
set
|
|
{
|
|
CheckModifyable();
|
|
|
|
if (m_Azonosito == value) return;
|
|
m_Azonosito = value;
|
|
FieldModified("Azonosito", value);
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Guid
|
|
|
|
protected internal Guid m_Guid;
|
|
|
|
/// <summary>
|
|
/// A fenntartó rendszerek közötti egyedi azonosítója
|
|
/// </summary>
|
|
[EntityProperty("Guid", EntityPropertyBaseType.ValueType, typeof(Guid), EntityCopyMethod.ShallowCopy)]
|
|
public virtual Guid Guid
|
|
{
|
|
get
|
|
{
|
|
return m_Guid;
|
|
}
|
|
set
|
|
{
|
|
CheckModifyable();
|
|
|
|
if (m_Guid == value) return;
|
|
m_Guid = value;
|
|
FieldModified("Guid", value);
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region LegmagasabbSzintuFenntartoId
|
|
|
|
protected internal int? m_LegmagasabbSzintuFenntartoId;
|
|
|
|
/// <summary>
|
|
/// Legmagasabb szintű fenntartó ID-je
|
|
/// </summary>
|
|
[EntityProperty("LegmagasabbSzintuFenntartoId", EntityPropertyBaseType.ValueType, typeof(int), EntityCopyMethod.ShallowCopy)]
|
|
public virtual int? LegmagasabbSzintuFenntartoId
|
|
{
|
|
get
|
|
{
|
|
return m_LegmagasabbSzintuFenntartoId;
|
|
}
|
|
set
|
|
{
|
|
CheckModifyable();
|
|
|
|
if (m_LegmagasabbSzintuFenntartoId == value) return;
|
|
m_LegmagasabbSzintuFenntartoId = value;
|
|
FieldModified("LegmagasabbSzintuFenntartoId", value);
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IsTesztFenntarto
|
|
|
|
protected internal bool m_IsTesztFenntarto;
|
|
|
|
/// <summary>
|
|
/// Ha értéke IGAZ, Teszt fenntartóról beszélünk
|
|
/// </summary>
|
|
[EntityProperty("IsTesztFenntarto", EntityPropertyBaseType.ValueType, typeof(bool), EntityCopyMethod.ShallowCopy)]
|
|
public virtual bool IsTesztFenntarto
|
|
{
|
|
get
|
|
{
|
|
return m_IsTesztFenntarto;
|
|
}
|
|
set
|
|
{
|
|
CheckModifyable();
|
|
|
|
if (m_IsTesztFenntarto == value) return;
|
|
m_IsTesztFenntarto = value;
|
|
FieldModified("IsTesztFenntarto", value);
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region Asszociációkkal kapcsolatos dolgok
|
|
|
|
protected internal virtual bool LoadByIntezmenyId(int id)
|
|
{
|
|
return m_DA.LoadByIntezmenyId(id, this);
|
|
}
|
|
|
|
#region Fenntarto (1) -> Intezmeny (*)
|
|
protected IAssociatedEntityCollection<Intezmeny> m_Intezmeny = null;
|
|
|
|
IReadOnlyList<IIntezmeny> IFenntarto.Intezmeny => Intezmeny.Cast<IIntezmeny>().ToList();
|
|
|
|
/// <summary>
|
|
/// Intézmény fenntartója
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Az UML modellben szereplő Fenntarto és Intezmeny entitások közötti asszociáció megvalósítása.
|
|
/// </remarks>
|
|
[EntityProperty("Intezmeny", EntityPropertyBaseType.EntityCollection, typeof(IAssociatedEntityCollection<Intezmeny>), EntityCopyMethod.DeepCopy, "FenntartoId")]
|
|
public virtual IAssociatedEntityCollection<Intezmeny> Intezmeny
|
|
{
|
|
get
|
|
{
|
|
if (m_Intezmeny == null)
|
|
{
|
|
m_Intezmeny = new AssociatedEntityCollection<Fenntarto, Intezmeny>(
|
|
new Fenntarto_Intezmeny_DA(this)
|
|
);
|
|
m_Intezmeny.Load();
|
|
}
|
|
return m_Intezmeny;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|