init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,86 @@
|
|||
USES Common/std;
|
||||
USES Common/Converters;
|
||||
USES Common/CommonUtil;
|
||||
USES Common/StringUtil;
|
||||
USES Common/ModelDataRetreive;
|
||||
USES Common/DBUtil;
|
||||
|
||||
USES Database/SQLGenerator;
|
||||
|
||||
proc main()
|
||||
// initialize the output and other context information
|
||||
Init();
|
||||
CreateDescriptionList();
|
||||
end proc
|
||||
|
||||
proc Init()
|
||||
setOutput( [OutputDir] "/" "create.comments.sql" );
|
||||
|
||||
// UTF-8 BOM bájtok
|
||||
setVar("BOM", "\xEF\xBB\xBF");
|
||||
end proc
|
||||
proc CreateDescriptionList()
|
||||
out = [BOM];
|
||||
loop ( Instances -> MClass where GetStereoType([MClass]) == "Entity" )
|
||||
if ( string_trim(ConvertDescriptionToString([MClass.description])) != "" )
|
||||
out = "EXEC sp_addextendedproperty @name = N'MS_Description', @level0type = N'Schema', @level0name = N'dbo' ,@level1type = N'Table', @level1name = N'"ConvertNameToSQLTableScript([MClass.name])"',@level2type = NULL, @level2name = NULL, @value = N'"string_trim(ConvertDescriptionToString([MClass.description]))"';\n";
|
||||
end if
|
||||
end loop
|
||||
loop ( Instances -> MClass where GetStereoType([MClass]) == "Entity" )
|
||||
loop ( MClass -> MAttribute )
|
||||
if ( string_trim(ConvertDescriptionToString([MAttribute.description])) != "" )
|
||||
out = "EXEC sp_addextendedproperty @name = N'MS_Description', @level0type = N'Schema', @level0name = N'dbo' ,@level1type = N'Table', @level1name = N'"ConvertNameToSQLTableScript([MClass.name])"' ,@level2type = N'Column', @level2name = N'"ConvertNameToSQLColumnName([MAttribute.name])"', @value = N'"string_trim(ConvertDescriptionToString([MAttribute.description]))"';\n";
|
||||
end if
|
||||
end loop
|
||||
end loop
|
||||
local HasAC = "";
|
||||
loop ( Instances -> MClass where GetStereoType([MClass]) == "Entity" )
|
||||
loop (MClass->Role as StartRole ->MAssociation as CurrentAssoc ->MAssociationEnd as EndRole -> MClass as PartnerClass where (([StartRole.id]!=[EndRole.id]) and GetStereoType([PartnerClass]) == "Entity"))
|
||||
[HasAC] = HasAssociationClass([CurrentAssoc]);
|
||||
if ([HasAC] == "")
|
||||
if (
|
||||
//0..1-1
|
||||
([StartRole.multiplicity]=="0..1" and [EndRole.multiplicity]=="1") or
|
||||
//1..*-1
|
||||
([StartRole.multiplicity]=="1..*" and [EndRole.multiplicity]=="1") or
|
||||
//*-1
|
||||
([StartRole.multiplicity]=="*" and [EndRole.multiplicity]=="1") or
|
||||
([StartRole.multiplicity]=="0..*" and [EndRole.multiplicity]=="1")
|
||||
)
|
||||
if (string_trim(ConvertDescriptionToString([CurrentAssoc.description])) != "" )
|
||||
out = "EXEC sp_addextendedproperty @name = N'MS_Description', @level0type = N'Schema', @level0name = N'dbo' ,@level1type = N'Table', @level1name = N'"ConvertNameToSQLTableScript([MClass.name])"' ,@level2type = N'Column', @level2name = N'"ConvertNameToSQLColumnName(ConvertRoleToName([EndRole]))"', @value = N'"string_trim(ConvertDescriptionToString([CurrentAssoc.description]))"';\n";
|
||||
end if
|
||||
end if
|
||||
if (
|
||||
//1..*-0..1
|
||||
([StartRole.multiplicity]=="1..*" and [EndRole.multiplicity]=="0..1") or
|
||||
//*-0..1
|
||||
([StartRole.multiplicity]=="*" and [EndRole.multiplicity]=="0..1") or
|
||||
([StartRole.multiplicity]=="0..*" and [EndRole.multiplicity]=="0..1")
|
||||
)
|
||||
if (string_trim(ConvertDescriptionToString([CurrentAssoc.description])) != "" )
|
||||
out = "EXEC sp_addextendedproperty @name = N'MS_Description', @level0type = N'Schema', @level0name = N'dbo' ,@level1type = N'Table', @level1name = N'"ConvertNameToSQLTableScript([MClass.name])"' ,@level2type = N'Column', @level2name = N'"ConvertNameToSQLColumnName(ConvertRoleToName([EndRole]))"', @value = N'"string_trim(ConvertDescriptionToString([CurrentAssoc.description]))"';\n";
|
||||
end if
|
||||
end if
|
||||
end if
|
||||
end loop
|
||||
end loop
|
||||
loop ( Instances -> MClass where GetStereoType([MClass]) == "Entity" )
|
||||
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" ))
|
||||
if (string_trim(ConvertDescriptionToString([CurrentAssoc.description])) != "" )
|
||||
out = "EXEC sp_addextendedproperty @name = N'MS_Description', @level0type = N'Schema', @level0name = N'dbo' ,@level1type = N'Table', @level1name = N'"ConvertNameToSQLTableScript([MClass.name])"' ,@level2type = N'Column', @level2name = N'"ConvertNameToSQLColumnName(ConvertRoleToName([StartRole]))"', @value = N'"string_trim(ConvertDescriptionToString([CurrentAssoc.description]))"';\n";
|
||||
out = "EXEC sp_addextendedproperty @name = N'MS_Description', @level0type = N'Schema', @level0name = N'dbo' ,@level1type = N'Table', @level1name = N'"ConvertNameToSQLTableScript([MClass.name])"' ,@level2type = N'Column', @level2name = N'"ConvertNameToSQLColumnName(ConvertRoleToName([EndRole]))"', @value = N'"string_trim(ConvertDescriptionToString([CurrentAssoc.description]))"';\n";
|
||||
end if
|
||||
end loop
|
||||
end loop
|
||||
end loop
|
||||
end proc
|
||||
|
||||
tcl_proc string_trim(str)
|
||||
return [string trim $str];
|
||||
end proc
|
||||
|
||||
proc ConvertDescriptionToString(description)
|
||||
return replace(replace(replace(replace([description], "\t", " "), "\r", ""), "\n", " "), "'", "''");
|
||||
end proc
|
Loading…
Add table
Add a link
Reference in a new issue