110 lines
No EOL
5.1 KiB
Text
110 lines
No EOL
5.1 KiB
Text
template GenerateEntityInterface(MClass as ENTITY)
|
|
[BOM]using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Kreta.DataAccess.Interfaces
|
|
{
|
|
public interface I[ENTITY.name] : I[GetBaseClassName([ENTITY], "Entity")]
|
|
{
|
|
[GenerateSimpleInterfaceFields([ENTITY])]
|
|
[GenerateAssociationClassInterfaceFields([ENTITY])]
|
|
[GenerateFirstCaseInterfaceAssociations([ENTITY])]
|
|
[GenerateThirdCaseInterfaceAssociations([ENTITY])]
|
|
}
|
|
}
|
|
|
|
end template
|
|
|
|
template GenerateAssociationClassInterfaceFields(MClass)
|
|
[loop (MClass -> MAssociation as CurrentAssoc -> MAssociationEnd as StartRole -> MClass as StartClass where (GetStereoType([StartClass]) == "Entity"))]
|
|
[loop (CurrentAssoc -> MAssociationEnd as EndRole -> MClass as EndClass where([StartRole.id] < [EndRole.id] and GetStereoType([EndClass]) == "Entity" ))]
|
|
[GetCSharpType("ID")] [ConvertRoleToName([StartRole])] { get; set; }
|
|
I[StartClass.name] [DefineRoleName([StartRole])] { get; set; }
|
|
[GetCSharpType("ID")] [ConvertRoleToName([EndRole])] { get; set; }
|
|
I[EndClass.name] [DefineRoleName([EndRole])] { get; set; }
|
|
|
|
[end loop]
|
|
[end loop]
|
|
|
|
end template
|
|
|
|
template GenerateSimpleInterfaceFields(MClass as ENTITY)
|
|
[loop (ENTITY -> MAttribute as ATTRIBUTE)]
|
|
[GenerateInterfaceAttributeProperty([ENTITY], [ATTRIBUTE])]
|
|
[end loop]
|
|
|
|
end template
|
|
|
|
template GenerateInterfaceAttributeProperty(MClass as ENTITY, MAttribute as ATTRIBUTE)
|
|
[if (IsComputedAttribute([ATTRIBUTE]) == _False())]
|
|
[if (IsAttributeRequired([ATTRIBUTE]) == _True())]
|
|
[GetCSharpType([ATTRIBUTE.type])] [ATTRIBUTE.name] { get; set; }
|
|
[else]
|
|
[GetCSharpNullableType([ATTRIBUTE.type])] [ATTRIBUTE.name] { get; set; }
|
|
[end if]
|
|
[else]
|
|
[if (IsAttributeRequired([ATTRIBUTE]) == _True())]
|
|
[GetCSharpType([ATTRIBUTE.type])] [ATTRIBUTE.name] { get; }
|
|
[else]
|
|
[GetCSharpNullableType([ATTRIBUTE.type])] [ATTRIBUTE.name] { get; }
|
|
[end if]
|
|
[end if]
|
|
end template
|
|
|
|
template GenerateFirstCaseInterfaceAssociations(MClass)
|
|
[loop (MClass -> Role as StartRole -> MAssociation as CurrentAssoc -> MAssociationEnd as EndRole -> MClass as PartnerClass where (([StartRole.id] != [EndRole.id]) and GetStereoType([PartnerClass]) == "Entity"))]
|
|
[if (HasAssociationClass([CurrentAssoc]) == "")]
|
|
[if ([EndRole.multiplicity] == "1" or [EndRole.multiplicity] == "0..1")]
|
|
[if (([PartnerClass.name] != [MClass.name]) or ([PartnerClass.name] == [MClass.name] and [MClass.name] != DefineRoleName([EndRole])))]
|
|
[if ([StartRole.multiplicity] == "1..*" or [StartRole.multiplicity] == "*" or [StartRole.multiplicity] == "0..*" or [EndRole.multiplicity] == "1")]
|
|
int [ConvertRoleToName([EndRole])] { get; set; }
|
|
[end if]
|
|
I[PartnerClass.name] [DefineRoleName([EndRole])] { get; set; }
|
|
[end if]
|
|
[end if]
|
|
[end if]
|
|
[end loop]
|
|
|
|
[loop (MClass -> Role as StartRole -> MAssociation as CurrentAssoc -> MAssociationEnd as EndRole -> MClass as PartnerClass where (([StartRole.id] != [EndRole.id]) and GetStereoType([PartnerClass]) == "Entity"))]
|
|
[if (HasAssociationClass([CurrentAssoc]) != "")]
|
|
[if ([EndRole.multiplicity] == "1" or [EndRole.multiplicity] == "0..1")]
|
|
[if (([PartnerClass.name] != [MClass.name]) or ([PartnerClass.name] == [MClass.name] and [MClass.name] != DefineRoleName([EndRole])))]
|
|
[loop (CurrentAssoc -> AssociationClass)]
|
|
I[AssociationClass.name] [DefineRoleName([EndRole])] { get; set; }
|
|
[end loop]
|
|
[end if]
|
|
[end if]
|
|
[end if]
|
|
[end loop]
|
|
|
|
end template
|
|
|
|
|
|
template GenerateThirdCaseInterfaceAssociations(MClass as ENTITY)
|
|
[loop (ENTITY -> Role as STARTROLE -> MAssociation as CURRENTASSOCIATION -> MAssociationEnd as ENDROLE -> MClass as PARTNERCLASS where (GetStereoType([PARTNERCLASS]) == "Entity") )]
|
|
[if ([STARTROLE.id] != [ENDROLE.id])]
|
|
[if (HasAssociationClass([CURRENTASSOCIATION]) == "")]
|
|
[if ([ENDROLE.multiplicity] == "*" or [ENDROLE.multiplicity] == "1..*" or [ENDROLE.multiplicity] == "0..*")]
|
|
[if (([PARTNERCLASS.name] != [ENTITY.name]) or ([PARTNERCLASS.name] == [ENTITY.name] and [ENTITY.name] != DefineRoleName([ENDROLE])))]
|
|
IReadOnlyList<I[PARTNERCLASS.name]> [DefineRoleName([ENDROLE])] { get; }
|
|
[end if]
|
|
[end if]
|
|
[end if]
|
|
[end if]
|
|
[end loop]
|
|
|
|
[loop (ENTITY -> Role as STARTROLE -> MAssociation as CURRENTASSOCIATION -> MAssociationEnd as ENDROLE -> MClass as PARTNERCLASS where (GetStereoType([PARTNERCLASS]) == "Entity") )]
|
|
[if ([STARTROLE.id] != [ENDROLE.id])]
|
|
[if (HasAssociationClass([CURRENTASSOCIATION]) != "")]
|
|
[if ([ENDROLE.multiplicity] == "*" or [ENDROLE.multiplicity] == "1..*" or [ENDROLE.multiplicity] == "0..*")]
|
|
[if (([PARTNERCLASS.name] != [ENTITY.name]) or ([PARTNERCLASS.name] == [ENTITY.name] and [ENTITY.name] != DefineRoleName([ENDROLE])))]
|
|
[loop (CURRENTASSOCIATION -> AssociationClass as ASSOCIATIONCLASS)]
|
|
IReadOnlyList<I[ASSOCIATIONCLASS.name]> [DefineRoleName([ENDROLE])] { get; }
|
|
[end loop]
|
|
[end if]
|
|
[end if]
|
|
[end if]
|
|
[end if]
|
|
[end loop]
|
|
|
|
end template |