home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
ot2varru.tcl
< prev
next >
Wrap
Text File
|
1997-08-04
|
8KB
|
264 lines
# Copyright (c) 1997 by Cayenne Software Inc.
#
# This software is furnished under a license and may be used only in
# accordance with the terms of such license and with the inclusion of
# the above copyright notice. This software or any other copies thereof
# may not be provided or otherwise made available to any other person.
# No title to and ownership of the software is hereby transferred.
#
# The information in this software is subject to change without notice
# and should not be construed as a commitment by Cayenne Software Inc
#
#---------------------------------------------------------------------------
#
# File : @(#)ot2varru.tcl /main/titanic/6 31 Jul 1997
# Author : H. Broeze
# Original date : 17 June 1997
# Description : ObjectTeam VAR conversion
#
#---------------------------------------------------------------------------
#
require ot2varto.tcl
global global ucgargv
global idCount
set idCount 6
global entity_sect
global anltext_sect
global diagProp_sect
global diagObjProp_sect
set diagProp1 [newDiagProp]
set diagProp2 [newDiagProp]
set enterprise [newEnterpriseModel b]
set datamodel [newDataModel dm $enterprise $diagProp1 $diagProp2]
global enterprise_sect
set enterprise_sect [set ${enterprise}.header]
global data_mod_sect
set data_mod_sect [set ${datamodel}.header]
set diagProp_sect \n[set ${diagProp1}.header]\n[set ${diagProp2}.header]
set entity_sect ""
set anltext_sect ""
set attribute_sect ""
set partnershipset_sect ""
set partnership_sect ""
set diagObjProp_sect ""
global doneTables
set doneTables ""
proc modelToVar {sqlModel} {
global doneTables
foreach table [get_tables $sqlModel] {
if {[get_source $table] != "table"} {
continue
}
if {[lsearch $doneTables $table] != -1} {
continue
}
entityToVar $table
}
set doneRels ""
foreach table [get_tables $sqlModel] {
if {[get_source $table] != "table"} {
continue
}
foreach export [get_exports $table] {
lappend doneRels [linkToVar $table $export $doneRels]
}
}
}
proc get_ftext {object} {
return [$object getPropertyValue freeText]
}
proc freeTextToVar {sqlObject} {
global anltext_sect
set freeText [get_ftext $sqlObject]
set anlText 0
if [llength $freeText] {
set anlText [newANLText $freeText]
set anltext_sect $anltext_sect\n[set ${anlText}.header]
}
return $anlText
}
proc entityToVar {table} {
global entity_sect
global diagObjProp_sect
global ent_diag_obj_sect
set anlText [freeTextToVar $table]
set entity [newEntity $table [get_name $table] $anlText]
global ${table}.no
set ${table}.no $entity
set entity_sect $entity_sect\n[set ${entity}.header]
set diagObjProp [newDiagObjProp]
set diagObjProp_sect $diagObjProp_sect\n[set ${diagObjProp}.header]
set ent_diag_obj_sect $ent_diag_obj_sect\n$entity,$diagObjProp
foreach column [get_columns $table] {
if {[get_name $column] != "class_type" && [get_obj_type $column] != "imp_column"} {
attributeToVar $entity $column
}
}
return $entity
}
proc keyToVar {entNo attrNo attrName} {
}
proc attributeToVar {entity attr} {
global attribute_sect
global diagObjProp_sect
global ent_attr_sect
set anlText [freeTextToVar $attr]
set stdType [get_type_std $attr]
set domain [newDomain $stdType]
set nullable "Y"
if [string match *no* [$attr getPropertyValue nullable]] {
set nullable "N"
}
set attrName [get_name $attr]
set attribute [newAttribute $entity $attrName 1 $nullable "" M $domain S $anlText]
set attribute_sect $attribute_sect\n[set ${attribute}.header]
set diagObjProp [newDiagObjProp]
set diagObjProp_sect $diagObjProp_sect\n[set ${diagObjProp}.header]
set ent_attr_sect $ent_attr_sect\n$entity,$attribute
if {[get_column_type $attr] == "key"} {
global ent_key_sect
set entKey [newEnt_Key $entity $attrName]
set ent_key_sect $ent_key_sect\n[set ${entKey}.header]
global attr_ent_key_sect
set attr_ent_key_sect $attr_ent_key_sect\n$attribute,$entKey
}
}
proc linkToVar {entity link doneRels} {
global partset_sect
global combset_sect
#global part_diag_obj_sect
global partset_diag_obj_sect
global combset_diag_obj_sect
set relation [get_relation $link]
if {[lsearch $doneRels $relation] != -1} {
return
}
set relName [get_name $relation]
set masterTable [get_master $link]
set detailTable [get_detail $link]
set friendLnk [get_friend $link]
if {[get_source $detailTable] != "table"} {
set relTable $detailTable
set masters [get_masters $relTable]
set table1 [lindex $masters 0]
set table2 [lindex $masters 1]
if {$table1 == $masterTable} {
set detailTable $table2
} else {
set detailTable $table1
}
}
set masterName [get_name $masterTable]
set detailName [get_name $detailTable]
set tab1Key [set ${detailTable}.no]
set tab2Key [set ${masterTable}.no]
if {[get_relation_type $relation] != "supersubtype"} {
set diag_obj_sect $partset_diag_obj_sect
set set_sect $partset_sect
set anlText1 [freeTextToVar $link]
set anlText2 [freeTextToVar $friendLnk]
set link1Name [$friendLnk getRoleName]
if ![llength $link1Name] {
set link1Name ${relName}$masterName
}
set link2Name [$link getRoleName]
if ![llength $link2Name] {
set link2Name ${relName}$detailName
}
set link1 [newPartnershipSet $link $relation $tab1Key $link1Name I $anlText1]
set link2 [newPartnershipSet $friendLnk $relation $tab2Key $link2Name I $anlText2]
set minVol1 [getMinVol $link $relation]
set maxVol1 [getMaxVol $link]
set minVol2 [getMinVol $friendLnk $relation]
set maxVol2 [getMaxVol $friendLnk]
relationToVar $link1 $link2 $minVol1 $minVol1 $maxVol1 $minVol2 $minVol2 $maxVol2
} else {
set link1 [newCombshipSet $link $relation $tab1Key]
set link2 [newCombshipSet $friendLnk $relation $tab2Key]
generToVar $link1 $link2
set diag_obj_sect $combset_diag_obj_sect
set set_sect $combset_sect
}
set set_sect $set_sect\n[set ${link1}.header]
set set_sect $set_sect\n[set ${link2}.header]
set diagObjProp [newDiagObjProp]
set diagObjProp_sect $diagObjProp_sect\n[set ${diagObjProp}.header]
set diag_obj_sect $diag_obj_sect\n$link1,$diagObjProp
set diagObjProp [newDiagObjProp]
set diagObjProp_sect $diagObjProp_sect\n[set ${diagObjProp}.header]
set diag_obj_sect $diag_obj_sect\n$link2,$diagObjProp
if {[get_relation_type $relation] != "supersubtype"} {
set partset_diag_obj_sect $diag_obj_sect
set partset_sect $set_sect
} else {
set combset_sect $set_sect
set combset_diag_obj_sect $diag_obj_sect
}
return $relation
}
proc generToVar {link1 link2 } {
global comb_sect
global comb_diag_obj_sect
set rel [newCombship $link1 $link2]
set comb_sect $comb_sect\n[set ${rel}.header]
set diagObjProp [newDiagObjProp]
set diagObjProp_sect $diagObjProp_sect\n[set ${diagObjProp}.header]
set comb_diag_obj_sect $comb_diag_obj_sect\n$rel,$diagObjProp
set diagObjProp [newDiagObjProp]
set diagObjProp_sect $diagObjProp_sect\n[set ${diagObjProp}.header]
set comb_diag_obj_sect $comb_diag_obj_sect\n$link1,$diagObjProp
}
proc relationToVar {link1 link2 minVolSrc expVolSrc maxVolSrc minVolDest expVolDest maxVolDest} {
global part_sect
global part_diag_obj_set
set rel [newPartnership $link1 $link2 $minVolSrc $expVolSrc $maxVolSrc $minVolDest $expVolDest $maxVolDest]
set part_sect $part_sect\n[set ${rel}.header]
set diagObjProp [newDiagObjProp]
set diagObjProp_sect $diagObjProp_sect\n[set ${diagObjProp}.header]
set part_diag_obj_sect $part_diag_obj_sect\n$rel,$diagObjProp
set diagObjProp [newDiagObjProp]
set diagObjProp_sect $diagObjProp_sect\n[set ${diagObjProp}.header]
set part_diag_obj_sect $part_diag_obj_sect\n$link1,$diagObjProp
}
set sqlModel [load_sql_model]
if {[get_tables $sqlModel] == ""} {
puts "No tables in SQLModel"
} else {
modelToVar $sqlModel
dumpToFile $ucgargv
puts "SQL Model converted to VAR into $ucgargv"
}