init
This commit is contained in:
@@ -0,0 +1,323 @@
|
||||
//***************************************************************************//
|
||||
// Legenerálja a megadott osztályhoz tartozó entitás teljes forráskódját. //
|
||||
//***************************************************************************//
|
||||
template GenerateEntity(MClass as ENTITY)
|
||||
[BOM]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.[ProjectName].Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Az UML modell [ENTITY.name] 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("[ENTITY.name]")\]
|
||||
[if (GetTaggedValue([ENTITY], "disabledsecuritymode") == "read")]
|
||||
\[Kreta.Framework.Security.EntitySecurityDisabled(Kreta.Framework.Security.EntitySecurityDisabledMode.DISABLE_READ)\]
|
||||
[else]
|
||||
[if (GetTaggedValue([ENTITY], "disabledsecuritymode") == "readwrite")]
|
||||
\[Kreta.Framework.Security.EntitySecurityDisabled(Kreta.Framework.Security.EntitySecurityDisabledMode.DISABLE_READWRITE)\]
|
||||
[end if]
|
||||
[end if]
|
||||
[GenerateEntityHistoryModeAttribute([ENTITY])]
|
||||
public class [ENTITY.name] : [GetBaseClassName([ENTITY], "Entity")], I[ENTITY.name]
|
||||
{
|
||||
internal protected [ENTITY.name]()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
[if (IsMasterEntity([ENTITY]) == "false")]
|
||||
[loop (ENTITY -> SuperClass as BASECLASS)]
|
||||
public new class AttributeInfo : [BASECLASS.name].AttributeInfo
|
||||
{
|
||||
[end loop]
|
||||
[else]
|
||||
public class AttributeInfo
|
||||
{
|
||||
[end if]
|
||||
[loop (ENTITY -> MAttribute as ATTRIBUTE)]
|
||||
public const string [ATTRIBUTE.name] = "[ATTRIBUTE.name]";
|
||||
[end loop]
|
||||
}
|
||||
|
||||
[if (IsMasterEntity([ENTITY]) == "false")]
|
||||
[loop (ENTITY -> SuperClass as BASECLASS)]
|
||||
public new class AttributeLengthInfo : [BASECLASS.name].AttributeLengthInfo
|
||||
{
|
||||
[end loop]
|
||||
[else]
|
||||
public class AttributeLengthInfo
|
||||
{
|
||||
[end if]
|
||||
[loop (ENTITY -> MAttribute as ATTRIBUTE)]
|
||||
[if (GetCSharpType([ATTRIBUTE.type]) == "string")]
|
||||
public const int [ATTRIBUTE.name]Length = [GetAttributeLength([ATTRIBUTE])];
|
||||
[end if]
|
||||
[end loop]
|
||||
}
|
||||
|
||||
[GenerateGeneralSection([ENTITY])]
|
||||
|
||||
[//GenerateXMLSection([ENTITY])]
|
||||
|
||||
[GenerateEntityValidation([ENTITY])]
|
||||
|
||||
[GenerateEntityReset([ENTITY])]
|
||||
|
||||
[GenerateDeAssociateBeforeDelete([ENTITY])]
|
||||
|
||||
#region Mezők és tulajdonságok
|
||||
|
||||
[GenerateSimpleFields([ENTITY])]
|
||||
|
||||
#region Asszociációkkal kapcsolatos dolgok
|
||||
|
||||
[GenerateAssociationClassFields([ENTITY])]
|
||||
[GenerateFirstCaseAssociations([ENTITY])]
|
||||
[//GenerateSecondCaseAssociations([ENTITY])]
|
||||
[GenerateThirdCaseAssociations([ENTITY])]
|
||||
[//GenerateFourthCaseAssociations([ENTITY])]
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
end template
|
||||
|
||||
|
||||
//***************************************************************************//
|
||||
// Legenerálja azt a metódust, ami törlés előtt elvégzi az asszociációinak //
|
||||
// felbontását, hogy ezzel törölhetővé tegye az entitást. //
|
||||
//***************************************************************************//
|
||||
template GenerateDeAssociateBeforeDelete(MClass as ENTITY)
|
||||
protected override void DeAssociateBeforeDelete(bool runHandler = false)
|
||||
{
|
||||
// Nem kaszkád törölhető asszociációk ellenőrzése, hogy üresek-e...
|
||||
|
||||
[loop (ENTITY -> Role as StartRole -> MAssociation as CurrentAssoc -> MAssociationEnd as EndRole -> MClass as PartnerClass
|
||||
where (([StartRole.id] != [EndRole.id])
|
||||
and GetStereoType([PartnerClass]) == "Entity")
|
||||
and IsCascadeDelete([CurrentAssoc]) == "False"
|
||||
)]
|
||||
[if (HasAssociationClass([CurrentAssoc]) == "")]
|
||||
[if (
|
||||
([StartRole.multiplicity] == "1" and [EndRole.multiplicity] == "0..1"))]
|
||||
[if ([ENTITY.name] != [PartnerClass.name] or [EndRole.isNavigable] == "TRUE")]
|
||||
if (this.[DefineRoleName([EndRole])] != null)
|
||||
{
|
||||
[/*
|
||||
// startrole: [StartRole.multiplicity], endrole: [EndRole.multiplicity]
|
||||
*/]
|
||||
throw new EntityDeleteFailedException("[ENTITY.name]", "[DefineRoleName([EndRole])]", EntityUtil.GetAssociationDescription("[ConvertNameToSQLTableName([PartnerClass.name])]", "[ConvertNameToSQLColumnName(ConvertRoleToName([StartRole]))]")); // nincs kapcsolotabla
|
||||
}
|
||||
[else]
|
||||
// [DefineRoleName([EndRole])] esetében önmagunkra mutatunk, nincs mit ellenőrizni. startrole: [StartRole.multiplicity], endrole: [EndRole.multiplicity]
|
||||
[end if]
|
||||
[else]
|
||||
[if ([StartRole.multiplicity] == "0..1" and [EndRole.multiplicity] == "0..1")]
|
||||
[if ([ENTITY.name] != [PartnerClass.name] or [EndRole.isNavigable] == "TRUE")]
|
||||
if (this.[DefineRoleName([EndRole])] != null)
|
||||
{
|
||||
throw new EntityDeleteFailedException("[ENTITY.name]", "[DefineRoleName([EndRole])]", EntityUtil.GetAssociationDescription("[ConvertNameToSQLTableName([PartnerClass.name])]", "ID")); // *-* + kapcsolotabla
|
||||
}
|
||||
[end if]
|
||||
[else]
|
||||
[if(
|
||||
([StartRole.multiplicity] == "1" and [EndRole.multiplicity] == "1..*") or
|
||||
([StartRole.multiplicity] == "1" and [EndRole.multiplicity] == "*") or
|
||||
([StartRole.multiplicity] == "1" and [EndRole.multiplicity] == "0..*") or
|
||||
|
||||
([StartRole.multiplicity] == "0..1" and [EndRole.multiplicity] == "1..*") or
|
||||
([StartRole.multiplicity] == "0..1" and [EndRole.multiplicity] == "*") or
|
||||
([StartRole.multiplicity] == "0..1" and [EndRole.multiplicity] == "0..*")
|
||||
/*
|
||||
([StartRole.multiplicity] == "0..*" and [EndRole.multiplicity] == "0..*") or
|
||||
([StartRole.multiplicity] == "1..*" and [EndRole.multiplicity] == "0..*") or
|
||||
([StartRole.multiplicity] == "*" and [EndRole.multiplicity] == "0..*") or
|
||||
|
||||
([StartRole.multiplicity] == "0..*" and [EndRole.multiplicity] == "*") or
|
||||
([StartRole.multiplicity] == "1..*" and [EndRole.multiplicity] == "*") or
|
||||
([StartRole.multiplicity] == "*" and [EndRole.multiplicity] == "*") or
|
||||
|
||||
([StartRole.multiplicity] == "0..*" and [EndRole.multiplicity] == "1..*") or
|
||||
([StartRole.multiplicity] == "1..*" and [EndRole.multiplicity] == "1..*") or
|
||||
([StartRole.multiplicity] == "*" and [EndRole.multiplicity] == "1..*")
|
||||
*/
|
||||
)]
|
||||
[if ([ENTITY.name] != [PartnerClass.name] or [EndRole.isNavigable] == "TRUE")]
|
||||
if (this.[DefineRoleName([EndRole])].Count > 0)
|
||||
{
|
||||
[/*
|
||||
// startrole: [StartRole.multiplicity], endrole: [EndRole.multiplicity]
|
||||
*/]
|
||||
throw new EntityDeleteFailedException("[ENTITY.name]", "[DefineRoleName([EndRole])]", EntityUtil.GetAssociationDescription("[ConvertNameToSQLTableName([PartnerClass.name])]", "[ConvertNameToSQLColumnName(ConvertRoleToName([StartRole]))]")); // nincs kapcsolotabla
|
||||
}
|
||||
[else]
|
||||
// [DefineRoleName([EndRole])] esetében önmagunkra mutatunk, nincs mit ellenőrizni. startrole: [StartRole.multiplicity], endrole: [EndRole.multiplicity]
|
||||
[end if]
|
||||
[else]
|
||||
[if (
|
||||
([StartRole.multiplicity] == "0..*" and [EndRole.multiplicity] == "0..*") or
|
||||
([StartRole.multiplicity] == "1..*" and [EndRole.multiplicity] == "0..*") or
|
||||
([StartRole.multiplicity] == "*" and [EndRole.multiplicity] == "0..*") or
|
||||
|
||||
([StartRole.multiplicity] == "0..*" and [EndRole.multiplicity] == "*") or
|
||||
([StartRole.multiplicity] == "1..*" and [EndRole.multiplicity] == "*") or
|
||||
([StartRole.multiplicity] == "*" and [EndRole.multiplicity] == "*") or
|
||||
|
||||
([StartRole.multiplicity] == "0..*" and [EndRole.multiplicity] == "1..*") or
|
||||
([StartRole.multiplicity] == "1..*" and [EndRole.multiplicity] == "1..*") or
|
||||
([StartRole.multiplicity] == "*" and [EndRole.multiplicity] == "1..*")
|
||||
)]
|
||||
[if ([ENTITY.name] != [PartnerClass.name] or [EndRole.isNavigable] == "TRUE")]
|
||||
if (this.[DefineRoleName([EndRole])].Count > 0)
|
||||
{
|
||||
[/*
|
||||
// startrole: [StartRole.multiplicity], endrole: [EndRole.multiplicity]
|
||||
*/]
|
||||
throw new EntityDeleteFailedException("[ENTITY.name]", "[DefineRoleName([EndRole])]", EntityUtil.GetAssociationDescription("[ConvertNameToSQLTableName([PartnerClass.name])]", "ID")); // *-* + kapcsolotabla
|
||||
}
|
||||
[end if]
|
||||
[else]
|
||||
// [DefineRoleName([EndRole])] esetében mi mutatunk a másikra: startrole: [StartRole.multiplicity], endrole: [EndRole.multiplicity]
|
||||
[end if]
|
||||
[end if]
|
||||
[end if]
|
||||
[end if]
|
||||
[else]
|
||||
[loop (CurrentAssoc -> AssociationClass)]
|
||||
[if ([ENTITY.name] != DefineRoleName([EndRole]) or [EndRole.isNavigable] == "TRUE")]
|
||||
[if ([EndRole.multiplicity] == "1" or [EndRole.multiplicity] == "0..1")]
|
||||
if (this.[DefineRoleName([EndRole])] != null)
|
||||
{
|
||||
[/*
|
||||
// asszociacios osztaly
|
||||
*/]
|
||||
throw new EntityDeleteFailedException("[ENTITY.name]", "[DefineRoleName([EndRole])]", EntityUtil.GetAssociationDescription("[ConvertNameToSQLTableName([AssociationClass.name])]", "[ConvertNameToSQLColumnName(ConvertRoleToName([EndRole]))]"));
|
||||
}
|
||||
[else]
|
||||
if (this.[DefineRoleName([EndRole])].Count > 0)
|
||||
{
|
||||
[/*
|
||||
// asszociacios osztaly
|
||||
*/]
|
||||
throw new EntityDeleteFailedException("[ENTITY.name]", "[DefineRoleName([EndRole])]", EntityUtil.GetAssociationDescription("[ConvertNameToSQLTableName([AssociationClass.name])]", "[ConvertNameToSQLColumnName(ConvertRoleToName([EndRole]))]"));
|
||||
}
|
||||
[end if]
|
||||
[else]
|
||||
// [DefineRoleName([EndRole])] esetében nincs ilyen property, nem navigálható, névütközés, stb., nincs mit ellenőrizni. startrole: [StartRole.multiplicity], endrole: [EndRole.multiplicity]
|
||||
[end if]
|
||||
[end loop]
|
||||
[end if]
|
||||
[end loop]
|
||||
|
||||
// kaszkád törlések...
|
||||
|
||||
[loop (ENTITY -> Role as StartRole -> MAssociation as CurrentAssoc -> MAssociationEnd as EndRole -> MClass as PartnerClass
|
||||
where (([StartRole.id] != [EndRole.id])
|
||||
and GetStereoType([PartnerClass]) == "Entity")
|
||||
and IsCascadeDelete([CurrentAssoc]) == "True"
|
||||
)]
|
||||
[if (([PartnerClass.name] != [ENTITY.name]) or ([PartnerClass.name] == [ENTITY.name] and [ENTITY.name] != DefineRoleName([EndRole])))]
|
||||
[if (HasAssociationClass([CurrentAssoc]) == "")]
|
||||
[if ([StartRole.multiplicity] == "1" and [EndRole.multiplicity] == "0..1")]
|
||||
if (this.[DefineRoleName([EndRole])] != null)
|
||||
{
|
||||
if (this.[DefineRoleName([EndRole])].State != EntityState.Removed)
|
||||
{
|
||||
if (this.[DefineRoleName([EndRole])].ID != this.ID)
|
||||
{
|
||||
this.[DefineRoleName([EndRole])].CascadeDelete(runHandler); // Kötelezően ránk mutat...
|
||||
}
|
||||
}
|
||||
}
|
||||
[else]
|
||||
[if(
|
||||
([StartRole.multiplicity] == "1" and [EndRole.multiplicity] == "1..*") or
|
||||
([StartRole.multiplicity] == "1" and [EndRole.multiplicity] == "*") or
|
||||
([StartRole.multiplicity] == "1" and [EndRole.multiplicity] == "0..*")
|
||||
)]
|
||||
foreach ([PartnerClass.name] partner in this.[DefineRoleName([EndRole])])
|
||||
{
|
||||
if (partner.State != EntityState.Removed)
|
||||
{
|
||||
if (partner.ID != this.ID)
|
||||
{
|
||||
partner.CascadeDelete(runHandler); // Kötelezően ránk mutat...
|
||||
}
|
||||
}
|
||||
}
|
||||
[else]
|
||||
[if ([EndRole.multiplicity] == "0..1")]
|
||||
this.[DefineRoleName([EndRole])] = null;
|
||||
[else]
|
||||
[if ([EndRole.multiplicity] != "1")]
|
||||
this.[DefineRoleName([EndRole])].RemoveAll();
|
||||
[end if]
|
||||
[end if]
|
||||
[end if]
|
||||
[end if]
|
||||
[else]
|
||||
[loop (CurrentAssoc -> AssociationClass)]
|
||||
[if ([EndRole.multiplicity] == "1" or [EndRole.multiplicity] == "0..1")]
|
||||
if (this.[DefineRoleName([EndRole])] != null)
|
||||
{
|
||||
if (this.[DefineRoleName([EndRole])].State != EntityState.Removed)
|
||||
{
|
||||
if (this.[DefineRoleName([EndRole])].ID != this.ID)
|
||||
{
|
||||
this.[DefineRoleName([EndRole])].CascadeDelete(runHandler); // Asszociációs osztály
|
||||
}
|
||||
}
|
||||
}
|
||||
[else]
|
||||
foreach ([AssociationClass.name] associationclass in this.[DefineRoleName([EndRole])])
|
||||
{
|
||||
if (associationclass.State != EntityState.Removed)
|
||||
{
|
||||
if (associationclass.ID != this.ID)
|
||||
{
|
||||
associationclass.CascadeDelete(runHandler); // Asszociációs osztály
|
||||
}
|
||||
}
|
||||
}
|
||||
[end if]
|
||||
[end loop]
|
||||
[end if]
|
||||
[end if]
|
||||
[end loop]
|
||||
[if (IsMasterEntity([ENTITY]) == "false")]
|
||||
base.DeAssociateBeforeDelete(runHandler);
|
||||
[end if]
|
||||
}
|
||||
end template
|
||||
|
||||
|
||||
proc GenerateEntityHistoryModeAttribute(MClass as ENTITY)
|
||||
local temp;
|
||||
[temp] = GetTaggedValue([ENTITY], "historymode");
|
||||
|
||||
if ([temp] != "")
|
||||
if (searchstr([temp], ",", 0) != "-1")
|
||||
return "[EntityHistoryModeAttribute(\"" [temp] "\")]";
|
||||
else
|
||||
return "[EntityHistoryModeAttribute(EntityHistoryModes." [temp] ")]";
|
||||
end if
|
||||
else
|
||||
return "// alapértelmezett EntityHistoryMode";
|
||||
//return "[EntityHistoryModeAttribute(EntityHistoryModes.Default)] // alapértelmezett EntityHistoryModesß";
|
||||
end if
|
||||
end proc
|
||||
|
||||
Reference in New Issue
Block a user