//***************************************************************************// // A paraméterként kapott stringet a névkonvenciókank megfelelő // // indexnévvé konvertálja // //***************************************************************************// proc ConvertNameToIndexName(targetTablename, str) return "NCI_" [targetTablename] "_" [str]; end proc proc ConvertNameToIndexNameOld(str) return toUpper(TruncateString("I_" ConvertNameToSQLTableScript([str]), 29) ); end proc proc ConvertNameToForeignKeyName(tablename, columnname, tablename2) return "FK_" [tablename] "_" [columnname] "_REF_" [tablename2]; end proc proc ConvertNameToUniqueIndexName(tablename, columnname) return "NCU_" [tablename] "_" [columnname]; end proc //***************************************************************************// // A paraméterként kapott cél tábla nevét, és az asszociáció azonosítóját // // a névkonvencióknak megfelelő foregnkeyconstraint névvé konvertája. // //***************************************************************************// proc ConvertNameToForeignKeyConstraint(targetTablename,Associd) return "FK_" [targetTablename] "_" [Associd]; end proc //***************************************************************************// // Kódtételhez táblanevet generál. // //***************************************************************************// proc ConvertDictItemTypeToItemTableName(dictItemType) return ConvertNameToSQLTableScript([dictItemType]); end proc //***************************************************************************// // Kódtételhez fordítástábla nevet generál. // //***************************************************************************// proc ConvertDictItemTypeToTranslationTableName(dictItemType) return ConvertNameToSQLTableScript("TRANS_" [dictItemType] ); end proc //***************************************************************************// // Visszaadja az attributumhoz típusához tartozó kényszereket // //***************************************************************************// proc GetColumnModifyerOfAttribute(MAttribute) local required = GetTaggedValueOfAttribute([MAttribute], "required"); if ( [required] == _True() ) return "NOT NULL"; else return "NULL"; end if // switch( [MAttribute.type] ) // case "String" : // return "null"; // case "Binary" : // return "null"; // case "Integer" : // return "not null"; // case "ID" : // return "null"; // case "Float" : // return "not null"; // case "DateTime": // return "not null"; // case "Boolean" : // return "not null"; // case "DictionaryItem" : // return "null"; // case "Char" : // return "not null"; // default: // return "UNKNOWN TYPE:" [MAttribute.type]; // end switch end proc //***************************************************************************// // Átalakítja az attributm leíró információit SQL típussá. Ezt a függvényt a // // más függvények használják. // // pl: ConvertAttributeToSQlType,ConvertUMLTypeToSQLType // //***************************************************************************// proc ConvertAttributeInfoToSQlType(attributetype, attributelength, attributeprecision, attributeunicode) // attribute length vizsgalat if ([attributelength] == "" ) [attributelength] = GetTaggedValueOfType([attributetype],"length"); end if // attribute precision vizsgalat if ([attributeprecision] == "" ) [attributeprecision] = GetTaggedValueOfType([attributetype],"precision"); end if if ([attributeunicode] == "" ) [attributeunicode] = GetTaggedValueOfType([attributetype],"unicode"); end if switch( [attributetype] ) //String Type case "String" : if ([attributelength] <= "4000") if ([attributeunicode] == "false") return "varchar(" [attributelength] ")"; else return "nvarchar(" [attributelength] ")"; end if else if ([attributeunicode] == "false") return "varchar(max)"; else return "nvarchar(max)"; end if end if case "FixString" : return "char(" [attributelength] ")"; // LongString type case "LongString" : if ([attributeunicode] == "false") return "varchar(max)"; else return "nvarchar(max)"; end if // Binary Type case "Binary" : return "varbinary(max)"; // Integer Type case "Integer" : return "int"; // ID Type case "ID" : return "int"; // retk teszt // Float Type case "Float" : if ([CimbyTest_MSSQL] == "true") return "numeric(" [attributelength] "," [attributeprecision] ")"; else return "numeric(" [attributelength] "," [attributeprecision] ")"; end if // DateTime Type case "DateTime": return "datetime"; // Boolean Type case "Boolean" : return "char(1)"; // DictionaryItem Type case "DictionaryItem" : if ([CimbyTest_MSSQL] == "true") return "int"; else return "numeric(" GetTaggedValueOfType("ID","length") ")"; end if // Char Type case "Char" : return "nchar(1)"; // Guid Type case "Guid" : return "uniqueidentifier"; // Kivetel ag default : return "UNKNOWN TYPE:" [attributetype]; end switch break; end proc //***************************************************************************// // Átalakítja az Attribútumot SQL típussá. // //***************************************************************************// proc ConvertAttributeToSQlType(MAttribute) local attributelength = ""; local attributeprecision = ""; local attributeunicode = ""; [attributelength] = GetTaggedValueOfAttribute([MAttribute],"length"); [attributeprecision] = GetTaggedValueOfAttribute([MAttribute],"precision"); [attributeunicode] = GetTaggedValueOfAttribute([MAttribute],"unicode"); return ConvertAttributeInfoToSQlType([MAttribute.type], [attributelength], [attributeprecision], [attributeunicode]); end proc //***************************************************************************// // Átalakítja az UML modelben felvett és ismert alap típust SQL típussá // //***************************************************************************// proc ConvertUMLTypeToSQLType(attributetype) //default null-okkal hívom meg a convertálást //így a típushoz definiált tulajdonságok figyelembe // vételével történik a convertálás. return ConvertAttributeInfoToSQlType([attributetype],"","", ""); end proc //***************************************************************************// // A paraméterként kapott stringet a név konvencióknak megfelelő SQL // // paraméter névvé konvertálja. // //***************************************************************************// proc ConvertNameToSQLParamName(str) local parPrefix = ""; switch ( [SQL_DBType] ) //ORACLE Type case "ORACLE" : [parPrefix] = ":p"; break; //MSSQL Type case "MSSQL" : [parPrefix] = "@p"; break; //DB2Type case "DB2" : [parPrefix] = ":p"; break; end switch return [parPrefix]toUpper([str]); end proc //***************************************************************************// // A paraméterként kapott stringet a névkonvencióknak megfelelő oszlopnévvé // // konvertálja // //***************************************************************************// proc ConvertNameToSQLColumnName(str) return toUpper(TruncateString("C_" [str], 29)); end proc //***************************************************************************// // A paraméterként kapott stringet a névkonvencióknak megfelelő táblanévvé // // konvertálja // //***************************************************************************// proc ConvertNameToSQLTableScript(str) if (TruncateString([str], 3) == "DKT_") return toUpper("T_"[str]); end if return toUpper(TruncateString("T_"[str], 29)); end proc //***************************************************************************// // A paraméterként kapott stringet a névkonvencióknak megfelelő táblanévvé // // konvertálja Tanév független Intézmény függővé // //***************************************************************************// proc ConvertNameToSQLTableName(str) return ConvertNameToSQLTableScript([str]) "_OSSZES"; end proc //***************************************************************************// // A paraméterként kapott stringet a névkonvencióknak megfelelő táblanévvé // // konvertálja // //***************************************************************************// proc ConvertNameToSQLDefaultTableName(str) return toUpper(TruncateString("D_"[str], 29)); end proc //***************************************************************************// // A paraméterként kapott stringet a névkonvencióknak megfelelő viewnévvé // // konvertálja // //***************************************************************************// proc ConvertNameToSQLViewName(str) return toUpper(TruncateString("T_"[str], 29)); end proc //***************************************************************************// // A paraméterként kapott stringet a névkonvenciókank megfelelő // // primarykey constraint névvé konvertálja // //***************************************************************************// proc ConvertNameToPrimaryKeyConstraintName(str) return "PK_" [str]; end proc //***************************************************************************// // A paraméterként kapott asszociáció azonosítót a névkonvencióknak megfelelő// // uniquekeyconstraint névvé konvertálja. // //***************************************************************************// proc ConvertNameToUniqueKeyConstraint(targetTablename, Associd) return toUpper("UQ_" TruncateString([targetTablename], 27) "_" [Associd]); end proc //***************************************************************************// // A paraméterként kapott stringet a névkonvenciókank megfelelő // // check constraint névvé konvertálja // //***************************************************************************// proc ConvertNameToCheckConstraintName(str) return toUpper(TruncateString("CK_" ConvertNameToSQLTableScript([str]), 29) ); end proc //***************************************************************************// // Meghatározza a paraméterként kapott asszociációsvégponthoz tartozó // // szerepkör nevét. Ha nincs a modelben beállított szerepkörnév akkor // // meghatároz egyet // //***************************************************************************// proc DefineRoleName(MAssociationEnd as StartRole) if ([StartRole.name]!="") return [StartRole.name]; else loop (StartRole -> MClass) return [MClass.name]; end loop end if end proc proc GetRoleClassName(MAssociationEnd as StartRole) loop (StartRole -> MClass) return [MClass.name]; end loop end proc //***************************************************************************// // A paraméterként kapott Asszociációsvégponttot oszlopnévvé konvertája // //***************************************************************************// proc ConvertRoleToName( MAssociationEnd as StartRole ) return DefineRoleName([StartRole]) "Id"; end proc //***************************************************************************// // A paraméterként kapott asszociációsvégpontokat kapcsolótábla névvé // // konvertálja // //***************************************************************************// proc ConvertAssociationRolesToSwitchTableName(MAssociationEnd as StartRole, MAssociationEnd as EndRole) if ([StartRole.id] < [EndRole.id]) return DefineRoleName([StartRole]) "_" DefineRoleName([EndRole]); else return DefineRoleName([EndRole]) "_" DefineRoleName([StartRole]); end if end proc //***************************************************************************// // Az SQL parancsok elválasztására szolgáló szeparátort adja vissza // //***************************************************************************// proc GetCommandSeparator() switch ( [SQL_DBType]) //ORACLE Type case "ORACLE" : return "/"; case "MSSQL" : return "GO"; case "DB2" : return ""; end switch end proc //***************************************************************************// // Az egyes SQL függvények néveltéréseit kiküszöbölő függvény // //***************************************************************************// proc GetFunctionName( functionType ) switch ( toUpper( [ functionType ] )) case "LENGTH" : switch ( [SQL_DBType]) //ORACLE Type case "ORACLE" : return "LENGTH"; case "MSSQL" : return "LEN"; case "DB2" : return "LENGTH"; end switch break; end switch end proc //***************************************************************************// // Az egyes default dátum értékekek kezeléséhez használt függvény // //***************************************************************************// proc GetDefaultDateTimeString() switch ( [SQL_DBType]) //ORACLE Type case "ORACLE" : return "DEFAULT SYSDATE"; case "MSSQL" : return "DEFAULT GETDATE()"; case "DB2" : return ""; end switch end proc