init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,184 @@
|
|||
//***************************************************************************//
|
||||
// A használt fájlok //
|
||||
//***************************************************************************//
|
||||
USES Common/std;
|
||||
USES Common/Converters;
|
||||
USES Common/CommonUtil;
|
||||
USES Common/StringUtil;
|
||||
USES Common/ModelDataRetreive;
|
||||
USES Common/DBUtil;
|
||||
|
||||
USES Database/SQLGenerator;
|
||||
|
||||
proc main()
|
||||
Init();
|
||||
// info = "";
|
||||
if ([SQL_DBType] == "MSSQL")
|
||||
out = MultiLanguageViews_Mssql();
|
||||
else
|
||||
if ([SQL_DBType] == "ORACLE")
|
||||
out = MultiLanguageViews_Oracle();
|
||||
end if
|
||||
end if
|
||||
// info = "";
|
||||
end proc
|
||||
|
||||
|
||||
//***************************************************************************//
|
||||
// Általános inicializálás //
|
||||
//***************************************************************************//
|
||||
proc Init()
|
||||
local dbtag = "";
|
||||
//current language
|
||||
setLanguage("SQL");
|
||||
//mkdir([OutputDir]);
|
||||
|
||||
switch( [SQL_DBType] )
|
||||
//ORACLE Type
|
||||
case "ORACLE" :
|
||||
[dbtag] = "ora";
|
||||
break;
|
||||
|
||||
//MSSQL Type
|
||||
case "MSSQL" :
|
||||
[dbtag] = "mssql";
|
||||
break;
|
||||
|
||||
//DB2 Type
|
||||
case "DB2" :
|
||||
[dbtag] = "db2";
|
||||
break;
|
||||
end switch
|
||||
|
||||
setOutput( [OutputDir] "/" "create.multilang." [dbtag] ".sql");
|
||||
|
||||
// UTF-8 BOM bájtok
|
||||
setVar("BOM", "\xEF\xBB\xBF");
|
||||
end proc
|
||||
|
||||
|
||||
|
||||
template MultiLanguageViews_Oracle()
|
||||
[BOM]
|
||||
[loop (Instances -> MClass as ENTITY where GetStereoType([ENTITY]) == "Entity" and HasMultiLanguageAttributes([ENTITY]) == _True())]
|
||||
[GenerateMultiLanguageView_Oracle([ENTITY], 1)]
|
||||
/
|
||||
|
||||
[GenerateMultiLanguageView_Oracle([ENTITY], 2)]
|
||||
/
|
||||
|
||||
[GenerateMultiLanguageView_Oracle([ENTITY], 3)]
|
||||
/
|
||||
|
||||
[GenerateMultiLanguageView_Oracle([ENTITY], 4)]
|
||||
/
|
||||
|
||||
[end loop]
|
||||
QUIT
|
||||
|
||||
end template
|
||||
|
||||
|
||||
template GenerateMultiLanguageView_Oracle(MClass as ENTITY, LANGUAGEINDEX)
|
||||
create or replace view [ConvertNameToSQLTableName([ENTITY.name])]_[LANGUAGEINDEX] as
|
||||
select
|
||||
[loop (ENTITY -> MAttribute as ATTRIBUTE)]
|
||||
[if (IsMultiLanguage([ATTRIBUTE]) == _True() and GetLanguageIndex([ATTRIBUTE]) == 0)]
|
||||
nvl([ConvertNameToSQLColumnName([ATTRIBUTE.name])]_[LANGUAGEINDEX], [ConvertNameToSQLColumnName([ATTRIBUTE.name])]) "[ConvertNameToSQLColumnName([ATTRIBUTE.name])]",
|
||||
[else]
|
||||
[ConvertNameToSQLColumnName([ATTRIBUTE.name])],
|
||||
[end if]
|
||||
[end loop]
|
||||
[loop (ENTITY -> 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") and (([StartRole.multiplicity] == "1..*") or ([StartRole.multiplicity] == "*") or ([StartRole.multiplicity] == "0..*"))))]
|
||||
[ConvertNameToSQLColumnName(ConvertRoleToName([EndRole]))],
|
||||
[end if]
|
||||
[end if]
|
||||
[end loop]
|
||||
[loop (ENTITY -> 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" ))]
|
||||
[ConvertNameToSQLColumnName(ConvertRoleToName([EndRole]))],
|
||||
[ConvertNameToSQLColumnName(ConvertRoleToName([StartRole]))],
|
||||
[end loop]
|
||||
[end loop]
|
||||
[if (IsMasterEntity([ENTITY]) == "true")]
|
||||
SERIAL,
|
||||
LASTCHANGED,
|
||||
MODIFIER,
|
||||
CREATED,
|
||||
CREATOR,
|
||||
[end if]
|
||||
ID
|
||||
from
|
||||
[ConvertNameToSQLTableName([ENTITY.name])]
|
||||
end template
|
||||
|
||||
|
||||
template MultiLanguageViews_Mssql()
|
||||
[BOM]
|
||||
[loop (Instances -> MClass as ENTITY where GetStereoType([ENTITY]) == "Entity" and HasMultiLanguageAttributes([ENTITY]) == _True())]
|
||||
[GenerateMultiLanguageView_Mssql([ENTITY], 1)]
|
||||
go
|
||||
|
||||
[GenerateMultiLanguageView_Mssql([ENTITY], 2)]
|
||||
go
|
||||
|
||||
[GenerateMultiLanguageView_Mssql([ENTITY], 3)]
|
||||
go
|
||||
|
||||
[GenerateMultiLanguageView_Mssql([ENTITY], 4)]
|
||||
go
|
||||
|
||||
[end loop]
|
||||
end template
|
||||
|
||||
|
||||
template GenerateMultiLanguageView_Mssql(MClass as ENTITY, LANGUAGEINDEX)
|
||||
if exists ( select name from sysobjects where name = '[ConvertNameToSQLTableName([ENTITY.name])]_[LANGUAGEINDEX]' and type = 'V')
|
||||
drop view [ConvertNameToSQLTableName([ENTITY.name])]_[LANGUAGEINDEX]
|
||||
go
|
||||
|
||||
create view [ConvertNameToSQLTableName([ENTITY.name])]_[LANGUAGEINDEX] as
|
||||
select
|
||||
[loop (ENTITY -> MAttribute as ATTRIBUTE)]
|
||||
[if (IsMultiLanguage([ATTRIBUTE]) == _True() and GetLanguageIndex([ATTRIBUTE]) == 0)]
|
||||
isnull([ConvertNameToSQLColumnName([ATTRIBUTE.name])]_[LANGUAGEINDEX], [ConvertNameToSQLColumnName([ATTRIBUTE.name])]) "[ConvertNameToSQLColumnName([ATTRIBUTE.name])]",
|
||||
[else]
|
||||
[ConvertNameToSQLColumnName([ATTRIBUTE.name])],
|
||||
[end if]
|
||||
[end loop]
|
||||
[loop (ENTITY -> 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") and (([StartRole.multiplicity] == "1..*") or ([StartRole.multiplicity] == "*") or ([StartRole.multiplicity] == "0..*"))))]
|
||||
[ConvertNameToSQLColumnName(ConvertRoleToName([EndRole]))],
|
||||
[end if]
|
||||
[end if]
|
||||
[end loop]
|
||||
[loop (ENTITY -> 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" ))]
|
||||
[ConvertNameToSQLColumnName(ConvertRoleToName([EndRole]))],
|
||||
[ConvertNameToSQLColumnName(ConvertRoleToName([StartRole]))],
|
||||
[end loop]
|
||||
[end loop]
|
||||
[if (IsMasterEntity([ENTITY]) == "true")]
|
||||
SERIAL,
|
||||
LASTCHANGED,
|
||||
MODIFIER,
|
||||
CREATED,
|
||||
CREATOR,
|
||||
[end if]
|
||||
ID
|
||||
from
|
||||
[ConvertNameToSQLTableName([ENTITY.name])]
|
||||
end template
|
||||
|
||||
|
||||
proc HasMultiLanguageAttributes(MClass as ENTITY)
|
||||
loop (ENTITY -> MAttribute as ATTRIBUTE where IsMultiLanguage([ATTRIBUTE]) == _True())
|
||||
return _True();
|
||||
end loop
|
||||
return _False();
|
||||
end proc
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue