home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
prep_db_fn.tcl
< prev
next >
Wrap
Text File
|
1996-06-05
|
10KB
|
310 lines
#---------------------------------------------------------------------------
#
# Copyright (c) 1993-1995 by Cadre Technologies 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 Cadre Technologies Inc.
#
#---------------------------------------------------------------------------
#
# File : @(#)prep_db_fn.tcl 2.1
# Author : edri
# Original date : 11-10-94
# Description : Prepare functions for "check", database dependent
#
#---------------------------------------------------------------------------
#
#
# Prepare functions for db objects; should be in TDB dependent dir
#
proc db_class_prepare {class model forwhat} {
if {$forwhat == "check"} {
prepare_db_class $class $model
}
}
proc db_class::prepare {class model forwhat} {
class::prepare $class $model $forwhat
db_class_prepare $class $model $forwhat
}
proc db_link_class::prepare {class model forwhat} {
link_class::prepare $class $model $forwhat
db_class_prepare $class $model $forwhat
}
#
# db_data_attrib
#
proc db_data_attrib::prepare {attrib class model forwhat} {
set name [cap [$attrib getName]]
set type [[$attrib ooplType] getName]
set column [$attrib column]
set op [$class addOperation get$name $type]
copy_access_mode $attrib $op 1 r
if {[$column getColumnType] == "field"} {
set op [$class addOperation set$name ""]
$op addParameter new$name $type
copy_access_mode $attrib $op 1 w
}
if [$column isNullable] {
set op [$class addOperation "[uncap $name]IsNull" int]
copy_access_mode $attrib $op 1 r
set op [$class addOperation nullify$name ""]
copy_access_mode $attrib $op 1 w
}
}
#
# db_assoc_attrib prepare functions
#
proc db_assoc_attrib::prepare {attrib class model forwhat} {
prepare_for_assoc $attrib $class $model $forwhat
}
proc db_assoc_attrib::one_get_prepare {attrib class model forwhat} {
set type [[$attrib ooplType] getName]
set name [cap [$attrib getName]]
set op [$class addOperation get$name $type]
copy_access_mode $attrib $op 0 r
}
proc db_assoc_attrib::one_set_prepare {attrib class model forwhat} {
set type [[$attrib ooplType] getName]
set name [cap [$attrib getName]]
set op [$class addOperation set$name int]
$op addParameter new$name $type
copy_access_mode $attrib $op 0 w
}
proc db_assoc_attrib::one_remove_prepare {attrib class model forwhat} {
if [$attrib isMandatory] {
return
}
if {[set opp [$attrib opposite]] != "" &&
[$opp get_obj_type] == "db_qual_assoc_attrib"} {
return
}
set name [cap [$attrib getName]]
set op [$class addOperation remove$name int]
copy_access_mode $attrib $op 0 w
}
proc db_assoc_attrib::many_get_prepare {attrib class model forwhat} {
set type [[$attrib ooplType] getName]
set name [$attrib getName]
set settype [set_type_name [$attrib ooplType]]
set setname [cap [set_name $name]]
catch {$model addClass $settype}
set op [$class addOperation get$setname int]
$op addParameter $setname $settype
copy_access_mode $attrib $op 0 r
}
proc db_assoc_attrib::many_set_prepare {attrib class model forwhat} {
if {[set opp [$attrib opposite]] != "" &&
[$opp get_obj_type] == "db_qual_assoc_attrib"} {
# Can't supply the key for a qualified assoc
return
}
set type [[$attrib ooplType] getName]
set name [cap [$attrib getName]]
set op [$class addOperation add$name int]
$op addParameter new$name $type
copy_access_mode $attrib $op 0 w
}
proc db_assoc_attrib::many_remove_prepare {attrib class model forwhat} {
if {[set opp [$attrib opposite]] != "" &&
[$opp get_obj_type] == "db_qual_assoc_attrib"} {
return
}
set type [[$attrib ooplType] getName]
set name [cap [$attrib getName]]
set op [$class addOperation remove$name int]
$op addParameter old$name $type
copy_access_mode $attrib $op 0 w
}
#
# db_qual_assoc_attrib prepare functions
#
proc db_qual_assoc_attrib::prepare {attrib class model forwhat} {
prepare_for_assoc $attrib $class $model $forwhat
}
proc db_qual_assoc_attrib::any_set_prepare {attrib class model forwhat prefix} {
set type [[$attrib ooplType] getName]
set name [cap [$attrib getName]]
set keyname [[$attrib qualifier] getName]
set keytype [[[$attrib qualifier] ooplType] getName]
set op [$class addOperation $prefix$name int]
$op addParameter $keyname $keytype
$op addParameter new$name $type
copy_access_mode $attrib $op 0 w
}
proc db_qual_assoc_attrib::one_get_prepare {attrib class model forwhat} {
set type [[$attrib ooplType] getName]
set name [$attrib getName]
set keyname [[$attrib qualifier] getName]
set keytype [[[$attrib qualifier] ooplType] getName]
set op [$class addOperation "get[cap $name]" $type]
$op addParameter $keyname $keytype
copy_access_mode $attrib $op 0 r
}
proc db_qual_assoc_attrib::one_set_prepare {attrib class model forwhat} {
db_qual_assoc_attrib::any_set_prepare $attrib $class $model $forwhat "set"
}
proc db_qual_assoc_attrib::one_remove_prepare {attrib class model forwhat} {
set name [cap [$attrib getName]]
set keyname [[$attrib qualifier] getName]
set keytype [[[$attrib qualifier] ooplType] getName]
set op [$class addOperation remove$name int]
$op addParameter $keyname $keytype
copy_access_mode $attrib $op 0 w
}
proc db_qual_assoc_attrib::many_get_prepare {attrib class model forwhat} {
set name [$attrib getName]
set settype [set_type_name [$attrib ooplType]]
set setname [cap [set_name $name]]
set keyname [[$attrib qualifier] getName]
set keytype [[[$attrib qualifier] ooplType] getName]
catch {$model addClass $settype}
set op [$class addOperation get$setname int]
$op addParameter $setname $settype
$op addParameter $keyname $keytype
copy_access_mode $attrib $op 0 r
}
proc db_qual_assoc_attrib::many_set_prepare {attrib class model forwhat} {
db_qual_assoc_attrib::any_set_prepare $attrib $class $model $forwhat "add"
}
proc db_qual_assoc_attrib::many_remove_prepare {attrib class model forwhat} {
set type [[$attrib ooplType] getName]
set name [cap [$attrib getName]]
set keyname [[$attrib qualifier] getName]
set keytype [[[$attrib qualifier] ooplType] getName]
set op [$class addOperation remove$name int]
$op addParameter $keyname $keytype
$op addParameter toRemove $type
copy_access_mode $attrib $op 0 w
}
#
# db_link_attrib prepare functions
#
proc db_link_attrib::prepare {attrib class model forwhat} {
prepare_for_link $attrib $class $model $forwhat
}
proc db_link_attrib::one_get_prepare {attrib class model forwhat} {
set type [[$attrib ooplType] getName]
set name [cap "${type}Of[cap [$attrib getName]]"]
set op [$class addOperation get$name $type]
copy_access_mode $attrib $op 0 r
}
proc db_link_attrib::many_get_prepare {attrib class model forwhat} {
set type [[$attrib ooplType] getName]
set name [$attrib getName]
set settype [set_type_name [$attrib ooplType]]
set setname [cap [set_name $name]]
set func_name get[cap [set_name "${type}Of[cap $name]"]]
catch {$model addClass $settype}
set op [$class addOperation $func_name int]
$op addParameter $setname $settype
copy_access_mode $attrib $op 0 r
}
#
# db_qual_link_attrib prepare functions
#
proc db_qual_link_attrib::prepare {attrib class model forwhat} {
prepare_for_link $attrib $class $model $forwhat
}
proc db_qual_link_attrib::one_get_prepare {attrib class model forwhat} {
set type [[$attrib ooplType] getName]
set name [$attrib getName]
set keyname [[$attrib qualifier] getName]
set keytype [[[$attrib qualifier] ooplType] getName]
set func_name get[cap "${type}Of[cap $name]"]
set op [$class addOperation $func_name $type]
$op addParameter $keyname $keytype
copy_access_mode $attrib $op 0 r
}
proc db_qual_link_attrib::many_get_prepare {attrib class model forwhat} {
set type [[$attrib ooplType] getName]
set name [$attrib getName]
set settype [set_type_name [$attrib ooplType]]
set setname [cap [set_name $name]]
set keyname [[$attrib qualifier] getName]
set keytype [[[$attrib qualifier] ooplType] getName]
set func_name get[cap [set_name "${type}Of[cap $name]"]]
catch {$model addClass $settype}
set op [$class addOperation $func_name int]
$op addParameter $setname $settype
$op addParameter $keyname $keytype
copy_access_mode $attrib $op 0 r
}
#
# db_rv_link_attrib prepare functions
#
proc db_rv_link_attrib::prepare {attrib class model forwhat} {
prepare_for_link $attrib $class $model $forwhat
}
proc db_rv_link_attrib::one_get_prepare {attrib class model forwhat} {
set type [[$attrib ooplType] getName]
set name [cap [$attrib getName]]
set op [$class addOperation get$name $type]
copy_access_mode $attrib $op 0 r
}
proc db_rv_link_attrib::many_get_prepare {attrib class model forwhat} {
# should not occur...
puts "ERROR: reverse link attribute '[$attrib getName]' with multiplicity \
'many' in class '[$class getName]'"
}