659 lines
21 KiB
C#
659 lines
21 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 DictionaryType 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("DictionaryType")]
|
|
// alapértelmezett EntityHistoryMode
|
|
public class DictionaryType : Entity, IDictionaryType
|
|
{
|
|
internal protected DictionaryType()
|
|
: base()
|
|
{
|
|
}
|
|
|
|
public class AttributeInfo
|
|
{
|
|
public const string CodeName = "CodeName";
|
|
public const string Description = "Description";
|
|
public const string IsColorEditable = "IsColorEditable";
|
|
public const string IsCustomItemAllowed = "IsCustomItemAllowed";
|
|
public const string Name = "Name";
|
|
}
|
|
|
|
public class AttributeLengthInfo
|
|
{
|
|
public const int CodeNameLength = 30;
|
|
public const int DescriptionLength = 255;
|
|
public const int NameLength = 50;
|
|
}
|
|
|
|
#region General
|
|
private DictionaryTypeDA m_DA = new DictionaryTypeDA();
|
|
|
|
protected static DictionaryType FakeDictionaryType { get; set; }
|
|
|
|
public static DictionaryType GiveAnInstance()
|
|
{
|
|
DictionaryType result = FakeDictionaryType == null
|
|
? new DictionaryType()
|
|
: (DictionaryType)FakeDictionaryType.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<DictionaryType> 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<DictionaryType> 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<DictionaryType> LoadWithFilter(string filter, Dictionary<string, object> commandParameters = null)
|
|
{
|
|
var result = new EntityCollection<DictionaryType>();
|
|
new DictionaryTypeDA().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<DictionaryType> LoadWithFilter(string filter, ColumnFilterMode columnFilterMode, IEnumerable<string> columns, Dictionary<string, object> commandParameters = null)
|
|
{
|
|
var result = new EntityCollection<DictionaryType>();
|
|
new DictionaryTypeDA().LoadWithFilter(result, filter, columnFilterMode, columns, commandParameters);
|
|
return result;
|
|
}
|
|
|
|
protected override void StoreOriginalValues()
|
|
{
|
|
base.StoreOriginalValues();
|
|
OriginalValues.Add("CodeName", (object)m_CodeName);
|
|
OriginalValues.Add("Description", (Description == null ? (object)DBNull.Value : (object)m_Description));
|
|
OriginalValues.Add("IsColorEditable", (object)m_IsColorEditable);
|
|
OriginalValues.Add("IsCustomItemAllowed", (object)m_IsCustomItemAllowed);
|
|
OriginalValues.Add("Name", (object)m_Name);
|
|
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_CodeName != null && m_CodeName.Length > 30)
|
|
{
|
|
throw new InvalidEntityAttributeException("DictionaryType", "CodeName", EntityAttributeError.TooLong);
|
|
}
|
|
if (m_Description != null && m_Description.Length > 255)
|
|
{
|
|
throw new InvalidEntityAttributeException("DictionaryType", "Description", EntityAttributeError.TooLong);
|
|
}
|
|
if (m_Name != null && m_Name.Length > 50)
|
|
{
|
|
throw new InvalidEntityAttributeException("DictionaryType", "Name", EntityAttributeError.TooLong);
|
|
}
|
|
|
|
}
|
|
|
|
// kötelező asszociációk ellenőrzése...
|
|
if (m_IntezmenyId == -1) { throw new InvalidEntityAttributeException("DictionaryType", "IntezmenyId", EntityAttributeError.Empty); }
|
|
if (m_TanevId == -1) { throw new InvalidEntityAttributeException("DictionaryType", "TanevId", EntityAttributeError.Empty); }
|
|
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Alaphelyzetbe állítás
|
|
protected override void Reset()
|
|
{
|
|
base.Reset();
|
|
|
|
// alaphelyzetbe állítjuk az egyszerű mezőket
|
|
this.m_CodeName = "";
|
|
this.m_Description = null;
|
|
this.m_IsColorEditable = false;
|
|
this.m_IsCustomItemAllowed = false;
|
|
this.m_Name = "";
|
|
|
|
// alaphelyzetbe állítjuk az asszociációkból származó mezőket
|
|
this.m_DictionaryItemBase = null; // EntityCollection
|
|
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.DictionaryItemBase.Count > 0)
|
|
{
|
|
throw new EntityDeleteFailedException("DictionaryType", "DictionaryItemBase", EntityUtil.GetAssociationDescription("T_DICTIONARYITEMBASE_OSSZES", "C_DICTIONARYTYPEID")); // nincs kapcsolotabla
|
|
}
|
|
// 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 CodeName
|
|
|
|
protected internal string m_CodeName;
|
|
|
|
/// <summary>
|
|
/// Kódnév, a típus neve, amire kódban hivatkozunk (C_TYPE a T_DICTIONARYITEMBASE-ben)
|
|
/// </summary>
|
|
[EntityProperty("CodeName", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)]
|
|
public virtual string CodeName
|
|
{
|
|
get
|
|
{
|
|
return m_CodeName;
|
|
}
|
|
set
|
|
{
|
|
CheckModifyable();
|
|
|
|
if (m_CodeName == value) return;
|
|
m_CodeName = value;
|
|
FieldModified("CodeName", value);
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Description
|
|
|
|
protected internal string m_Description;
|
|
|
|
/// <summary>
|
|
/// A szótárelem típus leírása
|
|
/// </summary>
|
|
[EntityProperty("Description", EntityPropertyBaseType.ValueType, typeof(string), EntityCopyMethod.ShallowCopy)]
|
|
public virtual string Description
|
|
{
|
|
get
|
|
{
|
|
return m_Description;
|
|
}
|
|
set
|
|
{
|
|
CheckModifyable();
|
|
|
|
if (m_Description == value) return;
|
|
m_Description = value;
|
|
FieldModified("Description", value);
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IsColorEditable
|
|
|
|
protected internal bool m_IsColorEditable;
|
|
|
|
/// <summary>
|
|
/// Szerkesztheto-e az elemek színe és háttérszíne
|
|
/// </summary>
|
|
[EntityProperty("IsColorEditable", EntityPropertyBaseType.ValueType, typeof(bool), EntityCopyMethod.ShallowCopy)]
|
|
public virtual bool IsColorEditable
|
|
{
|
|
get
|
|
{
|
|
return m_IsColorEditable;
|
|
}
|
|
set
|
|
{
|
|
CheckModifyable();
|
|
|
|
if (m_IsColorEditable == value) return;
|
|
m_IsColorEditable = value;
|
|
FieldModified("IsColorEditable", value);
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IsCustomItemAllowed
|
|
|
|
protected internal bool m_IsCustomItemAllowed;
|
|
|
|
/// <summary>
|
|
/// Adhat-e a felhasználó új elemet a listához
|
|
/// </summary>
|
|
[EntityProperty("IsCustomItemAllowed", EntityPropertyBaseType.ValueType, typeof(bool), EntityCopyMethod.ShallowCopy)]
|
|
public virtual bool IsCustomItemAllowed
|
|
{
|
|
get
|
|
{
|
|
return m_IsCustomItemAllowed;
|
|
}
|
|
set
|
|
{
|
|
CheckModifyable();
|
|
|
|
if (m_IsCustomItemAllowed == value) return;
|
|
m_IsCustomItemAllowed = value;
|
|
FieldModified("IsCustomItemAllowed", value);
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Name
|
|
|
|
protected internal string m_Name;
|
|
|
|
/// <summary>
|
|
/// A szótárelem típus megjelenítheto neve
|
|
/// </summary>
|
|
[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
|
|
|
|
#endregion
|
|
|
|
#region Asszociációkkal kapcsolatos dolgok
|
|
|
|
protected internal virtual bool LoadByDictionaryItemBaseId(int id)
|
|
{
|
|
return m_DA.LoadByDictionaryItemBaseId(id, this);
|
|
}
|
|
|
|
#region DictionaryType (*) -> 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 IDictionaryType.Intezmeny
|
|
{
|
|
get { return Intezmeny; }
|
|
set { Intezmeny = value as Intezmeny; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Nincs definiálva megjegyzés.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Az UML modellben szereplő DictionaryType é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_DictionaryType_DA da = new Intezmeny_DictionaryType_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 DictionaryType (*) -> Tanev (1)
|
|
|
|
protected internal int m_TanevId = -1;
|
|
|
|
/// <summary>
|
|
/// A(z) Tanev 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 TanevId
|
|
{
|
|
get
|
|
{
|
|
return InternalTanevId;
|
|
}
|
|
set
|
|
{
|
|
InternalTanevId = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ez egy külön bejárat a DA számára
|
|
/// <summary>
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ez egy külön bejárat a DA számára
|
|
/// <summary>
|
|
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 IDictionaryType.Tanev
|
|
{
|
|
get { return Tanev; }
|
|
set { Tanev = value as Tanev; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Nincs definiálva megjegyzés.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Az UML modellben szereplő DictionaryType és Tanev entitások közötti asszociáció megvalósítása.
|
|
/// </remarks>
|
|
[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_DictionaryType_DA da = new Tanev_DictionaryType_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 DictionaryType (1) -> DictionaryItemBase (*)
|
|
protected IAssociatedEntityCollection<DictionaryItemBase> m_DictionaryItemBase = null;
|
|
|
|
IReadOnlyList<IDictionaryItemBase> IDictionaryType.DictionaryItemBase => DictionaryItemBase.Cast<IDictionaryItemBase>().ToList();
|
|
|
|
/// <summary>
|
|
/// Nincs definiálva megjegyzés.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Az UML modellben szereplő DictionaryType és DictionaryItemBase entitások közötti asszociáció megvalósítása.
|
|
/// </remarks>
|
|
[EntityProperty("DictionaryItemBase", EntityPropertyBaseType.EntityCollection, typeof(IAssociatedEntityCollection<DictionaryItemBase>), EntityCopyMethod.DeepCopy, "DictionaryTypeId")]
|
|
public virtual IAssociatedEntityCollection<DictionaryItemBase> DictionaryItemBase
|
|
{
|
|
get
|
|
{
|
|
if (m_DictionaryItemBase == null)
|
|
{
|
|
m_DictionaryItemBase = new AssociatedEntityCollection<DictionaryType, DictionaryItemBase>(
|
|
new DictionaryType_DictionaryItemBase_DA(this)
|
|
);
|
|
m_DictionaryItemBase.Load();
|
|
}
|
|
return m_DictionaryItemBase;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|