250 lines
No EOL
8.6 KiB
Text
250 lines
No EOL
8.6 KiB
Text
//***************************************************************************//
|
|
// Legenerálja a metamodell teljes forráskódját. //
|
|
//***************************************************************************//
|
|
template GenerateMetaModel()
|
|
[BOM]using System;
|
|
using SDA.Framework.MetaPaletteShema;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
|
|
namespace SDA.[ProjectName].MetaPaletteShema
|
|
{
|
|
public sealed class [ProjectName]MetaPaletteStructure : AbstractMetaPaletteStructure
|
|
{
|
|
#region Base classes
|
|
|
|
[GenerateBaseClasses()]
|
|
|
|
#endregion Base classes
|
|
|
|
#region Static variables
|
|
|
|
[loop (Instances -> MClass Where( GetStereoType([MClass]) == "Entity" ))]
|
|
[GenerateMetaPalette([MClass])]
|
|
[GenerateMetaPaletteField([MClass])]
|
|
[GenerateMetaPaletteRole([MClass])]
|
|
[GenerateMetaPaletteAssociation([MClass])]
|
|
[end loop]
|
|
|
|
static readonly MetaPaletteCollection _palettes = new MetaPaletteCollection();
|
|
static readonly MetaPaletteFieldCollection _attributes = new MetaPaletteFieldCollection();
|
|
static readonly MetaPaletteRoleCollection _roles = new MetaPaletteRoleCollection();
|
|
static readonly MetaPaletteAssociationCollection _associations = new MetaPaletteAssociationCollection();
|
|
|
|
#endregion Static variables
|
|
|
|
static [ProjectName]MetaPaletteStructure()
|
|
{
|
|
IMetaPalette palette;
|
|
IMetaPaletteField field;
|
|
IMetaPaletteRole role;
|
|
IMetaPaletteAssociation association;
|
|
foreach (var value in
|
|
typeof([ProjectName]MetaPaletteStructure)
|
|
.GetFields(BindingFlags.Static|BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.DeclaredOnly)
|
|
.Select(f => f.GetValue(null)))
|
|
{
|
|
if ((palette = value as IMetaPalette) != null)
|
|
{
|
|
_palettes.Add(palette.Name, palette);
|
|
}
|
|
if ((field = value as IMetaPaletteField) != null)
|
|
{
|
|
_attributes.Add(field.ID, field);
|
|
}
|
|
if ((role = value as IMetaPaletteRole) != null)
|
|
{
|
|
_roles.Add(role.ID, role);
|
|
}
|
|
if ((association = value as IMetaPaletteAssociation) != null)
|
|
{
|
|
_associations.Add(association.ID, association);
|
|
}
|
|
}
|
|
}
|
|
|
|
#region Abstract members
|
|
|
|
public override MetaPaletteCollection Palettes { get { return _palettes; } }
|
|
|
|
public override MetaPaletteFieldCollection Attributes { get { return _attributes; } }
|
|
|
|
public override MetaPaletteRoleCollection AssociationRoles { get { return _roles; } }
|
|
|
|
public override MetaPaletteAssociationCollection Associations { get { return _associations; } }
|
|
|
|
#endregion Abstract members
|
|
}
|
|
}
|
|
end template
|
|
|
|
|
|
//***************************************************************************//
|
|
// Egy listat keszit a dictionaryitemekrol //
|
|
//***************************************************************************//
|
|
template DictionaryItemList()
|
|
[loop (Instances -> MClass)]
|
|
[if (IsEntity([MClass]) == "True")]
|
|
[if (IsProtectedDictionaryItem([MClass]) == "True")]
|
|
[GetEntityName([MClass])];[ConvertNameToSQLTableScript(GetEntityName([MClass]))];[IsProtectedDictionaryItem([MClass])];[GetPackage([MClass])]
|
|
[end if]
|
|
[end if]
|
|
[end loop]
|
|
end template
|
|
|
|
|
|
template GenerateMetaPalette(MClass)
|
|
public static readonly IMetaPalette [MClass.name] = new MetaPalette([MClass.id], "[split([MClass.guid], "_", 1)]")
|
|
{
|
|
Name = @"[MClass.name]",
|
|
[if ([MClass.description]!="")]
|
|
Description = "[replace([MClass.description],"\"","\\\"")]",
|
|
[end if]
|
|
[setVar("hastag", "")]
|
|
[loop (MClass -> TaggedValue)]
|
|
[if ([hastag]=="")]
|
|
TagedValues =
|
|
{
|
|
[setVar("hastag", "X")]
|
|
[end if]
|
|
{ @"[TaggedValue.tag]", @"[TaggedValue.value]" },
|
|
[end loop]
|
|
[if ([hastag]!="")]
|
|
},
|
|
[end if]
|
|
DBTableName = @"[ConvertNameToSQLTableName([MClass.name])]",
|
|
[setVar("scn","")]
|
|
[loop (MClass -> SuperClass as sc)]
|
|
[setVar("scn",[sc.name])]
|
|
[end loop]
|
|
[if ([scn]!="")]
|
|
BaseMetaPaletteName = @"[scn]",
|
|
[end if]
|
|
[setVar("associd", "")]
|
|
[loop (MClass -> MAssociation as assoc )]
|
|
[setVar("associd", [assoc.id])]
|
|
[end loop]
|
|
[if ([associd]!="")]
|
|
AssociationID = "[associd]",
|
|
[end if]
|
|
};
|
|
end template
|
|
|
|
|
|
template GenerateMetaPaletteField(MClass)
|
|
[loop (MClass -> MAttribute)]
|
|
internal static readonly IMetaPaletteField Attribute[MAttribute.id] = new MetaPaletteField([MAttribute.id], "[split([MAttribute.guid], "_", 1)]")
|
|
{
|
|
OwnerMetaPaletteName = @"[MClass.name]",
|
|
Name = @"[MAttribute.name]",
|
|
Type = AttributeType.[MAttribute.type],
|
|
[if ([MAttribute.description]!="")]
|
|
Description = "[replace([MAttribute.description],"\"","\\\"")]",
|
|
[end if]
|
|
[setVar("hastag", "")]
|
|
[loop (MAttribute -> TaggedValue)]
|
|
[if ([hastag]=="")]
|
|
TagedValues =
|
|
{
|
|
[setVar("hastag", "X")]
|
|
[end if]
|
|
{ @"[TaggedValue.tag]", @"[TaggedValue.value]" },
|
|
[end loop]
|
|
[if ([MAttribute.type]=="DictionaryItem")]
|
|
[if ([hastag]=="")]
|
|
TagedValues =
|
|
{
|
|
[setVar("hastag", "X")]
|
|
[end if]
|
|
{ @"DictionaryItemType", @"[MAttribute.defaultValue]" },
|
|
[else]
|
|
[if ([MAttribute.defaultValue]!="")]
|
|
[if ([hastag]=="")]
|
|
TagedValues =
|
|
{
|
|
[setVar("hastag", "X")]
|
|
[end if]
|
|
{ @"_DefaultValue_", @"[replace([MAttribute.defaultValue],"\"","\"\"")]" },
|
|
[end if]
|
|
[end if]
|
|
[if (GetStereoTypeForAttribute([MAttribute])=="DisplayName")]
|
|
[if ([hastag]=="")]
|
|
TagedValues =
|
|
{
|
|
[setVar("hastag", "X")]
|
|
[end if]
|
|
{ @"_DisplayName_", @"true" },
|
|
[end if]
|
|
[if ([hastag]!="")]
|
|
},
|
|
[end if]
|
|
DBFieldName = @"[ConvertNameToSQLColumnName([MAttribute.name])]",
|
|
};
|
|
[end loop]
|
|
end template
|
|
|
|
|
|
template GenerateMetaPaletteRole(MClass)
|
|
[loop (MClass -> Role as StartRole -> MAssociation -> MAssociationEnd as EndRole -> MClass as EndClass Where( ( GetStereoType([EndClass]) == "Entity" ) and ( [StartRole.id] != [EndRole.id] ) ))]
|
|
internal static readonly IMetaPaletteRole Role[StartRole.id] = new MetaPaletteRole([StartRole.id], "[split([StartRole.guid], "_", 1)]")
|
|
{
|
|
OwnerMetaPaletteName = @"[MClass.name]",
|
|
[if ([StartRole.name]!="")]
|
|
Name = @"[StartRole.name]",
|
|
[end if]
|
|
[if ([StartRole.description]!="")]
|
|
Description = "[replace([StartRole.description],"\"","\\\"")]",
|
|
[end if]
|
|
[setVar("hastag", "")]
|
|
[loop (StartRole -> TaggedValue)]
|
|
[if ([hastag]=="")]
|
|
TagedValues =
|
|
{
|
|
[setVar("hastag", "X")]
|
|
[end if]
|
|
{ @"[TaggedValue.tag]", @"[TaggedValue.value]" },
|
|
[end loop]
|
|
[if ([hastag]!="")]
|
|
},
|
|
[end if]
|
|
Multiplicity = "[StartRole.multiplicity]",
|
|
MetaPaletteAssociationName = "[MAssociation.id]",
|
|
};
|
|
[end loop]
|
|
end template
|
|
|
|
|
|
template GenerateMetaPaletteAssociation(MClass)
|
|
[loop (MClass -> Role as StartRole -> MAssociation -> MAssociationEnd as EndRole -> MClass as EndClass Where( ( GetStereoType([EndClass]) == "Entity" ) and ( [StartRole.id] < [EndRole.id] ) ) )]
|
|
internal static readonly IMetaPaletteAssociation Association[MAssociation.id] = new MetaPaletteAssociation([MAssociation.id], "[split([MAssociation.guid], "_", 1)]")
|
|
{
|
|
[if ([MAssociation.name]!="")]
|
|
Name = @"[MAssociation.name]",
|
|
[end if]
|
|
[if ([MAssociation.description]!="")]
|
|
Description = "[replace([MAssociation.description],"\"","\\\"")]",
|
|
[end if]
|
|
[setVar("hastag", "")]
|
|
[loop (MAssociation -> TaggedValue)]
|
|
[if ([hastag]=="")]
|
|
TagedValues =
|
|
{
|
|
[setVar("hastag", "X")]
|
|
[end if]
|
|
{ @"[TaggedValue.tag]", @"[TaggedValue.value]" },
|
|
[end loop]
|
|
[if ([hastag]!="")]
|
|
},
|
|
[end if]
|
|
[setVar("assocclassname","")]
|
|
[loop (MAssociation -> AssociationClass)]
|
|
[setVar("assocclassname",[AssociationClass.name])]
|
|
[end loop]
|
|
[if ([assocclassname]!="")]
|
|
AssociationMetaPaletteName = @"[assocclassname]",
|
|
[end if]
|
|
};
|
|
[end loop]
|
|
end template |