home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / komix / DATA.Z / ot2varto.tcl < prev    next >
Text File  |  1997-09-19  |  12KB  |  437 lines

  1. # Copyright (c) 1997 by Cayenne Software Inc.
  2. #
  3. # This software is furnished under a license and may be used only in
  4. # accordance with the terms of such license and with the inclusion of
  5. # the above copyright notice. This software or any other copies thereof
  6. # may not be provided or otherwise made available to any other person.
  7. # No title to and ownership of the software is hereby transferred.
  8. #
  9. # The information in this software is subject to change without notice
  10. # and should not be construed as a commitment by Cayenne Software Inc
  11. #
  12. #---------------------------------------------------------------------------
  13. #
  14. #       File            : @(#)ot2varto.tcl    /main/titanic/7 17 Jun 1997
  15. #       Author          : H. Broeze
  16. #       Original date   : 17 June 19977 
  17. #       Description     : ObjectTeam to VAR functions
  18. #
  19. #---------------------------------------------------------------------------
  20. #
  21.  
  22. global idCount
  23.  
  24. # datastructure
  25. # object.header contains the first header part
  26. # object.id     contains id
  27. # entity.attributes contains the attributes which are also objects
  28. # partnership.sets contains the partnership_set
  29.  
  30. #initialize
  31.  
  32. global ent_attr_sect 
  33. global ent_key_sect 
  34. global attr_ent_key_sect 
  35. global domain_sect
  36. global part_sect
  37. global partset_sect
  38. global comb_sect
  39. global combset_sect
  40. global attribute_sect
  41. global ent_diag_obj_sect
  42. global part_diag_obj_sect
  43. global partset_diag_obj_sect
  44. global parb_diag_obj_sect
  45. global comb_diag_obj_sect    
  46. global combset_diag_obj_sect
  47.  
  48. set ent_attr_sect     ""
  49. set ent_key_sect     ""
  50. set  attr_ent_key_sect     ""
  51. set domain_sect        ""
  52. set data_mod_sect    ""
  53. set part_sect        ""
  54. set partset_sect    ""
  55. set comb_sect        ""
  56. set combset_sect    ""
  57. set attribute_sect    ""
  58. set ent_diag_obj_sect    ""
  59. set part_diag_obj_sect    ""
  60. set partset_diag_obj_sect    ""
  61. set comb_diag_obj_sect    ""
  62. set combset_diag_obj_sect    ""
  63.  
  64. proc newVarObj {header } {
  65.     global idCount
  66.     incr idCount
  67.     global  ${idCount}.header
  68.     set ${idCount}.header $idCount,"",1997-01-01-00.00.00.000000,"",1997-01-01-00.00.00.000000,${header}
  69.     set ${idCount}.id $idCount
  70.     return $idCount
  71. }
  72.  
  73.  
  74. proc newEnterpriseModel {name} {
  75.     return [newVarObj 0,"${name}",0,0]
  76. }
  77.  
  78. proc newDataModel {name enterPId dp1 dp2} {
  79.     return [newVarObj 0,"${name}",0,0,0,0,"",0,${enterPId},0,0,0,0,0,0,$dp1,$dp2,0,0,0,0,0,0,0,0,0,0,0,0]
  80. }
  81.  
  82. proc newEntity { table name anltext} {
  83.     set localDone ""
  84.     set super 0 
  85.     global doneTables
  86.     foreach importLink [get_imports $table] {
  87.         if {[get_master_type $importLink] != "supertype"} {
  88.         continue
  89.         }
  90.         set masterTable [get_master $importLink]
  91.         if {[lsearch $doneTables $masterTable] != -1} {
  92.         global ${masterTable}.no
  93.                 set super [set ${masterTable}.no]
  94.                 continue
  95.             } else {
  96.                 lappend doneTables $masterTable
  97.                 set super [entityToVar $masterTable]
  98.             }
  99.         #when one found break
  100.         break
  101.     }
  102.     return [newVarObj 0,"${name}",0,9999999,0,0,"Y","C","N",$super,0,0,0,0,0,0,0,0,$anltext,0,0,0,0,0]
  103. }
  104.  
  105. proc newAttribute { entNo name seqNo nullable comments source domain storable anlText} {
  106.     return [newVarObj 0,$entNo,0,"$name",$seqNo,"$nullable","$comments","$source","$storable",0,$domain,0,0,0,0,$anlText,0,0]
  107. }
  108.  
  109. proc newEnt_Key { entNo name } {
  110.     return [newVarObj 0,$entNo,"$name",0,"Y",0,0,0,0]
  111. }
  112.  
  113. global availableDomains 
  114. set availableDomains ""
  115. proc newDomain { {stdType ""} } {
  116.     global domain_sect
  117.     global availableDomains
  118.     if {$stdType == "flag"} {
  119.         set type "C"
  120.         set stdType empty
  121.     } elseif [string match char* $stdType] {
  122.         set  type "A" 
  123.     } else {
  124.         set firstLetter [string index $stdType 0]
  125.         set type [string toupper $firstLetter]
  126.     }
  127.     if {[lsearch $availableDomains $stdType ] == -1} {
  128.         global $stdType
  129.         set $stdType [newVarObj 0,0,1,0,"$stdType",0,"$type","0.","0.",0,0,0,0,0,0,0,0,0,0,0]
  130.         lappend availableDomains $stdType
  131.     
  132.         set domain_sect $domain_sect\n[set [set $stdType].header]
  133.     }
  134.     return [set $stdType]
  135. }
  136.  
  137. proc newANLText { descr } {
  138.     return [newVarObj 0,0,"$descr"]
  139. }
  140.  
  141. proc newPartnership { partSet1 partSet2 minVolSrc expVolSrc maxVolSrc minVolDest expVolDest maxVolDest} {
  142.     return [newVarObj 0,$partSet1,$partSet2,$minVolSrc,$expVolSrc,$maxVolSrc,$minVolDest,$expVolDest,$maxVolDest,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
  143. }
  144.  
  145. proc getMinVol {link relation} {
  146.     set relType [get_relation_type $relation] 
  147.     if {$relType == "optional"} {
  148.         set minVol 0
  149.     } elseif {$relType == "total"} {
  150.         set minVol 1
  151.     } else {
  152.         set minVol 0
  153.         puts "Error: association type $relType not supported"
  154.     }
  155.     return $minVol
  156. }
  157.  
  158. proc getMaxVol {link} {
  159.     if {[get_card $link] ==  "one"} {
  160.             return 1
  161.     } else {
  162.             return 9999999
  163.         }
  164. }    
  165.  
  166. proc newPartnershipSet { link relation entNo name lop anlText} {
  167.     # minvol = 0 => optional
  168.     # maxvol = 1 to create a 1:1 or M:1 for a partnership which originates
  169.     # at this partnership
  170.     set expVol 1
  171.     set minVol [getMinVol $link $relation]
  172.     set maxVol [getMaxVol $link]
  173.     return [newVarObj 0,$entNo,"$name",$minVol,$maxVol,$expVol,"$lop",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"S",$anlText]
  174. }
  175.  
  176. proc newCombshipSet { link relation entNo} {
  177.     # minvol = 0 => optional
  178.     # maxvol = 1 to create a 1:1 or M:1 for a partnership which originates
  179.     # at this partnership
  180.     if {[get_link_type $link] == "subType"}   {
  181.         set type "B"
  182.     } else {
  183.         set type "P"
  184.     }
  185.     return [newVarObj 0,"$type",0,0,$entNo]
  186. }
  187.  
  188.  
  189. proc newCombship { combSet1 combSet2} {
  190.     return [newVarObj 0,$combSet1,$combSet2,0,0,0,0,0,0,0,0,0,0,0]
  191. }
  192.  
  193. proc newDiagProp { } {
  194.     return [newVarObj 0,0,0,1,1,1,1,0,0]
  195. }
  196.  
  197. proc newDiagObjProp { } {
  198.     return [newVarObj 0,8421376,0,0,"Arial",48,400,0]
  199. }
  200.  
  201. proc dumpToFile {fileName} {
  202.     #global enterprise_sect
  203.     global data_mod_sect 
  204.     global combset_sect
  205.     set sect [section create]
  206.     expand_text $sect {
  207.         Cayenne Grndwrk V6.1 865590839 0 "ObjectTeam-Model" "" "" 
  208.         **ENTERPRISE_MODEL**
  209.         ~$enterprise_sect
  210.         **ENTERPRISE_MODELKE**
  211.         **ENTERPRISE_MODELSY**
  212.         **DATA_MODEL** 
  213.         ~$data_mod_sect
  214.         **DATA_MODELANLTEXT**
  215.         **DATA_MODELSYNONYM_**
  216.         **DATA_MODELER_NOTES**
  217.         **DATA_MODELATTRIBUT**
  218.         **DATA_MODELDIAGRAM_**
  219.         **SWS_CONTROL**
  220.         **ANLTEXT**~$anltext_sect
  221.         **SYNONYM_OBJECT**
  222.         **KEYWORD**
  223.         **ER_NOTES**
  224.         **ENTITY**~$entity_sect
  225.         **ENTITYSYNONYM_OBJE**
  226.         **ENTITYKEYWORD**
  227.         **ENTITYER_NOTES**
  228.         **ENTITYMAP_SYSTEM_M**
  229.         **ENTITYATTRIBUTE**~$ent_attr_sect
  230.         **ENTITYALLOWED_VAL_**
  231.         **ENTITYMAP_SYSTEM_2**
  232.         **ENTITYBUSINESS_SJ_**
  233.         **ENTITYSUBSET_DEF**
  234.         **ENTITYDIAGRAM_OBJE** ~$ent_diag_obj_sect
  235.         **ENT_KEY**~$ent_key_sect 
  236.         **ENT_KEYSYNONYM_OBJ**
  237.         **ENT_KEYKEYWORD**
  238.         **ENT_KEYER_NOTES**
  239.         **ENT_KEYMAP_SYSTEM_**
  240.         **ATTR_JUNCTION** 
  241.         **PARTNERSHIP_SET** ~$partset_sect
  242.         **PARTNERSHIP_SETENT**
  243.         **PARTNERSHIP_SETSYN**
  244.         **PARTNERSHIP_SETKEY**
  245.         **PARTNERSHIP_SETER_**
  246.         **PARTNERSHIP_SETFOR**
  247.         **PARTNERSHIP_SETMAP**
  248.         **PARTNERSHIP_SETSUB**
  249.         **PARTNERSHIP_SETDIA** ~$partset_diag_obj_sect
  250.         **COMB_PSET**  ~$combset_sect
  251.         **COMB_PSETDIAGRAM_O** ~$combset_diag_obj_sect
  252.         **PARTNERSHIP**  ~$part_sect
  253.         **PARTNERSHIPER_NOTE**
  254.         **PARTNERSHIPFOREIGN**
  255.         **PARTNERSHIPFOREIG2**
  256.         **PARTNERSHIPDIAGRAM** ~$part_diag_obj_sect
  257.         **COMB_PSHIP**  ~$comb_sect
  258.         **COMB_PSHIPDIAGRAM_** ~$comb_diag_obj_sect
  259.         **DIMENSION** 
  260.         **DIMENSIONSYNONYM_O**
  261.         **DIMENSIONER_NOTES**
  262.         **DIMENSIONKEYWORD**
  263.         **DIMENSIONSUBSET_DE**
  264.         **DOMAINS** ~$domain_sect
  265.         **DOMAINSSYNONYM_OBJ**
  266.         **DOMAINSKEYWORD**
  267.         **DOMAINSER_NOTES**
  268.         **DOMAINSSUBSET_DEF**
  269.         **ATTRIBUTE**~$attribute_sect
  270.         **ATTRIBUTEENT_KEY**~$attr_ent_key_sect
  271.         **ATTRIBUTESYNONYM_O**
  272.         **ATTRIBUTEKEYWORD**
  273.         **ATTRIBUTEER_NOTES**
  274.         **ATTRIBUTEATTRIBUTE**
  275.         **ATTRIBUTEALLOWED_V**
  276.         **ATTRIBUTEMAP_SYSTE**
  277.         **ATTRIBUTEBUSINESS_**
  278.         **ATTRIBUTESUBSET_DE**
  279.         **METHOD** 
  280.         **METHODSUBSET_DEF**
  281.         **FOREIGN_KEY_ATTR** 
  282.         **FOREIGN_KEY_ATTRSY**
  283.         **MAP_EXT_DESIGN** 
  284.         **MAP_NAME_TABLE** 
  285.         **MAP_SYSTEM_MAP** 
  286.         **MAP_USER_MAP** 
  287.         **BUSINESS_SJ_AREA** 
  288.         **BUSINESS_SJ_AREAEX**
  289.         **SUBSET_DEF** 
  290.         **DATA_MDL_SBS_RUL** 
  291.         **PROC_MDL_SBS_RUL** 
  292.         **BSA_SUBSET_RULE** 
  293.         **STRUCTURE** 
  294.         **STRUCTURESYNONYM_O**
  295.         **STRUCTUREKEYWORD**
  296.         **STRUCTUREINFO_FLOW**
  297.         **STRUCTUREPROCESS_M**
  298.         **STRUCT_ENT** 
  299.         **STRUCT_ATTR** 
  300.         **STRUCT_ATTRSTRUCT_**
  301.         **STRUCT_PSET** 
  302.         **STRUCT_PSHP** 
  303.         **ALLOWED_VAL_TBL** 
  304.         **ALLOWED_VAL_TBLSYN**
  305.         **ALLOWED_VAL_TBLKEY**
  306.         **ALLOWED_VAL_TBLSUB**
  307.         **ALLOWABLE_VALUE** 
  308.         **SYMBOLIC_CONSTANT** 
  309.         **DA_FREE_TEXT_BLOCK** 
  310.         **EXTENSION_OBJECT** 
  311.         **ROUTE_OBJECT** 
  312.         **ANLEXT_RTE_OBJ** 
  313.         **ANLDGM_TEXT** 
  314.         **ANLDGM_TEXTDIAGRAM**
  315.         **DIAGRAM_PROPERTIES** ~$diagProp_sect
  316.         **PROCESS_MODEL** 
  317.         **PROCESS_MODELKEYWO**
  318.         **PROCESS_MODELANLTE**
  319.         **PROCESS_MODELSYNON**
  320.         **PROCESS_MODELSUBSE**
  321.         **PROCESS_MODELDIAGR**
  322.         **PROCESS_MODELDIAG2**
  323.         **PROCESS_MODELDIAG3**
  324.         **PROCESS** 
  325.         **PROCESSANLTEXT**
  326.         **PROCESSKEYWORD**
  327.         **PROCESSSYNONYM_OBJ**
  328.         **PROCESSPERSON_EVEN**
  329.         **PROCESSCLOCK_EVENT**
  330.         **PROCESSSTORAGE_EVE**
  331.         **PROCESSFLOW_EVENT**
  332.         **PROCESSDIAGRAM_OBJ**
  333.         **PROCESSDIAGRAM_OB2**
  334.         **EXTERNAL_AGENT** 
  335.         **EXTERNAL_AGENTKEYW**
  336.         **EXTERNAL_AGENTSYNO**
  337.         **EXTERNAL_AGENTDIAG**
  338.         **INFO_STORE** 
  339.         **INFO_STORESYNONYM_**
  340.         **INFO_STOREKEYWORD**
  341.         **INFO_STOREDIAGRAM_**
  342.         **INFO_FLOW** 
  343.         **INFO_FLOWKEYWORD**
  344.         **INFO_FLOWEXTERNAL_**
  345.         **INFO_FLOWINFO_STOR**
  346.         **INFO_FLOWPROCESS**
  347.         **INFO_FLOWSYNONYM_O**
  348.         **INFO_FLOWSEND_STAT**
  349.         **INFO_FLOWRECEIVE_S**
  350.         **INFO_FLOWINSERT_ST**
  351.         **INFO_FLOWSELECT_ST**
  352.         **INFO_FLOWUPDATE_ST**
  353.         **INFO_FLOWDELETE_ST**
  354.         **INFO_FLOWCONN_POIN**
  355.         **INFO_FLOWDIAGRAM_O**
  356.         **INFO_FLOWDIAGRAM_2**
  357.         **PWS** 
  358.         **PWSPSD_EXPR**
  359.         **FD_COMMENT** 
  360.         **STORAGE_EVENT** 
  361.         **STORAGE_EVENTSYNON**
  362.         **STORAGE_EVENTKEYWO**
  363.         **FLOW_EVENT** 
  364.         **FLOW_EVENTSYNONYM_**
  365.         **FLOW_EVENTKEYWORD**
  366.         **PERSON_EVENT** 
  367.         **PERSON_EVENTSYNONY**
  368.         **PERSON_EVENTKEYWOR**
  369.         **CLOCK_EVENT** 
  370.         **CLOCK_EVENTSYNONYM**
  371.         **CLOCK_EVENTKEYWORD**
  372.         **EXTERNAL_PROC** 
  373.         **EXTERNAL_PROCSUBSE**
  374.         **PSD** 
  375.         **PSD_TOPLEVEL** 
  376.         **PSD_TOPLEVELPWS**
  377.         **DO_STATEMENT** 
  378.         **SEND_STATEMENT** 
  379.         **SEND_STATEMENTCONN**
  380.         **RECEIVE_STATEMENT** 
  381.         **RECEIVE_STATEMENTC**
  382.         **SIGNAL_STATEMENT** 
  383.         **INSERT_STATEMENT** 
  384.         **INSERT_STATEMENTCO**
  385.         **DELETE_STATEMENT** 
  386.         **DELETE_STATEMENTCO**
  387.         **UPDATE_STATEMENT** 
  388.         **UPDATE_STATEMENTCO**
  389.         **SELECT_STATEMENT** 
  390.         **SELECT_STATEMENTCO**
  391.         **ORDER_ATTRIBUTE** 
  392.         **IF_STATEMENT** 
  393.         **CASE_STATEMENT** 
  394.         **CASE_EXPRESSION** 
  395.         **SET_STATEMENT** 
  396.         **SET_FIELD_PROP** 
  397.         **FOREACH_STATEMENT** 
  398.         **LOOP_STATEMENT** 
  399.         **CONDITION_HANDLER** 
  400.         **COMMENT_STATEMENT** 
  401.         **RETURN_STATEMENT** 
  402.         **COMMIT_STATEMENT** 
  403.         **RESUME_STATEMENT** 
  404.         **RETRY_STATEMENT** 
  405.         **CONTINUE_STATEMENT** 
  406.         **EXIT_STATEMENT** 
  407.         **SKIP_STATEMENT** 
  408.         **ABORT_STATEMENT** 
  409.         **STRUCTURE_STMT** 
  410.         **WITHIN_STATEMENT** 
  411.         **PSD_EXPR** 
  412.         **PSD_EXPRSTRUCT_ENT**
  413.         **PSD_EXPRSTRUCT_ATT**
  414.         **PSD_EXPRSTRUCT_PSE**
  415.         **PSD_EXPRSTRUCT_PSH**
  416.         **PSD_EXPRUSER_EXCEP**
  417.         **PSD_EXPRANLTEXT**
  418.         **PSD_EXPRSYMBOLIC_C**
  419.         **USER_EXCEPTION** 
  420.         **CONN_POINT** 
  421.         **NOTES** 
  422.         **NOTESKEYWORD**
  423.         **FILTER** 
  424.         **FILTEROBJECTS**
  425.         **FILTERKEYWORDS**
  426.         **DIAGRAM_OBJECT_PRO** ~$diagObjProp_sect
  427.         **DFD_TEXT_BLOCK** 
  428.         **BCDFIELD** 
  429.         **BCDFIELDDIAGRAM_OB**
  430.         **BCDTXTB** 
  431.         **ROLLBACK_STATEMENT** 
  432.     }
  433.     set fd [open $fileName w]
  434.     section write $sect $fd 
  435.     close $fd
  436. }
  437.